| 267 | ({ page, context, shots }) => |
| 268 | Effect.promise(async () => { |
| 269 | const step = async (label: string, action: (page: Page) => Promise<void>) => { |
| 270 | // Acting on the page IS focusing the browser window — and when |
| 271 | // filming, enterFocus lingers a beat on whatever the developer was |
| 272 | // looking at before tabbing here. |
| 273 | await enterFocus(dir, "browser"); |
| 274 | await context.tracing.group(label); |
| 275 | try { |
| 276 | await action(page); |
| 277 | } finally { |
| 278 | await context.tracing.groupEnd(); |
| 279 | } |
| 280 | await page.screenshot({ |
| 281 | path: join(dir, `${String(shots.count++).padStart(2, "0")}-${slug(label)}.png`), |
| 282 | }); |
| 283 | // Hold this step's result on screen so the film is readable (the |
| 284 | // consent screen, the success page, …). No-op unless filming. |
| 285 | await beat(); |
| 286 | }; |
| 287 | try { |
| 288 | await drive({ page, step }); |
| 289 | } catch (error) { |