/** * Visual Regression Testing Types (OWL-003) * * Types for the visual regression testing system that compares screenshots * to detect visual changes in web pages. */ /** * Result of comparing two screenshots */ export interface VisualDiffResult { /** Whether the images match within the threshold */ match: boolean; /** Number of different pixels */ diffPixelCount: number; /** Percentage of pixels that differ (0-100) */ diffPercentage: number; /** Total pixels compared */ totalPixels: number; /** Path to the diff image (if generated) */ diffImagePath?: string; /** Diff image as base64 (if requested) */ diffImageBase64?: string; /** Timestamp of comparison */ timestamp: number; /** Duration of comparison in ms */ durationMs: number; } /** * Baseline screenshot for comparison */ export interface VisualBaseline { /** Unique identifier */ id: string; /** URL this baseline is for */ url: string; /** Domain for grouping */ domain: string; /** Name/description of the baseline */ name: string; /** Screenshot data as base64 PNG */ screenshotBase64: string; /** Width of the screenshot */ width: number; /** Height of the screenshot */ height: number; /** Viewport configuration used */ viewport: { width: number; height: number; deviceScaleFactor?: number; }; /** Whether this is a full page screenshot */ fullPage: boolean; /** CSS selector if screenshot of specific element */ selector?: string; /** Tags for organization */ tags: string[]; /** When the baseline was created */ createdAt: number; /** When the baseline was last updated */ updatedAt: number; /** Workflow ID if associated with a workflow */ workflowId?: string; /** Step number if part of a workflow */ workflowStepNumber?: number; } /** * Result of a visual regression test */ export interface VisualRegressionTestResult { /** Unique identifier for this test run */ id: string; /** Baseline ID being tested against */ baselineId: string; /** URL tested */ url: string; /** Whether the test passed (no significant differences) */ passed: boolean; /** The diff result */ diff: VisualDiffResult; /** Threshold that was used */ threshold: number; /** New screenshot that was captured */ newScreenshotBase64: string; /** Baseline screenshot for reference */ baselineScreenshotBase64: string; /** Timestamp of the test */ timestamp: number; /** Duration of the full test (capture + comparison) in ms */ durationMs: number; /** Error if test couldn't be completed */ error?: string; /** Workflow ID if part of workflow test */ workflowId?: string; } /** * Options for taking a baseline screenshot */ export interface CaptureBaselineOptions { /** Name for the baseline */ name: string; /** Full page screenshot vs viewport only */ fullPage?: boolean; /** CSS selector for specific element */ selector?: string; /** Viewport configuration */ viewport?: { width: number; height: number; deviceScaleFactor?: number; }; /** Tags for organization */ tags?: string[]; /** Workflow ID to associate with */ workflowId?: string; /** Step number in workflow */ workflowStepNumber?: number; /** Wait time in ms before capturing (for animations to settle) */ waitBeforeCapture?: number; /** Hide specific elements before capture (CSS selectors) */ hideElements?: string[]; /** Mask specific elements before comparison (CSS selectors) */ maskElements?: string[]; } /** * Options for comparing screenshots */ export interface VisualCompareOptions { /** Threshold for acceptable difference (0-1, default 0.1 = 10%) */ threshold?: number; /** Whether to generate a diff image */ generateDiffImage?: boolean; /** Return diff image as base64 */ returnDiffAsBase64?: boolean; /** Path to save diff image */ diffImagePath?: string; /** Color for highlighting differences (RGBA) */ diffColor?: { r: number; g: number; b: number; a: number; }; /** Anti-aliasing detection (reduces false positives) */ antiAliasing?: boolean; /** Ignore specific regions (CSS selectors or pixel coordinates) */ ignoreRegions?: IgnoreRegion[]; } /** * Region to ignore during comparison */ export interface IgnoreRegion { /** Type of region specification */ type: 'selector' | 'coordinates'; /** CSS selector (for type='selector') */ selector?: string; /** Pixel coordinates (for type='coordinates') */ x?: number; y?: number; width?: number; height?: number; } /** * Workflow visual regression test configuration */ export interface WorkflowVisualTestConfig { /** Workflow ID to test */ workflowId: string; /** Steps to test (all if not specified) */ steps?: number[]; /** Threshold for all steps */ threshold?: number; /** Per-step thresholds (overrides global) */ stepThresholds?: { [stepNumber: number]: number; }; /** Capture baselines if they don't exist */ captureIfMissing?: boolean; /** Update baselines if test passes */ updateBaselinesOnPass?: boolean; /** Generate diff images for failures */ generateDiffs?: boolean; /** Fail fast on first regression */ failFast?: boolean; } /** * Result of testing a workflow for visual regressions */ export interface WorkflowVisualTestResult { /** Workflow ID tested */ workflowId: string; /** Overall pass/fail */ passed: boolean; /** Results for each step tested */ stepResults: WorkflowStepVisualResult[]; /** Number of steps that passed */ passedCount: number; /** Number of steps that failed */ failedCount: number; /** Number of steps skipped (no baseline) */ skippedCount: number; /** Total duration in ms */ durationMs: number; /** Timestamp */ timestamp: number; /** Summary message */ summary: string; } /** * Visual test result for a single workflow step */ export interface WorkflowStepVisualResult { /** Step number */ stepNumber: number; /** URL of the step */ url: string; /** Status of this step's visual test */ status: 'passed' | 'failed' | 'skipped' | 'error'; /** The visual regression test result (if run) */ testResult?: VisualRegressionTestResult; /** Error message if status is 'error' */ error?: string; /** Reason for skip if status is 'skipped' */ skipReason?: string; } /** * Configuration for the VisualRegressionTester */ export interface VisualRegressionTesterConfig { /** Directory to store baselines */ baselineDir: string; /** Directory to store diff images */ diffDir: string; /** Default threshold for comparisons */ defaultThreshold: number; /** Default viewport */ defaultViewport: { width: number; height: number; deviceScaleFactor?: number; }; /** Enable anti-aliasing detection */ antiAliasing: boolean; /** Maximum baselines to store (LRU eviction) */ maxBaselines: number; /** Auto-cleanup old diff images after days */ diffRetentionDays: number; } /** * Event emitted during visual regression testing */ export interface VisualRegressionEvent { type: 'baseline_created' | 'baseline_updated' | 'test_passed' | 'test_failed' | 'comparison_started' | 'comparison_completed'; baselineId?: string; url?: string; diffPercentage?: number; details: Record; timestamp: number; } //# sourceMappingURL=visual-regression.d.ts.map