Skip to content

Commit edbcc6e

Browse files
committed
fix(ci): settle extension screenshots after advancing browser timers
1 parent 60c8d93 commit edbcc6e

1 file changed

Lines changed: 19 additions & 11 deletions

File tree

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

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ function trackUploadedFile(key: string) {
8383
}
8484
let context: BrowserContext | undefined
8585
let panel: Page | undefined
86+
let acceleratedClock = false
8687
let userId: string | undefined
8788
let releaseHeldRequest = () => {}
8889
const alphaId = generateId()
@@ -130,17 +131,23 @@ async function check(name: string, run: () => Promise<void>) {
130131
async function screenshot(name: string) {
131132
if (!panel) return
132133
for (const frame of panel.frames()) {
133-
await frame.evaluate(() =>
134-
Promise.all(
135-
document
136-
.getAnimations()
137-
.filter(
138-
(animation) =>
139-
animation.playState === 'running' &&
140-
animation.effect?.getComputedTiming().iterations !== Number.POSITIVE_INFINITY
141-
)
142-
.map((animation) => animation.finished.catch(() => {}))
143-
)
134+
await frame.evaluate(
135+
(finishAnimations) =>
136+
Promise.all(
137+
document
138+
.getAnimations()
139+
.filter(
140+
(animation) =>
141+
animation.playState === 'running' &&
142+
animation.effect?.getComputedTiming().iterations !== Number.POSITIVE_INFINITY
143+
)
144+
.map((animation) => {
145+
// Mocked performance time can put native Web Animations far ahead of their timeline.
146+
if (finishAnimations) animation.finish()
147+
return animation.finished.catch(() => {})
148+
})
149+
),
150+
acceleratedClock
144151
)
145152
for (const element of await frame
146153
.getByRole('menu')
@@ -1213,6 +1220,7 @@ try {
12131220
panel = await openPanel()
12141221
shell = panel
12151222
await shell.clock.install()
1223+
acceleratedClock = true
12161224
source = await browserContext.newPage()
12171225
await source.goto(`${fixtureOrigin}/page?private=QUERY_SECRET#FRAGMENT_SECRET`)
12181226
await shell.goto(`chrome-extension://${extensionId}/sidepanel.html`)

0 commit comments

Comments
 (0)