shiplightai 0.1.96 → 0.1.97

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
@@ -9,8 +9,9 @@ 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
- * 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.
12
+ * A relative auth path is resolved against the project root (the directory holding
13
+ * playwright.config.*), not process.cwd() — see resolveProjectRoot for why the two
14
+ * can diverge, and resolveUserPath for the fallback to the old testDir anchor.
14
15
  * The login module must export a login(args, browser?) function that performs the
15
16
  * login flow, caches the storageState, and returns the file path. The fixture passes
16
17
  * its shared browser instance — the login function must NOT close it, only its context.
@@ -26,9 +27,10 @@ interface AuthSpec {
26
27
  args?: Record<string, unknown>;
27
28
  }
28
29
  /**
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).
30
+ * Resolve the project root used to anchor relative file paths a test declares —
31
+ * `auth`, `extensionDir`, `userDataDir` and `extensionStorageState`. The
32
+ * `upload_file` action's `paths` are NOT anchored here; they keep the older
33
+ * rootDir anchor, see resolveTestDataDir for why.
32
34
  *
33
35
  * Playwright does NOT chdir to the project root: `process.cwd()` is the directory
34
36
  * the test command was invoked from, which is not guaranteed to equal the project
@@ -37,11 +39,51 @@ interface AuthSpec {
37
39
  * monorepo invocation pointing at a sub-package config. Anchoring uploads to
38
40
  * `process.cwd()` breaks in exactly those cases.
39
41
  *
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.
42
+ * The anchor is the directory holding `playwright.config.*`, taken from
43
+ * `testInfo.config.configFile`.
44
+ *
45
+ * This deliberately does NOT use `testInfo.config.rootDir`. Despite the name,
46
+ * rootDir is not the project root: Playwright computes it as
47
+ * `path.resolve(configDir, userConfig.testDir) || configDir`, so any config
48
+ * carrying the conventional `testDir: './tests'` makes rootDir the *test*
49
+ * directory. Anchoring there resolved `extensionDir: ./dist` to
50
+ * `<root>/tests/dist` and left the user with a 2-minute browser-launch timeout
51
+ * and no diagnostic (issue #2208). rootDir remains the fallback for runs with
52
+ * no config file, where it equals the directory Playwright started from.
43
53
  */
44
54
  declare function resolveProjectRoot(testInfo: Pick<TestInfo, 'config'>): string;
55
+ /**
56
+ * The anchor for the `upload_file` action's relative `paths`, which the SDK
57
+ * joins against the agent context's `testDataDir`.
58
+ *
59
+ * Deliberately still `rootDir`, unlike every other user path. The others name a
60
+ * FILE, so resolveUserPath can check where it actually is and keep the old
61
+ * location working. This one is a bare DIRECTORY — the filename only appears
62
+ * later, inside sdk-core, where the join has no fallback and no existence check
63
+ * (see agentFile.ts and agentServices.getTestDataFilePath). There is nothing to
64
+ * probe at fixture time, so moving this anchor would silently relocate every
65
+ * relative upload fixture with no way to rescue it.
66
+ *
67
+ * For projects with no `testDir`, rootDir already equals the config directory,
68
+ * so this is identical to resolveProjectRoot and nothing is left behind by the
69
+ * #2208 fix. Moving the upload anchor needs its own change, with a fallback
70
+ * threaded into sdk-core's join and a deprecation period.
71
+ */
72
+ declare function resolveTestDataDir(testInfo: Pick<TestInfo, 'config'>): string;
73
+ /**
74
+ * Resolve a user-provided relative path (auth script, extensionDir, userDataDir,
75
+ * extensionStorageState) against the project root, falling back to the old
76
+ * rootDir anchor when the file lives only there.
77
+ *
78
+ * Correcting the anchor (see resolveProjectRoot) would otherwise break every
79
+ * project that had these files under `testDir` — they resolved correctly before
80
+ * and would start failing on an unchanged test. The new location wins whenever
81
+ * something is actually there, so the fallback cannot shadow a correct path; it
82
+ * only rescues layouts that used to work. When neither location has the file,
83
+ * the project-root path is returned so the resulting error names where the file
84
+ * is now expected.
85
+ */
86
+ declare function resolveUserPath(userPath: string, projectRoot: string, legacyRoot: string): string;
45
87
  /**
46
88
  * Calls the auth module's login(args, browser) function.
47
89
  * The login function is responsible for performing the login flow,
@@ -54,7 +96,7 @@ declare function resolveProjectRoot(testInfo: Pick<TestInfo, 'config'>): string;
54
96
  * The module is cached by Node's module system after the first import,
55
97
  * so multiple tests sharing the same auth path reuse the same instance.
56
98
  */
57
- declare function resolveAuthState(spec: AuthSpec, browser?: Browser, baseURL?: string, projectRoot?: string): Promise<string>;
99
+ declare function resolveAuthState(spec: AuthSpec, browser?: Browser, baseURL?: string, projectRoot?: string, legacyRoot?: string): Promise<string>;
58
100
  /**
59
101
  * Standard Playwright context-option `use:` keys whose resolved (per-test aware)
60
102
  * values we overlay onto `testInfo.project.use`. Must stay identical to the
@@ -212,4 +254,4 @@ type ShiplightFixtures = {
212
254
  };
213
255
  declare const test: _playwright_test.TestType<_playwright_test.PlaywrightTestArgs & _playwright_test.PlaywrightTestOptions & ShiplightFixtures, _playwright_test.PlaywrightWorkerArgs & _playwright_test.PlaywrightWorkerOptions>;
214
256
 
215
- 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 };
257
+ 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, resolveTestDataDir, resolveUserPath, test };