toby/tests/Browser/AuthenticationTest.php
Ewelina Lasowy 91bd46cc36
#17 - set up Laravel Dusk (#18)
* #17 - set up Laravel Dusk

* #17 - ecs fix

* #17 - fix

* #17 - fix

* #17 - fix

* #17 - fix

* Update .env.dusk.local

Co-authored-by: Krzysztof Rewak <krzysztof.rewak@blumilk.pl>

Co-authored-by: Adrian Hopek <adrian.hopek@blumilk.pl>
Co-authored-by: Krzysztof Rewak <krzysztof.rewak@blumilk.pl>
2022-01-18 12:22:02 +01:00

40 lines
951 B
PHP

<?php
declare(strict_types=1);
namespace Tests\Browser;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Laravel\Dusk\Browser;
use Tests\Browser\Pages\HomePage;
use Tests\DuskTestCase;
use Toby\Models\User;
class AuthenticationTest extends DuskTestCase
{
use DatabaseMigrations;
protected User $user;
protected function setUp(): void
{
parent::setUp();
$this->user = User::factory()->create();
}
public function testUserCanLogout(): void
{
$this->browse(function (Browser $browser): void {
$browser->loginAs($this->user)
->visit(new HomePage())
->assertVisible("@user-menu")
->click("@user-menu")
->assertVisible("@user-menu-list")
->assertSee("Sign out")
->press("Sign out")
->on(new HomePage())
->waitFor("@login-link");
});
}
}