Skip to content

Commit

Permalink
Version bump + Improved Dusk tests + Native Password Confirmation (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
pascalbaljet authored Feb 3, 2023
1 parent 561ae13 commit 6acdce6
Show file tree
Hide file tree
Showing 13 changed files with 40 additions and 48 deletions.
11 changes: 3 additions & 8 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
runs-on: ubuntu-latest

strategy:
fail-fast: true
fail-fast: false
matrix:
php: [8.2, 8.1, 8.0]
laravel: [9.*]
Expand All @@ -32,11 +32,6 @@ jobs:
run: rm -rf vendor/protonemedia/laravel-splade-breeze
if: matrix.os == 'ubuntu-latest'

- name: Remove installed Breeze (Windows)
run: rd "vendor/protonemedia/laravel-splade-breeze" /s /q
shell: cmd
if: matrix.os == 'windows-latest'

- name: Checkout code
uses: actions/checkout@v2
with:
Expand All @@ -57,8 +52,8 @@ jobs:
- name: Run Dusk Tests
uses: nick-invision/retry@v2
with:
timeout_minutes: 5
max_attempts: 3
timeout_minutes: 10
max_attempts: 5
command: php artisan dusk --env=dusk

- name: Upload Dusk Screenshots
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"illuminate/filesystem": "^9.37",
"illuminate/support": "^9.37",
"illuminate/validation": "^9.37",
"protonemedia/laravel-splade": "^1.2.2"
"protonemedia/laravel-splade": "^1.2.9"
},
"conflict": {
"laravel/framework": "<9.37.0"
Expand Down
2 changes: 1 addition & 1 deletion src/Console/InstallsSpladeStack.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ protected function installSpladeStack()
// NPM Packages...
$this->updateNodePackages(function ($packages) {
return [
'@protonemedia/laravel-splade' => '^1.2.2',
'@protonemedia/laravel-splade' => '^1.2.9',
'@tailwindcss/forms' => '^0.5.3',
'@tailwindcss/typography' => '^0.5.2',
'@vitejs/plugin-vue' => '^3.0.0',
Expand Down
3 changes: 3 additions & 0 deletions stubs/splade/dusk-tests/Auth/AuthenticationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public function test_login_screen_can_be_rendered()
$this->browse(function (Browser $browser) {
$browser->logout()
->visit('/login')
->waitForInput('email')
->assertInputPresent('email')
->assertInputPresent('password');
});
Expand All @@ -29,6 +30,7 @@ public function test_users_can_authenticate_using_the_login_screen()

$browser->logout()
->visit('/login')
->waitForInput('email')
->type('email', $user->email)
->type('password', 'password')
->press('Log in')
Expand All @@ -44,6 +46,7 @@ public function test_users_can_not_authenticate_with_invalid_password()

$browser->logout()
->visit('/login')
->waitForInput('email')
->type('email', $user->email)
->type('password', 'wrong-password')
->press('Log in')
Expand Down
1 change: 1 addition & 0 deletions stubs/splade/dusk-tests/Auth/EmailVerificationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public function test_email_verification_screen_can_be_rendered()

$browser->loginAs($user)
->visit('/verify-email')
->waitForText('Thanks for signing up!')
->assertSeeIn('button', 'Resend Verification Email');
});
}
Expand Down
3 changes: 3 additions & 0 deletions stubs/splade/dusk-tests/Auth/PasswordConfirmationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public function test_confirm_password_screen_can_be_rendered()

$browser->loginAs($user)
->visit('/confirm-password')
->waitForText('Please confirm your password before continuing.')
->assertInputPresent('password');
});
}
Expand All @@ -30,6 +31,7 @@ public function test_password_can_be_confirmed()

$browser->loginAs($user)
->visit('/confirm-password')
->waitForText('Please confirm your password before continuing.')
->type('password', 'password')
->press('Confirm')
->waitForLocation(RouteServiceProvider::HOME)
Expand All @@ -44,6 +46,7 @@ public function test_password_is_not_confirmed_with_invalid_password()

$browser->loginAs($user)
->visit('/confirm-password')
->waitForText('Please confirm your password before continuing.')
->type('password', 'wrong-password')
->press('Confirm')
->waitForText('The provided password is incorrect.')
Expand Down
1 change: 1 addition & 0 deletions stubs/splade/dusk-tests/Auth/PasswordResetTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ public function test_password_can_be_reset_with_valid_token()

$browser->logout()
->visit('/forgot-password')
->waitForText('Forgot your password?')
->type('email', $user->email)
->press('Email Password Reset Link')
->waitForText('We have emailed your password reset link!');
Expand Down
2 changes: 2 additions & 0 deletions stubs/splade/dusk-tests/Auth/PasswordUpdateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public function test_password_can_be_updated()
$this->browse(function (Browser $browser) use ($user) {
$browser->loginAs($user)
->visit('/profile')
->waitForText('Update Password')
->within('@update-password', function (Browser $browser) {
$browser->type('current_password', 'password')
->type('password', 'new-password')
Expand All @@ -38,6 +39,7 @@ public function test_correct_password_must_be_provided_to_update_password()
$this->browse(function (Browser $browser) use ($user) {
$browser->loginAs($user)
->visit('/profile')
->waitForText('Update Password')
->within('@update-password', function (Browser $browser) {
$browser->type('current_password', 'wrong-password')
->type('password', 'new-password')
Expand Down
2 changes: 2 additions & 0 deletions stubs/splade/dusk-tests/Auth/RegistrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public function test_registration_screen_can_be_rendered()
$this->browse(function (Browser $browser) {
$browser->logout()
->visit('/register')
->waitForInput('name')
->assertInputPresent('name')
->assertInputPresent('email')
->assertInputPresent('password')
Expand All @@ -28,6 +29,7 @@ public function test_new_users_can_register()
$this->browse(function (Browser $browser) {
$browser->logout()
->visit('/register')
->waitForInput('name')
->type('name', 'Test User')
->type('email', '[email protected]')
->type('password', 'password')
Expand Down
18 changes: 11 additions & 7 deletions stubs/splade/dusk-tests/ProfileTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public function test_profile_page_is_displayed()

$browser->loginAs($user)
->visit('/profile')
->waitForText('Profile Information')
->assertInputPresent('current_password');
});
}
Expand All @@ -29,6 +30,7 @@ public function test_profile_information_can_be_updated()
$this->browse(function (Browser $browser) use ($user) {
$browser->loginAs($user)
->visit('/profile')
->waitForText('Profile Information')
->within('@update-profile-information', function (Browser $browser) {
$browser->type('name', 'Test User')
->type('email', '[email protected]')
Expand All @@ -51,6 +53,7 @@ public function test_email_verification_status_is_unchanged_when_the_email_addre
$this->browse(function (Browser $browser) use ($user) {
$browser->loginAs($user)
->visit('/profile')
->waitForText('Profile Information')
->within('@update-profile-information', function (Browser $browser) use ($user) {
$browser->type('name', 'Test User')
->type('email', $user->email)
Expand All @@ -71,16 +74,17 @@ public function test_user_can_delete_their_account()
$this->browse(function (Browser $browser) use ($user) {
$browser->loginAs($user)
->visit('/profile')
->waitForText('Delete Account')
->scrollTo('@delete-user')
->click('@open-delete-modal')
->waitFor('@confirm-user-deletion')
->within('@confirm-user-deletion', function (Browser $browser) {
$browser->waitForText('Are you sure')
->press('Delete Account')
->waitForText('Are you sure you want to delete your account?')
->within('#headlessui-portal-root', function (Browser $browser) {
$browser
->type('password', 'wrong_password')
->press('@confirm-delete-account')
->waitForText('The password is incorrect.')
->press('Delete Account')
->waitForText('The provided password is incorrect.')
->type('password', 'password')
->press('@confirm-delete-account')
->press('Delete Account')
->waitForLocation('/')
->assertGuest();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,33 +9,14 @@
</p>
</header>

<Link href="#confirm-user-deletion" dusk="open-delete-modal" class="inline-flex rounded-md shadow-sm bg-red-500 hover:bg-red-700 text-white font-bold py-2 px-4 focus:outline-none focus:shadow-outline">
{{ __('Delete Account') }}
</Link>

<x-splade-modal name="confirm-user-deletion">
<x-splade-form dusk="confirm-user-deletion" method="delete" :action="route('profile.destroy')">
<h2 class="text-lg font-medium text-gray-900 dark:text-gray-100">
{{ __('Are you sure you want to delete your account?') }}
</h2>

<p class="mt-1 text-sm text-gray-600 dark:text-gray-400">
{{ __('Once your account is deleted, all of its resources and data will be permanently deleted. Please enter your password to confirm you would like to permanently delete your account.') }}
</p>

<div class="mt-6">
<x-splade-input id="password" name="password" type="password" :placeholder="__('Password')" />
</div>

<div class="mt-6 flex justify-end">
<button type="button" @click.prevent="modal.close" class="inline-flex rounded-md shadow-sm border border-gray-300 bg-white text-gray-700 hover:bg-gray-50 font-bold py-2 px-4 focus:outline-none focus:shadow-outline">
{{ __('Cancel') }}
</button>

<button dusk="confirm-delete-account" type="submit" class="ml-3 inline-flex rounded-md shadow-sm bg-red-500 hover:bg-red-700 text-white font-bold py-2 px-4 focus:outline-none focus:shadow-outline">
{{ __('Delete Account') }}
</button>
</div>
</x-splade-form>
</x-modal>
<x-splade-form
method="delete"
:action="route('profile.destroy')"
:confirm="__('Are you sure you want to delete your account?')"
:confirm-text="__('Once your account is deleted, all of its resources and data will be permanently deleted. Please enter your password to confirm you would like to permanently delete your account.')"
:confirm-button="__('Delete Account')"
require-password
>
<x-splade-submit danger :label="__('Delete Account')" />
</x-splade-form>
</section>
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</p>
</header>

<x-splade-form method="put" :action="route('password.update')" class="mt-6 space-y-6">
<x-splade-form method="put" :action="route('password.update')" class="mt-6 space-y-6" preserve-scroll>
<x-splade-input id="current_password" name="current_password" type="password" :label="__('Current Password')" autocomplete="current-password" />
<x-splade-input id="password" name="password" type="password" :label="__('New Password')" autocomplete="new-password" />
<x-splade-input id="password_confirmation" name="password_confirmation" type="password" :label="__('Confirm Password')" autocomplete="new-password" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</p>
</header>

<x-splade-form method="patch" :action="route('profile.update')" :default="$user" class="mt-6 space-y-6">
<x-splade-form method="patch" :action="route('profile.update')" :default="$user" class="mt-6 space-y-6" preserve-scroll>
<x-splade-input id="name" name="name" type="text" :label="__('Name')" required autofocus autocomplete="name" />
<x-splade-input id="email" name="email" type="email" :label="__('Email')" required autocomplete="email" />

Expand Down

0 comments on commit 6acdce6

Please sign in to comment.