Skip to content

Commit c1a8184

Browse files
committed
removing unneccessary package and updating test
1 parent 7ccd4ca commit c1a8184

File tree

3 files changed

+14
-304
lines changed

3 files changed

+14
-304
lines changed

package-lock.json

Lines changed: 0 additions & 270 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
"@radix-ui/react-select": "^2.1.6",
3636
"@radix-ui/react-separator": "^1.1.3",
3737
"@radix-ui/react-slot": "^1.1.2",
38-
"@radix-ui/react-tabs": "^1.1.4",
3938
"@radix-ui/react-toggle": "^1.1.2",
4039
"@radix-ui/react-toggle-group": "^1.1.2",
4140
"@radix-ui/react-tooltip": "^1.1.8",

tests/Feature/Auth/TwoFactorAuthTest.php

Lines changed: 14 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)