-
Notifications
You must be signed in to change notification settings - Fork 45
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
Showing
19 changed files
with
309 additions
and
37 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
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,55 @@ | ||
<?php | ||
|
||
/** | ||
* This is for the /auth/password/confirm page | ||
*/ | ||
|
||
use Devdojo\Auth\Tests\Browser\Pages\ConfirmPassword; | ||
use Illuminate\Foundation\Testing\DatabaseMigrations; | ||
use Laravel\Dusk\Browser; | ||
|
||
uses(DatabaseMigrations::class); | ||
|
||
test('Guest redirect to login page', function(){ | ||
$browser = $this->browse(function (Browser $browser) { | ||
$browser | ||
->visit(new ConfirmPassword) | ||
->assertPathIs('/auth/login'); | ||
}); | ||
}); | ||
|
||
test('Password Confirm Protected Page Redirects', function () { | ||
$browser = $this->browse(function (Browser $browser) { | ||
$browser | ||
->visitPasswordConfirmTestPage() | ||
->assertPathIs('/auth/login') | ||
->createJohnDoe() | ||
->loginAsJohnDoe() | ||
->visitPasswordConfirmTestPage() | ||
->assertPathIs('/auth/password/confirm'); | ||
}); | ||
}); | ||
|
||
test('Password Confirm Works', function(){ | ||
$browser = $this->browse(function (Browser $browser) { | ||
$browser | ||
->createJohnDoe() | ||
->loginAsJohnDoe() | ||
->visit(new ConfirmPassword) | ||
->type('@password-input', 'password') | ||
->clickAndWaitForReload('@submit-button') | ||
->assertRedirectAfterAuthUrlIsCorrect(); | ||
}); | ||
}); | ||
|
||
test('Password Confirm Works and redirect to password protected page', function(){ | ||
$browser = $this->browse(function (Browser $browser) { | ||
$browser | ||
->createJohnDoe() | ||
->loginAsJohnDoe() | ||
->visitPasswordConfirmTestPage() | ||
->type('@password-input', 'password') | ||
->clickAndWaitForReload('@submit-button') | ||
->assertSee('Test Confirmed'); | ||
}); | ||
}); |
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,73 @@ | ||
<?php | ||
|
||
/** | ||
* This is for the /auth/password/reset and /auth/password/hAsHeDsTrInG page | ||
*/ | ||
|
||
use Devdojo\Auth\Tests\Browser\Pages\PasswordResetRequest; | ||
use Illuminate\Foundation\Testing\DatabaseMigrations; | ||
use Laravel\Dusk\Browser; | ||
|
||
uses(DatabaseMigrations::class); | ||
|
||
test('Empty Email Validation', function () { | ||
$browser = $this->browse(function (Browser $browser) { | ||
$browser | ||
->visit(new PasswordResetRequest) | ||
->authAttributeRemove('#email', 'required') | ||
->testValidationErrorOnSubmit('The email field is required'); | ||
}); | ||
}); | ||
|
||
test('Invalid Email Validation', function () { | ||
$browser = $this->browse(function (Browser $browser) { | ||
$browser | ||
->visit(new PasswordResetRequest) | ||
->authAttributeChange('#email', 'type', 'text') | ||
->type('@email-input', 'johndoe') | ||
->testValidationErrorOnSubmit('The email field must be a valid email address'); | ||
}); | ||
}); | ||
|
||
test('Email Does Not Exist', function () { | ||
$browser = $this->browse(function (Browser $browser) { | ||
$browser | ||
->visit(new PasswordResetRequest) | ||
->type('@email-input', 'jimmycrackcorn@gmail.com') | ||
->testValidationErrorOnSubmit('We can\'t find a user with that email address'); | ||
}); | ||
}); | ||
|
||
test('Email reset functionality', function () { | ||
$browser = $this->browse(function (Browser $browser) { | ||
|
||
$browser | ||
->visit(new PasswordResetRequest) | ||
->createJohnDoe() | ||
->clearLogFile() | ||
->typeAndSubmit('@email-input', 'johndoe@gmail.com') | ||
->waitForText('We have emailed your password reset link') | ||
->getLogFile(function ($content) use ($browser) { | ||
|
||
$foundLine = $this->findLineContainingSubstring($content, 'Reset Password:'); | ||
$url = str_replace('Reset Password: ', '', $foundLine); | ||
$browser | ||
->visit($url) | ||
->assertSeeIn('#auth-heading-title', 'Reset Password') | ||
->type('@password-input', 'password123') | ||
->type('@password-confirm-input', 'password123') | ||
->clickAndWaitForReload('@submit-button') | ||
->assertRedirectAfterAuthUrlIsCorrect(); | ||
}); | ||
}); | ||
}); | ||
|
||
test('Link to Login Page', function () { | ||
$browser = $this->browse(function (Browser $browser) { | ||
$browser | ||
->visit(new PasswordResetRequest) | ||
->click('@login-link') | ||
->waitFor('@auth-login') | ||
->assertPathIs('/auth/login'); | ||
}); | ||
}); |
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
Empty file.
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,16 @@ | ||
<?php | ||
|
||
namespace Devdojo\Auth\Tests\Browser\Pages; | ||
|
||
use Laravel\Dusk\Page; | ||
|
||
class ConfirmPassword extends Page | ||
{ | ||
/** | ||
* Get the URL for the page. | ||
*/ | ||
public function url(): string | ||
{ | ||
return '/auth/password/confirm'; | ||
} | ||
} |
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,16 @@ | ||
<?php | ||
|
||
namespace Devdojo\Auth\Tests\Browser\Pages; | ||
|
||
use Laravel\Dusk\Page; | ||
|
||
class PasswordResetRequest extends Page | ||
{ | ||
/** | ||
* Get the URL for the page. | ||
*/ | ||
public function url(): string | ||
{ | ||
return '/auth/password/reset'; | ||
} | ||
} |
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,16 @@ | ||
<?php | ||
|
||
namespace Devdojo\Auth\Tests\Browser\Pages; | ||
|
||
use Laravel\Dusk\Page; | ||
|
||
class TwoFactorAuth extends Page | ||
{ | ||
/** | ||
* Get the URL for the page. | ||
*/ | ||
public function url(): string | ||
{ | ||
return '/user/two-factor-authentication'; | ||
} | ||
} |
Oops, something went wrong.