#17 - set up Laravel Dusk
This commit is contained in:
35
tests/Browser/AuthenticationTest.php
Normal file
35
tests/Browser/AuthenticationTest.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Browser;
|
||||
|
||||
use Illuminate\Foundation\Testing\DatabaseMigrations;
|
||||
use Laravel\Dusk\Browser;
|
||||
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()
|
||||
{
|
||||
$this->browse(function (Browser $browser) {
|
||||
$browser->loginAs($this->user)
|
||||
->visit("/")
|
||||
->assertVisible("@user-menu")
|
||||
->click("@user-menu")
|
||||
->assertVisible("@user-menu-list")
|
||||
->assertSee("Sign out")
|
||||
->press("Sign out")
|
||||
->assertPathIs("/");
|
||||
});
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user