fix(tests): update tests for granular auth toggles

- Add new fields to AppConfig type and buildAppConfig factory
- Update FE-PAGE-ADMIN-018: heading changed to "Authentication Methods"
- Update FE-PAGE-ADMIN-053: oidc_only toggle removed from OIDC panel
- Update FE-PAGE-LOGIN-007/017: mocks now include password_login/oidc_login
- Update ADMIN-SVC-049: updateOidcSettings no longer writes oidc_only
This commit is contained in:
jubnl
2026-04-11 20:30:30 +02:00
parent bfd2553d1e
commit 47d9cce936
5 changed files with 27 additions and 21 deletions
+4 -13
View File
@@ -359,13 +359,13 @@ describe('AdminPage', () => {
fireEvent.click(screen.getByRole('button', { name: /settings/i })); fireEvent.click(screen.getByRole('button', { name: /settings/i }));
const heading = await screen.findByRole('heading', { name: /allow registration/i }); const heading = await screen.findByRole('heading', { name: /authentication methods/i });
const card = heading.closest('.bg-white'); const card = heading.closest('.bg-white');
const toggle = within(card!).getByRole('button'); const toggles = within(card!).getAllByRole('button');
fireEvent.click(toggle); fireEvent.click(toggles[0]); // First toggle = password_login
await waitFor(() => { await waitFor(() => {
expect(capturedBody).toEqual(expect.objectContaining({ allow_registration: false })); expect(capturedBody).toEqual(expect.objectContaining({ password_login: false }));
}); });
}); });
}); });
@@ -1328,15 +1328,6 @@ describe('AdminPage', () => {
const clientSecretInput = clientSecretLabel.closest('div')!.querySelector('input')!; const clientSecretInput = clientSecretLabel.closest('div')!.querySelector('input')!;
fireEvent.change(clientSecretInput, { target: { value: 'my-client-secret' } }); fireEvent.change(clientSecretInput, { target: { value: 'my-client-secret' } });
// OIDC-only toggle — button within the OIDC card for oidc_only toggle
// admin.oidcOnlyMode = 'Disable password authentication'
const oidcOnlyText = within(oidcCard!).getByText('Disable password authentication');
const oidcOnlySection = oidcOnlyText.closest('.flex');
const oidcOnlyToggle = oidcOnlySection?.querySelector('button');
if (oidcOnlyToggle) {
fireEvent.click(oidcOnlyToggle);
}
// Verify the inputs updated // Verify the inputs updated
expect((issuerInput as HTMLInputElement).value).toBe('https://accounts.google.com'); expect((issuerInput as HTMLInputElement).value).toBe('https://accounts.google.com');
expect((clientIdInput as HTMLInputElement).value).toBe('my-client-id'); expect((clientIdInput as HTMLInputElement).value).toBe('my-client-id');
+5
View File
@@ -155,6 +155,9 @@ describe('LoginPage', () => {
oidc_configured: true, oidc_configured: true,
oidc_display_name: 'Okta', oidc_display_name: 'Okta',
oidc_only_mode: false, oidc_only_mode: false,
oidc_login: true,
password_login: true,
password_registration: true,
setup_complete: true, setup_complete: true,
}); });
}), }),
@@ -438,6 +441,8 @@ describe('LoginPage', () => {
demo_mode: false, demo_mode: false,
oidc_configured: true, oidc_configured: true,
oidc_only_mode: true, oidc_only_mode: true,
password_login: false,
oidc_login: true,
setup_complete: true, setup_complete: true,
}); });
}), }),
+7
View File
@@ -296,11 +296,18 @@ export interface AppConfig {
demo_mode: boolean demo_mode: boolean
oidc_configured: boolean oidc_configured: boolean
oidc_display_name?: string oidc_display_name?: string
oidc_only_mode?: boolean
has_maps_key?: boolean has_maps_key?: boolean
allowed_file_types?: string allowed_file_types?: string
timezone?: string timezone?: string
/** When true, users without MFA cannot use the app until they enable it */ /** When true, users without MFA cannot use the app until they enable it */
require_mfa?: boolean require_mfa?: boolean
// Granular auth toggles
password_login?: boolean
password_registration?: boolean
oidc_login?: boolean
oidc_registration?: boolean
env_override_oidc_only?: boolean
} }
// Translation function type // Translation function type
+6
View File
@@ -283,6 +283,12 @@ export function buildAppConfig(overrides: Partial<AppConfig> = {}): AppConfig {
allow_registration: true, allow_registration: true,
demo_mode: false, demo_mode: false,
oidc_configured: false, oidc_configured: false,
oidc_only_mode: false,
password_login: true,
password_registration: true,
oidc_login: true,
oidc_registration: true,
env_override_oidc_only: false,
...overrides, ...overrides,
}; };
} }
@@ -471,14 +471,11 @@ describe('OIDC Settings', () => {
expect(result.client_id).toBe('my-client'); expect(result.client_id).toBe('my-client');
}); });
it('ADMIN-SVC-049 — updateOidcSettings sets oidc_only flag correctly', () => { it('ADMIN-SVC-049 — updateOidcSettings does not write oidc_only (replaced by granular toggles)', () => {
updateOidcSettings({ oidc_only: true }); updateOidcSettings({ issuer: 'https://auth.example.com', client_id: 'my-client' });
const enabled = getOidcSettings() as any; const result = getOidcSettings() as any;
expect(enabled.oidc_only).toBe(true); // oidc_only is no longer managed by updateOidcSettings; use password_login/oidc_login toggles
expect(result.oidc_only).toBe(false);
updateOidcSettings({ oidc_only: false });
const disabled = getOidcSettings() as any;
expect(disabled.oidc_only).toBe(false);
}); });
}); });