shiplightai 0.1.74 → 0.1.76

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/dist/fixture.d.ts CHANGED
@@ -32,6 +32,76 @@ interface AuthSpec {
32
32
  * so multiple tests sharing the same auth path reuse the same instance.
33
33
  */
34
34
  declare function resolveAuthState(spec: AuthSpec): Promise<string>;
35
+ /**
36
+ * Standard Playwright context-option `use:` keys whose resolved (per-test aware)
37
+ * values we overlay onto `testInfo.project.use`. Must stay identical to the
38
+ * fixture-arg destructure and the `resolvedContextOptions` object in the
39
+ * `context` fixture below — the drift guard test
40
+ * (fixture.contextOptions.test.ts) asserts this set, together with
41
+ * EXCLUDED_CONTEXT_OPTION_KEYS, equals the full set Playwright actually resolves.
42
+ */
43
+ declare const HANDLED_CONTEXT_OPTION_KEYS: readonly ["acceptDownloads", "baseURL", "bypassCSP", "colorScheme", "deviceScaleFactor", "extraHTTPHeaders", "geolocation", "hasTouch", "httpCredentials", "ignoreHTTPSErrors", "isMobile", "javaScriptEnabled", "locale", "offline", "permissions", "proxy", "serviceWorkers", "timezoneId", "userAgent", "viewport"];
44
+ /**
45
+ * Context-option keys Playwright resolves that we deliberately do NOT overlay:
46
+ * - `storageState`: the fixture's auth system owns it (see resolveAuthState).
47
+ * - `contextOptions`: raw escape-hatch object, left to flow through unchanged.
48
+ * - `clientCertificates`: specially resolved by Playwright; left untouched.
49
+ */
50
+ declare const EXCLUDED_CONTEXT_OPTION_KEYS: readonly ["storageState", "contextOptions", "clientCertificates"];
51
+ /**
52
+ * Context options Playwright rejects when `viewport` is `null` (no fixed
53
+ * viewport / `noDefaultViewport`). Each entry's `conflicts` predicate mirrors
54
+ * the exact condition in Playwright's `validateBrowserContextOptions`:
55
+ * - `deviceScaleFactor`: throws when `!== void 0` (any defined value).
56
+ * - `isMobile`: throws when `!!isMobile` (any truthy value).
57
+ * The drift guard test asserts these keys stay in sync with that function, so a
58
+ * future Playwright that adds a new `viewport: null` conflict fails loudly
59
+ * instead of crashing context creation unguarded.
60
+ */
61
+ declare const VIEWPORT_INCOMPATIBLE_OPTIONS: ReadonlyArray<{
62
+ key: string;
63
+ conflicts: (value: unknown) => boolean;
64
+ }>;
65
+ /**
66
+ * Resolve the `viewport: null` ⇄ emulation conflict that Playwright rejects.
67
+ *
68
+ * An explicit `viewport: null` (no fixed viewport, for responsive testing) is
69
+ * incompatible with `deviceScaleFactor` / `isMobile: true` — `browser.newContext`
70
+ * and `launchPersistentContext` THROW on the combination. `viewport: null` is the
71
+ * more specific, intentional per-test signal, so we honor it and drop the
72
+ * incompatible emulation options (e.g. a project sets `deviceScaleFactor: 2`
73
+ * globally and a single test wants a responsive `viewport: null`).
74
+ *
75
+ * Mutates `options` in place; returns the names of the keys that were dropped
76
+ * (so the caller can warn). A no-op unless `options.viewport === null`.
77
+ */
78
+ declare function dropViewportIncompatibleOptions(options: Record<string, unknown>): string[];
79
+ /**
80
+ * Merge the project-level `use: { ... }` with the per-test context options
81
+ * Playwright resolved for THIS test.
82
+ *
83
+ * Why this is needed: the Shiplight `context` fixture overrides Playwright's
84
+ * built-in `context` fixture and builds context options from
85
+ * `testInfo.project.use`. That object only carries the PROJECT-level `use:`
86
+ * block — it does NOT contain a per-test `test.use({ ... })` (which is exactly
87
+ * what the transpiled YAML `use:` block emits). When the project sets a context
88
+ * option (e.g. `viewport: 1280x720`), it pre-seeds that key, and Playwright's
89
+ * fill-missing merge (`runBeforeCreateBrowserContext`, which only fills keys NOT
90
+ * already present) can then never apply the per-test value. Options the project
91
+ * did NOT set got filled from the per-test values, so they appeared to work —
92
+ * only project-set keys (viewport, in the typical config) were silently dropped.
93
+ *
94
+ * `resolved` holds the values of Playwright's standard context-option fixtures
95
+ * (viewport, colorScheme, locale, isMobile, ...). Those honor the full override
96
+ * chain (file-level test.use() > project use: > defaults), so applying them over
97
+ * the project use restores the documented precedence for every context option.
98
+ * Keys resolved to `undefined` are skipped so we never inject options the test
99
+ * never asked for.
100
+ *
101
+ * Finally, `dropViewportIncompatibleOptions` resolves the `viewport: null` ⇄
102
+ * emulation conflict that Playwright would otherwise throw on.
103
+ */
104
+ declare function mergeResolvedContextOptions(projectUse: Record<string, unknown>, resolved: Record<string, unknown>): Record<string, unknown>;
35
105
  /**
36
106
  * TestContext — Proxy-backed object for reading/writing runtime variables.
37
107
  * Supports property-style access: testContext.myVar = 'value' / const v = testContext.myVar
@@ -118,4 +188,4 @@ type ShiplightFixtures = {
118
188
  };
119
189
  declare const test: _playwright_test.TestType<_playwright_test.PlaywrightTestArgs & _playwright_test.PlaywrightTestOptions & ShiplightFixtures, _playwright_test.PlaywrightWorkerArgs & _playwright_test.PlaywrightWorkerOptions>;
120
190
 
121
- export { type AuthSpec, SDK_ENV_ALLOWLIST, type TestContext, applyVarsOverride, buildSdkEnv, createTestContext, isDeclaredSensitive, parseVarsOverrideEnv, resolveAuthState, test };
191
+ export { type AuthSpec, EXCLUDED_CONTEXT_OPTION_KEYS, HANDLED_CONTEXT_OPTION_KEYS, SDK_ENV_ALLOWLIST, type TestContext, VIEWPORT_INCOMPATIBLE_OPTIONS, applyVarsOverride, buildSdkEnv, createTestContext, dropViewportIncompatibleOptions, isDeclaredSensitive, mergeResolvedContextOptions, parseVarsOverrideEnv, resolveAuthState, test };