Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 336bc09987 | |||
| eb2538772e | |||
| 5e07b963b9 | |||
| c6885077bc |
@@ -0,0 +1,45 @@
|
|||||||
|
# Interview parent state lifetime
|
||||||
|
|
||||||
|
17 November 2026; final revalidation 18 November 2026. Development checkpoint based on A3 `eb253877`, branch `codex/interview-parent-lifetime`. Scope is the interview-preparation and follow-up parent components and their unit tests. No runtime locale expansion, model/service calls, schema changes, production work or approval changes.
|
||||||
|
|
||||||
|
## Reproduced defects and fix
|
||||||
|
|
||||||
|
On unchanged baseline, deferred reads for application 7 were completed after rendering application 8. Seven regression cases failed: previous prep content replaced the current board; previous follow-up data overwrote a current draft; stale errors appeared in either current surface; stale finalisers dismissed either current loading state; and parent drafts/data survived the application boundary, causing a failed new follow-up read to expose old editable data instead of a GET-only retry.
|
||||||
|
|
||||||
|
A second pre-fix run added three cases: an older same-application refresh replaced a newer board, and a late prep addition cleared the new application's title draft and initiated a previous-application reload (both failed); a late follow-up write already retained its original API target (positive control passed). Thus nine expected failing regressions and one passing control were observed before editing production code; overlapping reruns are not additional unique tests.
|
||||||
|
|
||||||
|
The exported prep/follow-up components now render a job-keyed private workspace, following the existing keyed interview-assistant ownership pattern. Changing job unmounts its board, drafts, error and busy state together. A per-workspace active flag and read sequence guard read success/error/finally, and prevent an unmounted workspace from starting a refresh after an existing write completes. Only the newest read can update a mounted owner. Explicit writes retain their original closure/API target; no write is cancelled, migrated to another application or retried automatically. Same-application language changes keep the same workspace and its drafts.
|
||||||
|
|
||||||
|
Two additional same-application controls exercise stale errors and stale finalisers while a newer refresh remains pending. Existing rerender tests now await remount reads inside `act`, avoiding React test warnings caused by unawaited new parent workspaces. No test suppresses console output.
|
||||||
|
|
||||||
|
## Verification
|
||||||
|
|
||||||
|
Commands from `job-tracker-ui`:
|
||||||
|
|
||||||
|
```powershell
|
||||||
|
rtk proxy node node_modules/jest/bin/jest.js --runInBand --runTestsByPath src/interview-prep.test.tsx --cacheDirectory='../.test-cache'
|
||||||
|
rtk proxy node node_modules/typescript/bin/tsc --noEmit --incremental false
|
||||||
|
rtk proxy node node_modules/eslint/bin/eslint.js src/components/InterviewPrep.tsx src/interview-prep.test.tsx --max-warnings=0
|
||||||
|
```
|
||||||
|
|
||||||
|
- Final focused jsdom suite: **63/63 passed**, no snapshots, no React warnings. This includes 12 added cases and the existing 51; prior focused runs are not added to that total.
|
||||||
|
- Native runner receipt: [jest-results.json](jest-results.json), produced with `--json --outputFile='../docs/validation/interview-parent-lifetime/jest-results.json'` added to the command above. Final revalidation passed 63/63 with zero failed/pending tests and 23.206 seconds reported by the runner. This is a repeat of the same source-bound cases, not an additional 63 distinct tests.
|
||||||
|
- Full UI TypeScript check: passed, exit 0.
|
||||||
|
- Scoped lint: passed, exit 0, zero warnings. An earlier cleanup-ref lint warning was fixed by checking the active flag on completion instead of mutating the read ref during cleanup.
|
||||||
|
- `rtk git diff --check`: passed.
|
||||||
|
- Graph-first query used the existing isolated A3 research graph before source inspection. `rtk proxy graphify update .` performed AST-only extraction in this new worktree, without API/model calls or shared graph mutation. The initial refresh created 19,835 nodes and 48,044 edges; an incremental refresh followed the final source/test edits. Generated graph output is local untracked research material, not a new runtime dependency. Graph reported missing optional PDF/SQL extraction dependencies and unsupported/no-symbol files; this is structural orientation, not full runtime or document analysis.
|
||||||
|
|
||||||
|
Existing dependencies were accessed read-only through a directory junction to `E:/Storage/Projects/Active/temp docs/jobjakt-local-build/next-security-patch/job-tracker-ui/node_modules`. No install/build/browser lane ran.
|
||||||
|
|
||||||
|
Validated working-file SHA-256:
|
||||||
|
|
||||||
|
| File | SHA-256 |
|
||||||
|
| --- | --- |
|
||||||
|
| `job-tracker-ui/src/components/InterviewPrep.tsx` | `57d208df5880d8b93c9a3acf13e7b11d2791f4a9d3fdf55da56debe68c3145ee` |
|
||||||
|
| `job-tracker-ui/src/interview-prep.test.tsx` | `82c36af6225d4fb00fb689bf7243ef2163b6abc237c91a7058f283c173d34471` |
|
||||||
|
|
||||||
|
## Limits and integration
|
||||||
|
|
||||||
|
Browser/native/device, broader repository suites, hosted CI, backend/database, live AI, provider and production checks were not run. Root owns source-bound browser qualification, integration/publication and central tracking. This checkpoint does not grant release or roadmap-stage approval.
|
||||||
|
|
||||||
|
Adjacent existing behaviour remains: ordinary same-application board refresh hides/remounts row editors through `Shell`'s loading condition; preserving row-local unsaved answers during every ordinary refresh needs a separate behavioural decision and test package. This fix prevents superseded reads from replacing the newest board/draft state; it does not redesign refresh presentation or persistence. Pending writes may still finish on the original application after navigation, as explicitly initiated by the user.
|
||||||
File diff suppressed because one or more lines are too long
@@ -43,6 +43,10 @@ function Shell({ title, subtitle, loading, error, children, onRetry, keepContent
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function ApplicationInterviewPrep({ jobId }: { jobId: number }) {
|
export function ApplicationInterviewPrep({ jobId }: { jobId: number }) {
|
||||||
|
return <InterviewPrepWorkspace key={jobId} jobId={jobId} />;
|
||||||
|
}
|
||||||
|
|
||||||
|
function InterviewPrepWorkspace({ jobId }: { jobId: number }) {
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const [board, setBoard] = useState<InterviewPrepBoard | null>(null);
|
const [board, setBoard] = useState<InterviewPrepBoard | null>(null);
|
||||||
const [error, setError] = useState<{ cause: unknown; fallback: "interviewPrepLoadFailed" | "interviewPrepUpdateFailed" | "interviewPrepAnswerSaveFailed" } | null>(null);
|
const [error, setError] = useState<{ cause: unknown; fallback: "interviewPrepLoadFailed" | "interviewPrepUpdateFailed" | "interviewPrepAnswerSaveFailed" } | null>(null);
|
||||||
@@ -50,16 +54,26 @@ export function ApplicationInterviewPrep({ jobId }: { jobId: number }) {
|
|||||||
const [busy, setBusy] = useState(false);
|
const [busy, setBusy] = useState(false);
|
||||||
const [title, setTitle] = useState("");
|
const [title, setTitle] = useState("");
|
||||||
const [category, setCategory] = useState(INTERVIEW_PREP_CATEGORIES[0].key);
|
const [category, setCategory] = useState(INTERVIEW_PREP_CATEGORIES[0].key);
|
||||||
|
const active = useRef(true);
|
||||||
|
const readSequence = useRef(0);
|
||||||
|
useLayoutEffect(() => {
|
||||||
|
active.current = true;
|
||||||
|
return () => { active.current = false; };
|
||||||
|
}, []);
|
||||||
|
|
||||||
const load = useCallback(async () => {
|
const load = useCallback(async () => {
|
||||||
|
if (!active.current) return;
|
||||||
|
const request = ++readSequence.current;
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
try {
|
try {
|
||||||
setBoard(await interviewPrepApi.get(jobId));
|
const result = await interviewPrepApi.get(jobId);
|
||||||
|
if (!active.current || request !== readSequence.current) return;
|
||||||
|
setBoard(result);
|
||||||
setError(null);
|
setError(null);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
setError({ cause: err, fallback: "interviewPrepLoadFailed" });
|
if (active.current && request === readSequence.current) setError({ cause: err, fallback: "interviewPrepLoadFailed" });
|
||||||
} finally {
|
} finally {
|
||||||
setLoading(false);
|
if (active.current && request === readSequence.current) setLoading(false);
|
||||||
}
|
}
|
||||||
}, [jobId]);
|
}, [jobId]);
|
||||||
|
|
||||||
@@ -424,6 +438,10 @@ function PrepRow({ jobId, item, busy, onChanged, onError }: {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function ApplicationFollowUp({ jobId }: { jobId: number }) {
|
export function ApplicationFollowUp({ jobId }: { jobId: number }) {
|
||||||
|
return <FollowUpWorkspace key={jobId} jobId={jobId} />;
|
||||||
|
}
|
||||||
|
|
||||||
|
function FollowUpWorkspace({ jobId }: { jobId: number }) {
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const [data, setData] = useState<FollowUp | null>(null);
|
const [data, setData] = useState<FollowUp | null>(null);
|
||||||
const [error, setError] = useState<{ cause: unknown; fallback: "interviewFollowUpLoadFailed" | "interviewFollowUpSaveFailed" } | null>(null);
|
const [error, setError] = useState<{ cause: unknown; fallback: "interviewFollowUpLoadFailed" | "interviewFollowUpSaveFailed" } | null>(null);
|
||||||
@@ -431,19 +449,28 @@ export function ApplicationFollowUp({ jobId }: { jobId: number }) {
|
|||||||
const [busy, setBusy] = useState(false);
|
const [busy, setBusy] = useState(false);
|
||||||
const [date, setDate] = useState<string>("");
|
const [date, setDate] = useState<string>("");
|
||||||
const [action, setAction] = useState<string>("");
|
const [action, setAction] = useState<string>("");
|
||||||
|
const active = useRef(true);
|
||||||
|
const readSequence = useRef(0);
|
||||||
|
useLayoutEffect(() => {
|
||||||
|
active.current = true;
|
||||||
|
return () => { active.current = false; };
|
||||||
|
}, []);
|
||||||
|
|
||||||
const load = useCallback(async () => {
|
const load = useCallback(async () => {
|
||||||
|
if (!active.current) return;
|
||||||
|
const request = ++readSequence.current;
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
try {
|
try {
|
||||||
const result = await interviewPrepApi.followUp(jobId);
|
const result = await interviewPrepApi.followUp(jobId);
|
||||||
|
if (!active.current || request !== readSequence.current) return;
|
||||||
setData(result);
|
setData(result);
|
||||||
setDate(result.followUpAt ? result.followUpAt.slice(0, 10) : "");
|
setDate(result.followUpAt ? result.followUpAt.slice(0, 10) : "");
|
||||||
setAction(result.nextAction ?? "");
|
setAction(result.nextAction ?? "");
|
||||||
setError(null);
|
setError(null);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
setError({ cause: err, fallback: "interviewFollowUpLoadFailed" });
|
if (active.current && request === readSequence.current) setError({ cause: err, fallback: "interviewFollowUpLoadFailed" });
|
||||||
} finally {
|
} finally {
|
||||||
setLoading(false);
|
if (active.current && request === readSequence.current) setLoading(false);
|
||||||
}
|
}
|
||||||
}, [jobId]);
|
}, [jobId]);
|
||||||
|
|
||||||
|
|||||||
@@ -63,6 +63,135 @@ beforeEach(() => {
|
|||||||
window.localStorage.setItem("uiLanguage", "en");
|
window.localStorage.setItem("uiLanguage", "en");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function deferredRead() {
|
||||||
|
let resolve!: (value: any) => void;
|
||||||
|
let reject!: (reason: unknown) => void;
|
||||||
|
const promise = new Promise<any>((yes, no) => { resolve = yes; reject = no; });
|
||||||
|
return { promise, resolve, reject };
|
||||||
|
}
|
||||||
|
|
||||||
|
test.each(['success', 'failure', 'pending-newer'] as const)('a newer preparation refresh wins against an older %s completion', async completion => {
|
||||||
|
mockedApi.get.mockReset(); routeGet();
|
||||||
|
const read = mockedApi.get.getMockImplementation()!;
|
||||||
|
const older = deferredRead(); const newer = deferredRead();
|
||||||
|
let reads = 0;
|
||||||
|
mockedApi.get.mockImplementation((url: string) => url.endsWith('/interview-prep') && ++reads > 1 ? (reads === 2 ? older.promise : newer.promise) : read(url));
|
||||||
|
const firstWrite = deferredRead(); const secondWrite = deferredRead();
|
||||||
|
mockedApi.patch.mockReset().mockReturnValueOnce(firstWrite.promise).mockReturnValueOnce(secondWrite.promise);
|
||||||
|
render(<ApplicationInterviewPrep jobId={7} />);
|
||||||
|
fireEvent.click(await screen.findByRole('checkbox', { name: 'Ready: Funding history' }));
|
||||||
|
fireEvent.click(screen.getByRole('checkbox', { name: 'Ready: Tell me about a conflict' }));
|
||||||
|
await act(async () => firstWrite.resolve({ data: {} }));
|
||||||
|
await act(async () => secondWrite.resolve({ data: {} }));
|
||||||
|
expect(reads).toBe(3);
|
||||||
|
if (completion === 'pending-newer') {
|
||||||
|
await act(async () => older.resolve({ data: board }));
|
||||||
|
const region = within(screen.getByRole('region', { name: translations.en.interviewPrepTitle }));
|
||||||
|
expect(region.getByRole('progressbar', { name: translations.en.loading })).toBeVisible();
|
||||||
|
expect(region.queryByLabelText(translations.en.interviewPrepAddLabel)).not.toBeInTheDocument();
|
||||||
|
}
|
||||||
|
const currentBoard = { ...board, groups: [{ ...board.groups[0], items: [{ ...board.groups[0].items[0], title: 'Newest board' }] }] };
|
||||||
|
await act(async () => newer.resolve({ data: currentBoard }));
|
||||||
|
expect(await screen.findByText('Newest board')).toBeVisible();
|
||||||
|
fireEvent.change(screen.getByLabelText(translations.en.interviewPrepAddLabel), { target: { value: 'Current draft' } });
|
||||||
|
if (completion === 'success') await act(async () => older.resolve({ data: board }));
|
||||||
|
if (completion === 'failure') await act(async () => older.reject(new Error('Older refresh failure')));
|
||||||
|
expect(screen.getByText('Newest board')).toBeVisible();
|
||||||
|
expect(screen.queryByText(translations.en.interviewPrepLoadFailed)).not.toBeInTheDocument();
|
||||||
|
expect(screen.getByLabelText(translations.en.interviewPrepAddLabel)).toHaveValue('Current draft');
|
||||||
|
});
|
||||||
|
|
||||||
|
test.each(['prep', 'follow-up'] as const)('late %s write keeps its original target and cannot clear a new application draft', async surface => {
|
||||||
|
mockedApi.get.mockReset(); routeGet();
|
||||||
|
const write = deferredRead();
|
||||||
|
mockedApi.post.mockReset().mockReturnValueOnce(write.promise);
|
||||||
|
mockedApi.put.mockReset().mockReturnValueOnce(write.promise);
|
||||||
|
const component = (id: number) => surface === 'prep' ? <ApplicationInterviewPrep jobId={id} /> : <ApplicationFollowUp jobId={id} />;
|
||||||
|
const label = surface === 'prep' ? translations.en.interviewPrepAddLabel : translations.en.workspaceNextAction;
|
||||||
|
const view = render(component(7));
|
||||||
|
fireEvent.change(await screen.findByLabelText(label), { target: { value: 'Original application write' } });
|
||||||
|
fireEvent.click(screen.getByRole('button', { name: translations.en[surface === 'prep' ? 'interviewPrepAdd' : 'save'] }));
|
||||||
|
await act(async () => view.rerender(<I18nProvider><ConfirmProvider>{component(8)}</ConfirmProvider></I18nProvider>));
|
||||||
|
fireEvent.change(await screen.findByLabelText(label), { target: { value: 'New application draft' } });
|
||||||
|
await act(async () => write.resolve({ data: surface === 'prep' ? board.groups[0].items[0] : followUp }));
|
||||||
|
expect(screen.getByLabelText(label)).toHaveValue('New application draft');
|
||||||
|
expect(surface === 'prep' ? mockedApi.post : mockedApi.put).toHaveBeenCalledTimes(1);
|
||||||
|
expect((surface === 'prep' ? mockedApi.post : mockedApi.put).mock.calls[0][0]).toBe(`/jobapplications/7/${surface === 'prep' ? 'interview-prep' : 'follow-up'}`);
|
||||||
|
expect(mockedApi.get.mock.calls.filter(([url]) => url === '/jobapplications/7/interview-prep')).toHaveLength(surface === 'prep' ? 1 : 0);
|
||||||
|
});
|
||||||
|
|
||||||
|
test.each(['prep', 'follow-up'] as const)('late %s read cannot replace the current application or its draft', async surface => {
|
||||||
|
mockedApi.get.mockReset(); routeGet();
|
||||||
|
const read = mockedApi.get.getMockImplementation()!;
|
||||||
|
const old = deferredRead();
|
||||||
|
const suffix = surface === 'prep' ? 'interview-prep' : 'follow-up';
|
||||||
|
mockedApi.get.mockImplementation((url: string) => url === `/jobapplications/7/${suffix}` ? old.promise : read(url));
|
||||||
|
const component = (id: number) => surface === 'prep' ? <ApplicationInterviewPrep jobId={id} /> : <ApplicationFollowUp jobId={id} />;
|
||||||
|
const view = render(component(7));
|
||||||
|
await act(async () => view.rerender(<I18nProvider><ConfirmProvider>{component(8)}</ConfirmProvider></I18nProvider>));
|
||||||
|
const label = surface === 'prep' ? translations.en.interviewPrepAddLabel : translations.en.workspaceNextAction;
|
||||||
|
fireEvent.change(await screen.findByLabelText(label), { target: { value: 'Current application draft' } });
|
||||||
|
const oldData = surface === 'prep'
|
||||||
|
? { ...board, groups: [{ ...board.groups[0], items: [{ ...board.groups[0].items[0], title: 'Previous application only' }] }] }
|
||||||
|
: { ...followUp, nextAction: 'Previous application only' };
|
||||||
|
await act(async () => old.resolve({ data: oldData }));
|
||||||
|
expect(screen.getByLabelText(label)).toHaveValue('Current application draft');
|
||||||
|
expect(screen.queryByText('Previous application only')).not.toBeInTheDocument();
|
||||||
|
expect(screen.queryByDisplayValue('Previous application only')).not.toBeInTheDocument();
|
||||||
|
expect(mockedApi.post).not.toHaveBeenCalled(); expect(mockedApi.put).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
test.each(['prep', 'follow-up'] as const)('late %s read failure cannot hide the current draft', async surface => {
|
||||||
|
mockedApi.get.mockReset(); routeGet();
|
||||||
|
const read = mockedApi.get.getMockImplementation()!;
|
||||||
|
const old = deferredRead();
|
||||||
|
const suffix = surface === 'prep' ? 'interview-prep' : 'follow-up';
|
||||||
|
mockedApi.get.mockImplementation((url: string) => url === `/jobapplications/7/${suffix}` ? old.promise : read(url));
|
||||||
|
const component = (id: number) => surface === 'prep' ? <ApplicationInterviewPrep jobId={id} /> : <ApplicationFollowUp jobId={id} />;
|
||||||
|
const view = render(component(7));
|
||||||
|
await act(async () => view.rerender(<I18nProvider><ConfirmProvider>{component(8)}</ConfirmProvider></I18nProvider>));
|
||||||
|
const label = surface === 'prep' ? translations.en.interviewPrepAddLabel : translations.en.workspaceNextAction;
|
||||||
|
fireEvent.change(await screen.findByLabelText(label), { target: { value: 'Current application draft' } });
|
||||||
|
await act(async () => old.reject(new Error('Previous application failure')));
|
||||||
|
expect(screen.queryByText(translations.en[surface === 'prep' ? 'interviewPrepLoadFailed' : 'interviewFollowUpLoadFailed'])).not.toBeInTheDocument();
|
||||||
|
expect(screen.getByLabelText(label)).toHaveValue('Current application draft');
|
||||||
|
});
|
||||||
|
|
||||||
|
test.each(['prep', 'follow-up'] as const)('late %s finally cannot dismiss the current application loading state', async surface => {
|
||||||
|
mockedApi.get.mockReset(); routeGet();
|
||||||
|
const read = mockedApi.get.getMockImplementation()!;
|
||||||
|
const old = deferredRead(); const current = deferredRead();
|
||||||
|
const suffix = surface === 'prep' ? 'interview-prep' : 'follow-up';
|
||||||
|
mockedApi.get.mockImplementation((url: string) => url.endsWith(`/${suffix}`) ? (url.includes('/7/') ? old.promise : current.promise) : read(url));
|
||||||
|
const component = (id: number) => surface === 'prep' ? <ApplicationInterviewPrep jobId={id} /> : <ApplicationFollowUp jobId={id} />;
|
||||||
|
const view = render(component(7));
|
||||||
|
await act(async () => view.rerender(<I18nProvider><ConfirmProvider>{component(8)}</ConfirmProvider></I18nProvider>));
|
||||||
|
await act(async () => old.resolve({ data: surface === 'prep' ? board : followUp }));
|
||||||
|
const region = within(screen.getByRole('region', { name: translations.en[surface === 'prep' ? 'interviewPrepTitle' : 'interviewFollowUpTitle'] }));
|
||||||
|
expect(region.getByRole('progressbar', { name: translations.en.loading })).toBeVisible();
|
||||||
|
expect(region.queryByLabelText(translations.en[surface === 'prep' ? 'interviewPrepAddLabel' : 'workspaceNextAction'])).not.toBeInTheDocument();
|
||||||
|
await act(async () => current.resolve({ data: surface === 'prep' ? board : followUp }));
|
||||||
|
expect(await region.findByLabelText(translations.en[surface === 'prep' ? 'interviewPrepAddLabel' : 'workspaceNextAction'])).toBeVisible();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('changing application resets parent drafts and a failed follow-up read retains a GET-only retry', async () => {
|
||||||
|
mockedApi.get.mockReset(); routeGet();
|
||||||
|
const read = mockedApi.get.getMockImplementation()!;
|
||||||
|
mockedApi.get.mockImplementation((url: string) => url === '/jobapplications/8/follow-up' ? Promise.reject(new Error('Current read failure')) : read(url));
|
||||||
|
const view = render(<ApplicationInterviewPrep jobId={7} />);
|
||||||
|
fireEvent.change(await screen.findByLabelText(translations.en.interviewPrepAddLabel), { target: { value: 'Application seven draft' } });
|
||||||
|
await screen.findByDisplayValue(followUp.nextAction);
|
||||||
|
await act(async () => view.rerender(<I18nProvider><ConfirmProvider><ApplicationInterviewPrep jobId={8} /></ConfirmProvider></I18nProvider>));
|
||||||
|
expect(await screen.findByLabelText(translations.en.interviewPrepAddLabel)).toHaveValue('');
|
||||||
|
expect(await screen.findByText(translations.en.interviewFollowUpLoadFailed)).toBeVisible();
|
||||||
|
const region = within(screen.getByRole('region', { name: translations.en.interviewFollowUpTitle }));
|
||||||
|
expect(region.queryByLabelText(translations.en.workspaceNextAction)).not.toBeInTheDocument();
|
||||||
|
mockedApi.get.mockImplementation(read);
|
||||||
|
fireEvent.click(region.getByRole('button', { name: translations.en.retry }));
|
||||||
|
expect(await region.findByLabelText(translations.en.workspaceNextAction)).toHaveValue(followUp.nextAction);
|
||||||
|
expect(mockedApi.put).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
test.each(['en', 'nb'] as const)('pending preparation deletion follows %s without a preparation reload or answer loss', async from => {
|
test.each(['en', 'nb'] as const)('pending preparation deletion follows %s without a preparation reload or answer loss', async from => {
|
||||||
localStorage.setItem('uiLanguage', from);
|
localStorage.setItem('uiLanguage', from);
|
||||||
const to = from === 'en' ? 'nb' : 'en';
|
const to = from === 'en' ? 'nb' : 'en';
|
||||||
@@ -352,7 +481,7 @@ test('late generation cannot offer another application the previous application
|
|||||||
fireEvent.change(screen.getByLabelText(translations.en.coverAiAdditionalInstructions), { target: { value: 'Private instructions for application seven' } });
|
fireEvent.change(screen.getByLabelText(translations.en.coverAiAdditionalInstructions), { target: { value: 'Private instructions for application seven' } });
|
||||||
fireEvent.click(screen.getByRole('button', { name: translations.en.interviewAiGenerate }));
|
fireEvent.click(screen.getByRole('button', { name: translations.en.interviewAiGenerate }));
|
||||||
await waitFor(() => expect(mockedApi.post).toHaveBeenCalledTimes(1));
|
await waitFor(() => expect(mockedApi.post).toHaveBeenCalledTimes(1));
|
||||||
view.rerender(<I18nProvider><ConfirmProvider><ApplicationInterviewPrep jobId={8} /></ConfirmProvider></I18nProvider>);
|
await act(async () => view.rerender(<I18nProvider><ConfirmProvider><ApplicationInterviewPrep jobId={8} /></ConfirmProvider></I18nProvider>));
|
||||||
await act(async () => finish({ data: { result: { text: 'Only for application seven' } } }));
|
await act(async () => finish({ data: { result: { text: 'Only for application seven' } } }));
|
||||||
const assistant = within(screen.getByRole('region', { name: translations.en.interviewAiTitle }));
|
const assistant = within(screen.getByRole('region', { name: translations.en.interviewAiTitle }));
|
||||||
expect(assistant.queryByText('Only for application seven')).not.toBeInTheDocument();
|
expect(assistant.queryByText('Only for application seven')).not.toBeInTheDocument();
|
||||||
@@ -368,7 +497,7 @@ test('completed AI suggestion is scoped to its application instead of becoming a
|
|||||||
await screen.findByText('Backend CV');
|
await screen.findByText('Backend CV');
|
||||||
fireEvent.click(screen.getByRole('button', { name: translations.en.interviewAiGenerate }));
|
fireEvent.click(screen.getByRole('button', { name: translations.en.interviewAiGenerate }));
|
||||||
expect(await screen.findByText('Prepared for application seven only')).toBeVisible();
|
expect(await screen.findByText('Prepared for application seven only')).toBeVisible();
|
||||||
view.rerender(<I18nProvider><ConfirmProvider><ApplicationInterviewPrep jobId={8} /></ConfirmProvider></I18nProvider>);
|
await act(async () => view.rerender(<I18nProvider><ConfirmProvider><ApplicationInterviewPrep jobId={8} /></ConfirmProvider></I18nProvider>));
|
||||||
const assistant = within(screen.getByRole('region', { name: translations.en.interviewAiTitle }));
|
const assistant = within(screen.getByRole('region', { name: translations.en.interviewAiTitle }));
|
||||||
expect(assistant.queryByText('Prepared for application seven only')).not.toBeInTheDocument();
|
expect(assistant.queryByText('Prepared for application seven only')).not.toBeInTheDocument();
|
||||||
expect(assistant.queryByRole('button', { name: translations.en.interviewAiAddToPrep })).not.toBeInTheDocument();
|
expect(assistant.queryByRole('button', { name: translations.en.interviewAiAddToPrep })).not.toBeInTheDocument();
|
||||||
@@ -385,7 +514,7 @@ test('late accepted suggestion does not reload the previous application board in
|
|||||||
await screen.findByText('Application seven suggestion');
|
await screen.findByText('Application seven suggestion');
|
||||||
fireEvent.click(screen.getByRole('button', { name: translations.en.interviewAiAddToPrep }));
|
fireEvent.click(screen.getByRole('button', { name: translations.en.interviewAiAddToPrep }));
|
||||||
await waitFor(() => expect(mockedApi.post).toHaveBeenCalledTimes(2));
|
await waitFor(() => expect(mockedApi.post).toHaveBeenCalledTimes(2));
|
||||||
view.rerender(<I18nProvider><ConfirmProvider><ApplicationInterviewPrep jobId={8} /></ConfirmProvider></I18nProvider>);
|
await act(async () => view.rerender(<I18nProvider><ConfirmProvider><ApplicationInterviewPrep jobId={8} /></ConfirmProvider></I18nProvider>));
|
||||||
await waitFor(() => expect(mockedApi.get).toHaveBeenCalledWith('/jobapplications/8/interview-prep'));
|
await waitFor(() => expect(mockedApi.get).toHaveBeenCalledWith('/jobapplications/8/interview-prep'));
|
||||||
await act(async () => finish({ data: board.groups[0].items[0] }));
|
await act(async () => finish({ data: board.groups[0].items[0] }));
|
||||||
expect(mockedApi.get.mock.calls.filter(([url]) => url === '/jobapplications/7/interview-prep')).toHaveLength(1);
|
expect(mockedApi.get.mock.calls.filter(([url]) => url === '/jobapplications/7/interview-prep')).toHaveLength(1);
|
||||||
@@ -444,7 +573,7 @@ test.each(['en', 'nb'] as const)('changing application hides the previous linked
|
|||||||
mockedApi.get.mockImplementation((url: string) => url === '/jobapplications/8/cv' ? pending as any : read(url));
|
mockedApi.get.mockImplementation((url: string) => url === '/jobapplications/8/cv' ? pending as any : read(url));
|
||||||
const view = render(<ApplicationInterviewPrep jobId={7} />);
|
const view = render(<ApplicationInterviewPrep jobId={7} />);
|
||||||
await screen.findByText('Backend CV');
|
await screen.findByText('Backend CV');
|
||||||
view.rerender(<I18nProvider><ConfirmProvider><ApplicationInterviewPrep jobId={8} /></ConfirmProvider></I18nProvider>);
|
await act(async () => view.rerender(<I18nProvider><ConfirmProvider><ApplicationInterviewPrep jobId={8} /></ConfirmProvider></I18nProvider>));
|
||||||
const assistant = within(screen.getByRole('region', { name: translations[language].interviewAiTitle }));
|
const assistant = within(screen.getByRole('region', { name: translations[language].interviewAiTitle }));
|
||||||
expect(assistant.queryByText('Backend CV')).not.toBeInTheDocument();
|
expect(assistant.queryByText('Backend CV')).not.toBeInTheDocument();
|
||||||
expect(assistant.getByRole('progressbar', { name: translations[language].loading })).toBeVisible();
|
expect(assistant.getByRole('progressbar', { name: translations[language].loading })).toBeVisible();
|
||||||
|
|||||||
Reference in New Issue
Block a user