-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e1e7b84
commit c549981
Showing
5 changed files
with
68 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
|
||
namespace Tests\Browser; | ||
|
||
use App\Models\User; | ||
use Illuminate\Support\Str; | ||
use PHPUnit\Framework\Attributes\DataProvider; | ||
use PHPUnit\Framework\Attributes\Test; | ||
use Tests\DuskTestCase; | ||
|
||
class SessionTest extends DuskTestCase | ||
{ | ||
#[DataProvider('booleanProvider')] | ||
#[Test] | ||
public function it_can_submit_a_form_and_redirect_and_keep_the_user_logged_in(bool $navigate) | ||
{ | ||
$this->browse(function (Browser $browser) use ($navigate) { | ||
$firstUser = User::orderBy('name')->first(); | ||
|
||
$browser | ||
->loginAs($firstUser) | ||
->visit('/users'.($navigate ? '?navigate=1' : '')) | ||
->waitForFirstUser() | ||
->assertSee("Logged in as: {$firstUser->id}") | ||
->click("@edit-user-{$firstUser->id}") | ||
->waitForTextIn('.im-modal-content', 'Edit User') | ||
->assertSee("Logged in as: {$firstUser->id}") | ||
->type('name', $newName = Str::random(10)) | ||
->press('Save') | ||
->waitForText('User updated successfully!') | ||
->waitUntilMissing('.im-dialog') | ||
->assertPathIs('/users') | ||
->assertSee("Logged in as: {$firstUser->id}") | ||
->assertAuthenticatedAs($firstUser); | ||
|
||
$this->assertDatabaseHas('users', [ | ||
'id' => $firstUser->id, | ||
'name' => $newName, | ||
]); | ||
}); | ||
} | ||
} |