import "@stablyai/playwright-base"; import * as _stablyai_playwright_base from '@stablyai/playwright-base'; import { Agent } from '@stablyai/playwright-base'; export { AIModel, Agent, GetLocatorsByAIOptions, GetLocatorsByAIResult, ScreenshotPromptOptions, setApiKey } from '@stablyai/playwright-base'; import * as _playwright_test from '@playwright/test'; import { BrowserContext, defineConfig as defineConfig$1, test as test$1 } from '@playwright/test'; export * from '@playwright/test'; import { S as StablyNotificationConfig } from './index.d-CYCd1ME4.js'; export { N as NotificationResultPolicy, P as ProjectNotificationConfig, a as StablyEmailNotificationConfig, b as StablyReporterOptions, c as StablySlackNotificationConfig, s as stablyReporter } from './index.d-CYCd1ME4.js'; import 'child_process'; import 'stream'; import 'fs'; type PlaywrightCookie = Parameters[0][number]; type LocalStorageEntry = { name: string; value: string; }; type StorageOrigin = { localStorage: LocalStorageEntry[]; origin: string; }; /** * Playwright-compatible storage state. */ type GoogleStorageState = { cookies: PlaywrightCookie[]; origins: StorageOrigin[]; }; /** * Input for {@link authWithGoogle}. */ type AuthWithGoogleOptions = { /** * Browser context where auth state should be applied. */ context: BrowserContext; /** * Google account email. */ email: string; /** * Google account password. */ password: string; /** * TOTP seed/secret used to generate the Google 2FA code. */ otpSecret: string; /** * Force a cache refresh server-side. Defaults to `false`. */ forceRefresh?: boolean; /** * Optional API key override. Defaults to the configured Stably API key. */ apiKey?: string; }; /** * Signs in a Google test account and applies the authenticated session to a Playwright context. * * Use this when your test needs to start in an already-authenticated state without * manually driving the login UI. After this resolves, cookies and localStorage are * applied to the provided context and subsequent pages in that context can continue * as an authenticated user. * * @param options - Google credentials and target Playwright context. * @param options.context - Browser context to receive the authenticated session. * @param options.email - Google account email. * @param options.password - Google account password. * @param options.otpSecret - TOTP secret for 2FA. See https://docs.stably.ai/stably2/auth/google-otp-secret-helper. * @param options.forceRefresh - Optional flag to force regeneration of session state. * @param options.apiKey - Optional Stably API key override. * * @returns Resolves when auth state has been successfully applied to the context. * * @example * ```ts * import { test } from "@stablyai/playwright-test"; * * test("opens Google settings as authenticated user", async ({ context, page }) => { * await context.authWithGoogle({ * email: "qa@example.com", * password: process.env.GOOGLE_TEST_PASSWORD!, * otpSecret: process.env.GOOGLE_TEST_OTP_SECRET!, * }); * * await page.goto("https://myaccount.google.com"); * }); * ``` */ declare function authWithGoogle(options: AuthWithGoogleOptions): Promise; /** * Get the directory name from an import.meta.url. * This is the ESM equivalent of __dirname. * * @example * ```ts * import { getDirname } from '@stablyai/playwright-test'; * const __dirname = getDirname(import.meta.url); * * // Use in tests for file paths * await page.setInputFiles('input', path.join(__dirname, 'fixtures', 'file.pdf')); * ``` */ declare function getDirname(importMetaUrl: string): string; /** * Get the filename from an import.meta.url. * This is the ESM equivalent of __filename. * * @example * ```ts * import { getFilename } from '@stablyai/playwright-test'; * const __filename = getFilename(import.meta.url); * ``` */ declare function getFilename(importMetaUrl: string): string; declare const test: typeof test$1; declare const expect: _playwright_test.Expect<{ readonly aiAssert: (this: { isNot: boolean; message?: () => string; }, received: _playwright_test.Page | _playwright_test.Locator, condition: string, options?: _stablyai_playwright_base.ScreenshotPromptOptions) => Promise<_playwright_test.MatcherReturnType>; readonly toMatchScreenshotPrompt: (this: { isNot: boolean; message?: () => string; }, received: _playwright_test.Page | _playwright_test.Locator, condition: string, options?: _stablyai_playwright_base.ScreenshotPromptOptions) => Promise<_playwright_test.MatcherReturnType>; }>; type StablyProjectConfig = { notifications?: StablyNotificationConfig; }; /** * Stably-enhanced defineConfig with typed support for stably notification configuration in projects. * The `stably` property on projects is available via module augmentation of `@playwright/test`. * * @example * ```ts * import { defineConfig, stablyReporter } from "@stablyai/playwright-test"; * * export default defineConfig({ * reporter: [stablyReporter({ apiKey: "..." })], * projects: [ * { * name: "smoke", * stably: { * notifications: { * slack: { channelName: "#alerts", notifyOnResult: "failures-only" }, * }, * }, * }, * ], * }); * ``` */ declare const defineConfig: typeof defineConfig$1; declare module "@playwright/test" { interface LocatorAssertions { /** * Asserts that the locator satisfies a natural language condition using AI vision. * * Takes a screenshot of the locator and uses AI to verify whether the specified condition is met. * * @param condition - A natural language description of what should be true about the locator * @param options - Optional screenshot options (e.g., timeout) * * @example * ```typescript * await expect(page.locator('.button')).aiAssert('The button is disabled and grayed out'); * ``` */ aiAssert(condition: string, options?: _stablyai_playwright_base.ScreenshotPromptOptions): Promise; /** * @deprecated Use `aiAssert` instead. This method will be removed in a future version. */ toMatchScreenshotPrompt(condition: string, options?: _stablyai_playwright_base.ScreenshotPromptOptions): Promise; } interface PageAssertions { /** * Asserts that the page satisfies a natural language condition using AI vision. * * Takes a screenshot of the page and uses AI to verify whether the specified condition is met. * * @param condition - A natural language description of what should be true about the page * @param options - Optional screenshot options (e.g., fullPage, timeout) * * @example * ```typescript * await expect(page).aiAssert('The page shows a success message after form submission'); * ``` */ aiAssert(condition: string, options?: _stablyai_playwright_base.ScreenshotPromptOptions): Promise; /** * @deprecated Use `aiAssert` instead. This method will be removed in a future version. */ toMatchScreenshotPrompt(condition: string, options?: _stablyai_playwright_base.ScreenshotPromptOptions): Promise; } interface PlaywrightTestArgs { agent: Agent; } interface BrowserContext { /** * Generates and applies Google auth state to this context. * * Calls Stably's Google auth-state endpoint and proactively sets cookies and * localStorage values on this context. */ authWithGoogle(options: Omit): Promise; } interface Project { stably?: StablyProjectConfig; } } export { StablyNotificationConfig, authWithGoogle, defineConfig, expect, getDirname, getFilename, test }; export type { AuthWithGoogleOptions, GoogleStorageState, StablyProjectConfig }; //# sourceMappingURL=index.d.ts.map