fix(desktop-e2e): remove root causes of four retry-masked desktop flakes by waleedlatif1 · Pull Request #8940 · simstudioai/sim · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 51 additions & 25 deletions apps/desktop/e2e/background-executor.spec.ts
2 changes: 1 addition & 1 deletion apps/desktop/e2e/browser-focus.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ test('browser focus and shortcuts stay with the surface the user is using', asyn
(globalThis as Bridge).simDesktop.browserAgent.executeTool(callId, tool, args, scope),
{ callId, tool, args, scope: SCOPE }
)
expect(result.ok).toBe(true)
expect(result.ok, result.error).toBe(true)
return result.ok ? result.result : undefined
}
const panelAction = (action: Record<string, unknown>) =>
Expand Down
9 changes: 7 additions & 2 deletions apps/desktop/e2e/browser-page-dialogs.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ createRoot(document.getElementById('root')).render(createElement(Fixture));`,
(globalThis as Bridge).simDesktop.browserAgent.executeTool(callId, tool, args, scope),
{ callId, tool, args, scope: SCOPE }
)
expect(result.ok).toBe(true)
expect(result.ok, result.error).toBe(true)
return result.ok ? result.result : undefined
}
/** Browser-chrome actions are user gestures, so each follows a real click in Sim. */
Expand Down Expand Up @@ -439,8 +439,13 @@ createRoot(document.getElementById('root')).render(createElement(Fixture));`,
caret: 'initial',
})
await expect(shell.getByRole('button', { name: 'Stay', exact: true })).toBeFocused()
const shown = await pageDialog()
await shell.keyboard.press('Escape')
await expect.poll(pageDialog).toBeNull()
await expect
.poll(pageDialog, {
message: `dialog ${shown?.requestId} was showing when Escape was pressed`,
})
.toBeNull()
await expect
.poll(() =>
shellApp.evaluate(({ webContents }) => webContents.getFocusedWebContents()?.getURL())
Expand Down
3 changes: 2 additions & 1 deletion apps/desktop/e2e/browser-tools.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,8 @@ test.describe('browser tools', () => {
/button "Allow" \[ref=(\d+)\]/
)?.[1]
expect(allow, JSON.stringify(popup.result)).toBeTruthy()
expect((await execute('browser_click', { elementId: Number(allow) })).ok).toBe(true)
const allowed = await execute('browser_click', { elementId: Number(allow) })
expect(allowed.ok, allowed.error).toBe(true)

await expect.poll(dataset).toMatchObject({ connected: 'granted' })
await expect
Expand Down
20 changes: 20 additions & 0 deletions apps/desktop/e2e/executor-sim.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
expect,
type Page,
} from '@playwright/test'
import { getErrorMessage } from '@sim/utils/errors'

/**
* A fixture Sim that speaks the background executor's device protocol (register, inbox,
Expand Down Expand Up @@ -497,6 +498,25 @@ export async function settled(
return sim.requireCall(toolCallId).completions[0] as Completion
}

/**
* Answers a shell dialog with one of its buttons. The dialog destroys its window as soon as the
* answer reaches the main process, which can happen before Chromium acknowledges the click to
* Playwright; the click then rejects with a closed target although the answer went through. The
* window closing is the proof the answer landed, so that is what this waits for.
*/
export async function answerShellDialog(dialog: Page, button: string): Promise<void> {
const closed = dialog.waitForEvent('close')
await dialog
.getByRole('button', { name: button, exact: true })
.click()
.catch((error: unknown) => {
if (!getErrorMessage(error).includes('Target page, context or browser has been closed')) {
throw error
}
})
await closed
}

export function refFor(outline: string, name: string): number {
const match = outline
.split('\n')
Expand Down
67 changes: 53 additions & 14 deletions apps/desktop/e2e/packaged-smoke.spec.ts
Loading
Loading