opnform/tests/Browser/LoginTest.php

41 lines
1.1 KiB
PHP
Raw Normal View History

2022-09-20 19:59:52 +00:00
<?php
use App\Models\User;
use Tests\Browser\Pages\Home;
use Tests\Browser\Pages\Login;
uses(\Tests\DuskTestCase::class);
/** @test */
it('can login onboarded users', function () {
$user = User::factory()->create();
$this->createUserWorkspace($user);
$this->browse(function ($browser) use ($user) {
2024-02-23 10:54:12 +00:00
$browser->visit(new Login())
2022-09-20 19:59:52 +00:00
->submit($user->email, 'password')
->assertPageIs(Home::class);
});
});
2024-02-23 10:54:12 +00:00
it('cannot login with invalid credentials', function () {
2022-09-20 19:59:52 +00:00
$this->browse(function ($browser) {
2024-02-23 10:54:12 +00:00
$browser->visit(new Login())
2022-09-20 19:59:52 +00:00
->submit('test@test.app', 'password')
->pause(100)
->assertSee('These credentials do not match our records.');
});
});
2024-02-23 10:54:12 +00:00
it('can log out the user', function () {
2022-09-20 19:59:52 +00:00
$user = User::factory()->create();
$this->browse(function ($browser) use ($user) {
2024-02-23 10:54:12 +00:00
$browser->visit(new Login())
2022-09-20 19:59:52 +00:00
->submit($user->email, 'password')
2024-02-23 10:54:12 +00:00
->on(new Home())
2022-09-20 19:59:52 +00:00
->clickLogout()
->assertPageIs(Login::class);
});
});