Skip to content

Commit

Permalink
fix(tests): fix end-to-end test on browserstack
Browse files Browse the repository at this point in the history
Signed-off-by: Fery Wardiyanto <[email protected]>
  • Loading branch information
feryardiant committed Sep 29, 2023
1 parent ed075b2 commit ea5b581
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 12 deletions.
13 changes: 8 additions & 5 deletions tests/Browser/AuthenticationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@ public function should_not_be_able_to_authenticate_using_invalid_credential()
$this->browse(function (Browser $browser) {
$page = $browser->visit(new Login);

$page->assertFocused('#username input[type="text"]')
->type('@username', 'johndoe')
$page->assertFocused('@username');

$page->type('@username', 'johndoe')
->type('@password', 'secret')
->pressAndWaitFor('@login');
->press('@login')
->waitFor('.n-form-item-feedback-wrapper');

$page->assertSee(__('auth.failed'));
});
Expand All @@ -39,8 +41,9 @@ public function should_be_able_to_authenticate_using_existing_credential()
$this->browse(function (Browser $browser) use ($user) {
$page = $browser->visit(new Login);

$page->assertFocused('#username input[type="text"]')
->type('@username', $user->name)
$page->assertFocused('@username');

$page->type('@username', $user->name)
->type('@password', 'secret')
->press('@login')
->waitForInertia();
Expand Down
2 changes: 1 addition & 1 deletion tests/Browser/Pages/ForgotPassword.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function assert(Browser $browser)
public function elements()
{
return [
'@email' => '#email input[type="text"]',
'@email' => 'input#email',
];
}
}
3 changes: 2 additions & 1 deletion tests/Browser/Pages/HomePage.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Tests\Browser\Pages;

use App\Providers\RouteServiceProvider;
use Laravel\Dusk\Browser;

class HomePage extends Page
Expand All @@ -13,7 +14,7 @@ class HomePage extends Page
*/
public function url()
{
return '/';
return RouteServiceProvider::HOME;
}

/**
Expand Down
4 changes: 2 additions & 2 deletions tests/Browser/Pages/Login.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ public function assert(Browser $browser)
public function elements()
{
return [
'@username' => '#username input[type="text"]',
'@password' => '#password input[type="password"]',
'@username' => 'input#username',
'@password' => 'input#password',
'@remember' => '.n-checkbox',
'@login' => 'button[type=submit]',
];
Expand Down
7 changes: 4 additions & 3 deletions tests/Browser/Pages/Register.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,10 @@ public function assert(Browser $browser)
public function elements()
{
return [
'@email' => '#email input[type="text"]',
'@password' => '#password input[type="password"]',
'@confirmPassword' => '#confirm-password input[type="password"]',
'@username' => 'input#username',
'@email' => 'input#email',
'@password' => 'input#password',
'@confirmPassword' => 'input#confirm_password',
'@register' => 'button[type=submit]',
];
}
Expand Down

0 comments on commit ea5b581

Please sign in to comment.