initial partically working
This commit is contained in:
parent
ff5ab3aa58
commit
1e35e485ad
1 changed files with 60 additions and 0 deletions
60
tests/Browser/LoginDashAdminTest.php
Normal file
60
tests/Browser/LoginDashAdminTest.php
Normal file
|
|
@ -0,0 +1,60 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests\Browser;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Testing\DatabaseTruncation;
|
||||||
|
use Laravel\Dusk\Browser;
|
||||||
|
use Tests\Browser\Concerns\AuthenticatesUsers;
|
||||||
|
use Tests\DuskTestCase;
|
||||||
|
|
||||||
|
class LoginTest extends DuskTestCase
|
||||||
|
{
|
||||||
|
use DatabaseTruncation;
|
||||||
|
use AuthenticatesUsers;
|
||||||
|
|
||||||
|
public function test_login(): void
|
||||||
|
{
|
||||||
|
$user = $this->createTestUser("login-test@example.com");
|
||||||
|
|
||||||
|
$this->browse(function (Browser $browser) use ($user) {
|
||||||
|
$this->loginUser($browser, $user);
|
||||||
|
$this->assertWithDebugPause($browser, fn($b) =>
|
||||||
|
$b->assertPathIs('/dashboard'),
|
||||||
|
1000 // Custom pause time for this test
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_invalid_login(): void
|
||||||
|
{
|
||||||
|
$user = $this->createTestUser("invalid-email@example.com");
|
||||||
|
|
||||||
|
$this->browse(function (Browser $browser) use ($user) {
|
||||||
|
$this->loginUser($browser, $user);
|
||||||
|
$this->assertWithDebugPause($browser, fn($b) =>
|
||||||
|
$b->visit('/admin')
|
||||||
|
->waitForLocation('/admin')
|
||||||
|
->assertPathIs('/admin')
|
||||||
|
->assertSee('FORBIDDEN'),
|
||||||
|
1000 // Custom pause time for this test
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_access_admin_panel(): void
|
||||||
|
{
|
||||||
|
$user = $this->createTestUser("login-test@example.com");
|
||||||
|
|
||||||
|
$this->browse(function (Browser $browser) use ($user) {
|
||||||
|
$this->loginUser($browser, $user);
|
||||||
|
$this->assertWithDebugPause($browser, fn($b) =>
|
||||||
|
$b->visit('/admin')
|
||||||
|
->waitForLocation('/admin')
|
||||||
|
->assertPathIs('/admin')
|
||||||
|
->assertTitleContains('Dashboard')
|
||||||
|
->assertDontSee('FORBIDDEN'),
|
||||||
|
1000 // Custom pause time for this test
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue