@unotest/web 0.29.0 → 0.31.0

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.
@@ -226,6 +226,10 @@ interface ScreenshotOptions {
226
226
  * pins that floor. */
227
227
  type?: "png" | "jpeg" | "webp";
228
228
  }
229
+ /** Encoding options for an element capture — `ScreenshotOptions` minus
230
+ * the page-geometry fields (`fullPage`, `clip`) that have no meaning for a
231
+ * single element. */
232
+ type ElementScreenshotOptions = Pick<ScreenshotOptions, "type" | "quality">;
229
233
  interface CookieOptions {
230
234
  domain?: string;
231
235
  path?: string;
@@ -234,6 +238,13 @@ interface CookieOptions {
234
238
  secure?: boolean;
235
239
  sameSite?: "Strict" | "Lax" | "None";
236
240
  }
241
+ /** What an attaching client applies to a context it did not create. Only
242
+ * the dialog policy: the rest of {@link ContextOptions} was decided by the
243
+ * process that owns the browser. Without a `dialog` listener Playwright
244
+ * dismisses every dialog on behalf of the client that has none — and a
245
+ * second client watching the run's page would answer `confirm()` with
246
+ * "no" before the run's own accept lands. */
247
+ type AttachOptions = Pick<ContextOptions, "dialogPolicy">;
237
248
 
238
249
  interface WebDriver {
239
250
  /**
@@ -263,7 +274,7 @@ interface WebDriver {
263
274
  */
264
275
  wsEndpoint(): string | undefined;
265
276
  connectShared(wsEndpoint: string, browser: LaunchOptions["browser"]): Promise<void>;
266
- attachExisting(): DriverContext;
277
+ attachExisting(opts?: AttachOptions): DriverContext;
267
278
  }
268
279
  /** One captured network request/response, recorded only under
269
280
  * `UNOTEST_NETWORK`. `status`/`ok` come from the response; `failureText`
@@ -422,6 +433,10 @@ interface DriverPage {
422
433
  evaluate<T = unknown>(js: string, arg?: unknown): Promise<T>;
423
434
  evaluateOnLocator<T = unknown>(loc: LocatorValue, js: string): Promise<T>;
424
435
  screenshot(opts?: ScreenshotOptions): Promise<Buffer>;
436
+ /** Capture ONE element (first match, scrolled into view) instead of the
437
+ * viewport — the evidence shot of a card / row / dialog. Same encoding
438
+ * options as `screenshot`; `fullPage` / `clip` don't apply. */
439
+ screenshotElement(loc: LocatorValue, opts?: ElementScreenshotOptions): Promise<Buffer>;
425
440
  inspectElement(loc: LocatorValue): Promise<ElementHint | null>;
426
441
  /** outerHTML of the element the locator matches (first match), or null
427
442
  * when it resolves to zero elements. Used by debug logging to persist
@@ -526,4 +541,4 @@ interface AncestorHint {
526
541
  className?: string;
527
542
  }
528
543
 
529
- export { type ActionTimeout as A, type ContextOptions as C, type DriverContext as D, type ElementHint as E, type FillOptions as F, type GotoOptions as G, type HoverOptions as H, type LaunchOptions as L, type NetworkEntry as N, type PressOptions as P, type ReloadOptions as R, type ScreenshotOptions as S, type Viewport as V, type WebDriver as W, type CheckOptions as a, type ClickOptions as b, type CookieOptions as c, type DriverPage as d, type NavigationOptions as e, type SelectOptions as f, type WaitOptions as g, type WaitState as h, type LocatorValue as i, type LocatorStep as j, appendStep as k, describeLocator as l, isLocatorValue as m, rootedAt as r };
544
+ export { type AttachOptions as A, type ContextOptions as C, type DriverContext as D, type ElementHint as E, type FillOptions as F, type GotoOptions as G, type HoverOptions as H, type LaunchOptions as L, type NetworkEntry as N, type PressOptions as P, type ReloadOptions as R, type ScreenshotOptions as S, type Viewport as V, type WebDriver as W, type ActionTimeout as a, type CheckOptions as b, type ClickOptions as c, type CookieOptions as d, type DriverPage as e, type NavigationOptions as f, type SelectOptions as g, type WaitOptions as h, type WaitState as i, type LocatorValue as j, type LocatorStep as k, appendStep as l, describeLocator as m, isLocatorValue as n, rootedAt as r };
@@ -0,0 +1,8 @@
1
+ interface LegacyLayout {
2
+ /** Root-relative config path that is no longer read, if there is one. */
3
+ configPath?: string;
4
+ /** True when the product's own manifest still carries the runner. */
5
+ pinInProductManifest: boolean;
6
+ }
7
+
8
+ export type { LegacyLayout as L };
@@ -0,0 +1,36 @@
1
+ import { BlockStatement } from '@unotest/dsl';
2
+
3
+ type LintSeverity = 'error' | 'warning' | 'info';
4
+ interface LintDiagnostic {
5
+ rule: string;
6
+ severity: LintSeverity;
7
+ message: string;
8
+ line: number;
9
+ col: number;
10
+ }
11
+ /** What the linter may ask about external variables (bare UPPER_SNAKE
12
+ * identifiers). A predicate, not a list, because the two callers hold
13
+ * different truths: `lint` knows the NAMES declared in the project's
14
+ * files, a run knows what the runtime will actually RESOLVE (files plus
15
+ * the ambient shell) — and the run-time store already answers `has`. */
16
+ interface ExternalVariableLookup {
17
+ has(name: string): boolean;
18
+ /** Where `has` looked, for the diagnostic (`unotest/.env, unotest/.env.dev (no such file)`). */
19
+ describeSources?(): string;
20
+ }
21
+ interface LintOptions {
22
+ /** Per-rule severity override. Default severities live with each rule. */
23
+ ruleSeverity?: Partial<Record<string, LintSeverity>>;
24
+ /** Pass through if the agent provided documented justification — e.g. a
25
+ * `// reason:` comment immediately above the line. The lexer doesn't
26
+ * preserve comments today; for v1 we accept a flag from the caller. */
27
+ allowDisambigByIndex?: boolean;
28
+ /** Enables `lint:external-variable-undeclared`: every bare UPPER_SNAKE
29
+ * identifier that is neither bound in this file nor known to the
30
+ * lookup is an error. Absent → the rule is off (the caller has no
31
+ * project to check against, e.g. an ad-hoc source string). */
32
+ externalVariables?: ExternalVariableLookup;
33
+ }
34
+ declare function lintAst(ast: BlockStatement, opts?: LintOptions): LintDiagnostic[];
35
+
36
+ export { type ExternalVariableLookup as E, type LintDiagnostic as L, type LintSeverity as a, type LintOptions as b, lintAst as l };