Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions packages/runtime-playground/src/browser-actions-runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -474,16 +474,16 @@ export async function runBrowserActionsCommand({
try {
const screenshotCaptureBudgetMs = adaptiveCaptureNavigationUnsettled ? Math.min(adaptiveCaptureBudgetMs, livenessRemainingWallTimeMs(startedAtMs, totalTimeoutMs)) : 0
if (adaptiveCaptureNavigationUnsettled && screenshotCaptureBudgetMs <= 0) throw new Error("Adaptive screenshot capture budget was exhausted before capture started.")
const screenshotCapture = artifactSession.writeGenerated("screenshot", "screenshot.png", (path) => page.screenshot({ path, fullPage: true }).then(() => undefined))
if (adaptiveCaptureNavigationUnsettled) {
await withBrowserCommandLiveness({
const screenshot = await withBrowserCommandLiveness({
command: "wordpress.browser-actions",
phase: "adaptive partial screenshot capture",
operation: screenshotCapture,
operation: page.screenshot({ fullPage: true }),
policy: { wallTimeoutMs: screenshotCaptureBudgetMs, idleTimeoutMs: 0 },
})
await artifactSession.writeBuffer("screenshot", "screenshot.png", screenshot)
} else {
await screenshotCapture
await artifactSession.writeGenerated("screenshot", "screenshot.png", (path) => page.screenshot({ path, fullPage: true }).then(() => undefined))
}
screenshotSha256 = await fileSha256(screenshotPath)
if (capture.has("dom-snapshot")) {
Expand Down
10 changes: 9 additions & 1 deletion tests/browser-actions-navigation-capture.browser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,15 @@ test("adaptive capture classifies unresolved navigation and retains partial evid
assert(Date.now() - startedAt < 1_500, "capture settlement must remain inside the command budget")
await access(join(artifactRoot, "files/browser/steps.jsonl"))
await access(join(artifactRoot, "files/browser/network.jsonl"))
await access(join(artifactRoot, "files/browser/screenshot.png"))
const screenshotPath = join(artifactRoot, "files/browser/screenshot.png")
const screenshotUnavailable = adaptive.result.diagnostics.some(({ code }: { code: string }) => code === "browser_adaptive_capture_screenshot_unavailable")
if (result.artifact.summary.screenshot) {
assert.equal(screenshotUnavailable, false)
await access(screenshotPath)
} else {
assert.equal(screenshotUnavailable, true)
await assert.rejects(access(screenshotPath))
}
await assert.rejects(access(join(artifactRoot, "files/browser/snapshot.html")))
} finally {
await context.close()
Expand Down
Loading