47 lines
1.9 KiB
TypeScript
47 lines
1.9 KiB
TypeScript
import React from 'react';
|
|
import { describe, it, expect, vi } from 'vitest';
|
|
import { render, screen, waitFor } from '@testing-library/react';
|
|
import AccountPage from '../app/account/page';
|
|
|
|
// Account page only needs next/navigation stubbed; firebase-client initialises under the
|
|
// staging test env and reports a signed-out user (onAuthStateChanged -> null).
|
|
vi.mock('next/navigation', () => ({
|
|
usePathname: () => '/account',
|
|
useRouter: () => ({ push: vi.fn(), replace: vi.fn(), back: vi.fn() }),
|
|
}));
|
|
|
|
describe('WEB-W1b/W-2FA/W-devices: account page truthful states', () => {
|
|
it('does not fabricate a connected mobile device, paired comms, or sync status', async () => {
|
|
render(<AccountPage />);
|
|
|
|
await waitFor(() => {
|
|
expect(screen.getByText('App Connections & Sync')).toBeDefined();
|
|
});
|
|
|
|
// Fabricated device/pairing claims must be gone.
|
|
expect(screen.queryByText(/iPhone 16 Pro/)).toBeNull();
|
|
expect(screen.queryByText(/Cardo Packtalk Edge/)).toBeNull();
|
|
expect(screen.queryByText(/^Paired$/)).toBeNull();
|
|
expect(screen.queryByText(/^14m ago$/)).toBeNull();
|
|
expect(screen.queryByText(/^All Synced$/)).toBeNull();
|
|
|
|
// Truthful states are present instead.
|
|
expect(screen.getByText('Authenticated Devices')).toBeDefined();
|
|
expect(screen.getByText('Helmet Comms & Accessories')).toBeDefined();
|
|
expect(screen.getAllByText(/Unavailable on web/i).length).toBeGreaterThan(0);
|
|
});
|
|
|
|
it('never shows 2FA as ENABLED unless a factor is actually enrolled (signed-out = NOT ENABLED)', async () => {
|
|
render(<AccountPage />);
|
|
|
|
await waitFor(() => {
|
|
expect(screen.getByText('Two-Factor Authentication (2FA)')).toBeDefined();
|
|
});
|
|
|
|
// Exact-match: the badge node reads "NOT ENABLED" for a user with no enrolled factor,
|
|
// so an exact "ENABLED" node must not exist.
|
|
expect(screen.getByText('NOT ENABLED')).toBeDefined();
|
|
expect(screen.queryByText('ENABLED')).toBeNull();
|
|
});
|
|
});
|