@@ -125,6 +125,22 @@ public function test_sends_recovery_email()
125125 ]);
126126 }
127127
128+ public function test_sends_recovery_email_using_json ()
129+ {
130+ $ notification = Notification::fake ();
131+
132+ $ this ->postJson ('webauthn/lost ' , [
133+ 'email ' => 'john.doe@mail.com '
134+ ])
135+ ->assertSeeText (trans ('larapass::recovery.sent ' ));
136+
137+ $ notification ->assertSentTo (TestWebAuthnUser::first (), AccountRecoveryNotification::class);
138+
139+ $ this ->assertDatabaseHas ('web_authn_recoveries ' , [
140+ 'email ' => 'john.doe@mail.com '
141+ ]);
142+ }
143+
128144 public function test_error_if_email_invalid ()
129145 {
130146 $ notification = Notification::fake ();
@@ -137,6 +153,11 @@ public function test_error_if_email_invalid()
137153 ->assertRedirect (route ('webauthn.lost.form ' ))
138154 ->assertSessionHasErrors (['email ' ]);
139155
156+ $ this ->postJson ('webauthn/lost ' , [
157+ 'email ' => 'invalid '
158+ ])
159+ ->assertSeeText ('The given data was invalid ' );
160+
140161 $ notification ->assertNothingSent ();
141162
142163 $ this ->assertDatabaseMissing ('web_authn_recoveries ' , [
@@ -156,6 +177,11 @@ public function test_error_if_user_email_doesnt_exists()
156177 ->assertRedirect (route ('webauthn.lost.form ' ))
157178 ->assertSessionHasErrors (['email ' ]);
158179
180+ $ this ->postJson ('webauthn/lost ' , [
181+ 'email ' => 'foo@bar.com '
182+ ])
183+ ->assertSeeText ('The given data was invalid ' );
184+
159185 $ notification ->assertNothingSent ();
160186
161187 $ this ->assertDatabaseMissing ('web_authn_recoveries ' , [
@@ -190,6 +216,11 @@ public function test_throttled_on_resend()
190216 ])
191217 ->assertRedirect (route ('webauthn.lost.form ' ))
192218 ->assertSessionHasErrors (['email ' ]);
219+
220+ $ this ->postJson ('webauthn/lost ' , [
221+ 'email ' => 'john.doe@mail.com '
222+ ])
223+ ->assertSeeText (trans ('larapass::recovery.throttled ' ));
193224 }
194225
195226 public function test_error_if_no_broker_is_set ()
0 commit comments