Skip to content

Commit a7409e0

Browse files
committed
wip
Signed-off-by: Mior Muhammad Zaki <[email protected]>
1 parent 4634eaf commit a7409e0

File tree

3 files changed

+90
-2
lines changed

3 files changed

+90
-2
lines changed

tests/Browser/Auth/EmailVerificationTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@
106106
Event::assertNotDispatched(Verified::class);
107107
});
108108

109-
test('already_verified_user_visiting_verification_link_is_redirected_without_firing_event_again', function () {
109+
test('already verified user visiting verification link is redirected without firing event again', function () {
110110
$user = User::factory()->create([
111111
'email_verified_at' => now(),
112112
]);

tests/Browser/Settings/PasswordUpdateTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
->fill('password', 'new-password')
2424
->fill('password_confirmation', 'new-password')
2525
->press('Save password')
26-
->assertSee('Saved')
26+
->assertSee('Saved.')
2727
->assertUrlIs(route('password.edit'))
2828
->assertNoConsoleLogs()
2929
->assertNoJavaScriptErrors();
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,89 @@
11
<?php
2+
3+
use App\Models\User;
4+
5+
use function Pest\Laravel\actingAs;
6+
use function Pest\Laravel\assertAuthenticated;
7+
use function Pest\Laravel\assertGuest;
8+
9+
test('profile page is displayed', function () {
10+
actingAs($user = User::factory()->create());
11+
12+
visit(route('profile.edit'))
13+
->assertSee('Profile information')
14+
->assertSee('Update your name and email address')
15+
->assertValue('name', $user->name)
16+
->assertValue('email', $user->email)
17+
->assertNoConsoleLogs()
18+
->assertNoJavaScriptErrors();
19+
});
20+
21+
test('profile information can be updated', function () {
22+
actingAs($user = User::factory()->create());
23+
24+
visit(route('profile.edit'))
25+
->assertSee('Profile information')
26+
->assertSee('Update your name and email address')
27+
->fill('name', 'Test User')
28+
->fill('email', '[email protected]')
29+
->press('Save')
30+
->assertSee('Saved.')
31+
->assertUrlIs(route('profile.edit'))
32+
->assertNoConsoleLogs()
33+
->assertNoJavaScriptErrors();
34+
35+
$user->refresh();
36+
37+
expect($user->name)->toBe('Test User');
38+
expect($user->email)->toBe('[email protected]');
39+
expect($user->email_verified_at)->toBeNull();
40+
});
41+
42+
test('email verification status is unchanged when the email address is unchanged', function () {
43+
actingAs($user = User::factory()->create());
44+
45+
visit(route('profile.edit'))
46+
->assertSee('Profile information')
47+
->assertSee('Update your name and email address')
48+
->fill('name', 'Test User')
49+
->fill('email', $user->email)
50+
->press('Save')
51+
->assertSee('Saved.')
52+
->assertUrlIs(route('profile.edit'))
53+
->assertNoConsoleLogs()
54+
->assertNoJavaScriptErrors();
55+
56+
expect($user->refresh()->email_verified_at)->not->toBeNull();
57+
});
58+
59+
test('user can delete their account', function () {
60+
actingAs($user = User::factory()->create());
61+
62+
visit(route('profile.edit'))
63+
->press('@delete-user')
64+
->assertSee('Are you sure you want to delete your account?')
65+
->fill('password', 'password')
66+
->press('@confirm-delete-user')
67+
->assertUrlIs(route('home'))
68+
->assertNoConsoleLogs()
69+
->assertNoJavaScriptErrors();
70+
71+
assertGuest();
72+
expect($user->fresh())->toBeNull();
73+
});
74+
75+
test('correct password must be provided to delete account', function () {
76+
actingAs($user = User::factory()->create());
77+
78+
visit(route('profile.edit'))
79+
->press('@delete-user')
80+
->assertSee('Are you sure you want to delete your account?')
81+
->fill('password', 'wrong-password')
82+
->press('@confirm-delete-user')
83+
->assertUrlIs(route('profile.edit'))
84+
->assertNoConsoleLogs()
85+
->assertNoJavaScriptErrors();
86+
87+
assertAuthenticated();
88+
expect($user->fresh())->not->toBeNull();
89+
});

0 commit comments

Comments
 (0)