57 lines
1.5 KiB
PHP
57 lines
1.5 KiB
PHP
<?php
|
|
|
|
use App\Models\User;
|
|
use Facades\Tests\Setup\UserFactory;
|
|
|
|
beforeEach(function () {
|
|
$this->artisan('db:seed');
|
|
});
|
|
|
|
it('lists users with their details', function () {
|
|
browserLogin();
|
|
|
|
User::factory()->create(['email' => 'listed@vanguard.test', 'username' => 'listeduser']);
|
|
|
|
visit('/users')
|
|
->assertNoJavaScriptErrors()
|
|
->assertSee('Users')
|
|
->assertSee('Registration Date')
|
|
->assertSee('listed@vanguard.test')
|
|
->assertSee('listeduser');
|
|
});
|
|
|
|
it('filters the list with the search box', function () {
|
|
browserLogin();
|
|
|
|
User::factory()->create(['username' => 'findme']);
|
|
User::factory()->create(['username' => 'hidden']);
|
|
|
|
visit('/users')
|
|
->assertSee('hidden')
|
|
->fill('#search', 'findme')
|
|
->assertSee('findme')
|
|
->assertDontSee('hidden');
|
|
});
|
|
|
|
it('filters the list by status', function () {
|
|
browserLogin();
|
|
|
|
UserFactory::banned()->create(['username' => 'bannedone']);
|
|
|
|
visit('/users')
|
|
->assertSee('bannedone')
|
|
->select('#status', 'Active')
|
|
->assertDontSee('bannedone');
|
|
});
|
|
|
|
it('renders the row actions', function () {
|
|
browserLogin();
|
|
|
|
// Each row carries the same controls, so these are asserted by presence
|
|
// rather than clicked: a text or aria locator would match every row.
|
|
visit('/users')
|
|
->assertPresent('[aria-label="Action"]')
|
|
->assertPresent('[aria-label="Edit User"]')
|
|
->assertPresent('[aria-label="Delete User"]');
|
|
});
|