@dev-blinq/bvt-playwright-js 1.0.0-dev.3 → 1.0.0-dev.4.latest.66.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.d.mts CHANGED
@@ -1,7 +1,6 @@
1
1
  import { z } from "zod";
2
- import { Browser, BrowserContext, ConnectOptions, Frame, FrameLocator, LaunchOptions, Locator, Page } from "@playwright/test";
2
+ import { Browser, BrowserContext, ConnectOptions, Frame, FrameLocator, LaunchOptions, Locator, Page, TestType } from "@playwright/test";
3
3
  import * as playwright from 'playwright';
4
- import * as playwright_core0 from 'playwright-core';
5
4
 
6
5
  declare const apiResponseSnapshotSchema: z.ZodObject<{
7
6
  status: z.ZodNumber;
@@ -13,6 +12,85 @@ declare const apiResponseSnapshotSchema: z.ZodObject<{
13
12
  bodyJson: z.ZodOptional<z.ZodUnknown>;
14
13
  }, z.core.$strict>;
15
14
  type ApiResponseSnapshot = z.infer<typeof apiResponseSnapshotSchema>;
15
+ declare const apiRequestSchema: z.ZodObject<{
16
+ method: z.ZodEnum<{
17
+ GET: "GET";
18
+ POST: "POST";
19
+ PUT: "PUT";
20
+ PATCH: "PATCH";
21
+ DELETE: "DELETE";
22
+ }>;
23
+ url: z.ZodString;
24
+ headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
25
+ body: z.ZodOptional<z.ZodString>;
26
+ saveAs: z.ZodOptional<z.ZodString>;
27
+ capturedResponse: z.ZodOptional<z.ZodObject<{
28
+ status: z.ZodNumber;
29
+ statusText: z.ZodString;
30
+ timeMs: z.ZodNumber;
31
+ sizeBytes: z.ZodNumber;
32
+ headers: z.ZodRecord<z.ZodString, z.ZodString>;
33
+ bodyText: z.ZodString;
34
+ bodyJson: z.ZodOptional<z.ZodUnknown>;
35
+ }, z.core.$strict>>;
36
+ options: z.ZodOptional<z.ZodObject<{
37
+ timeout: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
38
+ }, z.core.$strict>>;
39
+ }, z.core.$strict>;
40
+ type ApiRequest = z.infer<typeof apiRequestSchema>;
41
+ declare const apiResponseAssertionCommandData: z.ZodDiscriminatedUnion<[
42
+ z.ZodObject<{
43
+ operator: z.ZodEnum<{
44
+ equals: "equals";
45
+ notEquals: "notEquals";
46
+ contains: "contains";
47
+ lessThan: "lessThan";
48
+ greaterThan: "greaterThan";
49
+ exists: "exists";
50
+ }>;
51
+ target: z.ZodLiteral<"status">;
52
+ expected: z.ZodString;
53
+ }, z.core.$strict>,
54
+ z.ZodObject<{
55
+ operator: z.ZodEnum<{
56
+ equals: "equals";
57
+ notEquals: "notEquals";
58
+ contains: "contains";
59
+ lessThan: "lessThan";
60
+ greaterThan: "greaterThan";
61
+ exists: "exists";
62
+ }>;
63
+ target: z.ZodLiteral<"responseTime">;
64
+ expected: z.ZodString;
65
+ }, z.core.$strict>,
66
+ z.ZodObject<{
67
+ operator: z.ZodEnum<{
68
+ equals: "equals";
69
+ notEquals: "notEquals";
70
+ contains: "contains";
71
+ lessThan: "lessThan";
72
+ greaterThan: "greaterThan";
73
+ exists: "exists";
74
+ }>;
75
+ expected: z.ZodDefault<z.ZodOptional<z.ZodString>>;
76
+ target: z.ZodLiteral<"header">;
77
+ path: z.ZodString;
78
+ }, z.core.$strict>,
79
+ z.ZodObject<{
80
+ operator: z.ZodEnum<{
81
+ equals: "equals";
82
+ notEquals: "notEquals";
83
+ contains: "contains";
84
+ lessThan: "lessThan";
85
+ greaterThan: "greaterThan";
86
+ exists: "exists";
87
+ }>;
88
+ expected: z.ZodDefault<z.ZodOptional<z.ZodString>>;
89
+ target: z.ZodLiteral<"bodyField">;
90
+ path: z.ZodString;
91
+ }, z.core.$strict>
92
+ ], "target">;
93
+ type ApiResponseAssertionCommandData = z.infer<typeof apiResponseAssertionCommandData>;
16
94
  declare const elementActionSchema: z.ZodDiscriminatedUnion<[
17
95
  z.ZodObject<{
18
96
  type: z.ZodLiteral<"click">;
@@ -7159,8 +7237,8 @@ declare const RecoveryMetadataSchema: z.ZodObject<{
7159
7237
  healedSelector: z.ZodOptional<z.ZodString>;
7160
7238
  commandPatchSummary: z.ZodOptional<z.ZodString>;
7161
7239
  retryOutcome: z.ZodEnum<{
7162
- failed: "failed";
7163
7240
  passed: "passed";
7241
+ failed: "failed";
7164
7242
  }>;
7165
7243
  recoveredAt: z.ZodOptional<z.ZodString>;
7166
7244
  healedLocatorPersistedAt: z.ZodOptional<z.ZodString>;
@@ -7189,11 +7267,11 @@ declare const RecoveryStatusEventSchema: z.ZodObject<{
7189
7267
  stepId: z.ZodString;
7190
7268
  commandId: z.ZodString;
7191
7269
  phase: z.ZodEnum<{
7270
+ failed: "failed";
7192
7271
  analyzing: "analyzing";
7193
7272
  trying_fix: "trying_fix";
7194
7273
  checking_fix: "checking_fix";
7195
7274
  fixed: "fixed";
7196
- failed: "failed";
7197
7275
  }>;
7198
7276
  message: z.ZodString;
7199
7277
  timestamp: z.ZodString;
@@ -7942,7 +8020,7 @@ declare class DownloadStore {
7942
8020
  cancelAll(): void;
7943
8021
  }
7944
8022
  type CustomCodeAllowedHost = {
7945
- readonly protocol: "http:" | "https:";
8023
+ readonly protocol: "http:" | "https:" | "pg:";
7946
8024
  readonly hostname: string;
7947
8025
  };
7948
8026
  type CustomCodePolicy = {
@@ -7957,6 +8035,7 @@ type CustomCodePolicy = {
7957
8035
  readonly network: {
7958
8036
  readonly allowedHosts: readonly CustomCodeAllowedHost[];
7959
8037
  readonly blockPrivateIpRanges: boolean;
8038
+ readonly requirePgTls: boolean;
7960
8039
  };
7961
8040
  readonly filesystem: {
7962
8041
  readonly root: string;
@@ -8976,9 +9055,9 @@ type GlobalThis = {
8976
9055
  __bvt_emit: (event: any) => void;
8977
9056
  };
8978
9057
  declare const browserTypesMap: {
8979
- chromium: playwright_core0.BrowserType<{}>;
8980
- firefox: playwright_core0.BrowserType<{}>;
8981
- webkit: playwright_core0.BrowserType<{}>;
9058
+ chromium: playwright.BrowserType<{}>;
9059
+ firefox: playwright.BrowserType<{}>;
9060
+ webkit: playwright.BrowserType<{}>;
8982
9061
  };
8983
9062
  type BrowserConnectInput = {
8984
9063
  browser: {
@@ -9182,12 +9261,12 @@ declare class Tester {
9182
9261
  launchBrowser(input: BrowserLaunchInput): Promise<{
9183
9262
  browser: Browser;
9184
9263
  browserContext: BrowserContext;
9185
- browserType: playwright_core0.BrowserType<{}>;
9264
+ browserType: playwright.BrowserType<{}>;
9186
9265
  }>;
9187
9266
  connectBrowser(input: BrowserConnectInput): Promise<{
9188
9267
  browser: Browser;
9189
9268
  browserContext: BrowserContext;
9190
- browserType: playwright_core0.BrowserType<{}>;
9269
+ browserType: playwright.BrowserType<{}>;
9191
9270
  }>;
9192
9271
  openTab(browserContext: BrowserContext, config?: {
9193
9272
  url?: string;
@@ -9361,6 +9440,67 @@ export declare function toMatcherValue(value: MatcherValueInput): string | numbe
9361
9440
  export declare function toMatcherValue(value: undefined): undefined;
9362
9441
  export declare function toMatcherValue(value: MatcherValueInput | undefined): string | number | boolean | RegExp | undefined;
9363
9442
  type GeneratedCommand = Command;
9443
+ /**
9444
+ * Stateful API helper for generated `api.action` / `api.assertion` steps.
9445
+ * Mirrors the Tester's runtime: a request stores its response as `lastResponse`
9446
+ * (and writes `saveAs` to runtime test data), and an assertion runs against
9447
+ * that stored response. The shared state lives here because the request and
9448
+ * assertion are emitted as separate `test.step` blocks with no shared scope.
9449
+ */
9450
+ export type BlinqApi = {
9451
+ /** Run the request, store it as `lastResponse`, and persist `saveAs` if set. */
9452
+ request(request: ApiRequest): Promise<ApiResponseSnapshot>;
9453
+ /** Assert against `lastResponse`; throws if no request has run yet. */
9454
+ assert(assertion: ApiResponseAssertionCommandData): Promise<void>;
9455
+ readonly lastResponse: ApiResponseSnapshot | undefined;
9456
+ };
9457
+ /**
9458
+ * The `context` object AI-chat (`custom`) command code receives. Mirrors the
9459
+ * recorder sandbox's `context`: the resolution-scope fields plus a `testData`
9460
+ * accessor (which is the runner's `TestDataApi`, exposing
9461
+ * `set`/`get`/`setRuntime`/`getRuntime`).
9462
+ */
9463
+ export type AiChatContext = {
9464
+ readonly testData: TestDataApi;
9465
+ readonly projectId?: string;
9466
+ readonly environmentId?: string;
9467
+ readonly featureId?: string;
9468
+ readonly scenarioId?: string;
9469
+ readonly executionId?: string;
9470
+ };
9471
+ /**
9472
+ * The globals AI-chat custom code expects beyond `page` / `expect` / `console`.
9473
+ * Generated specs declare `context`, `checkpoint`, `onCommandStart`, and
9474
+ * `onCommandPass` above the inlined code, sourced from the bvt fixture.
9475
+ *
9476
+ * Recovery helpers (`helpers.getPreferredInteractiveTarget`, etc.) are
9477
+ * intentionally NOT provided — they depend on bvt-agent's runtime recovery and
9478
+ * have no standalone equivalent.
9479
+ */
9480
+ export type AiChatGlobals = {
9481
+ readonly context: AiChatContext;
9482
+ checkpoint(label: string, data?: unknown): void;
9483
+ onCommandStart(label: string): Promise<void>;
9484
+ onCommandPass(opts?: {
9485
+ delayMs?: number;
9486
+ }): Promise<void>;
9487
+ };
9488
+ /**
9489
+ * Build the AI-chat command globals. Mirrors the recorder sandbox:
9490
+ * `onCommandStart` waits the watch-delay then records the command boundary,
9491
+ * `onCommandPass` waits the (overridable) watch-delay, and `checkpoint`
9492
+ * records a labelled marker. In a standalone Playwright run the sandbox's
9493
+ * live-timeline bridge is replaced by Playwright test annotations (via the
9494
+ * injected `annotate` callback).
9495
+ */
9496
+ export declare function createAiChatGlobals(input: {
9497
+ testDataApi: TestDataApi;
9498
+ parameters: PlaywrightRunnerParameters;
9499
+ annotate: (annotation: {
9500
+ type: string;
9501
+ description: string;
9502
+ }) => void;
9503
+ }): AiChatGlobals;
9364
9504
  export declare class TempFileTestDataProvider implements ITestDataProvider {
9365
9505
  readonly filePath: string;
9366
9506
  readonly seedFilePath?: string | undefined;
@@ -9392,6 +9532,7 @@ export declare class PlaywrightRunner {
9392
9532
  private readonly scopeManager?;
9393
9533
  private readonly preprocessors;
9394
9534
  private resolutionContext;
9535
+ private apiRuntime?;
9395
9536
  constructor(options?: PlaywrightRunnerOptions, dependencies?: PlaywrightRunnerDependencies);
9396
9537
  private applyResolutionContext;
9397
9538
  /**
@@ -9400,6 +9541,13 @@ export declare class PlaywrightRunner {
9400
9541
  */
9401
9542
  attach(page: Page): void;
9402
9543
  detach(): void;
9544
+ /**
9545
+ * Stateful API helper for `api.action` / `api.assertion` steps. Lazily built
9546
+ * and held for the runner's lifetime so a request and its following assertion
9547
+ * share `lastResponse`. Throws if no test-data provider/context is available
9548
+ * (the `saveAs` path needs it).
9549
+ */
9550
+ get api(): BlinqApi;
9403
9551
  executeCommand(command: GeneratedCommand, parameters?: Record<string, string>): Promise<unknown>;
9404
9552
  /**
9405
9553
  * Run the preprocessor pipeline (step parameters, data-resolver tokens,
@@ -9472,6 +9620,25 @@ export type BlinqTestRuntime = {
9472
9620
  * `{{key}}` in later steps.
9473
9621
  */
9474
9622
  readonly testDataApi: TestDataApi;
9623
+ /**
9624
+ * Stateful API helper. `api.action` steps call `bvt.api.request(...)` and
9625
+ * `api.assertion` steps call `bvt.api.assert(...)`; the request's response is
9626
+ * shared with the following assertion via `bvt.api.lastResponse`.
9627
+ */
9628
+ readonly api: BlinqApi;
9629
+ /**
9630
+ * The `context` object AI-chat (`custom`) command code receives; generated
9631
+ * specs declare `const context = bvt.aiChatContext` above the inlined code.
9632
+ */
9633
+ readonly aiChatContext: AiChatContext;
9634
+ /** AI-chat `checkpoint(label, data?)` global — records a Playwright annotation. */
9635
+ checkpoint(label: string, data?: unknown): void;
9636
+ /** AI-chat `onCommandStart(label)` global — watch-delay then a boundary annotation. */
9637
+ onCommandStart(label: string): Promise<void>;
9638
+ /** AI-chat `onCommandPass(opts?)` global — watch-delay (overridable via `delayMs`). */
9639
+ onCommandPass(opts?: {
9640
+ delayMs?: number;
9641
+ }): Promise<void>;
9475
9642
  executeCommand(command: GeneratedCommand, parameters?: Record<string, string>): Promise<unknown>;
9476
9643
  resolveCommand(command: unknown, parameters?: Record<string, string>): Promise<Command>;
9477
9644
  find(command: Command): Promise<Locator | Page | FrameLocator | null>;
@@ -9495,7 +9662,7 @@ export type BlinqTestFixtures = {
9495
9662
  * Generated spec files import `test` from this function and call
9496
9663
  * `bvt.executeCommand(...)` inside `test.step` blocks.
9497
9664
  */
9498
- export declare function createBlinqTest(options?: CreateBlinqTestOptions): import("@playwright/test").TestType<import("@playwright/test").PlaywrightTestArgs & import("@playwright/test").PlaywrightTestOptions & BlinqTestFixtures, import("@playwright/test").PlaywrightWorkerArgs & import("@playwright/test").PlaywrightWorkerOptions>;
9665
+ export declare function createBlinqTest(options?: CreateBlinqTestOptions): TestType<import("@playwright/test").PlaywrightTestArgs & import("@playwright/test").PlaywrightTestOptions & BlinqTestFixtures, import("@playwright/test").PlaywrightWorkerArgs & import("@playwright/test").PlaywrightWorkerOptions>;
9499
9666
 
9500
9667
  export {
9501
9668
  createBlinqTest as default,