Skip to content

Commit fddd7a1

Browse files
committed
test(extension): use accessible link fields and retain voice proof
1 parent 044e867 commit fddd7a1

1 file changed

Lines changed: 8 additions & 30 deletions

File tree

‎apps/sim/scripts/test-browser-extension-e2e.ts‎

Lines changed: 8 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1368,17 +1368,19 @@ try {
13681368
})
13691369
await draft.goto(`${base.origin}/extension/create-link#${hash}`)
13701370
const dialog = draft.getByRole('dialog', { name: 'New link', exact: true })
1371-
await expect(dialog.getByLabel('Destination URL', { exact: true })).toHaveValue(destination)
1371+
await expect(
1372+
dialog.getByRole('textbox', { name: 'Destination URL', exact: true })
1373+
).toHaveValue(destination)
13721374
await expect.poll(() => new URL(draft.url()).hash).toBe('')
13731375
await screenshot('create-link-draft', draft)
13741376
await dialog.getByRole('button', { name: 'Create', exact: true }).click()
1375-
await expect(dialog.getByLabel('Name', { exact: true })).toHaveAttribute(
1377+
await expect(dialog.getByRole('textbox', { name: 'Name', exact: true })).toHaveAttribute(
13761378
'aria-invalid',
13771379
'true'
13781380
)
13791381
assert.equal(writes, 0, 'An invalid draft reached the create boundary')
13801382
await screenshot('create-link-validation', draft)
1381-
await dialog.getByLabel('Name', { exact: true }).fill('qa-draft')
1383+
await dialog.getByRole('textbox', { name: 'Name', exact: true }).fill('qa-draft')
13821384
const saved = draft.waitForResponse(
13831385
(response) =>
13841386
new URL(response.url()).pathname === endpoint && response.request().method() === 'POST'
@@ -1401,6 +1403,9 @@ try {
14011403
} finally {
14021404
await resolved.close()
14031405
}
1406+
} catch (error) {
1407+
await screenshot('create-link-failure', draft)
1408+
throw error
14041409
} finally {
14051410
await draft.close()
14061411
await sql`delete from organization where id=${organizationId}`
@@ -1416,7 +1421,6 @@ try {
14161421
const sessions: { socket: WebSocketRoute; chunks: number; closed: boolean }[] = []
14171422
await shell.route('**/api/speech/token', (route) => {
14181423
injectedRequests.add(route.request())
1419-
voiceDiagnostics.push({ event: 'token-request' })
14201424
return route.fulfill({ json: { token: 'synthetic-extension-voice' } })
14211425
})
14221426
await shell.routeWebSocket(
@@ -1438,11 +1442,6 @@ try {
14381442
})
14391443
}
14401444
)
1441-
const voiceConsole = (message: { text: () => string }) => {
1442-
const text = message.text()
1443-
if (text.includes('useSpeechToText')) voiceDiagnostics.push({ event: 'console', text })
1444-
}
1445-
shell.on('console', voiceConsole)
14461445
const microphone = await browserContext.newCDPSession(shell)
14471446
const setMicrophonePermission = async (setting: 'granted' | 'denied') => {
14481447
await microphone.send('Browser.setPermission', {
@@ -1485,29 +1484,9 @@ try {
14851484
await shell.bringToFront()
14861485
const viewport = shell.viewportSize()
14871486
assert(viewport)
1488-
const { windowId } = await microphone.send('Browser.getWindowForTarget')
1489-
const before = await microphone.send('Browser.getWindowBounds', { windowId })
14901487
await setPanelViewport(viewport.width, viewport.height)
1491-
const after = await microphone.send('Browser.getWindowBounds', { windowId })
1492-
voiceDiagnostics.push({ event: 'settings-return', viewport, before, after })
14931488
await setMicrophonePermission('granted')
1494-
const retryClick = await mic.evaluateHandle((button) => {
1495-
let clicked = false
1496-
button.addEventListener(
1497-
'click',
1498-
(event) => {
1499-
clicked = event.isTrusted
1500-
},
1501-
{ once: true }
1502-
)
1503-
return () => clicked
1504-
})
15051489
await mic.click()
1506-
voiceDiagnostics.push({
1507-
event: 'retry-click',
1508-
trusted: await retryClick.evaluate((read) => read()),
1509-
})
1510-
await retryClick.dispose()
15111490
await expect(stop).toBeVisible()
15121491
await expect.poll(() => sessions[0]?.chunks ?? 0).toBeGreaterThan(0)
15131492
sessions[0].socket.send(
@@ -1566,7 +1545,6 @@ try {
15661545
event: 'finally',
15671546
sessions: sessions.map(({ chunks, closed }) => ({ chunks, closed })),
15681547
})
1569-
shell.off('console', voiceConsole)
15701548
await shell.unroute('**/api/speech/token')
15711549
await shell.unroute('**/api/mothership/chat')
15721550
await microphone.send('Browser.resetPermissions')

0 commit comments

Comments
 (0)