feat(12-05): drop DB-vs-env aside, add read-only DB-name field (gaps 1, 3)
- Remove the 'written to the database — not your environment file' aside from the Instance step intro - Render a read-only, disabled DB-name field under App URL, populated from GET /api/setup/status dbName - Helper text explains DB is configured via Docker env; only dbName is surfaced (T-12-3DB) - Tests: assert aside absent, DB field readOnly/disabled with mocked dbName, existing DB validation row intact
This commit is contained in:
@@ -210,9 +210,14 @@ describe('SetupPage — Already Locked screen', () => {
|
||||
describe('SetupPage — Step 2 VAPID validation (CR-01 gap)', () => {
|
||||
let queryClient: QueryClient;
|
||||
|
||||
beforeEach(() => {
|
||||
beforeEach(async () => {
|
||||
queryClient = makeQueryClient();
|
||||
vi.resetAllMocks();
|
||||
const { fetchSetupStatus } = await import('../api/client.js');
|
||||
(fetchSetupStatus as ReturnType<typeof vi.fn>).mockResolvedValue({
|
||||
setupComplete: false,
|
||||
dbName: 'familysync',
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
@@ -305,3 +310,66 @@ describe('SetupPage — Step 2 VAPID validation (CR-01 gap)', () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// ── Tests: Step 2 Instance copy + read-only DB-name field (gaps 1, 3-frontend) ──
|
||||
|
||||
describe('SetupPage — Step 2 Instance copy + DB-name field (gaps 1, 3)', () => {
|
||||
let queryClient: QueryClient;
|
||||
|
||||
beforeEach(async () => {
|
||||
queryClient = makeQueryClient();
|
||||
vi.resetAllMocks();
|
||||
const { fetchSetupStatus } = await import('../api/client.js');
|
||||
(fetchSetupStatus as ReturnType<typeof vi.fn>).mockResolvedValue({
|
||||
setupComplete: false,
|
||||
dbName: 'familysync',
|
||||
});
|
||||
});
|
||||
|
||||
async function advanceToStep2() {
|
||||
renderSetupPage(queryClient);
|
||||
const continueBtn = await screen.findByRole('button', { name: 'Continue' });
|
||||
fireEvent.click(continueBtn);
|
||||
await screen.findByText('Instance Configuration');
|
||||
}
|
||||
|
||||
it('Instance step intro no longer contains the DB-vs-env-file aside (gap 1)', async () => {
|
||||
await advanceToStep2();
|
||||
expect(screen.queryByText(/not your environment file/i)).toBeNull();
|
||||
// First sentence is preserved
|
||||
expect(screen.getByText(/Enter your instance/i)).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('renders a read-only, disabled DB-name field populated from status dbName (gap 3)', async () => {
|
||||
await advanceToStep2();
|
||||
const dbField = await screen.findByLabelText('Database');
|
||||
await waitFor(() => {
|
||||
expect(dbField).toHaveValue('familysync');
|
||||
});
|
||||
expect(dbField).toHaveAttribute('readonly');
|
||||
expect(dbField).toBeDisabled();
|
||||
expect(dbField).toHaveAttribute('aria-readonly', 'true');
|
||||
});
|
||||
|
||||
it('keeps the existing "Database connection verified" validation row available', async () => {
|
||||
const { postSetupConfig, validateSetupDb, validateSetupOidc, validateSetupVapid } =
|
||||
await import('../api/client.js');
|
||||
(postSetupConfig as ReturnType<typeof vi.fn>).mockResolvedValue(undefined);
|
||||
(validateSetupDb as ReturnType<typeof vi.fn>).mockResolvedValue(undefined);
|
||||
(validateSetupOidc as ReturnType<typeof vi.fn>).mockResolvedValue(undefined);
|
||||
(validateSetupVapid as ReturnType<typeof vi.fn>).mockResolvedValue(undefined);
|
||||
|
||||
await advanceToStep2();
|
||||
fireEvent.change(screen.getByLabelText('App URL'), { target: { value: 'https://app.example.com' } });
|
||||
fireEvent.change(screen.getByLabelText('OIDC issuer URL'), { target: { value: 'https://auth.example.com' } });
|
||||
fireEvent.change(screen.getByLabelText('OIDC client ID'), { target: { value: 'familysync' } });
|
||||
fireEvent.change(screen.getByLabelText('VAPID public key'), { target: { value: 'BHtest123' } });
|
||||
fireEvent.click(screen.getByRole('button', { name: 'Save & Validate' }));
|
||||
|
||||
await waitFor(() => {
|
||||
expect(screen.getByText('Database connection verified.')).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// (gap-4 Back-navigation tests added in Task 2)
|
||||
|
||||
Reference in New Issue
Block a user