@skyramp/mcp 0.3.2-rc.pom-4 → 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.
- package/build/adapters/jestAdapter.d.ts +14 -0
- package/build/adapters/jestAdapter.js +113 -0
- package/build/adapters/mochaAdapter.d.ts +13 -0
- package/build/adapters/mochaAdapter.js +87 -0
- package/build/adapters/playwrightAdapter.d.ts +17 -0
- package/build/adapters/playwrightAdapter.js +182 -0
- package/build/adapters/pytestAdapter.d.ts +15 -0
- package/build/adapters/pytestAdapter.js +108 -0
- package/build/commands/commandLibrary.d.ts +1 -0
- package/build/commands/commandLibrary.js +19 -13
- package/build/commands/localDevTestChangesCommand.d.ts +15 -0
- package/build/commands/localDevTestChangesCommand.js +201 -0
- package/build/index.js +129 -8
- package/build/playwright/PlaywrightTraceService.d.ts +8 -0
- package/build/playwright/PlaywrightTraceService.js +1 -0
- package/build/prompts/code-reuse.js +3 -0
- package/build/prompts/enhance-assertions/sharedAssertionRules.d.ts +1 -0
- package/build/prompts/enhance-assertions/sharedAssertionRules.js +17 -0
- package/build/prompts/initialize-workspace/initializeWorkspacePrompt.js +11 -9
- package/build/prompts/local-dev/local-dev-plan.d.ts +35 -0
- package/build/prompts/local-dev/local-dev-plan.js +429 -0
- package/build/prompts/local-dev/local-dev-prompts.d.ts +4 -0
- package/build/prompts/local-dev/local-dev-prompts.js +190 -0
- package/build/prompts/pom-aware-code-reuse.js +17 -8
- package/build/prompts/prompt-utils.d.ts +8 -0
- package/build/prompts/prompt-utils.js +33 -0
- package/build/prompts/sut-setup/modes/adaptWorkflowPrompt.js +70 -7
- package/build/prompts/sut-setup/modes/dockerComposePrompt.js +1 -1
- package/build/prompts/sut-setup/shared.js +19 -17
- package/build/prompts/test-maintenance/drift-analysis-prompt.d.ts +10 -1
- package/build/prompts/test-maintenance/drift-analysis-prompt.js +54 -1
- package/build/prompts/test-recommendation/analysisOutputPrompt.js +21 -29
- package/build/prompts/test-recommendation/scopeAssessment.d.ts +5 -2
- package/build/prompts/test-recommendation/scopeAssessment.js +78 -6
- package/build/prompts/test-recommendation/test-recommendation-prompt.js +41 -4
- package/build/prompts/testbot/testbot-prompts.d.ts +2 -17
- package/build/prompts/testbot/testbot-prompts.js +63 -60
- package/build/recommendation/planRanker.d.ts +15 -2
- package/build/recommendation/planRanker.js +76 -5
- package/build/resources/testbotResource.js +23 -5
- package/build/services/AnalyticsService.d.ts +1 -1
- package/build/services/TestExecutionService.d.ts +15 -9
- package/build/services/TestExecutionService.js +56 -28
- package/build/services/TestGenerationService.d.ts +2 -2
- package/build/services/TestGenerationService.js +39 -21
- package/build/services/containerEnv.js +27 -1
- package/build/tool-phases.js +7 -0
- package/build/tools/code-refactor/codeReuseTool.js +43 -4
- package/build/tools/code-refactor/enhanceAssertionsTool.js +68 -18
- package/build/tools/code-refactor/reuse-outcome.d.ts +109 -0
- package/build/tools/code-refactor/reuse-outcome.js +158 -0
- package/build/tools/code-refactor/reuse-state.d.ts +45 -0
- package/build/tools/code-refactor/reuse-state.js +140 -0
- package/build/tools/enrichTestWithMocksTool.d.ts +28 -0
- package/build/tools/enrichTestWithMocksTool.js +726 -0
- package/build/tools/executeSkyrampTestTool.d.ts +11 -0
- package/build/tools/executeSkyrampTestTool.js +62 -21
- package/build/tools/generate-tests/batchMockGenerationTool.d.ts +106 -0
- package/build/tools/generate-tests/batchMockGenerationTool.js +545 -0
- package/build/tools/generate-tests/generateBatchScenarioRestTool.js +25 -23
- package/build/tools/generate-tests/generateContractRestTool.js +2 -2
- package/build/tools/generate-tests/generateE2ERestTool.d.ts +1 -1
- package/build/tools/generate-tests/generateE2ERestTool.js +1 -1
- package/build/tools/generate-tests/generateLoadRestTool.d.ts +1 -1
- package/build/tools/generate-tests/generateLoadRestTool.js +1 -1
- package/build/tools/generate-tests/generateMockRestTool.d.ts +179 -6
- package/build/tools/generate-tests/generateMockRestTool.js +391 -22
- package/build/tools/generate-tests/loadTestSchema.d.ts +1 -1
- package/build/tools/generate-tests/planGuard.js +2 -22
- package/build/tools/generateEnrichedIntegrationTestTool.d.ts +25 -0
- package/build/tools/generateEnrichedIntegrationTestTool.js +235 -0
- package/build/tools/localDevWorkerComposeTool.d.ts +24 -0
- package/build/tools/localDevWorkerComposeTool.js +264 -0
- package/build/tools/one-click/oneClickTool.d.ts +13 -0
- package/build/tools/one-click/oneClickTool.js +195 -24
- package/build/tools/preflightMockCheckTool.d.ts +2 -0
- package/build/tools/preflightMockCheckTool.js +96 -0
- package/build/tools/queryProxyMocksTool.d.ts +70 -0
- package/build/tools/queryProxyMocksTool.js +521 -0
- package/build/tools/runExistingTestsTool.d.ts +138 -0
- package/build/tools/runExistingTestsTool.js +644 -0
- package/build/tools/submitReportTool.js +40 -2
- package/build/tools/test-management/actionsTool.js +12 -2
- package/build/tools/test-management/analyzeChangesTool.d.ts +2 -1
- package/build/tools/test-management/analyzeChangesTool.js +63 -40
- package/build/tools/test-management/analyzeTestHealthTool.d.ts +11 -0
- package/build/tools/test-management/analyzeTestHealthTool.js +63 -1
- package/build/tools/test-management/registerTestPlanTool.js +55 -7
- package/build/tools/trace/startTraceCollectionTool.js +3 -3
- package/build/types/ExternalTestExecution.d.ts +67 -0
- package/build/types/ExternalTestExecution.js +8 -0
- package/build/types/OneClickCommands.d.ts +1 -1
- package/build/types/Recommendation.d.ts +20 -0
- package/build/types/Recommendation.js +32 -6
- package/build/types/RepositoryAnalysis.d.ts +131 -14
- package/build/types/RepositoryAnalysis.js +16 -2
- package/build/types/ReuseOutcome.d.ts +63 -0
- package/build/types/ReuseOutcome.js +33 -0
- package/build/types/TestAnalysis.d.ts +7 -3
- package/build/types/TestExecution.d.ts +1 -0
- package/build/types/TestTypes.d.ts +25 -7
- package/build/types/TestTypes.js +25 -7
- package/build/types/TestbotPromptOptions.d.ts +35 -0
- package/build/types/TestbotPromptOptions.js +1 -0
- package/build/types/TestbotReport.d.ts +7 -0
- package/build/types/index.d.ts +3 -0
- package/build/types/index.js +1 -0
- package/build/utils/AnalysisStateManager.d.ts +33 -0
- package/build/utils/AnalysisStateManager.js +36 -2
- package/build/utils/analyze-openapi.js +18 -1
- package/build/utils/branchDiff.d.ts +17 -1
- package/build/utils/branchDiff.js +99 -14
- package/build/utils/featureFlags.d.ts +31 -0
- package/build/utils/featureFlags.js +37 -0
- package/build/utils/frontendSelectors.js +0 -1
- package/build/utils/gitStaging.d.ts +5 -0
- package/build/utils/gitStaging.js +1 -1
- package/build/utils/grpcMockValidation.d.ts +1 -0
- package/build/utils/grpcMockValidation.js +49 -0
- package/build/utils/httpMethodValidation.d.ts +4 -0
- package/build/utils/httpMethodValidation.js +15 -0
- package/build/utils/logger.js +1 -1
- package/build/utils/mockCompatibility.d.ts +49 -0
- package/build/utils/mockCompatibility.js +82 -0
- package/build/utils/pom-catalog.d.ts +23 -0
- package/build/utils/pom-catalog.js +30 -0
- package/build/utils/pom-scope/pom-files.d.ts +14 -0
- package/build/utils/pom-scope/pom-files.js +32 -6
- package/build/utils/pom-scope/testIdDiscovery.d.ts +40 -0
- package/build/utils/pom-scope/testIdDiscovery.js +104 -0
- package/build/utils/pom-verify/verify.d.ts +5 -0
- package/build/utils/pom-verify/verify.js +1 -0
- package/build/utils/progress.js +10 -5
- package/build/utils/proxy-terminal.js +3 -3
- package/build/utils/reportVerification.d.ts +7 -2
- package/build/utils/reportVerification.js +9 -3
- package/build/utils/routeParsers.d.ts +3 -9
- package/build/utils/routeParsers.js +79 -4
- package/build/utils/utils.js +2 -2
- package/build/utils/versions.d.ts +4 -3
- package/build/utils/versions.js +3 -1
- package/build/utils/workspaceAuth.d.ts +46 -0
- package/build/utils/workspaceAuth.js +156 -1
- package/build/workspace/frameworks.d.ts +11 -0
- package/build/workspace/frameworks.js +22 -0
- package/build/workspace/testSuites.d.ts +20 -0
- package/build/workspace/testSuites.js +17 -0
- package/build/workspace/workspace.d.ts +206 -24
- package/build/workspace/workspace.js +52 -2
- package/node_modules/playwright/ThirdPartyNotices.txt +319 -266
- package/node_modules/playwright/lib/dom-analyzer/blueprint.js +154 -27
- package/node_modules/playwright/lib/dom-analyzer/crawler.js +2 -2
- package/node_modules/playwright/lib/mcp/browser/tools/pageBlueprint.js +1 -1
- package/node_modules/playwright/lib/mcp/browser/tools/sitemap.js +6 -2
- package/node_modules/playwright/lib/mcp/skyramp/loadTraceTool.js +3 -2
- package/node_modules/playwright/lib/mcp/skyramp/resultCode.js +4 -3
- package/node_modules/playwright/lib/mcp/skyramp/skyRampImport.js +15 -3
- package/node_modules/playwright/lib/mcp/skyramp/specImport.js +781 -0
- package/node_modules/playwright/lib/mcp/skyramp/traceRecordingBackend.js +14 -3
- package/node_modules/playwright/lib/mcp/test/resultCode.test.js +2 -1
- package/node_modules/playwright/lib/mcp/test/skyRampExport.js +1 -1
- package/node_modules/playwright/lib/mcp/test/skyRampExport.test.js +30 -0
- package/node_modules/playwright/lib/transform/babelBundleImpl.js +200 -199
- package/node_modules/playwright/node_modules/playwright-core/ThirdPartyNotices.txt +3 -3
- package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/.package-lock.json +3 -3
- package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/adapter/aws-lambda/handler.js +16 -25
- package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/adapter/bun/websocket.js +3 -1
- package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/adapter/lambda-edge/handler.js +20 -4
- package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/cjs/adapter/aws-lambda/handler.js +16 -25
- package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/cjs/adapter/bun/websocket.js +3 -1
- package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/cjs/adapter/lambda-edge/handler.js +20 -4
- package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/cjs/client/client.js +10 -1
- package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/cjs/client/utils.js +1 -1
- package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/cjs/helper/css/common.js +3 -1
- package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/cjs/helper/css/index.js +9 -1
- package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/cjs/jsx/base.js +8 -14
- package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/cjs/jsx/components.js +41 -21
- package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/cjs/jsx/context.js +131 -5
- package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/cjs/jsx/streaming.js +9 -7
- package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/cjs/middleware/bearer-auth/index.js +1 -1
- package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/cjs/middleware/cache/index.js +1 -1
- package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/cjs/middleware/compress/index.js +2 -1
- package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/cjs/middleware/cors/index.js +2 -5
- package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/cjs/middleware/etag/index.js +2 -1
- package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/cjs/middleware/language/language.js +10 -32
- package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/cjs/middleware/method-override/index.js +5 -3
- package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/cjs/middleware/serve-static/index.js +2 -2
- package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/cjs/middleware/timing/timing.js +3 -1
- package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/cjs/router/trie-router/node.js +9 -0
- package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/cjs/utils/body.js +12 -4
- package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/cjs/utils/buffer.js +2 -1
- package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/cjs/utils/ipaddr.js +6 -1
- package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/cjs/validator/validator.js +3 -3
- package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/client/client.js +10 -1
- package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/client/utils.js +1 -1
- package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/helper/css/common.js +3 -1
- package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/helper/css/index.js +9 -1
- package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/jsx/base.js +15 -15
- package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/jsx/components.js +42 -22
- package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/jsx/context.js +129 -5
- package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/jsx/streaming.js +10 -8
- package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/middleware/bearer-auth/index.js +1 -1
- package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/middleware/cache/index.js +1 -1
- package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/middleware/compress/index.js +2 -1
- package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/middleware/cors/index.js +2 -5
- package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/middleware/etag/index.js +2 -1
- package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/middleware/language/language.js +10 -32
- package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/middleware/method-override/index.js +5 -3
- package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/middleware/serve-static/index.js +2 -2
- package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/middleware/timing/timing.js +3 -1
- package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/router/trie-router/node.js +9 -0
- package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/types/adapter/aws-lambda/handler.d.ts +1 -1
- package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/types/adapter/lambda-edge/handler.d.ts +1 -1
- package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/types/helper/websocket/index.d.ts +1 -1
- package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/types/jsx/base.d.ts +1 -3
- package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/types/jsx/context.d.ts +39 -0
- package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/types/middleware/context-storage/index.d.ts +2 -2
- package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/types/middleware/language/language.d.ts +18 -0
- package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/types/utils/body.d.ts +1 -1
- package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/types/utils/types.d.ts +1 -1
- package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/utils/body.js +12 -4
- package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/utils/buffer.js +2 -1
- package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/utils/ipaddr.js +6 -1
- package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/validator/validator.js +3 -3
- package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/package.json +29 -22
- package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/package-lock.json +3 -3
- package/node_modules/playwright/node_modules/playwright-core/lib/generated/pollingRecorderSource.js +1 -1
- package/node_modules/playwright/node_modules/playwright-core/lib/server/codegen/skyramp/jsonlReader.js +5 -1
- package/node_modules/playwright/node_modules/playwright-core/lib/server/codegen/skyramp/specReader.js +781 -0
- package/node_modules/playwright/node_modules/playwright-core/lib/server/recorder/recorderApp.js +25 -6
- package/node_modules/playwright/node_modules/playwright-core/lib/server/recorder/skyramp/replayEngine.js +3 -1
- package/node_modules/playwright/node_modules/playwright-core/lib/utils.js +2 -0
- package/node_modules/playwright/node_modules/playwright-core/lib/vite/htmlReport/index.html +253 -27
- package/node_modules/playwright/node_modules/playwright-core/lib/vite/recorder/assets/{codeMirrorModule-D0BjbCb7.js → codeMirrorModule-DtudTj_v.js} +1 -1
- package/node_modules/playwright/node_modules/playwright-core/lib/vite/recorder/assets/index-BpDwp16L.js +422 -0
- package/node_modules/playwright/node_modules/playwright-core/lib/vite/recorder/index.html +1 -1
- package/node_modules/playwright/node_modules/playwright-core/lib/vite/traceViewer/assets/{codeMirrorModule-Bzd72-bG.js → codeMirrorModule-FNMuBzX1.js} +1 -1
- package/node_modules/playwright/node_modules/playwright-core/lib/vite/traceViewer/assets/defaultSettingsView-Co9upU5h.js +1035 -0
- package/node_modules/playwright/node_modules/playwright-core/lib/vite/traceViewer/index.DXNIQ_dx.js +2 -0
- package/node_modules/playwright/node_modules/playwright-core/lib/vite/traceViewer/index.html +2 -2
- package/node_modules/playwright/node_modules/playwright-core/lib/vite/traceViewer/uiMode.CIKB3XSv.js +5 -0
- package/node_modules/playwright/node_modules/playwright-core/lib/vite/traceViewer/uiMode.html +2 -2
- package/node_modules/playwright/node_modules/playwright-core/package.json +1 -1
- package/node_modules/playwright/node_modules/playwright-core/src/generated/pollingRecorderSource.ts +1 -1
- package/node_modules/playwright/node_modules/playwright-core/src/server/codegen/skyramp/jsonlReader.ts +4 -0
- package/node_modules/playwright/node_modules/playwright-core/src/server/codegen/skyramp/specReader.ts +1028 -0
- package/node_modules/playwright/node_modules/playwright-core/src/server/recorder/recorderApp.ts +31 -8
- package/node_modules/playwright/node_modules/playwright-core/src/server/recorder/skyramp/replayEngine.ts +1 -0
- package/node_modules/playwright/node_modules/playwright-core/src/utils.ts +1 -0
- package/node_modules/playwright/package.json +1 -1
- package/package.json +12 -6
- package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/tsconfig.build.tsbuildinfo +0 -1
- package/node_modules/playwright/node_modules/playwright-core/lib/vite/recorder/assets/index-lvTRGFx-.js +0 -193
- package/node_modules/playwright/node_modules/playwright-core/lib/vite/traceViewer/assets/defaultSettingsView-DzxTioTK.js +0 -809
- package/node_modules/playwright/node_modules/playwright-core/lib/vite/traceViewer/index.BGc30U3S.js +0 -2
- package/node_modules/playwright/node_modules/playwright-core/lib/vite/traceViewer/uiMode.IaDrb29A.js +0 -5
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { HttpMethod } from "../types/TestTypes.js";
|
|
2
|
+
export const REST_MOCK_HTTP_METHODS = Object.values(HttpMethod);
|
|
3
|
+
export function normalizeRestMockMethod(method) {
|
|
4
|
+
return method ? method.trim().toUpperCase() : "";
|
|
5
|
+
}
|
|
6
|
+
export function getRestMockMethodValidationError(method) {
|
|
7
|
+
if (!method)
|
|
8
|
+
return null;
|
|
9
|
+
const normalized = normalizeRestMockMethod(method);
|
|
10
|
+
if (!normalized)
|
|
11
|
+
return null; // whitespace-only → treated as empty (valid)
|
|
12
|
+
if (REST_MOCK_HTTP_METHODS.includes(normalized))
|
|
13
|
+
return null;
|
|
14
|
+
return `REST mock method must be one of ${REST_MOCK_HTTP_METHODS.join(", ")} or empty string (got "${method}")`;
|
|
15
|
+
}
|
package/build/utils/logger.js
CHANGED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mock Compatibility Pre-flight Check
|
|
3
|
+
*
|
|
4
|
+
* Validates mock protocol combinations BEFORE deployment to surface
|
|
5
|
+
* known incompatibilities early rather than at test execution time.
|
|
6
|
+
*/
|
|
7
|
+
import { MockProtocol } from "../types/TestTypes.js";
|
|
8
|
+
export { MockProtocol };
|
|
9
|
+
/** Narrow view of a mock spec used only for protocol compatibility checking. */
|
|
10
|
+
export interface MockCompatibilitySpec {
|
|
11
|
+
protocol: MockProtocol;
|
|
12
|
+
endpointURL: string;
|
|
13
|
+
method?: string;
|
|
14
|
+
grpcServiceName?: string;
|
|
15
|
+
kafkaTopic?: string;
|
|
16
|
+
}
|
|
17
|
+
export interface CompatibilityWarning {
|
|
18
|
+
code: string;
|
|
19
|
+
message: string;
|
|
20
|
+
suggestion: string;
|
|
21
|
+
affectedMocks: string[];
|
|
22
|
+
/** When true, the affected mocks cannot intercept traffic and must not be generated or deployed. */
|
|
23
|
+
blocking?: boolean;
|
|
24
|
+
}
|
|
25
|
+
export interface CompatibilityResult {
|
|
26
|
+
compatible: boolean;
|
|
27
|
+
/** True when at least one warning is blocking — those mocks must be skipped entirely. */
|
|
28
|
+
hasBlockers: boolean;
|
|
29
|
+
warnings: CompatibilityWarning[];
|
|
30
|
+
}
|
|
31
|
+
export interface MockCompatibilityOptions {
|
|
32
|
+
/** Enable Docker local-dev checks that require mocks to intercept service DNS aliases. */
|
|
33
|
+
dockerLocalDev?: boolean;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Validates a set of mock specs for known protocol compatibility issues.
|
|
37
|
+
*
|
|
38
|
+
* Rules:
|
|
39
|
+
* - Any gRPC mock present → GRPC_PERSISTENT_CONN warning (DNS hijacking skips persistent conns)
|
|
40
|
+
* - Docker local-dev REST mock using loopback/host.docker.internal → REST_LOOPBACK_URL blocking warning
|
|
41
|
+
*
|
|
42
|
+
* REST mocks work correctly in Docker local-dev mode only when the mock URL uses
|
|
43
|
+
* the real Docker service hostname (e.g. "billing" from "http://billing:5001").
|
|
44
|
+
* The worker adds that hostname as a Docker network alias so DNS resolves to the mock server.
|
|
45
|
+
*
|
|
46
|
+
* `compatible` is false when any warning is blocking and the mock cannot intercept traffic.
|
|
47
|
+
* `hasBlockers` is true when at least one warning is blocking (mock must not be generated/deployed).
|
|
48
|
+
*/
|
|
49
|
+
export declare function validateMockCompatibility(mocks: MockCompatibilitySpec[], options?: MockCompatibilityOptions): CompatibilityResult;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mock Compatibility Pre-flight Check
|
|
3
|
+
*
|
|
4
|
+
* Validates mock protocol combinations BEFORE deployment to surface
|
|
5
|
+
* known incompatibilities early rather than at test execution time.
|
|
6
|
+
*/
|
|
7
|
+
import { MockProtocol } from "../types/TestTypes.js";
|
|
8
|
+
export { MockProtocol };
|
|
9
|
+
function parseRestHostname(endpointURL) {
|
|
10
|
+
try {
|
|
11
|
+
const hostname = new URL(endpointURL).hostname.toLowerCase();
|
|
12
|
+
return hostname.startsWith("[") && hostname.endsWith("]")
|
|
13
|
+
? hostname.slice(1, -1)
|
|
14
|
+
: hostname;
|
|
15
|
+
}
|
|
16
|
+
catch {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
function isLoopbackRestEndpoint(endpointURL) {
|
|
21
|
+
const hostname = parseRestHostname(endpointURL);
|
|
22
|
+
return (hostname === "localhost" ||
|
|
23
|
+
hostname === "127.0.0.1" ||
|
|
24
|
+
hostname === "0.0.0.0" ||
|
|
25
|
+
hostname === "::1" ||
|
|
26
|
+
hostname === "host.docker.internal");
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Validates a set of mock specs for known protocol compatibility issues.
|
|
30
|
+
*
|
|
31
|
+
* Rules:
|
|
32
|
+
* - Any gRPC mock present → GRPC_PERSISTENT_CONN warning (DNS hijacking skips persistent conns)
|
|
33
|
+
* - Docker local-dev REST mock using loopback/host.docker.internal → REST_LOOPBACK_URL blocking warning
|
|
34
|
+
*
|
|
35
|
+
* REST mocks work correctly in Docker local-dev mode only when the mock URL uses
|
|
36
|
+
* the real Docker service hostname (e.g. "billing" from "http://billing:5001").
|
|
37
|
+
* The worker adds that hostname as a Docker network alias so DNS resolves to the mock server.
|
|
38
|
+
*
|
|
39
|
+
* `compatible` is false when any warning is blocking and the mock cannot intercept traffic.
|
|
40
|
+
* `hasBlockers` is true when at least one warning is blocking (mock must not be generated/deployed).
|
|
41
|
+
*/
|
|
42
|
+
export function validateMockCompatibility(mocks, options = {}) {
|
|
43
|
+
const warnings = [];
|
|
44
|
+
const restMocks = mocks.filter((m) => m.protocol === MockProtocol.Rest);
|
|
45
|
+
const grpcMocks = mocks.filter((m) => m.protocol === MockProtocol.Grpc);
|
|
46
|
+
const loopbackRestMocks = options.dockerLocalDev
|
|
47
|
+
? restMocks.filter((m) => isLoopbackRestEndpoint(m.endpointURL))
|
|
48
|
+
: [];
|
|
49
|
+
if (loopbackRestMocks.length > 0) {
|
|
50
|
+
warnings.push({
|
|
51
|
+
code: "REST_LOOPBACK_URL",
|
|
52
|
+
message: "REST mocks for Docker local-dev must use the original Docker service hostname. " +
|
|
53
|
+
"Loopback hosts such as localhost, 127.0.0.1, 0.0.0.0, ::1, or host.docker.internal " +
|
|
54
|
+
"do not give the Skyramp worker the downstream service DNS alias it needs to intercept traffic.",
|
|
55
|
+
suggestion: "Use the real Docker service origin in endpointURL, for example http://ams:4000 or " +
|
|
56
|
+
"http://billing:5001. Do not use localhost, host.docker.internal, or the Skyramp worker address " +
|
|
57
|
+
"for deployable REST mocks.",
|
|
58
|
+
affectedMocks: loopbackRestMocks.map((m) => m.endpointURL),
|
|
59
|
+
blocking: true,
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
// Rule: gRPC mocks use DNS hijacking that doesn't intercept persistent connections
|
|
63
|
+
if (grpcMocks.length > 0) {
|
|
64
|
+
warnings.push({
|
|
65
|
+
code: "GRPC_PERSISTENT_CONN",
|
|
66
|
+
message: "gRPC mocks use DNS hijacking which does not intercept persistent connections. " +
|
|
67
|
+
"If the service under test establishes a gRPC connection before mocks are applied, " +
|
|
68
|
+
"the existing connection will bypass the mock.",
|
|
69
|
+
suggestion: "Apply gRPC mocks before the service under test starts, or restart " +
|
|
70
|
+
"the service after applying mocks so it establishes a new connection through the mock DNS. " +
|
|
71
|
+
"For Docker local-dev, also verify the worker has the original downstream hostname alias " +
|
|
72
|
+
"from endpointURL (for example, partner-accounts for partner-accounts:50051).",
|
|
73
|
+
affectedMocks: grpcMocks.map((m) => m.grpcServiceName || m.endpointURL),
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
const hasBlockers = warnings.some((w) => w.blocking);
|
|
77
|
+
return {
|
|
78
|
+
compatible: !hasBlockers,
|
|
79
|
+
hasBlockers,
|
|
80
|
+
warnings,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
@@ -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
|
-
|
|
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
|
-
|
|
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) => !
|
|
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) => !
|
|
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
|
+
}
|
|
@@ -10,5 +10,10 @@ export type VerifyResult = {
|
|
|
10
10
|
unverifiable: string[];
|
|
11
11
|
parseError?: string;
|
|
12
12
|
checkedCalls: number;
|
|
13
|
+
/** Every POM call found in the spec, verifiable or not. NOT checkedCalls +
|
|
14
|
+
* unverifiable.length: `unverifiable` also absorbs `unrecognized` bindings,
|
|
15
|
+
* which are not calls at all, so that sum overcounts. This is the count of
|
|
16
|
+
* POM members the delivered spec actually reuses. */
|
|
17
|
+
reusedCalls: number;
|
|
13
18
|
};
|
|
14
19
|
export declare function verifyReuse(testFile: string, language: string): Promise<VerifyResult>;
|
package/build/utils/progress.js
CHANGED
|
@@ -10,11 +10,16 @@ export function makeProgressReporter(extra) {
|
|
|
10
10
|
return async (progress, total, message) => {
|
|
11
11
|
const progressToken = extra._meta?.progressToken;
|
|
12
12
|
if (progressToken !== undefined) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
try {
|
|
14
|
+
const notification = {
|
|
15
|
+
method: "notifications/progress",
|
|
16
|
+
params: { progressToken, progress, total, message },
|
|
17
|
+
};
|
|
18
|
+
await extra.sendNotification(notification);
|
|
19
|
+
}
|
|
20
|
+
catch {
|
|
21
|
+
// Progress is best-effort; a disconnected client should not fail the tool.
|
|
22
|
+
}
|
|
18
23
|
}
|
|
19
24
|
};
|
|
20
25
|
}
|
|
@@ -334,7 +334,7 @@ export async function closeProxyTerminal() {
|
|
|
334
334
|
terminalPID,
|
|
335
335
|
});
|
|
336
336
|
}
|
|
337
|
-
catch (
|
|
337
|
+
catch (_killErr) {
|
|
338
338
|
// Process is already dead, which is what we want
|
|
339
339
|
logger.debug("Terminal process already terminated", {
|
|
340
340
|
terminalPID,
|
|
@@ -384,14 +384,14 @@ export async function closeProxyTerminal() {
|
|
|
384
384
|
terminalPID,
|
|
385
385
|
});
|
|
386
386
|
}
|
|
387
|
-
catch (
|
|
387
|
+
catch (_killErr) {
|
|
388
388
|
// Process is already dead, which is what we want
|
|
389
389
|
logger.debug("Terminal process already terminated", {
|
|
390
390
|
terminalPID,
|
|
391
391
|
});
|
|
392
392
|
}
|
|
393
393
|
}
|
|
394
|
-
catch (
|
|
394
|
+
catch (_pidErr) {
|
|
395
395
|
// Fallback to regular process kill
|
|
396
396
|
try {
|
|
397
397
|
process.kill(terminalPID, "SIGTERM");
|
|
@@ -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
|
|
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
|
|
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
|
-
|
|
100
|
-
|
|
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;
|
|
@@ -59,15 +59,9 @@ export declare function isRouteLikeFile(filePath: string): boolean;
|
|
|
59
59
|
* route that existed in the base branch.
|
|
60
60
|
*/
|
|
61
61
|
export declare function selectRemovalCandidateFiles(diffData: BranchDiffData): string[];
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
* `git show base:<file>`); files that throw are skipped. Returns every endpoint
|
|
66
|
-
* found in the base versions — callers pass the result to
|
|
67
|
-
* `classifyEndpointsByChangedFiles`, whose moved/still-present filter drops any
|
|
68
|
-
* endpoint that survives in the current catalog, leaving only genuine removals.
|
|
69
|
-
*/
|
|
70
|
-
export declare function recoverRemovedEndpointsFromBase(candidateFiles: string[], fetchBaseContent: (file: string) => Promise<string>): Promise<ScannedEndpoint[]>;
|
|
62
|
+
export declare function recoverRemovedEndpointsFromBase(candidateFiles: string[], fetchBaseContent: (file: string) => Promise<string>, repositoryPath?: string, baseBranch?: string): Promise<ScannedEndpoint[]>;
|
|
63
|
+
/** Strip git's `a/` / `b/` diff-path prefix and normalize separators. */
|
|
64
|
+
export declare function normalizeDiffPath(spec: string): string;
|
|
71
65
|
/**
|
|
72
66
|
* Parse a unified diff into the set of new-side (post-change) line numbers that
|
|
73
67
|
* were touched, keyed by normalized file path.
|