@skyramp/mcp 0.3.2 → 0.3.3

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.
Files changed (137) hide show
  1. package/build/index.js +47 -2
  2. package/build/playwright/PlaywrightTraceService.d.ts +8 -0
  3. package/build/playwright/PlaywrightTraceService.js +1 -0
  4. package/build/prompts/pom-aware-code-reuse.js +17 -8
  5. package/build/prompts/testbot/testbot-prompts.d.ts +2 -12
  6. package/build/prompts/testbot/testbot-prompts.js +24 -5
  7. package/build/resources/testbotResource.js +21 -4
  8. package/build/services/TestExecutionService.d.ts +13 -8
  9. package/build/services/TestExecutionService.js +48 -25
  10. package/build/services/containerEnv.js +24 -0
  11. package/build/tools/queryProxyMocksTool.js +0 -1
  12. package/build/tools/submitReportTool.js +10 -1
  13. package/build/tools/test-management/actionsTool.js +12 -2
  14. package/build/types/TestAnalysis.d.ts +7 -3
  15. package/build/types/TestbotPromptOptions.d.ts +35 -0
  16. package/build/types/TestbotPromptOptions.js +1 -0
  17. package/build/types/index.d.ts +1 -0
  18. package/build/utils/frontendSelectors.js +0 -1
  19. package/build/utils/gitStaging.d.ts +5 -0
  20. package/build/utils/gitStaging.js +1 -1
  21. package/build/utils/pom-catalog.d.ts +23 -0
  22. package/build/utils/pom-catalog.js +30 -0
  23. package/build/utils/pom-scope/pom-files.d.ts +14 -0
  24. package/build/utils/pom-scope/pom-files.js +32 -6
  25. package/build/utils/pom-scope/testIdDiscovery.d.ts +40 -0
  26. package/build/utils/pom-scope/testIdDiscovery.js +104 -0
  27. package/build/utils/reportVerification.d.ts +7 -2
  28. package/build/utils/reportVerification.js +9 -3
  29. package/build/utils/versions.d.ts +3 -3
  30. package/build/utils/versions.js +1 -1
  31. package/node_modules/playwright/ThirdPartyNotices.txt +319 -266
  32. package/node_modules/playwright/lib/dom-analyzer/blueprint.js +154 -27
  33. package/node_modules/playwright/lib/dom-analyzer/crawler.js +2 -2
  34. package/node_modules/playwright/lib/mcp/browser/tools/pageBlueprint.js +1 -1
  35. package/node_modules/playwright/lib/mcp/browser/tools/sitemap.js +6 -2
  36. package/node_modules/playwright/lib/mcp/skyramp/loadTraceTool.js +3 -2
  37. package/node_modules/playwright/lib/mcp/skyramp/resultCode.js +4 -3
  38. package/node_modules/playwright/lib/mcp/skyramp/skyRampImport.js +15 -3
  39. package/node_modules/playwright/lib/mcp/skyramp/specImport.js +781 -0
  40. package/node_modules/playwright/lib/mcp/skyramp/traceRecordingBackend.js +14 -3
  41. package/node_modules/playwright/lib/mcp/test/resultCode.test.js +2 -1
  42. package/node_modules/playwright/lib/mcp/test/skyRampExport.js +1 -1
  43. package/node_modules/playwright/lib/mcp/test/skyRampExport.test.js +30 -0
  44. package/node_modules/playwright/lib/transform/babelBundleImpl.js +200 -199
  45. package/node_modules/playwright/node_modules/playwright-core/ThirdPartyNotices.txt +3 -3
  46. package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/.package-lock.json +3 -3
  47. package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/adapter/aws-lambda/handler.js +16 -25
  48. package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/adapter/bun/websocket.js +3 -1
  49. package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/adapter/lambda-edge/handler.js +20 -4
  50. package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/cjs/adapter/aws-lambda/handler.js +16 -25
  51. package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/cjs/adapter/bun/websocket.js +3 -1
  52. package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/cjs/adapter/lambda-edge/handler.js +20 -4
  53. package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/cjs/client/client.js +10 -1
  54. package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/cjs/client/utils.js +1 -1
  55. package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/cjs/helper/css/common.js +3 -1
  56. package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/cjs/helper/css/index.js +9 -1
  57. package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/cjs/jsx/base.js +8 -14
  58. package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/cjs/jsx/components.js +41 -21
  59. package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/cjs/jsx/context.js +131 -5
  60. package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/cjs/jsx/streaming.js +9 -7
  61. package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/cjs/middleware/bearer-auth/index.js +1 -1
  62. package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/cjs/middleware/cache/index.js +1 -1
  63. package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/cjs/middleware/compress/index.js +2 -1
  64. package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/cjs/middleware/cors/index.js +2 -5
  65. package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/cjs/middleware/etag/index.js +2 -1
  66. package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/cjs/middleware/language/language.js +10 -32
  67. package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/cjs/middleware/method-override/index.js +5 -3
  68. package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/cjs/middleware/serve-static/index.js +2 -2
  69. package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/cjs/middleware/timing/timing.js +3 -1
  70. package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/cjs/router/trie-router/node.js +9 -0
  71. package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/cjs/utils/body.js +12 -4
  72. package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/cjs/utils/buffer.js +2 -1
  73. package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/cjs/utils/ipaddr.js +6 -1
  74. package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/cjs/validator/validator.js +3 -3
  75. package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/client/client.js +10 -1
  76. package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/client/utils.js +1 -1
  77. package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/helper/css/common.js +3 -1
  78. package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/helper/css/index.js +9 -1
  79. package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/jsx/base.js +15 -15
  80. package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/jsx/components.js +42 -22
  81. package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/jsx/context.js +129 -5
  82. package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/jsx/streaming.js +10 -8
  83. package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/middleware/bearer-auth/index.js +1 -1
  84. package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/middleware/cache/index.js +1 -1
  85. package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/middleware/compress/index.js +2 -1
  86. package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/middleware/cors/index.js +2 -5
  87. package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/middleware/etag/index.js +2 -1
  88. package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/middleware/language/language.js +10 -32
  89. package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/middleware/method-override/index.js +5 -3
  90. package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/middleware/serve-static/index.js +2 -2
  91. package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/middleware/timing/timing.js +3 -1
  92. package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/router/trie-router/node.js +9 -0
  93. package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/types/adapter/aws-lambda/handler.d.ts +1 -1
  94. package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/types/adapter/lambda-edge/handler.d.ts +1 -1
  95. package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/types/helper/websocket/index.d.ts +1 -1
  96. package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/types/jsx/base.d.ts +1 -3
  97. package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/types/jsx/context.d.ts +39 -0
  98. package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/types/middleware/context-storage/index.d.ts +2 -2
  99. package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/types/middleware/language/language.d.ts +18 -0
  100. package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/types/utils/body.d.ts +1 -1
  101. package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/types/utils/types.d.ts +1 -1
  102. package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/utils/body.js +12 -4
  103. package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/utils/buffer.js +2 -1
  104. package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/utils/ipaddr.js +6 -1
  105. package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/validator/validator.js +3 -3
  106. package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/package.json +29 -22
  107. package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/package-lock.json +3 -3
  108. package/node_modules/playwright/node_modules/playwright-core/lib/generated/pollingRecorderSource.js +1 -1
  109. package/node_modules/playwright/node_modules/playwright-core/lib/server/codegen/skyramp/jsonlReader.js +5 -1
  110. package/node_modules/playwright/node_modules/playwright-core/lib/server/codegen/skyramp/specReader.js +781 -0
  111. package/node_modules/playwright/node_modules/playwright-core/lib/server/recorder/recorderApp.js +25 -6
  112. package/node_modules/playwright/node_modules/playwright-core/lib/server/recorder/skyramp/replayEngine.js +3 -1
  113. package/node_modules/playwright/node_modules/playwright-core/lib/utils.js +2 -0
  114. package/node_modules/playwright/node_modules/playwright-core/lib/vite/htmlReport/index.html +253 -27
  115. package/node_modules/playwright/node_modules/playwright-core/lib/vite/recorder/assets/{codeMirrorModule-D0BjbCb7.js → codeMirrorModule-DtudTj_v.js} +1 -1
  116. package/node_modules/playwright/node_modules/playwright-core/lib/vite/recorder/assets/index-BpDwp16L.js +422 -0
  117. package/node_modules/playwright/node_modules/playwright-core/lib/vite/recorder/index.html +1 -1
  118. package/node_modules/playwright/node_modules/playwright-core/lib/vite/traceViewer/assets/{codeMirrorModule-Bzd72-bG.js → codeMirrorModule-FNMuBzX1.js} +1 -1
  119. package/node_modules/playwright/node_modules/playwright-core/lib/vite/traceViewer/assets/defaultSettingsView-Co9upU5h.js +1035 -0
  120. package/node_modules/playwright/node_modules/playwright-core/lib/vite/traceViewer/index.DXNIQ_dx.js +2 -0
  121. package/node_modules/playwright/node_modules/playwright-core/lib/vite/traceViewer/index.html +2 -2
  122. package/node_modules/playwright/node_modules/playwright-core/lib/vite/traceViewer/uiMode.CIKB3XSv.js +5 -0
  123. package/node_modules/playwright/node_modules/playwright-core/lib/vite/traceViewer/uiMode.html +2 -2
  124. package/node_modules/playwright/node_modules/playwright-core/package.json +1 -1
  125. package/node_modules/playwright/node_modules/playwright-core/src/generated/pollingRecorderSource.ts +1 -1
  126. package/node_modules/playwright/node_modules/playwright-core/src/server/codegen/skyramp/jsonlReader.ts +4 -0
  127. package/node_modules/playwright/node_modules/playwright-core/src/server/codegen/skyramp/specReader.ts +1028 -0
  128. package/node_modules/playwright/node_modules/playwright-core/src/server/recorder/recorderApp.ts +31 -8
  129. package/node_modules/playwright/node_modules/playwright-core/src/server/recorder/skyramp/replayEngine.ts +1 -0
  130. package/node_modules/playwright/node_modules/playwright-core/src/utils.ts +1 -0
  131. package/node_modules/playwright/package.json +1 -1
  132. package/package.json +9 -6
  133. package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/tsconfig.build.tsbuildinfo +0 -1
  134. package/node_modules/playwright/node_modules/playwright-core/lib/vite/recorder/assets/index-lvTRGFx-.js +0 -193
  135. package/node_modules/playwright/node_modules/playwright-core/lib/vite/traceViewer/assets/defaultSettingsView-DzxTioTK.js +0 -809
  136. package/node_modules/playwright/node_modules/playwright-core/lib/vite/traceViewer/index.BGc30U3S.js +0 -2
  137. package/node_modules/playwright/node_modules/playwright-core/lib/vite/traceViewer/uiMode.IaDrb29A.js +0 -5
@@ -10,6 +10,11 @@ export declare function isInsideDir(child: string, parent: string): boolean;
10
10
  * is unset or the path is already inside it.
11
11
  */
12
12
  export declare function resolveOutputDir(outputDir: string, testsRepoDir: string | undefined): string;
13
+ /**
14
+ * Detect the git repository root for a given file or directory path.
15
+ * Returns undefined if detection fails (not inside a git repo).
16
+ */
17
+ export declare function detectGitRoot(filePath: string): string | undefined;
13
18
  /**
14
19
  * Stages a file path an MCP tool just wrote into the git index by
15
20
  * running `git add -- <path>`.
@@ -33,7 +33,7 @@ const execFileAsync = promisify(execFile);
33
33
  * Detect the git repository root for a given file or directory path.
34
34
  * Returns undefined if detection fails (not inside a git repo).
35
35
  */
36
- function detectGitRoot(filePath) {
36
+ export function detectGitRoot(filePath) {
37
37
  if (!path.isAbsolute(filePath))
38
38
  return undefined;
39
39
  try {
@@ -0,0 +1,23 @@
1
+ export declare const POM_CATALOG_FILENAME = "skyramp-pom-catalog.md";
2
+ /**
3
+ * The one canonical path for a test file's `skyramp-pom-catalog.md`:
4
+ * `<repoRoot>/.skyramp/skyramp-pom-catalog.md`.
5
+ *
6
+ * The catalog is cross-run state, and one path per repository is what keeps it
7
+ * usable — two runs writing at different depths fork the cache so neither finds
8
+ * the other's. It sits beside `workspace.yml` rather than in the customer's test
9
+ * directory because it is generated tooling state, not a deliverable, and
10
+ * delivery stages it by name (SKYR-4125).
11
+ *
12
+ * The root is resolved in priority order:
13
+ * 1. `getTestsRepoDir()` — the test-repo clone root set by `skyramp_analyze_changes`
14
+ * when `testsRepoDir` is provided. In cross-repo delivery testbot commits ONLY
15
+ * to this clone, so the catalog must anchor here or it is never staged and the
16
+ * cache dies silently.
17
+ * 2. `detectGitRoot` — the fallback for same-repo runs (where nothing sets the
18
+ * tests-repo dir) and for the NL path, where a developer drives
19
+ * `skyramp_ui_test_generation`/`skyramp_reuse_code` directly without ever
20
+ * calling `skyramp_analyze_changes`.
21
+ * 3. The test file's own directory, for a path in no repository at all.
22
+ */
23
+ export declare function resolvePomCatalogPath(testFile: string): string;
@@ -0,0 +1,30 @@
1
+ import path from "path";
2
+ import { getTestsRepoDir } from "./AnalysisStateManager.js";
3
+ import { detectGitRoot } from "./gitStaging.js";
4
+ export const POM_CATALOG_FILENAME = "skyramp-pom-catalog.md";
5
+ /**
6
+ * The one canonical path for a test file's `skyramp-pom-catalog.md`:
7
+ * `<repoRoot>/.skyramp/skyramp-pom-catalog.md`.
8
+ *
9
+ * The catalog is cross-run state, and one path per repository is what keeps it
10
+ * usable — two runs writing at different depths fork the cache so neither finds
11
+ * the other's. It sits beside `workspace.yml` rather than in the customer's test
12
+ * directory because it is generated tooling state, not a deliverable, and
13
+ * delivery stages it by name (SKYR-4125).
14
+ *
15
+ * The root is resolved in priority order:
16
+ * 1. `getTestsRepoDir()` — the test-repo clone root set by `skyramp_analyze_changes`
17
+ * when `testsRepoDir` is provided. In cross-repo delivery testbot commits ONLY
18
+ * to this clone, so the catalog must anchor here or it is never staged and the
19
+ * cache dies silently.
20
+ * 2. `detectGitRoot` — the fallback for same-repo runs (where nothing sets the
21
+ * tests-repo dir) and for the NL path, where a developer drives
22
+ * `skyramp_ui_test_generation`/`skyramp_reuse_code` directly without ever
23
+ * calling `skyramp_analyze_changes`.
24
+ * 3. The test file's own directory, for a path in no repository at all.
25
+ */
26
+ export function resolvePomCatalogPath(testFile) {
27
+ const abs = path.resolve(testFile);
28
+ const root = getTestsRepoDir() ?? detectGitRoot(abs) ?? path.dirname(abs);
29
+ return path.join(root, ".skyramp", POM_CATALOG_FILENAME);
30
+ }
@@ -1,3 +1,17 @@
1
+ /**
2
+ * Spec/test basenames. POM discovery excludes them; {@link globSpecFiles}
3
+ * targets them.
4
+ */
5
+ export declare const SPEC_BASENAME: RegExp;
1
6
  export declare function globPomFiles(root: string): Promise<string[]>;
7
+ /**
8
+ * Spec files anywhere under `root`, by basename rather than by directory.
9
+ *
10
+ * Suites are often grouped by feature or customer rather than under `tests/`
11
+ * (e.g. `box/workflow.spec.ts`), so the directory name gives nothing away — but
12
+ * the filename always does. Keeps the cypress/`__tests__` trees that POM
13
+ * discovery skips: here the tests are the subject, not the thing to skip past.
14
+ */
15
+ export declare function globSpecFiles(root: string): Promise<string[]>;
2
16
  /** Fallback discovery for repos whose POM layer doesn't match the conventional glob patterns. */
3
17
  export declare function globAllSourceFiles(root: string): Promise<string[]>;
@@ -16,18 +16,24 @@ const POM_GLOBS = [
16
16
  "**/{test,tests,e2e,playwright}/**/{lib,utils,helpers,support}/**/*.{ts,js}",
17
17
  "**/{testUtils,test-utils,testHelpers,test-helpers}.{ts,js}",
18
18
  ];
19
- const EXCLUDED_BASENAME = /\.(spec|test|cy)\.(ts|js|tsx|jsx|mjs|cjs)$/;
19
+ /**
20
+ * Spec/test basenames. POM discovery excludes them; {@link globSpecFiles}
21
+ * targets them.
22
+ */
23
+ export const SPEC_BASENAME = /\.(spec|test|cy)\.(ts|js|tsx|jsx|mjs|cjs)$/;
20
24
  const ALL_SOURCE_GLOBS = ["**/*.{ts,js,tsx,jsx,mjs,cjs}"];
21
- const ALL_SOURCE_IGNORE = [
25
+ /** Never source: dependencies, build output, VCS metadata. */
26
+ const BUILD_IGNORE = [
22
27
  "**/node_modules/**",
23
28
  "**/dist/**",
24
29
  "**/build/**",
25
30
  "**/coverage/**",
26
31
  "**/.git/**",
27
32
  "**/vendor/**",
28
- "**/cypress/**",
29
- "**/__tests__/**",
30
33
  ];
34
+ /** Test trees a POM is not expected to live in. Not skipped when the tests themselves are the subject. */
35
+ const TEST_TREE_IGNORE = ["**/cypress/**", "**/__tests__/**"];
36
+ const ALL_SOURCE_IGNORE = [...BUILD_IGNORE, ...TEST_TREE_IGNORE];
31
37
  export async function globPomFiles(root) {
32
38
  const matches = await fg(POM_GLOBS, {
33
39
  cwd: root,
@@ -37,7 +43,27 @@ export async function globPomFiles(root) {
37
43
  followSymbolicLinks: false,
38
44
  });
39
45
  return [...new Set(matches)]
40
- .filter((f) => !EXCLUDED_BASENAME.test(path.basename(f)))
46
+ .filter((f) => !SPEC_BASENAME.test(path.basename(f)))
47
+ .sort();
48
+ }
49
+ /**
50
+ * Spec files anywhere under `root`, by basename rather than by directory.
51
+ *
52
+ * Suites are often grouped by feature or customer rather than under `tests/`
53
+ * (e.g. `box/workflow.spec.ts`), so the directory name gives nothing away — but
54
+ * the filename always does. Keeps the cypress/`__tests__` trees that POM
55
+ * discovery skips: here the tests are the subject, not the thing to skip past.
56
+ */
57
+ export async function globSpecFiles(root) {
58
+ const matches = await fg(ALL_SOURCE_GLOBS, {
59
+ cwd: root,
60
+ absolute: true,
61
+ ignore: BUILD_IGNORE,
62
+ suppressErrors: true,
63
+ followSymbolicLinks: false,
64
+ });
65
+ return [...new Set(matches)]
66
+ .filter((f) => SPEC_BASENAME.test(path.basename(f)))
41
67
  .sort();
42
68
  }
43
69
  /** Fallback discovery for repos whose POM layer doesn't match the conventional glob patterns. */
@@ -50,6 +76,6 @@ export async function globAllSourceFiles(root) {
50
76
  followSymbolicLinks: false,
51
77
  });
52
78
  return [...new Set(matches)]
53
- .filter((f) => !EXCLUDED_BASENAME.test(path.basename(f)))
79
+ .filter((f) => !SPEC_BASENAME.test(path.basename(f)))
54
80
  .sort();
55
81
  }
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Which attribute does this repository use for test ids?
3
+ *
4
+ * The blueprint capture anchors every element's xpath on a test-id attribute
5
+ * when it can find one, and assumes Playwright's `data-testid` otherwise. A repo
6
+ * using anything else gets no anchor and a positional xpath instead — which
7
+ * resolves at capture time and breaks later, so the miss is invisible.
8
+ *
9
+ * Enumerating popular names (`data-test`, `data-qa`, ...) only covers the repos
10
+ * someone thought of. The repository already answers the question itself: its
11
+ * page objects and specs name the attribute every time they select on it. So
12
+ * read the answer out of the selectors rather than guessing at it.
13
+ */
14
+ export type AttributeCount = {
15
+ attribute: string;
16
+ count: number;
17
+ };
18
+ export type TestIdDiscovery = {
19
+ /** Most-used qualifying attribute, or undefined when nothing qualified. */
20
+ attribute?: string;
21
+ /** Every qualifying attribute with its selector count, most-used first. */
22
+ counts: AttributeCount[];
23
+ /**
24
+ * Most-used attributes overall, qualifying or not.
25
+ *
26
+ * The point of reporting these is the case no name rule can reach: a suite
27
+ * selecting on something arbitrary like `xyz-id` produces no qualifying
28
+ * candidate, and the miss is otherwise invisible. Printed on a miss, this names
29
+ * the attribute an operator would set explicitly.
30
+ */
31
+ observed: AttributeCount[];
32
+ filesScanned: number;
33
+ };
34
+ /**
35
+ * Report which test-id attribute this repository's page objects and specs use.
36
+ *
37
+ * Never throws: an unreadable tree yields no attribute, which leaves the capture
38
+ * on Playwright's default.
39
+ */
40
+ export declare function discoverTestIdAttribute(root: string): Promise<TestIdDiscovery>;
@@ -0,0 +1,104 @@
1
+ /**
2
+ * Which attribute does this repository use for test ids?
3
+ *
4
+ * The blueprint capture anchors every element's xpath on a test-id attribute
5
+ * when it can find one, and assumes Playwright's `data-testid` otherwise. A repo
6
+ * using anything else gets no anchor and a positional xpath instead — which
7
+ * resolves at capture time and breaks later, so the miss is invisible.
8
+ *
9
+ * Enumerating popular names (`data-test`, `data-qa`, ...) only covers the repos
10
+ * someone thought of. The repository already answers the question itself: its
11
+ * page objects and specs name the attribute every time they select on it. So
12
+ * read the answer out of the selectors rather than guessing at it.
13
+ */
14
+ import { readFile } from "fs/promises";
15
+ import { globPomFiles, globSpecFiles } from "./pom-files.js";
16
+ import { DEFAULT_TESTID_ATTRS } from "./selector-extractor.js";
17
+ /** Bound the read — a monorepo scan must not delay server startup. */
18
+ const MAX_FILES = 400;
19
+ const MAX_BYTES_PER_FILE = 256 * 1024;
20
+ /**
21
+ * Attribute name inside an attribute selector: `[data-test="x"]`, `[qa-id='y']`.
22
+ *
23
+ * Deliberately open-ended, which is why it cannot reuse `selector-extractor`'s
24
+ * pattern: that one is built from a known attribute list to *extract values for
25
+ * attributes we already named*, whereas this has to surface names nobody listed.
26
+ */
27
+ const ATTR_SELECTOR_RE = /\[\s*([A-Za-z][A-Za-z0-9_:-]*)\s*[~^$*|]?=\s*["']/g;
28
+ /**
29
+ * Tokens by which an attribute name declares itself to be about testing.
30
+ *
31
+ * Matched as whole tokens, never as prefixes. `auto` is deliberately absent —
32
+ * it admitted `data-auto-play` and `data-auto-height`, and `automation` already
33
+ * covers the convention it was there for (`data-automation-id`).
34
+ */
35
+ const TEST_TOKENS = new Set(["test", "testid", "tests", "qa", "cy", "cypress", "e2e", "automation"]);
36
+ /**
37
+ * Whether a name plausibly denotes a test id.
38
+ *
39
+ * A name heuristic, safe only because of what it is applied to: an attribute the
40
+ * repository's own tests already select on. A name that is both used as a
41
+ * selector and self-describes as test-related is not going to be
42
+ * `data-testimonial`. Applied to raw DOM attributes the same rule would be
43
+ * reckless.
44
+ *
45
+ * Requiring a token is also what keeps the standard attributes out — `type`,
46
+ * `role`, `href`, `aria-label`, `placeholder` and the rest carry no such token,
47
+ * so no exclusion list is needed alongside this. (`autocomplete` tokenises as one
48
+ * word, so it does not match `auto`.)
49
+ */
50
+ function looksLikeTestId(attr) {
51
+ const lower = attr.toLowerCase();
52
+ if (DEFAULT_TESTID_ATTRS.includes(lower))
53
+ return true;
54
+ const tokens = lower.split(/[^a-z0-9]+/).filter(Boolean);
55
+ if (tokens.some((t) => TEST_TOKENS.has(t)))
56
+ return true;
57
+ // Glued forms like `datatestid`. Anchored at the end on purpose: a
58
+ // `startsWith("test")` catch-all also admits `data-testimonial`, and since
59
+ // candidates are ranked by use count, a false positive used more often than
60
+ // the real attribute becomes the anchor for the whole repo.
61
+ return tokens.some((t) => t.endsWith("testid"));
62
+ }
63
+ const OBSERVED_REPORT_LIMIT = 5;
64
+ /**
65
+ * Report which test-id attribute this repository's page objects and specs use.
66
+ *
67
+ * Never throws: an unreadable tree yields no attribute, which leaves the capture
68
+ * on Playwright's default.
69
+ */
70
+ export async function discoverTestIdAttribute(root) {
71
+ let files;
72
+ try {
73
+ const [poms, specs] = await Promise.all([globPomFiles(root), globSpecFiles(root)]);
74
+ files = [...new Set([...poms, ...specs])].slice(0, MAX_FILES);
75
+ }
76
+ catch {
77
+ return { counts: [], observed: [], filesScanned: 0 };
78
+ }
79
+ const all = new Map();
80
+ for (const file of files) {
81
+ let content;
82
+ try {
83
+ content = (await readFile(file, "utf8")).slice(0, MAX_BYTES_PER_FILE);
84
+ }
85
+ catch {
86
+ continue;
87
+ }
88
+ for (const match of content.matchAll(ATTR_SELECTOR_RE)) {
89
+ const attr = match[1];
90
+ all.set(attr, (all.get(attr) ?? 0) + 1);
91
+ }
92
+ }
93
+ // Count first; name as a tiebreak so the result never depends on walk order.
94
+ const ranked = [...all.entries()]
95
+ .map(([attribute, count]) => ({ attribute, count }))
96
+ .sort((a, b) => b.count - a.count || a.attribute.localeCompare(b.attribute));
97
+ const counts = ranked.filter((c) => looksLikeTestId(c.attribute));
98
+ return {
99
+ attribute: counts[0]?.attribute,
100
+ counts,
101
+ observed: ranked.slice(0, OBSERVED_REPORT_LIMIT),
102
+ filesScanned: files.length,
103
+ };
104
+ }
@@ -26,10 +26,12 @@ export interface UnbackedClaimsInput {
26
26
  fileName?: string;
27
27
  repository?: string;
28
28
  }[];
29
- /** Maintenance verdicts (server-derived from skyramp_actions). */
29
+ /** Maintenance verdicts (server-derived from skyramp_actions). `pomFile`, when set, is
30
+ * the file the edit actually lands in — see the UPDATE rule below. */
30
31
  verdicts: {
31
32
  action: DriftAction;
32
33
  testFilePath: string;
34
+ pomFile?: string;
33
35
  }[];
34
36
  /** owner/repo of the primary repo — used to exempt cross-repo newTest claims
35
37
  * whose files live in a different checkout. */
@@ -46,7 +48,10 @@ export interface UnbackedClaimsInput {
46
48
  * edit (or drops the claim) rather than hallucinating it into the report.
47
49
  *
48
50
  * Only UPDATE verdicts are gated: an UPDATE is a targeted in-place edit that
49
- * reliably implies a working-tree change. Exemptions:
51
+ * reliably implies a working-tree change — in `pomFile` when the verdict names one,
52
+ * otherwise in `testFilePath`. For a POM-based test those are different files: the spec
53
+ * is what runs, the page object is what gets patched, so checking only `testFilePath`
54
+ * would reject maintenance that did land (SKYR-4129). Exemptions:
50
55
  * - REGENERATE verdicts — on an EXTERNAL (user-authored Playwright/Cypress/RTL)
51
56
  * test these are report-only (Skyramp can't auto-regenerate them; the developer
52
57
  * acts manually), so no working-tree change is expected; and even an internal
@@ -50,7 +50,10 @@ export async function listChangedFiles(repoRoot) {
50
50
  * edit (or drops the claim) rather than hallucinating it into the report.
51
51
  *
52
52
  * Only UPDATE verdicts are gated: an UPDATE is a targeted in-place edit that
53
- * reliably implies a working-tree change. Exemptions:
53
+ * reliably implies a working-tree change — in `pomFile` when the verdict names one,
54
+ * otherwise in `testFilePath`. For a POM-based test those are different files: the spec
55
+ * is what runs, the page object is what gets patched, so checking only `testFilePath`
56
+ * would reject maintenance that did land (SKYR-4129). Exemptions:
54
57
  * - REGENERATE verdicts — on an EXTERNAL (user-authored Playwright/Cypress/RTL)
55
58
  * test these are report-only (Skyramp can't auto-regenerate them; the developer
56
59
  * acts manually), so no working-tree change is expected; and even an internal
@@ -96,8 +99,11 @@ export function findUnbackedClaims(input) {
96
99
  // change, and internal ones may regenerate to identical content.
97
100
  if (v.action !== DriftAction.Update)
98
101
  continue;
99
- if (!isBacked(v.testFilePath)) {
100
- unbacked.push(`testMaintenance ${v.action} claims an edit to "${path.basename(v.testFilePath)}", but that file has no working-tree change`);
102
+ // The edit target, not the spec: for a POM-based test the page object is what
103
+ // gets patched while testFilePath stays the spec (SKYR-4129).
104
+ const editTarget = v.pomFile ?? v.testFilePath;
105
+ if (!isBacked(editTarget)) {
106
+ unbacked.push(`testMaintenance ${v.action} claims an edit to "${path.basename(editTarget)}", but that file has no working-tree change`);
101
107
  }
102
108
  }
103
109
  return unbacked;
@@ -1,4 +1,4 @@
1
- export declare const SKYRAMP_IMAGE_VERSION = "v1.3.37";
2
- export declare const EXECUTOR_DOCKER_IMAGE = "skyramp/executor:v1.3.37";
3
- export declare const WORKER_DOCKER_IMAGE = "skyramp/worker:v1.3.37";
1
+ export declare const SKYRAMP_IMAGE_VERSION = "v1.3.38";
2
+ export declare const EXECUTOR_DOCKER_IMAGE = "skyramp/executor:v1.3.38";
3
+ export declare const WORKER_DOCKER_IMAGE = "skyramp/worker:v1.3.38";
4
4
  export declare const WORKER_CONTROL_PORT = 35142;
@@ -1,4 +1,4 @@
1
- export const SKYRAMP_IMAGE_VERSION = "v1.3.37";
1
+ export const SKYRAMP_IMAGE_VERSION = "v1.3.38";
2
2
  export const EXECUTOR_DOCKER_IMAGE = `skyramp/executor:${SKYRAMP_IMAGE_VERSION}`;
3
3
  export const WORKER_DOCKER_IMAGE = `skyramp/worker:${SKYRAMP_IMAGE_VERSION}`;
4
4
  // Control port the Skyramp worker listens on (SDK `CONTAINER_PORT`).