mirror of
https://github.com/Heretek-AI/opencode.git
synced 2026-11-21 21:29:28 -10:00
+16
![opencode-agent[bot]](/assets/img/avatar_default.png)



![opencode-agent[bot]](/assets/img/avatar_default.png)



9e0d3976e1
Co-authored-by: Frank <[email protected]> Co-authored-by: Aarav Sareen <[email protected]> Co-authored-by: Brendan Allan <[email protected]> Co-authored-by: opencode-agent[bot] <opencode-agent[bot]@users.noreply.github.com> Co-authored-by: Jack <[email protected]> Co-authored-by: Brendan Allan <[email protected]> Co-authored-by: Shoubhit Dash <[email protected]> Co-authored-by: opencode-agent[bot] <219766164+opencode-agent[bot]@users.noreply.github.com> Co-authored-by: James Long <[email protected]> Co-authored-by: Dustin Deus <[email protected]> Co-authored-by: starptech <[email protected]> Co-authored-by: Luke Parker <[email protected]> Co-authored-by: 𝓛𝓲𝓽𝓽𝓵𝓮 𝓕𝓻𝓪𝓷𝓴 <[email protected]> Co-authored-by: Dax <[email protected]> Co-authored-by: usrnk1 <[email protected]> Co-authored-by: Jay <[email protected]> Co-authored-by: runvip <[email protected]> Co-authored-by: opencode <[email protected]> Co-authored-by: Julian Coy <[email protected]> Co-authored-by: Vladimir Glafirov <[email protected]> Co-authored-by: Adam <[email protected]> Co-authored-by: Kit Langton <[email protected]> Co-authored-by: Simon Klee <[email protected]> Co-authored-by: Jay <[email protected]> Co-authored-by: David Hill <[email protected]>
55 lines
2.0 KiB
TypeScript
55 lines
2.0 KiB
TypeScript
import type { Page, TestInfo } from "@playwright/test"
|
|
import { analyzeVisualObservations, analyzeVisualTraceByMarker } from "./visual-stability/analyzer"
|
|
import { legacyVisualPlan, type LegacyVisualStabilityOptions } from "./visual-stability/invariant"
|
|
import type { CapturedFrame, VisualStabilityTrace } from "./visual-stability/model"
|
|
import { markVisualProbe, startVisualProbe, stopVisualProbe } from "./visual-stability/probe"
|
|
import type { VisualRegionDefinition } from "./visual-stability/regions"
|
|
import { reportVisualStability } from "./visual-stability/reporter"
|
|
|
|
export * from "./visual-stability/index"
|
|
|
|
const capturedFrames = Symbol("capturedFrames")
|
|
|
|
export async function startVisualStabilityProbe(page: Page, regions: Record<string, VisualRegionDefinition>) {
|
|
await startVisualProbe(page, regions)
|
|
}
|
|
|
|
export async function stopVisualStabilityProbe(page: Page) {
|
|
const result = await stopVisualProbe(page)
|
|
const trace: VisualStabilityTrace = { markers: result.markers, samples: result.samples }
|
|
Object.defineProperty(trace, capturedFrames, { value: result.frames })
|
|
return trace
|
|
}
|
|
|
|
export async function markVisualStability(page: Page, label: string) {
|
|
await markVisualProbe(page, label)
|
|
}
|
|
|
|
export function analyzeVisualStability(trace: VisualStabilityTrace, options: LegacyVisualStabilityOptions = {}) {
|
|
return analyzeVisualObservations(trace.samples, legacyVisualPlan(options))
|
|
}
|
|
|
|
export function analyzeVisualStabilityByMarker(
|
|
trace: VisualStabilityTrace,
|
|
options: LegacyVisualStabilityOptions = {},
|
|
) {
|
|
return analyzeVisualTraceByMarker(trace, legacyVisualPlan(options))
|
|
}
|
|
|
|
export async function expectVisualStability(
|
|
testInfo: TestInfo,
|
|
name: string,
|
|
trace: VisualStabilityTrace,
|
|
options: LegacyVisualStabilityOptions = {},
|
|
) {
|
|
await reportVisualStability(
|
|
testInfo,
|
|
name,
|
|
{
|
|
...trace,
|
|
frames: (trace as VisualStabilityTrace & { [capturedFrames]?: CapturedFrame[] })[capturedFrames] ?? [],
|
|
},
|
|
legacyVisualPlan(options),
|
|
)
|
|
}
|