2023-06-29 12:58:05 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Tests\EndToEnd;
|
|
|
|
|
|
|
|
use App\Group;
|
2023-12-19 02:00:42 +01:00
|
|
|
use App\Invoice\Models\Invoice;
|
|
|
|
use App\Invoice\Models\InvoicePosition;
|
2023-06-29 12:58:05 +02:00
|
|
|
use App\Member\Member;
|
|
|
|
use Illuminate\Foundation\Testing\DatabaseMigrations;
|
2024-01-26 00:35:00 +01:00
|
|
|
use Illuminate\Support\Facades\Artisan;
|
|
|
|
use Laravel\Scout\Console\SyncIndexSettingsCommand;
|
2023-06-29 12:58:05 +02:00
|
|
|
use Tests\TestCase;
|
|
|
|
|
|
|
|
class MemberIndexTest extends TestCase
|
|
|
|
{
|
|
|
|
use DatabaseMigrations;
|
|
|
|
|
2024-01-26 00:35:00 +01:00
|
|
|
public function setUp(): void
|
|
|
|
{
|
|
|
|
parent::setUp();
|
|
|
|
|
|
|
|
config()->set('scout.driver', 'meilisearch');
|
|
|
|
Artisan::call(SyncIndexSettingsCommand::class);
|
|
|
|
}
|
|
|
|
|
2023-06-29 12:58:05 +02:00
|
|
|
public function testItHandlesFullTextSearch(): void
|
|
|
|
{
|
|
|
|
$this->withoutExceptionHandling()->login()->loginNami();
|
2024-01-26 14:52:33 +01:00
|
|
|
Member::factory()->defaults()->create(['firstname' => 'Alexander']);
|
|
|
|
Member::factory()->defaults()->create(['firstname' => 'Heinrich']);
|
2023-06-29 12:58:05 +02:00
|
|
|
|
2024-01-26 14:52:51 +01:00
|
|
|
sleep(5);
|
2024-01-26 10:28:05 +01:00
|
|
|
$response = $this->callFilter('member.index', ['search' => 'Alexander']);
|
2023-06-29 12:58:05 +02:00
|
|
|
|
|
|
|
$this->assertCount(1, $this->inertia($response, 'data.data'));
|
|
|
|
}
|
|
|
|
|
2023-07-24 16:55:07 +02:00
|
|
|
public function testItHandlesAddress(): void
|
|
|
|
{
|
|
|
|
$this->withoutExceptionHandling()->login()->loginNami();
|
2024-01-26 14:52:33 +01:00
|
|
|
Member::factory()->defaults()->create(['address' => '']);
|
|
|
|
Member::factory()->defaults()->create(['zip' => '']);
|
|
|
|
Member::factory()->defaults()->create(['location' => '']);
|
2023-07-24 16:55:07 +02:00
|
|
|
|
2024-01-26 14:52:51 +01:00
|
|
|
sleep(5);
|
2023-07-24 16:55:07 +02:00
|
|
|
$response = $this->callFilter('member.index', ['has_full_address' => true]);
|
|
|
|
$noResponse = $this->callFilter('member.index', ['has_full_address' => false]);
|
|
|
|
|
|
|
|
$this->assertCount(0, $this->inertia($response, 'data.data'));
|
|
|
|
$this->assertCount(3, $this->inertia($noResponse, 'data.data'));
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testItHandlesBirthday(): void
|
|
|
|
{
|
|
|
|
$this->withoutExceptionHandling()->login()->loginNami();
|
2024-01-26 14:52:33 +01:00
|
|
|
$member = Member::factory()->defaults()->create(['birthday' => null]);
|
2023-07-24 16:55:07 +02:00
|
|
|
|
2024-01-26 14:52:51 +01:00
|
|
|
sleep(5);
|
2023-07-24 16:55:07 +02:00
|
|
|
$response = $this->callFilter('member.index', ['has_birthday' => true]);
|
|
|
|
|
|
|
|
$this->assertCount(0, $this->inertia($response, 'data.data'));
|
|
|
|
$member->delete();
|
|
|
|
}
|
|
|
|
|
2023-06-29 12:58:05 +02:00
|
|
|
public function testItFiltersForSearchButNotForPayments(): void
|
|
|
|
{
|
|
|
|
$this->withoutExceptionHandling()->login()->loginNami();
|
2024-01-26 14:52:33 +01:00
|
|
|
Member::factory()->defaults()
|
2023-12-19 02:00:42 +01:00
|
|
|
->has(InvoicePosition::factory()->for(Invoice::factory()))
|
2023-06-29 12:58:05 +02:00
|
|
|
->create(['firstname' => '::firstname::']);
|
2024-01-26 14:52:33 +01:00
|
|
|
Member::factory()->defaults()->create(['firstname' => '::firstname::']);
|
2023-06-29 12:58:05 +02:00
|
|
|
|
2024-01-26 14:52:51 +01:00
|
|
|
sleep(5);
|
2023-06-29 12:58:05 +02:00
|
|
|
$response = $this->callFilter('member.index', ['search' => '::firstname::', 'ausstand' => true]);
|
|
|
|
|
|
|
|
$this->assertCount(1, $this->inertia($response, 'data.data'));
|
|
|
|
}
|
|
|
|
}
|