@@ -25,16 +25,10 @@ public function test_can_view_two_factor_settings_page()
2525
2626 // Check Inertia props instead of HTML
2727 $ inertiaProps = $ response ->original ?->getData() ?? [];
28- if (isset ($ inertiaProps ['page ' ]['props ' ])) {
29- $ props = $ inertiaProps ['page ' ]['props ' ];
30- $ this ->assertArrayHasKey ('confirmed ' , $ props );
31- $ this ->assertArrayHasKey ('recoveryCodes ' , $ props );
32- $ this ->assertFalse ($ props ['confirmed ' ]);
33- } else {
34- // Fallback: check for expected strings in HTML (legacy/SSR)
35- $ response ->assertSee ('Two Factor Authentication ' );
36- $ response ->assertSee ('Disabled ' );
37- }
28+ $ props = $ inertiaProps ['page ' ]['props ' ];
29+ $ this ->assertArrayHasKey ('confirmed ' , $ props );
30+ $ this ->assertArrayHasKey ('recoveryCodes ' , $ props );
31+ $ this ->assertFalse ($ props ['confirmed ' ]);
3832 }
3933
4034 public function test_can_enable_two_factor_authentication ()
@@ -48,14 +42,13 @@ public function test_can_enable_two_factor_authentication()
4842 // Assert JSON response with expected structure
4943 $ response ->assertStatus (200 )
5044 ->assertJsonStructure ([
51- 'qrCode ' , // Changed from 'svg' to 'qrCode'
45+ 'qrCode ' ,
5246 'secret '
53- // 'recovery_codes' removed as they're now generated in the confirm step
5447 ]);
5548
5649 $ user ->refresh ();
5750 $ this ->assertNotNull ($ user ->two_factor_secret );
58- // Recovery codes are now null until confirm step
51+ // Recovery codes are null until confirm step
5952 $ this ->assertNull ($ user ->two_factor_recovery_codes );
6053 }
6154
@@ -85,18 +78,12 @@ public function test_can_manually_enable_two_factor_authentication()
8578 $ response ->assertStatus (200 );
8679 // For Inertia/React, check the JSON response props instead of HTML content
8780 $ inertiaProps = $ response ->original ?->getData() ?? [];
88- if (isset ($ inertiaProps ['page ' ]['props ' ])) {
89- $ props = $ inertiaProps ['page ' ]['props ' ];
90- $ this ->assertTrue (
91- ($ props ['confirmed ' ] ?? false ) === true ,
92- '2FA should be confirmed in page props. '
93- );
94- $ this ->assertArrayHasKey ('recoveryCodes ' , $ props );
95- } else {
96- // Fallback: check for expected strings in HTML (for legacy Inertia SSR)
97- $ response ->assertSee ('Enabled ' );
98- $ response ->assertSee ('2FA Recovery Codes ' );
99- }
81+ $ props = $ inertiaProps ['page ' ]['props ' ];
82+ $ this ->assertTrue (
83+ ($ props ['confirmed ' ] ?? false ) === true ,
84+ '2FA should be confirmed in page props. '
85+ );
86+ $ this ->assertArrayHasKey ('recoveryCodes ' , $ props );
10087 }
10188
10289 public function test_user_with_two_factor_enabled_is_redirected_to_challenge_page_after_login ()
@@ -182,8 +169,6 @@ public function test_unauthenticated_user_is_redirected_to_login_when_accessing_
182169
183170 public function test_authenticated_user_without_pending_two_factor_challenge_is_redirected_to_login ()
184171 {
185- // Note: This test name has been changed to match the actual behavior
186- // In your implementation, users without pending 2FA are redirected to login, not dashboard
187172 $ user = User::factory ()->create ();
188173
189174 // Authenticate the user but don't set the login.id session
@@ -197,12 +182,8 @@ public function test_authenticated_user_without_pending_two_factor_challenge_is_
197182 $ response ->assertRedirect ('/login ' );
198183 }
199184
200- public function test_user_with_pending_two_factor_challenge_can_access_dashboard_in_test_environment ()
201- {
202- // Note: This test name has been changed to match the actual behavior
203- // In your test environment, the middleware that would normally redirect to the 2FA challenge
204- // might not be active, so we're testing what actually happens
205-
185+ public function test_user_with_two_factor_confirmed_can_access_dashboard ()
186+ {
206187 $ user = User::factory ()->create ();
207188
208189 // Generate QR code and secret key
0 commit comments