diff --git a/desktop/e2e/smoke.spec.ts b/desktop/e2e/smoke.spec.ts index e603627c..26c20277 100644 --- a/desktop/e2e/smoke.spec.ts +++ b/desktop/e2e/smoke.spec.ts @@ -144,7 +144,8 @@ test('renderer security', async ({ launch }) => { // "Error invoking remote method" envelope, so codes like codemm:repair still match. test('errors cross IPC as their own message', async ({ launch }) => { const { app, page } = await launch(); - await expect(page.getByRole('button', { name: 'Connect an agent', exact: true })).toBeVisible(); + // A first window on a busy CI runner can take longer than the default 5 seconds. + await expect(page.getByRole('button', { name: 'Connect an agent', exact: true })).toBeVisible({ timeout: 30_000 }); const messages = await page.evaluate(async () => { const bridge = (window as unknown as { codemm: { invoke(m: string, a: unknown[]): Promise } }).codemm; const call = (method: string, args: unknown[]) => bridge.invoke(method, args).then(() => 'resolved', (e: Error) => e.message); diff --git a/desktop/src/renderer/app/workNow.test.tsx b/desktop/src/renderer/app/workNow.test.tsx index 6faec07e..e58b7d7a 100644 --- a/desktop/src/renderer/app/workNow.test.tsx +++ b/desktop/src/renderer/app/workNow.test.tsx @@ -99,17 +99,18 @@ describe('running jobs in the sidebar (§4.11)', () => { act(() => tell(jobAt('l1', 'lesson', { concept: TOPIC }))); act(() => tell(jobAt('a1', 'author', { concept: TOPIC, stage: 2, part: { done: 2, total: 3 } }))); act(() => tell(jobAt('r1', 'roadmap'))); - expect(names()).toEqual([ + // The list can land a moment after the events on a slow runner: wait for it. + await waitFor(() => expect(names()).toEqual([ 'Writing a lesson on JavaScript basics, Writing the lesson', 'Writing an activity on JavaScript basics, Checking the exercise, step 2 of 3', 'Changing the roadmap, Changing the roadmap', - ]); + ])); // A retry reads short; a job quiet for 90 seconds says it is still working; a finished job leaves. act(() => tell(jobAt('l1', 'lesson', { concept: TOPIC, retry: { attempt: 2, of: 3 } }))); act(() => tell(jobAt('a1', 'author', { concept: TOPIC, idleMs: 95_000 }))); act(() => tell({ ...jobAt('r1', 'roadmap'), ended: true })); - expect(names()).toEqual(['Writing a lesson on JavaScript basics, Taking a little longer', 'Writing an activity on JavaScript basics, Still working']); + await waitFor(() => expect(names()).toEqual(['Writing a lesson on JavaScript basics, Taking a little longer', 'Writing an activity on JavaScript basics, Still working'])); await user.click(within(working()!).getByRole('button', { name: /^Writing a lesson/ })); expect(await screen.findByRole('heading', { name: 'JavaScript basics' })).toBeInTheDocument(); @@ -174,7 +175,8 @@ describe('running jobs in the sidebar (§4.11)', () => { await screen.findByRole('heading', { name: 'React' }); const rebuilding = jobAt('rb', 'rebuild', { track: 'React', stage: 0, thinking: false }); act(() => tell(rebuilding)); - const job = within(working()!).getByRole('button'); + // The list can land a moment after the event on a slow runner: wait for it. + const job = within(await within(sidebar()).findByRole('list', { name: 'Codemm is working' })).getByRole('button'); act(() => job.focus()); expect(job).toHaveFocus(); act(() => tell({ ...rebuilding, ended: true }));