shiplightai 0.1.84 → 0.1.85

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
@@ -1,5 +1,5 @@
1
1
  import * as _playwright_test from '@playwright/test';
2
- import { Browser } from '@playwright/test';
2
+ import { Browser, TestInfo } from '@playwright/test';
3
3
  export { expect } from '@playwright/test';
4
4
  import { VariableStore } from './VariableStore.js';
5
5
  import { WebAgent } from './agent/webAgent.js';
@@ -9,7 +9,8 @@ import './config.js';
9
9
 
10
10
  /**
11
11
  * Per-test auth: path to a login script + optional args passed to the login function.
12
- * The auth path is resolved relative to process.cwd() (the project root where `playwright test` runs).
12
+ * A relative auth path is resolved against the Playwright project root (config.rootDir),
13
+ * not process.cwd() — see resolveProjectRoot for why the two can diverge.
13
14
  * The login module must export a login(args, browser?) function that performs the
14
15
  * login flow, caches the storageState, and returns the file path. The fixture passes
15
16
  * its shared browser instance — the login function must NOT close it, only its context.
@@ -24,6 +25,23 @@ interface AuthSpec {
24
25
  auth: string;
25
26
  args?: Record<string, unknown>;
26
27
  }
28
+ /**
29
+ * Resolve the project root used to anchor relative file paths in tests — most
30
+ * notably the `upload_file` action's `paths`, which the SDK joins against the
31
+ * agent context's `testDataDir` (falling back to `process.cwd()` when unset).
32
+ *
33
+ * Playwright does NOT chdir to the project root: `process.cwd()` is the directory
34
+ * the test command was invoked from, which is not guaranteed to equal the project
35
+ * root. It diverges whenever the run is launched from elsewhere — e.g.
36
+ * `playwright test --config sub/playwright.config.ts` from a parent dir, or a
37
+ * monorepo invocation pointing at a sub-package config. Anchoring uploads to
38
+ * `process.cwd()` breaks in exactly those cases.
39
+ *
40
+ * `testInfo.config.rootDir` is Playwright's own anchor — the directory of the
41
+ * resolved config file — so it tracks the project root regardless of cwd. Fall
42
+ * back to `process.cwd()` only if rootDir is somehow unavailable.
43
+ */
44
+ declare function resolveProjectRoot(testInfo: Pick<TestInfo, 'config'>): string;
27
45
  /**
28
46
  * Calls the auth module's login(args, browser) function.
29
47
  * The login function is responsible for performing the login flow,
@@ -36,7 +54,7 @@ interface AuthSpec {
36
54
  * The module is cached by Node's module system after the first import,
37
55
  * so multiple tests sharing the same auth path reuse the same instance.
38
56
  */
39
- declare function resolveAuthState(spec: AuthSpec, browser?: Browser, baseURL?: string): Promise<string>;
57
+ declare function resolveAuthState(spec: AuthSpec, browser?: Browser, baseURL?: string, projectRoot?: string): Promise<string>;
40
58
  /**
41
59
  * Standard Playwright context-option `use:` keys whose resolved (per-test aware)
42
60
  * values we overlay onto `testInfo.project.use`. Must stay identical to the
@@ -193,4 +211,4 @@ type ShiplightFixtures = {
193
211
  };
194
212
  declare const test: _playwright_test.TestType<_playwright_test.PlaywrightTestArgs & _playwright_test.PlaywrightTestOptions & ShiplightFixtures, _playwright_test.PlaywrightWorkerArgs & _playwright_test.PlaywrightWorkerOptions>;
195
213
 
196
- 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 };
214
+ 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, resolveProjectRoot, test };