Skip to content

Commit 39397fb

Browse files
committed
wip
Signed-off-by: Mior Muhammad Zaki <[email protected]>
1 parent 3913030 commit 39397fb

File tree

1 file changed

+38
-37
lines changed

1 file changed

+38
-37
lines changed

tests/Browser/Auth/PasswordResetTest.php

Lines changed: 38 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
use Illuminate\Auth\Notifications\ResetPassword;
55
use Illuminate\Support\Facades\Notification;
66

7+
use function Pest\Laravel\post;
8+
79
test('reset password link screen can be rendered', function () {
810
visit(route('password.request'))
911
->assertSee('Forgot password')
@@ -12,59 +14,58 @@
1214
->assertNoJavaScriptErrors();
1315
});
1416

15-
test('test_reset_password_link_can_be_requested', function () {
16-
Notification::fake();
17-
17+
test('test reset password link can be requested', function () {
1818
$user = User::factory()->create();
1919

20+
Notification::fake();
21+
2022
visit(route('password.request'))
2123
->fill('email', $user->email)
2224
->press('Email password reset link')
23-
->assertSee('A reset link will be sent if the account exists.');
25+
->assertSee('A reset link will be sent if the account exists.')
26+
->assertNoConsoleLogs()
27+
->assertNoJavaScriptErrors();
2428

2529
Notification::assertSentTo($user, ResetPassword::class);
2630
});
2731

28-
// public function test_reset_password_screen_can_be_rendered()
29-
// {
30-
// Notification::fake();
31-
32-
// $user = User::factory()->create();
33-
34-
// $this->post(route('password.email'), ['email' => $user->email]);
35-
36-
// Notification::assertSentTo($user, ResetPassword::class, function ($notification) {
37-
// $response = $this->get(route('password.request', $notification->token));
38-
39-
// $response->assertStatus(200);
32+
test('reset password screen can be rendered', function () {
33+
$user = User::factory()->create();
4034

41-
// return true;
42-
// });
43-
// }
35+
Notification::fake();
4436

45-
// public function test_password_can_be_reset_with_valid_token()
46-
// {
47-
// Notification::fake();
37+
post(route('password.email'), ['email' => $user->email]);
4838

49-
// $user = User::factory()->create();
39+
Notification::assertSentTo($user, ResetPassword::class, function ($notification) {
40+
visit(route('password.reset', $notification->token))
41+
->assertNoConsoleLogs()
42+
->assertNoJavaScriptErrors();
5043

51-
// $this->post(route('password.email'), ['email' => $user->email]);
44+
return true;
45+
});
46+
});
5247

53-
// Notification::assertSentTo($user, ResetPassword::class, function ($notification) use ($user) {
54-
// $response = $this->post(route('password.store'), [
55-
// 'token' => $notification->token,
56-
// 'email' => $user->email,
57-
// 'password' => 'password',
58-
// 'password_confirmation' => 'password',
59-
// ]);
48+
test('password can be reset with valid token', function () {
49+
$user = User::factory()->create();
6050

61-
// $response
62-
// ->assertSessionHasNoErrors()
63-
// ->assertRedirect(route('login'));
51+
Notification::fake();
6452

65-
// return true;
66-
// });
67-
// }
53+
post(route('password.email'), ['email' => $user->email]);
54+
55+
Notification::assertSentTo($user, ResetPassword::class, function ($notification) use ($user) {
56+
visit(route('password.reset', $notification->token))
57+
->fill('password', 'password')
58+
->fill('password_confirmation', 'password')
59+
->assertNoConsoleLogs()
60+
->assertNoJavaScriptErrors()
61+
->press('Reset password')
62+
->assertUrlIs(route('home'))
63+
->assertNoConsoleLogs()
64+
->assertNoJavaScriptErrors();
65+
66+
return true;
67+
});
68+
});
6869

6970
// public function test_password_cannot_be_reset_with_invalid_token(): void
7071
// {

0 commit comments

Comments
 (0)