@dev-blinq/bvt-playwright-js 1.0.0-dev.3 → 1.0.0-dev.4.latest.103.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;
@@ -7331,6 +7409,7 @@ type ExecutionStatusUpdateEventData = {
7331
7409
  stepDefinitionId: string;
7332
7410
  completedAt?: ExecutionEventTimestamp;
7333
7411
  result: ExecResult;
7412
+ resolvedChosenSelectorIndex?: number;
7334
7413
  recovery?: RecoveryMetadata;
7335
7414
  } | RecoveryStatusEvent;
7336
7415
  type ExecutionCompletedEventData = {
@@ -7819,6 +7898,7 @@ declare const ExecutionResultSchema: z.ZodObject<{
7819
7898
  data: z.ZodOptional<z.ZodUnknown>;
7820
7899
  }, z.core.$strict>>>>;
7821
7900
  duration: z.ZodNumber;
7901
+ screenshotBefore: z.ZodOptional<z.ZodString>;
7822
7902
  screenshotAfter: z.ZodOptional<z.ZodString>;
7823
7903
  mutationSignals: z.ZodOptional<z.ZodObject<{
7824
7904
  httpMutations: z.ZodArray<z.ZodObject<{
@@ -7942,7 +8022,7 @@ declare class DownloadStore {
7942
8022
  cancelAll(): void;
7943
8023
  }
7944
8024
  type CustomCodeAllowedHost = {
7945
- readonly protocol: "http:" | "https:";
8025
+ readonly protocol: "http:" | "https:" | "pg:";
7946
8026
  readonly hostname: string;
7947
8027
  };
7948
8028
  type CustomCodePolicy = {
@@ -7957,6 +8037,7 @@ type CustomCodePolicy = {
7957
8037
  readonly network: {
7958
8038
  readonly allowedHosts: readonly CustomCodeAllowedHost[];
7959
8039
  readonly blockPrivateIpRanges: boolean;
8040
+ readonly requirePgTls: boolean;
7960
8041
  };
7961
8042
  readonly filesystem: {
7962
8043
  readonly root: string;
@@ -8133,11 +8214,13 @@ type CustomCodeRuntimeOptions = {
8133
8214
  readonly driver?: CustomCodeDriver;
8134
8215
  readonly policy?: CustomCodePolicy;
8135
8216
  readonly logger?: AgentLoggerInput;
8217
+ readonly pgHostBridge?: boolean;
8136
8218
  };
8137
8219
  declare class CustomCodeRuntime {
8138
8220
  private readonly driver;
8139
8221
  private readonly policy;
8140
8222
  private readonly logger?;
8223
+ private readonly pgHostBridge;
8141
8224
  constructor(options?: CustomCodeRuntimeOptions);
8142
8225
  execute(input: ExecuteCustomCodeInput): Promise<CustomCodeExecutionResult>;
8143
8226
  }
@@ -8830,6 +8913,7 @@ declare class BrowserObserver {
8830
8913
  private rrwebBufferedBytes;
8831
8914
  private rrwebCommandAnchors;
8832
8915
  static instance: BrowserObserver | null;
8916
+ private writeConsole;
8833
8917
  private getRrwebChunkEventCountThreshold;
8834
8918
  private getRrwebChunkByteThreshold;
8835
8919
  private getRrwebMaskProfile;
@@ -8976,9 +9060,9 @@ type GlobalThis = {
8976
9060
  __bvt_emit: (event: any) => void;
8977
9061
  };
8978
9062
  declare const browserTypesMap: {
8979
- chromium: playwright_core0.BrowserType<{}>;
8980
- firefox: playwright_core0.BrowserType<{}>;
8981
- webkit: playwright_core0.BrowserType<{}>;
9063
+ chromium: playwright.BrowserType<{}>;
9064
+ firefox: playwright.BrowserType<{}>;
9065
+ webkit: playwright.BrowserType<{}>;
8982
9066
  };
8983
9067
  type BrowserConnectInput = {
8984
9068
  browser: {
@@ -9182,12 +9266,12 @@ declare class Tester {
9182
9266
  launchBrowser(input: BrowserLaunchInput): Promise<{
9183
9267
  browser: Browser;
9184
9268
  browserContext: BrowserContext;
9185
- browserType: playwright_core0.BrowserType<{}>;
9269
+ browserType: playwright.BrowserType<{}>;
9186
9270
  }>;
9187
9271
  connectBrowser(input: BrowserConnectInput): Promise<{
9188
9272
  browser: Browser;
9189
9273
  browserContext: BrowserContext;
9190
- browserType: playwright_core0.BrowserType<{}>;
9274
+ browserType: playwright.BrowserType<{}>;
9191
9275
  }>;
9192
9276
  openTab(browserContext: BrowserContext, config?: {
9193
9277
  url?: string;
@@ -9235,6 +9319,7 @@ declare class Tester {
9235
9319
  result?: unknown;
9236
9320
  error?: string | undefined;
9237
9321
  userMessage?: string | undefined;
9322
+ screenshotBefore?: string | undefined;
9238
9323
  screenshotAfter?: string | undefined;
9239
9324
  mutationSignals?: {
9240
9325
  httpMutations: {
@@ -9279,6 +9364,8 @@ declare class Tester {
9279
9364
  headers: Record<string, string>;
9280
9365
  bodyText: string;
9281
9366
  bodyJson?: unknown;
9367
+ } | {
9368
+ resolvedChosenSelectorIndex: number;
9282
9369
  } | undefined>;
9283
9370
  /**
9284
9371
  * Runtime test-data accessor bound to the tester's current data provider and
@@ -9361,6 +9448,67 @@ export declare function toMatcherValue(value: MatcherValueInput): string | numbe
9361
9448
  export declare function toMatcherValue(value: undefined): undefined;
9362
9449
  export declare function toMatcherValue(value: MatcherValueInput | undefined): string | number | boolean | RegExp | undefined;
9363
9450
  type GeneratedCommand = Command;
9451
+ /**
9452
+ * Stateful API helper for generated `api.action` / `api.assertion` steps.
9453
+ * Mirrors the Tester's runtime: a request stores its response as `lastResponse`
9454
+ * (and writes `saveAs` to runtime test data), and an assertion runs against
9455
+ * that stored response. The shared state lives here because the request and
9456
+ * assertion are emitted as separate `test.step` blocks with no shared scope.
9457
+ */
9458
+ export type BlinqApi = {
9459
+ /** Run the request, store it as `lastResponse`, and persist `saveAs` if set. */
9460
+ request(request: ApiRequest): Promise<ApiResponseSnapshot>;
9461
+ /** Assert against `lastResponse`; throws if no request has run yet. */
9462
+ assert(assertion: ApiResponseAssertionCommandData): Promise<void>;
9463
+ readonly lastResponse: ApiResponseSnapshot | undefined;
9464
+ };
9465
+ /**
9466
+ * The `context` object AI-chat (`custom`) command code receives. Mirrors the
9467
+ * recorder sandbox's `context`: the resolution-scope fields plus a `testData`
9468
+ * accessor (which is the runner's `TestDataApi`, exposing
9469
+ * `set`/`get`/`setRuntime`/`getRuntime`).
9470
+ */
9471
+ export type AiChatContext = {
9472
+ readonly testData: TestDataApi;
9473
+ readonly projectId?: string;
9474
+ readonly environmentId?: string;
9475
+ readonly featureId?: string;
9476
+ readonly scenarioId?: string;
9477
+ readonly executionId?: string;
9478
+ };
9479
+ /**
9480
+ * The globals AI-chat custom code expects beyond `page` / `expect` / `console`.
9481
+ * Generated specs declare `context`, `checkpoint`, `onCommandStart`, and
9482
+ * `onCommandPass` above the inlined code, sourced from the bvt fixture.
9483
+ *
9484
+ * Recovery helpers (`helpers.getPreferredInteractiveTarget`, etc.) are
9485
+ * intentionally NOT provided — they depend on bvt-agent's runtime recovery and
9486
+ * have no standalone equivalent.
9487
+ */
9488
+ export type AiChatGlobals = {
9489
+ readonly context: AiChatContext;
9490
+ checkpoint(label: string, data?: unknown): void;
9491
+ onCommandStart(label: string): Promise<void>;
9492
+ onCommandPass(opts?: {
9493
+ delayMs?: number;
9494
+ }): Promise<void>;
9495
+ };
9496
+ /**
9497
+ * Build the AI-chat command globals. Mirrors the recorder sandbox:
9498
+ * `onCommandStart` waits the watch-delay then records the command boundary,
9499
+ * `onCommandPass` waits the (overridable) watch-delay, and `checkpoint`
9500
+ * records a labelled marker. In a standalone Playwright run the sandbox's
9501
+ * live-timeline bridge is replaced by Playwright test annotations (via the
9502
+ * injected `annotate` callback).
9503
+ */
9504
+ export declare function createAiChatGlobals(input: {
9505
+ testDataApi: TestDataApi;
9506
+ parameters: PlaywrightRunnerParameters;
9507
+ annotate: (annotation: {
9508
+ type: string;
9509
+ description: string;
9510
+ }) => void;
9511
+ }): AiChatGlobals;
9364
9512
  export declare class TempFileTestDataProvider implements ITestDataProvider {
9365
9513
  readonly filePath: string;
9366
9514
  readonly seedFilePath?: string | undefined;
@@ -9392,6 +9540,7 @@ export declare class PlaywrightRunner {
9392
9540
  private readonly scopeManager?;
9393
9541
  private readonly preprocessors;
9394
9542
  private resolutionContext;
9543
+ private apiRuntime?;
9395
9544
  constructor(options?: PlaywrightRunnerOptions, dependencies?: PlaywrightRunnerDependencies);
9396
9545
  private applyResolutionContext;
9397
9546
  /**
@@ -9400,6 +9549,13 @@ export declare class PlaywrightRunner {
9400
9549
  */
9401
9550
  attach(page: Page): void;
9402
9551
  detach(): void;
9552
+ /**
9553
+ * Stateful API helper for `api.action` / `api.assertion` steps. Lazily built
9554
+ * and held for the runner's lifetime so a request and its following assertion
9555
+ * share `lastResponse`. Throws if no test-data provider/context is available
9556
+ * (the `saveAs` path needs it).
9557
+ */
9558
+ get api(): BlinqApi;
9403
9559
  executeCommand(command: GeneratedCommand, parameters?: Record<string, string>): Promise<unknown>;
9404
9560
  /**
9405
9561
  * Run the preprocessor pipeline (step parameters, data-resolver tokens,
@@ -9472,6 +9628,25 @@ export type BlinqTestRuntime = {
9472
9628
  * `{{key}}` in later steps.
9473
9629
  */
9474
9630
  readonly testDataApi: TestDataApi;
9631
+ /**
9632
+ * Stateful API helper. `api.action` steps call `bvt.api.request(...)` and
9633
+ * `api.assertion` steps call `bvt.api.assert(...)`; the request's response is
9634
+ * shared with the following assertion via `bvt.api.lastResponse`.
9635
+ */
9636
+ readonly api: BlinqApi;
9637
+ /**
9638
+ * The `context` object AI-chat (`custom`) command code receives; generated
9639
+ * specs declare `const context = bvt.aiChatContext` above the inlined code.
9640
+ */
9641
+ readonly aiChatContext: AiChatContext;
9642
+ /** AI-chat `checkpoint(label, data?)` global — records a Playwright annotation. */
9643
+ checkpoint(label: string, data?: unknown): void;
9644
+ /** AI-chat `onCommandStart(label)` global — watch-delay then a boundary annotation. */
9645
+ onCommandStart(label: string): Promise<void>;
9646
+ /** AI-chat `onCommandPass(opts?)` global — watch-delay (overridable via `delayMs`). */
9647
+ onCommandPass(opts?: {
9648
+ delayMs?: number;
9649
+ }): Promise<void>;
9475
9650
  executeCommand(command: GeneratedCommand, parameters?: Record<string, string>): Promise<unknown>;
9476
9651
  resolveCommand(command: unknown, parameters?: Record<string, string>): Promise<Command>;
9477
9652
  find(command: Command): Promise<Locator | Page | FrameLocator | null>;
@@ -9495,7 +9670,7 @@ export type BlinqTestFixtures = {
9495
9670
  * Generated spec files import `test` from this function and call
9496
9671
  * `bvt.executeCommand(...)` inside `test.step` blocks.
9497
9672
  */
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>;
9673
+ 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
9674
 
9500
9675
  export {
9501
9676
  createBlinqTest as default,