Skip to content

Commit dd8ff9e

Browse files
committed
test(extension): grant microphone for the embedded app origin
1 parent e4fe115 commit dd8ff9e

1 file changed

Lines changed: 13 additions & 6 deletions

File tree

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

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,6 @@ try {
530530
await signInAndSeed()
531531
await login.close()
532532
await shell.bringToFront()
533-
await frame().getByRole('heading', { name: 'Sign in to Sim', exact: true }).click()
534533
await expect(
535534
frame().getByRole('link', { name: 'Extension QA alpha', exact: true })
536535
).toBeVisible()
@@ -1357,10 +1356,17 @@ try {
13571356
})
13581357
socket.onClose(() => {
13591358
session.closed = true
1359+
void socket.close()
13601360
})
13611361
}
13621362
)
1363-
await browserContext.grantPermissions(['microphone'], { origin: base.origin })
1363+
const microphone = await browserContext.newCDPSession(shell)
1364+
await microphone.send('Browser.setPermission', {
1365+
permission: { name: 'microphone' },
1366+
setting: 'granted',
1367+
origin: `chrome-extension://${extensionId}`,
1368+
embeddedOrigin: base.origin,
1369+
})
13641370
try {
13651371
await expect(mic).toBeVisible()
13661372
await input.fill('Keep my draft')
@@ -1379,13 +1385,13 @@ try {
13791385
await mic.click()
13801386
await expect(stop).toBeVisible()
13811387
await expect.poll(() => sessions.length).toBe(2)
1388+
sessions[0].socket.send(
1389+
JSON.stringify({ message_type: 'partial_transcript', text: 'stale thought' })
1390+
)
13821391
await expect.poll(() => sessions[0].closed).toBe(true)
13831392
await expect(stop).toBeVisible()
13841393
const chunks = sessions[1].chunks
13851394
await expect.poll(() => sessions[1].chunks).toBeGreaterThan(chunks)
1386-
sessions[0].socket.send(
1387-
JSON.stringify({ message_type: 'partial_transcript', text: 'stale thought' })
1388-
)
13891395
sessions[1].socket.send(
13901396
JSON.stringify({ message_type: 'partial_transcript', text: 'second thought' })
13911397
)
@@ -1397,7 +1403,8 @@ try {
13971403
await input.fill('')
13981404
} finally {
13991405
await shell.unroute('**/api/speech/token')
1400-
await browserContext.clearPermissions()
1406+
await microphone.send('Browser.resetPermissions')
1407+
await microphone.detach()
14011408
}
14021409
}
14031410
)

0 commit comments

Comments
 (0)