UNPKG

donobu

Version:

Create browser automations with an LLM agent and replay them as Playwright scripts.

115 lines 4.54 kB
import type { LanguageModel } from 'ai'; import type { GptClient } from '../clients/GptClient'; import type { AuditCoreSchemaType } from '../tools/AuditTool'; import type { AccessibilityResults } from '../tools/RunAccessibilityTestTool'; export type AccessibilityImpact = 'minor' | 'moderate' | 'serious' | 'critical'; export interface AuditOptions { /** * URL to navigate to before running checks. When provided, the audit owns * the full page lifecycle — navigation, console errors, and network failures * are all captured from the moment the page begins loading. * * When omitted, the audit checks the current page as-is. Console and network * error checks will only reflect errors captured *during* the audit (e.g. * from lazy-loaded resources or the page load assertion retries), not errors * that occurred during a prior `page.goto()` call. */ url?: string; /** GPT client used for AI-powered checks (e.g. page load assertion). */ gptClient?: GptClient | Exclude<LanguageModel, string>; /** Page load check. Set to `false` to skip. */ pageLoad?: false | { /** Custom assertion describing what "fully loaded" means for this page. */ assertion?: string; /** Number of retry attempts. @default 3 */ retries?: number; /** Seconds to wait between retries. @default 2 */ retryDelaySeconds?: number; /** When to consider navigation complete. @default 'load' */ waitUntil?: 'load' | 'domcontentloaded' | 'networkidle' | 'commit'; }; /** Accessibility check. Set to `false` to skip. */ accessibility?: false; /** Unique `id` attribute check. Set to `false` to skip. */ uniqueIds?: false; /** Unique test-id attribute check. Set to `false` to skip. */ uniqueTestIds?: false | { /** Attributes to check for uniqueness. @default ['data-testid', 'data-test-id', 'data-test', 'data-cy', 'data-qa'] */ attributes?: string[]; }; /** Console error check. Set to `false` to skip. */ consoleErrors?: false | { /** Patterns to ignore — errors matching any pattern are excluded. */ ignore?: RegExp[]; }; /** Network error check. Set to `false` to skip. */ networkErrors?: false | { /** URL patterns to ignore — matching requests are excluded. */ ignore?: RegExp[]; }; } export interface AuditReport { /** Whether all checks passed without issues. */ passed: boolean; /** URL of the page at the time the audit was requested. */ page: string; /** Unix epoch milliseconds when the audit was requested. */ startedAt: number; /** Unix epoch milliseconds when the audit finished. */ completedAt: number; /** Start index (inclusive) in the flow log buffer for entries captured during this audit. */ logStartIndex: number; /** End index (exclusive) in the flow log buffer for entries captured during this audit. */ logEndIndex: number; /** * The serialized tool parameters the audit was run with. Ignore patterns * are stored as regex source strings (not RegExp objects). */ options: AuditCoreSchemaType; pageLoad: { passed: boolean; /** Description of the issue if the page did not fully load. */ error?: string; }; accessibility: { passed: boolean; /** Critical accessibility violations found by axe-core. */ violations: AccessibilityResults['violations']; }; uniqueIds: { passed: boolean; /** DOM `id` values that appear more than once. */ duplicates: Array<{ id: string; count: number; }>; }; uniqueTestIds: { passed: boolean; /** `data-testid` (and common variant) values that appear more than once. */ duplicates: Array<{ attribute: string; value: string; count: number; }>; }; consoleErrors: { passed: boolean; /** Console errors and uncaught exceptions captured during page load. */ errors: Array<{ message: string; source?: string; }>; }; networkErrors: { passed: boolean; /** Failed network requests (4xx/5xx responses and request failures). */ errors: Array<{ url: string; method?: string; statusCode?: number; failureReason?: string; }>; }; } //# sourceMappingURL=AuditReport.d.ts.map