-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Adding dusk tests --------- Co-authored-by: tnylea <[email protected]> Co-authored-by: Bobby Iliev <[email protected]> Co-authored-by: bobbyiliev <[email protected]>
- Loading branch information
1 parent
0db8096
commit f857826
Showing
26 changed files
with
632 additions
and
19 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
APP_NAME='DevDojo Auth' | ||
APP_ENV=testing | ||
APP_KEY=base64:La7oMA4FgO9U3dEgYzu7UwlpYjFvGKSgP2uwnkbaPK8= | ||
APP_DEBUG=true | ||
APP_TIMEZONE=UTC | ||
APP_URL=http://127.0.0.1:8000 | ||
|
||
APP_LOCALE=en | ||
APP_FALLBACK_LOCALE=en | ||
APP_FAKER_LOCALE=en_US | ||
|
||
APP_MAINTENANCE_DRIVER=file | ||
APP_MAINTENANCE_STORE=database | ||
|
||
BCRYPT_ROUNDS=12 | ||
|
||
LOG_CHANNEL=stack | ||
LOG_STACK=single | ||
LOG_DEPRECATIONS_CHANNEL=null | ||
LOG_LEVEL=debug | ||
|
||
DB_CONNECTION=sqlite | ||
DB_DATABASE=/home/runner/work/auth/auth/laravel_app/database/dusk.sqlite | ||
|
||
SESSION_DRIVER=file | ||
SESSION_LIFETIME=120 | ||
SESSION_ENCRYPT=false | ||
SESSION_PATH=/ | ||
SESSION_DOMAIN=null | ||
|
||
BROADCAST_CONNECTION=log | ||
FILESYSTEM_DISK=local | ||
QUEUE_CONNECTION=database | ||
|
||
CACHE_STORE=file | ||
CACHE_PREFIX= | ||
|
||
MEMCACHED_HOST=127.0.0.1 | ||
|
||
REDIS_CLIENT=phpredis | ||
REDIS_HOST=127.0.0.1 | ||
REDIS_PASSWORD=null | ||
REDIS_PORT=6379 | ||
|
||
MAIL_MAILER=log | ||
MAIL_HOST=127.0.0.1 | ||
MAIL_PORT=2525 | ||
MAIL_USERNAME=null | ||
MAIL_PASSWORD=null | ||
MAIL_ENCRYPTION=null | ||
MAIL_FROM_ADDRESS="[email protected]" | ||
MAIL_FROM_NAME="${APP_NAME}" | ||
|
||
AWS_ACCESS_KEY_ID= | ||
AWS_SECRET_ACCESS_KEY= | ||
AWS_DEFAULT_REGION=us-east-1 | ||
AWS_BUCKET= | ||
AWS_USE_PATH_STYLE_ENDPOINT=false | ||
|
||
VITE_APP_NAME="${APP_NAME}" |
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
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,71 @@ | ||
<?php | ||
|
||
namespace Devdojo\Auth\Providers; | ||
|
||
use Illuminate\Support\ServiceProvider; | ||
use Laravel\Dusk\Browser; | ||
use Laravel\Dusk\Dusk; | ||
|
||
class DuskServiceProvider extends ServiceProvider | ||
{ | ||
/** | ||
* Register Dusk's browser macros. | ||
*/ | ||
public function boot(): void | ||
{ | ||
Dusk::selectorHtmlAttribute('data-auth'); | ||
|
||
Browser::macro('authAttributeChange', function (?string $selector, string $attribute, string $value) { | ||
$this->script("document.querySelector('$selector').setAttribute('$attribute', '$value');"); | ||
|
||
return $this; | ||
}); | ||
|
||
Browser::macro('authAttributeRemove', function (?string $selector, string $attribute) { | ||
$this->script("document.querySelector('$selector').removeAttribute('$attribute');"); | ||
|
||
return $this; | ||
}); | ||
|
||
Browser::macro('testValidationErrorOnSubmit', function (string $message = '') { | ||
$this | ||
->click('@submit-button') | ||
->waitForText($message) | ||
->assertSee($message); | ||
|
||
return $this; | ||
}); | ||
|
||
Browser::macro('createJohnDoe', function () { | ||
$user = \App\Models\User::factory()->create([ | ||
'email' => '[email protected]', | ||
'password' => \Hash::make('password'), | ||
]); | ||
|
||
return $this; | ||
}); | ||
|
||
Browser::macro('assertRedirectAfterAuthUrlIsCorrect', function () { | ||
$redirectExpectedToBe = '/'; | ||
if (class_exists(\Devdojo\Genesis\Genesis::class)) { | ||
$redirectExpectedToBe = '/dashboard'; | ||
} | ||
$this->assertPathIs($redirectExpectedToBe); | ||
|
||
return $this; | ||
}); | ||
|
||
Browser::macro('clearLogFile', function () { | ||
file_put_contents(storage_path('logs/laravel.log'), ''); | ||
|
||
return $this; | ||
}); | ||
|
||
Browser::macro('getLogFile', function ($callback) { | ||
$content = file_get_contents(storage_path('logs/laravel.log')); | ||
$callback($content); | ||
|
||
return $this; | ||
}); | ||
} | ||
} |
Oops, something went wrong.