formatting, browser tests
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Browser;
|
||||
|
||||
use App\Models\User;
|
||||
use Laravel\Dusk\Browser;
|
||||
use Tests\DuskTestCase;
|
||||
|
||||
test('user can register, log in, and log out', function () {
|
||||
$this->browse(function (Browser $browser) {
|
||||
// 1. Test Registration
|
||||
$browser->visit('/register')
|
||||
->waitForText('Create an account')
|
||||
->type('name', 'New Browser User')
|
||||
->type('email', 'newbrowseruser@example.com')
|
||||
->type('password', 'password')
|
||||
->type('password_confirmation', 'password')
|
||||
->press('Create account')
|
||||
->waitForLocation('/dashboard')
|
||||
->assertPathIs('/dashboard')
|
||||
->assertSee('New Browser User');
|
||||
|
||||
// 2. Test Logout
|
||||
// Open the user menu (trigger button shows initials or user name)
|
||||
$browser->click('button[aria-haspopup="menu"]')
|
||||
->waitForText('Log out')
|
||||
->clickLink('Log out')
|
||||
->waitForLocation('/login') // Fortify logs out and redirects to login or home
|
||||
->assertPathIs('/login');
|
||||
|
||||
// 3. Test Login
|
||||
$browser->type('email', 'newbrowseruser@example.com')
|
||||
->type('password', 'password')
|
||||
->press('Log in')
|
||||
->waitForLocation('/dashboard')
|
||||
->assertPathIs('/dashboard')
|
||||
->assertSee('New Browser User');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user