mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-27 15:17:30 +00:00
test(settings): follow the redesigned settings and admin pages
The tests now look for what the pages show after the redesign: the admin Settings tab is Security and Services, MCP Access and User Defaults are MCP and Defaults, notification channels and the 2FA rule are rows with a named switch, hints sit behind the info mark, each addon type card counts its own addons, OAuth scopes and the AI sharing note are shown in full, and the 2FA disable password is the field beside the code. The phone's MCP admin header keeps its own title, MCP Access. The mail pill test renders with translations, so it finds From mail rather than the key.
This commit is contained in:
@@ -426,9 +426,10 @@ describe('AddonManager', () => {
|
||||
expect(paperlessRow.querySelector('svg')).toBeInTheDocument();
|
||||
expect(isOn(subToggle('Paperless-ngx'))).toBe(true);
|
||||
expect(isOn(subToggle('Nextcloud'))).toBe(false);
|
||||
// Documents and Journey are the addons; an enabled provider is a shelf row
|
||||
// and must not turn 1/2 into 2/2.
|
||||
expect(screen.getByText('1/2')).toBeInTheDocument();
|
||||
// Documents and Journey are the addons, one per type card; an enabled
|
||||
// provider is a shelf row and must not turn the trip card's 1/1 into 2/2.
|
||||
expect(screen.getByText('1/1')).toBeInTheDocument();
|
||||
expect(screen.getByText('0/1')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('FE-ADMIN-ADDON-034: document providers stay hidden while Documents itself is off', async () => {
|
||||
|
||||
@@ -395,10 +395,11 @@ describe('DefaultUserSettingsTab', () => {
|
||||
render(<DefaultUserSettingsTab />);
|
||||
await screen.findByText('3D buildings & terrain');
|
||||
|
||||
// 3D defaults to on, quality mode to off when neither is stored
|
||||
const threeD = within(screen.getByText('3D buildings & terrain').closest('div') as HTMLElement);
|
||||
// 3D defaults to on, quality mode to off when neither is stored. The row
|
||||
// (label left, control right) holds the On/Off pair.
|
||||
const threeD = within(screen.getByText('3D buildings & terrain').closest('.flex-wrap') as HTMLElement);
|
||||
expect(isActive(threeD.getByRole('button', { name: 'On' }))).toBe(true);
|
||||
const quality = within(screen.getByText('High-quality mode').closest('div') as HTMLElement);
|
||||
const quality = within(screen.getByText('High-quality mode').closest('.flex-wrap') as HTMLElement);
|
||||
expect(isActive(quality.getByRole('button', { name: 'Off' }))).toBe(true);
|
||||
|
||||
await user.click(threeD.getByRole('button', { name: 'Off' }));
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// FE-PLANNER-BKPARTS-001 to FE-PLANNER-BKPARTS-006
|
||||
import { fireEvent, render, screen } from '@testing-library/react';
|
||||
import { describe, expect, it, vi } from 'vitest';
|
||||
import { fireEvent, render, screen } from '../../../../tests/helpers/render';
|
||||
|
||||
import { buildReservation, buildTripFile } from '../../../../tests/helpers/factories';
|
||||
import { downloadFile, openFile } from '../../../utils/fileDownload';
|
||||
|
||||
@@ -27,6 +27,13 @@ beforeEach(() => {
|
||||
seedStore(useSettingsStore, { settings: buildSettings() });
|
||||
});
|
||||
|
||||
/** The password field of the 2FA disable panel: the one beside the code field. */
|
||||
function mfaDisablePassword(): HTMLInputElement {
|
||||
const input = screen.getByPlaceholderText('6-digit code').parentElement?.querySelector<HTMLInputElement>('input[type="password"]');
|
||||
if (!input) throw new Error('no password field beside the 2FA code');
|
||||
return input;
|
||||
}
|
||||
|
||||
describe('AccountTab', () => {
|
||||
it('FE-COMP-ACCOUNT-001: renders without crashing', () => {
|
||||
render(<AccountTab />);
|
||||
@@ -374,12 +381,9 @@ describe('AccountTab – MFA', () => {
|
||||
http.get('/api/auth/me', () => HttpResponse.json({ user: buildUser() })),
|
||||
);
|
||||
render(<><ToastContainer /><AccountTab /></>);
|
||||
// When mfa_enabled + !oidcOnlyMode, there are 4 password inputs total:
|
||||
// 3 in Change Password section + 1 in MFA disable section (last one)
|
||||
const passwordInputs = document.querySelectorAll('input[type="password"]');
|
||||
const mfaPasswordInput = passwordInputs[passwordInputs.length - 1] as HTMLInputElement;
|
||||
await user.type(mfaPasswordInput, 'mypassword');
|
||||
// The disable panel asks for the password right beside the code field.
|
||||
const codeInput = screen.getByPlaceholderText('6-digit code');
|
||||
await user.type(mfaDisablePassword(), 'mypassword');
|
||||
await user.type(codeInput, '123456');
|
||||
await user.click(screen.getByRole('button', { name: 'Disable 2FA' }));
|
||||
expect(await screen.findByText('Two-factor authentication disabled')).toBeInTheDocument();
|
||||
@@ -799,8 +803,7 @@ describe('AccountTab – MFA error paths', () => {
|
||||
);
|
||||
render(<><ToastContainer /><AccountTab /></>);
|
||||
|
||||
const passwordInputs = document.querySelectorAll('input[type="password"]');
|
||||
await user.type(passwordInputs[passwordInputs.length - 1], 'mypassword');
|
||||
await user.type(mfaDisablePassword(), 'mypassword');
|
||||
await user.type(screen.getByPlaceholderText('6-digit code'), '123456');
|
||||
await user.click(screen.getByRole('button', { name: 'Disable 2FA' }));
|
||||
|
||||
|
||||
@@ -427,8 +427,7 @@ describe('IntegrationsTab', () => {
|
||||
expect(screen.getByText(/clid-abc/)).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('FE-COMP-INTEGRATIONS-022: scope expansion toggle shows more/fewer scopes', async () => {
|
||||
const user = userEvent.setup();
|
||||
it('FE-COMP-INTEGRATIONS-022: every scope of a client is shown, none folded behind a +N', async () => {
|
||||
const scopes = ['trips:read', 'trips:write', 'places:read', 'places:write', 'budget:read', 'budget:write', 'packing:read'];
|
||||
server.use(
|
||||
http.get('/api/oauth/clients', () =>
|
||||
@@ -442,11 +441,8 @@ describe('IntegrationsTab', () => {
|
||||
enableMcp();
|
||||
render(<IntegrationsTab />);
|
||||
await screen.findByText('Big App');
|
||||
// "+2 more" button visible (7 scopes, 5 shown)
|
||||
const moreBtn = screen.getByText(/^\+\d+$/);
|
||||
await user.click(moreBtn);
|
||||
// Show less / collapse button now visible
|
||||
expect(screen.getByText('−')).toBeInTheDocument();
|
||||
for (const scope of scopes) expect(screen.getByText(scope)).toBeInTheDocument();
|
||||
expect(screen.queryByText(/^\+\d+$/)).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('FE-COMP-INTEGRATIONS-023: active OAuth sessions section renders when sessions exist', async () => {
|
||||
|
||||
@@ -172,10 +172,10 @@ describe('AiConnectPanel', () => {
|
||||
expect(screen.getByRole('button', { name: /Connect OpenRouter/ })).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('FE-COMP-AI-CONNECT-PANEL-008: the sharing details fold out', async () => {
|
||||
const user = userEvent.setup();
|
||||
it('FE-COMP-AI-CONNECT-PANEL-008: the sharing details are said in full, not folded behind a button', () => {
|
||||
render(<AiConnectPanel scope="user" onConnected={vi.fn()} />);
|
||||
await user.click(screen.getByRole('button', { name: /What gets shared\?/ }));
|
||||
expect(screen.getByText('What gets shared?')).toBeInTheDocument();
|
||||
expect(screen.queryByRole('button', { name: /What gets shared\?/ })).not.toBeInTheDocument();
|
||||
expect(screen.getByText('Not your password, your files or your other trips.')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user