| 145 | ({ page, context, shots }) => |
| 146 | Effect.promise(async () => { |
| 147 | const step = async (label: string, action: (page: Page) => Promise<void>) => { |
| 148 | // Acting on the page IS focusing the browser window — and when |
| 149 | // filming, enterFocus lingers a beat on whatever the developer was |
| 150 | // looking at before tabbing here. |
| 151 | await enterFocus(dir, "browser"); |
| 152 | await context.tracing.group(label); |
| 153 | try { |
| 154 | await action(page); |
| 155 | } finally { |
| 156 | await context.tracing.groupEnd(); |
| 157 | } |
| 158 | await page.screenshot({ |
| 159 | path: join(dir, `${String(shots.count++).padStart(2, "0")}-${slug(label)}.png`), |
| 160 | }); |
| 161 | // Hold this step's result on screen so the film is readable (the |
| 162 | // consent screen, the success page, …). No-op unless filming. |
| 163 | await beat(); |
| 164 | }; |
| 165 | try { |
| 166 | await drive({ page, step }); |
| 167 | } catch (error) { |