Skip to content

Commit eade0b9

Browse files
committed
fix(extension): stabilize browser recovery checks
1 parent 9b07424 commit eade0b9

2 files changed

Lines changed: 30 additions & 4 deletions

File tree

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

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1282,9 +1282,21 @@ try {
12821282
reply.type === 'send-context' && reply.snapshot.text.includes('visible-reference-482'),
12831283
`${stale} intent cancelled the current reference: ${reply.type}`
12841284
)
1285+
const replayKey = `${key}:idle-replay`
1286+
const keys = [key, replayKey]
1287+
// A fresh storage event drains deferred intents without depending on the periodic sweep's phase.
1288+
await worker.evaluate(({ key, intent }) => chrome.storage.session.set({ [key]: intent }), {
1289+
key: replayKey,
1290+
intent,
1291+
})
12851292
await expect
1286-
.poll(() =>
1287-
worker.evaluate(async (key) => !(key in (await chrome.storage.session.get(key))), key)
1293+
.poll(
1294+
() =>
1295+
worker.evaluate(async (keys) => {
1296+
const stored = await chrome.storage.session.get(keys)
1297+
return keys.every((key) => !(key in stored))
1298+
}, keys),
1299+
{ message: `${stale}: idle storage delivery drains deferred stale intents` }
12881300
)
12891301
.toBe(true)
12901302
await settleMessages()

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

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -632,7 +632,21 @@ try {
632632
const { name, png } = await screenshotFile()
633633
return uploadFile(name, async () => {
634634
const receipt = await dropOnChat(shell, target, { files: [png] })
635-
if (scope) dropReceipts.push({ scope, phase: 'recovery', receipt })
635+
if (scope) {
636+
dropReceipts.push({ scope, phase: 'recovery', receipt })
637+
assert(
638+
receipt.events.some(
639+
(event) =>
640+
event.type === 'drop' &&
641+
event.trusted &&
642+
event.files === 1 &&
643+
event.chatBody &&
644+
event.intendedTarget &&
645+
event.defaultPrevented
646+
),
647+
`${scope}: the recovery file drop did not reach the chat body`
648+
)
649+
}
636650
})
637651
}
638652
const installCaptureGate = () =>
@@ -804,7 +818,7 @@ try {
804818
).toHaveCount(0)
805819
assert.equal(uploadAttempts, 0)
806820
await browserContext.unroute(uploadEndpoint, interceptUpload)
807-
await attachScreenshot(input, scope)
821+
await attachScreenshot(app.getByRole('main'), scope)
808822
await screenshot(`pending-capture-drop-${scope}-recovered`)
809823
await app.getByRole('button', { name: `Remove ${name}`, exact: true }).click()
810824
assert.equal(submitted.length, 1, `${scope}: recovering drops duplicated the turn`)

0 commit comments

Comments
 (0)