@skyramp/mcp 0.2.8 → 0.2.150-rc.ldw
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/commands/commandLibrary.d.ts +1 -0
- package/build/commands/commandLibrary.js +20 -14
- package/build/commands/commandLibrary.test.d.ts +1 -0
- package/build/commands/commandLibrary.test.js +59 -0
- package/build/commands/localDevTestChangesCommand.d.ts +15 -0
- package/build/commands/localDevTestChangesCommand.js +188 -0
- package/build/index.js +77 -13
- 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 +9 -8
- package/build/prompts/local-dev/local-dev-plan.d.ts +25 -0
- package/build/prompts/local-dev/local-dev-plan.js +419 -0
- package/build/prompts/local-dev/local-dev-prompts.d.ts +4 -0
- package/build/prompts/local-dev/local-dev-prompts.js +157 -0
- 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 +3 -1
- package/build/prompts/sut-setup/modes/dockerComposePrompt.js +3 -1
- package/build/prompts/sut-setup/shared.d.ts +20 -0
- package/build/prompts/sut-setup/shared.js +69 -7
- package/build/prompts/test-recommendation/analysisOutputPrompt.js +21 -29
- package/build/prompts/test-recommendation/analysisOutputPrompt.test.js +0 -28
- package/build/prompts/test-recommendation/test-recommendation-prompt.js +41 -4
- package/build/prompts/test-recommendation/test-recommendation-prompt.test.js +16 -1
- package/build/prompts/testbot/testbot-prompts.d.ts +0 -5
- package/build/prompts/testbot/testbot-prompts.js +4 -34
- package/build/resources/testbotResource.js +2 -1
- package/build/services/AnalyticsService.d.ts +1 -1
- package/build/services/TestExecutionService.d.ts +2 -1
- package/build/services/TestExecutionService.js +15 -10
- package/build/services/TestExecutionService.test.js +75 -1
- package/build/services/TestGenerationService.d.ts +2 -2
- package/build/tool-phases.js +4 -0
- package/build/tools/code-refactor/enhanceAssertionsTool.js +47 -18
- package/build/tools/enrichTestWithMocksTool.d.ts +28 -0
- package/build/tools/enrichTestWithMocksTool.js +726 -0
- package/build/tools/enrichTestWithMocksTool.test.d.ts +1 -0
- package/build/tools/enrichTestWithMocksTool.test.js +266 -0
- package/build/tools/executeSkyrampTestTool.d.ts +4 -0
- package/build/tools/executeSkyrampTestTool.js +48 -24
- package/build/tools/executeSkyrampTestTool.test.d.ts +1 -0
- package/build/tools/executeSkyrampTestTool.test.js +16 -0
- package/build/tools/generate-tests/batchMockGenerationTool.d.ts +85 -0
- package/build/tools/generate-tests/batchMockGenerationTool.js +432 -0
- package/build/tools/generate-tests/generateContractRestTool.js +2 -2
- package/build/tools/generate-tests/generateMockRestTool.d.ts +129 -6
- package/build/tools/generate-tests/generateMockRestTool.js +234 -22
- package/build/tools/generate-tests/loadTestSchema.d.ts +1 -1
- package/build/tools/generateEnrichedIntegrationTestTool.d.ts +24 -0
- package/build/tools/generateEnrichedIntegrationTestTool.js +225 -0
- package/build/tools/generateEnrichedIntegrationTestTool.test.d.ts +1 -0
- package/build/tools/generateEnrichedIntegrationTestTool.test.js +44 -0
- package/build/tools/localDevWorkflowFixes.test.d.ts +1 -0
- package/build/tools/localDevWorkflowFixes.test.js +255 -0
- package/build/tools/one-click/oneClickTool.d.ts +10 -0
- package/build/tools/one-click/oneClickTool.js +177 -21
- package/build/tools/one-click/oneClickTool.test.d.ts +1 -0
- package/build/tools/one-click/oneClickTool.test.js +172 -0
- package/build/tools/preflightMockCheckTool.d.ts +2 -0
- package/build/tools/preflightMockCheckTool.js +96 -0
- package/build/tools/submitReportTool.d.ts +14 -14
- package/build/tools/test-management/analyzeChangesTool.d.ts +2 -1
- package/build/tools/test-management/analyzeChangesTool.js +59 -38
- package/build/tools/trace/startTraceCollectionTool.js +3 -3
- package/build/tools/workspace/initializeWorkspaceTool.js +2 -9
- package/build/tools/workspace/initializeWorkspaceTool.test.js +9 -4
- package/build/types/OneClickCommands.d.ts +1 -1
- package/build/types/RepositoryAnalysis.d.ts +117 -0
- package/build/types/RepositoryAnalysis.js +16 -2
- package/build/types/TestExecution.d.ts +1 -0
- package/build/types/TestTypes.d.ts +20 -8
- package/build/types/TestTypes.js +19 -5
- package/build/utils/analyze-openapi.js +18 -1
- package/build/utils/analyze-openapi.test.d.ts +1 -0
- package/build/utils/analyze-openapi.test.js +19 -0
- package/build/utils/branchDiff.d.ts +17 -1
- package/build/utils/branchDiff.js +96 -14
- package/build/utils/branchDiff.test.d.ts +1 -0
- package/build/utils/branchDiff.test.js +109 -0
- package/build/utils/docker.test.js +1 -1
- package/build/utils/featureFlags.d.ts +20 -1
- package/build/utils/featureFlags.js +26 -2
- package/build/utils/featureFlags.test.js +57 -2
- package/build/utils/grpcMockValidation.d.ts +1 -0
- package/build/utils/grpcMockValidation.js +49 -0
- package/build/utils/grpcMockValidation.test.d.ts +1 -0
- package/build/utils/grpcMockValidation.test.js +41 -0
- package/build/utils/httpMethodValidation.d.ts +4 -0
- package/build/utils/httpMethodValidation.js +13 -0
- package/build/utils/mockCompatibility.d.ts +49 -0
- package/build/utils/mockCompatibility.js +82 -0
- package/build/utils/mockCompatibility.test.d.ts +1 -0
- package/build/utils/mockCompatibility.test.js +79 -0
- package/build/utils/versions.d.ts +3 -3
- package/build/utils/versions.js +1 -1
- package/build/workspace/workspace.d.ts +49 -35
- package/build/workspace/workspace.js +10 -5
- package/build/workspace/workspace.test.js +65 -6
- package/package.json +2 -2
|
@@ -9,10 +9,10 @@ import { logger } from "../utils/logger.js";
|
|
|
9
9
|
import { TestExecutionStatus, } from "../types/TestExecution.js";
|
|
10
10
|
import { TestType } from "../types/TestTypes.js";
|
|
11
11
|
import { buildContainerEnv } from "./containerEnv.js";
|
|
12
|
-
import {
|
|
12
|
+
import { EXECUTOR_DOCKER_IMAGE } from "../utils/versions.js";
|
|
13
|
+
export { EXECUTOR_DOCKER_IMAGE };
|
|
13
14
|
const DEFAULT_TIMEOUT = 300000; // 5 minutes
|
|
14
15
|
const MAX_CONCURRENT_EXECUTIONS = 5;
|
|
15
|
-
export const EXECUTOR_DOCKER_IMAGE = `skyramp/executor:${SKYRAMP_IMAGE_VERSION}`;
|
|
16
16
|
const DOCKER_PLATFORM = "linux/amd64";
|
|
17
17
|
const EXECUTION_PROGRESS_INTERVAL = 10000; // 10 seconds between progress updates during execution
|
|
18
18
|
// Temp file with valid empty JSON — used instead of /dev/null for .json config files
|
|
@@ -84,14 +84,14 @@ function setupVideoCapture(options, workspacePath, containerMountPath) {
|
|
|
84
84
|
};
|
|
85
85
|
if (!browserTest)
|
|
86
86
|
return setup;
|
|
87
|
-
//
|
|
88
|
-
//
|
|
89
|
-
|
|
87
|
+
// Each execution gets a unique video directory so there is nothing to clean up
|
|
88
|
+
// between runs. Avoids EACCES when the Docker executor (which runs as root) has
|
|
89
|
+
// left root-owned files in a previous run's directory. The timestamp keeps the
|
|
90
|
+
// name readable/ordered; the random suffix guarantees uniqueness even when two
|
|
91
|
+
// executions land in the same millisecond (retries, parallel runs).
|
|
92
|
+
const videoSubdir = `${getVideoSubdir(options.testFile)}-${Date.now()}-${crypto.randomBytes(3).toString("hex")}`;
|
|
90
93
|
setup.videoHostDir = path.join(workspacePath, ".skyramp", "videos", videoSubdir);
|
|
91
94
|
setup.videoContainerDir = path.join(containerMountPath, ".skyramp", "videos", videoSubdir);
|
|
92
|
-
if (fs.existsSync(setup.videoHostDir)) {
|
|
93
|
-
fs.rmSync(setup.videoHostDir, { recursive: true, force: true });
|
|
94
|
-
}
|
|
95
95
|
fs.mkdirSync(setup.videoHostDir, { recursive: true });
|
|
96
96
|
// TypeScript/JavaScript: generate a per-execution Playwright config with video.
|
|
97
97
|
if (options.language === "typescript" || options.language === "javascript") {
|
|
@@ -440,7 +440,7 @@ export class TestExecutionService {
|
|
|
440
440
|
try {
|
|
441
441
|
fs.accessSync(workspacePath, fs.constants.R_OK);
|
|
442
442
|
}
|
|
443
|
-
catch
|
|
443
|
+
catch {
|
|
444
444
|
throw new Error(`Workspace path does not exist or is not readable: ${workspacePath}`);
|
|
445
445
|
}
|
|
446
446
|
// Validate test file - use basename for safer filename extraction
|
|
@@ -470,10 +470,15 @@ export class TestExecutionService {
|
|
|
470
470
|
testFilePath,
|
|
471
471
|
options.testType,
|
|
472
472
|
];
|
|
473
|
+
const networkMode = options.dockerNetwork?.trim()
|
|
474
|
+
? options.dockerNetwork.trim()
|
|
475
|
+
: options.useHostNetwork && process.platform === "linux"
|
|
476
|
+
? "host"
|
|
477
|
+
: undefined;
|
|
473
478
|
// Prepare host config with mounts
|
|
474
479
|
const hostConfig = {
|
|
475
480
|
ExtraHosts: ["host.docker.internal:host-gateway"],
|
|
476
|
-
...(
|
|
481
|
+
...(networkMode ? { NetworkMode: networkMode } : {}),
|
|
477
482
|
Mounts: [
|
|
478
483
|
{
|
|
479
484
|
Type: "bind",
|
|
@@ -303,6 +303,23 @@ describe("TestExecutionService.executeTest - Docker env forwarding", () => {
|
|
|
303
303
|
delete process.env.SKYRAMP_TEST_SERVICE_URL_BACKEND;
|
|
304
304
|
delete process.env.SKYRAMP_TEST_SERVICE_URL_FRONTEND;
|
|
305
305
|
});
|
|
306
|
+
it.each(["python", "typescript", "javascript", "java"])("passes %s integration tests through to runner.sh", async (language) => {
|
|
307
|
+
const mockContainer = { remove: jest.fn().mockResolvedValue(undefined) };
|
|
308
|
+
mockRun.mockResolvedValue([{ StatusCode: 0 }, mockContainer]);
|
|
309
|
+
const service = new TestExecutionService();
|
|
310
|
+
await service.executeTest({
|
|
311
|
+
testFile: `/workspace/${language}_integration_test.txt`,
|
|
312
|
+
workspacePath: "/workspace",
|
|
313
|
+
language,
|
|
314
|
+
testType: "integration",
|
|
315
|
+
});
|
|
316
|
+
const command = mockRun.mock.calls[0][1];
|
|
317
|
+
expect(command[0]).toBe("/root/runner.sh");
|
|
318
|
+
expect(command[1]).toBe(language);
|
|
319
|
+
expect(command[2]).toBe(`/home/user/${language}_integration_test.txt`);
|
|
320
|
+
expect(command[3]).toBe("integration");
|
|
321
|
+
mockRun.mockClear();
|
|
322
|
+
});
|
|
306
323
|
it("passes SKYRAMP_TEST_BASE_URL to Docker container Env", async () => {
|
|
307
324
|
process.env.SKYRAMP_TEST_BASE_URL = "http://external-host:8000";
|
|
308
325
|
const mockContainer = { remove: jest.fn().mockResolvedValue(undefined) };
|
|
@@ -349,6 +366,22 @@ describe("TestExecutionService.executeTest - Docker env forwarding", () => {
|
|
|
349
366
|
e.startsWith("SKYRAMP_TEST_SERVICE_URL_"));
|
|
350
367
|
expect(envWithBaseUrl).toHaveLength(0);
|
|
351
368
|
});
|
|
369
|
+
it("attaches executor to dockerNetwork without treating it as host networking", async () => {
|
|
370
|
+
process.env.SKYRAMP_TEST_BASE_URL = "http://localhost:3000";
|
|
371
|
+
const mockContainer = { remove: jest.fn().mockResolvedValue(undefined) };
|
|
372
|
+
mockRun.mockResolvedValue([{ StatusCode: 0 }, mockContainer]);
|
|
373
|
+
const service = new TestExecutionService();
|
|
374
|
+
await service.executeTest({
|
|
375
|
+
testFile: "/workspace/test_file.py",
|
|
376
|
+
workspacePath: "/workspace",
|
|
377
|
+
language: "python",
|
|
378
|
+
testType: "smoke",
|
|
379
|
+
dockerNetwork: "checkr-demo_checkr_default",
|
|
380
|
+
});
|
|
381
|
+
const dockerOptions = mockRun.mock.calls[0][3];
|
|
382
|
+
expect(dockerOptions.HostConfig.NetworkMode).toBe("checkr-demo_checkr_default");
|
|
383
|
+
expect(dockerOptions.Env).toContain("SKYRAMP_TEST_BASE_URL=http://host.docker.internal:3000");
|
|
384
|
+
});
|
|
352
385
|
// Approach B: every workspace mount is mirrored at the host-absolute path so
|
|
353
386
|
// tests that embed absolute references (storageState, fixtures, snapshots)
|
|
354
387
|
// resolve correctly inside the executor regardless of which path-shape the
|
|
@@ -408,6 +441,44 @@ describe("TestExecutionService.executeTest - Docker env forwarding", () => {
|
|
|
408
441
|
}
|
|
409
442
|
});
|
|
410
443
|
});
|
|
444
|
+
describe("TestExecutionService.executeBatch", () => {
|
|
445
|
+
let TestExecutionService;
|
|
446
|
+
beforeAll(async () => {
|
|
447
|
+
const mod = await import("./TestExecutionService.js");
|
|
448
|
+
TestExecutionService = mod.TestExecutionService;
|
|
449
|
+
});
|
|
450
|
+
it("executes tests in parallel batches", async () => {
|
|
451
|
+
const service = new TestExecutionService();
|
|
452
|
+
const order = [];
|
|
453
|
+
let resolveFirst;
|
|
454
|
+
jest.spyOn(service, "executeTest").mockImplementation(async (options) => {
|
|
455
|
+
order.push(`start:${options.testFile}`);
|
|
456
|
+
if (options.testFile === "one.py") {
|
|
457
|
+
await new Promise((resolve) => {
|
|
458
|
+
resolveFirst = resolve;
|
|
459
|
+
});
|
|
460
|
+
}
|
|
461
|
+
order.push(`end:${options.testFile}`);
|
|
462
|
+
return {
|
|
463
|
+
testFile: options.testFile,
|
|
464
|
+
status: "pass",
|
|
465
|
+
executedAt: new Date().toISOString(),
|
|
466
|
+
duration: 1,
|
|
467
|
+
errors: [],
|
|
468
|
+
warnings: [],
|
|
469
|
+
};
|
|
470
|
+
});
|
|
471
|
+
const batchPromise = service.executeBatch([
|
|
472
|
+
{ testFile: "one.py", workspacePath: "/workspace", language: "python", testType: "smoke" },
|
|
473
|
+
{ testFile: "two.py", workspacePath: "/workspace", language: "python", testType: "smoke" },
|
|
474
|
+
]);
|
|
475
|
+
await Promise.resolve();
|
|
476
|
+
expect(order).toEqual(["start:one.py", "start:two.py", "end:two.py"]);
|
|
477
|
+
resolveFirst?.();
|
|
478
|
+
await batchPromise;
|
|
479
|
+
expect(order).toEqual(["start:one.py", "start:two.py", "end:two.py", "end:one.py"]);
|
|
480
|
+
});
|
|
481
|
+
});
|
|
411
482
|
describe("TestExecutionService.executeTest - Video capture for browser tests", () => {
|
|
412
483
|
let TestExecutionService;
|
|
413
484
|
let getVideoSubdir;
|
|
@@ -521,7 +592,10 @@ describe("TestExecutionService.executeTest - Video capture for browser tests", (
|
|
|
521
592
|
});
|
|
522
593
|
const dockerOptions = mockRun.mock.calls[0][3];
|
|
523
594
|
const videoSubdir = getVideoSubdir("/workspace/tests/login.spec.ts");
|
|
524
|
-
|
|
595
|
+
// Each execution gets a unique per-run dir: `${videoSubdir}-<timestamp>`,
|
|
596
|
+
// so match by prefix rather than exact equality.
|
|
597
|
+
const videoMountPrefix = `/home/user/.skyramp/videos/${videoSubdir}`;
|
|
598
|
+
const videoMount = dockerOptions.HostConfig.Mounts.find((m) => m.Target.startsWith(videoMountPrefix));
|
|
525
599
|
expect(videoMount).toBeDefined();
|
|
526
600
|
expect(videoMount.Type).toBe("bind");
|
|
527
601
|
expect(videoMount.ReadOnly).toBe(false);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SkyrampClient } from "@skyramp/skyramp";
|
|
2
2
|
import { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
|
|
3
|
-
import { TestType } from "../types/TestTypes.js";
|
|
3
|
+
import { TestType, MOCK_TYPE } from "../types/TestTypes.js";
|
|
4
4
|
export interface BaseTestParams {
|
|
5
5
|
endpointURL?: string;
|
|
6
6
|
method?: string;
|
|
@@ -42,7 +42,7 @@ export declare abstract class TestGenerationService {
|
|
|
42
42
|
generateTest(params: BaseTestParams & Record<string, any>): Promise<CallToolResult>;
|
|
43
43
|
protected validateInputs(params: BaseTestParams): CallToolResult;
|
|
44
44
|
protected abstract buildGenerationOptions(params: BaseTestParams & Record<string, any>): any;
|
|
45
|
-
protected abstract getTestType(): TestType;
|
|
45
|
+
protected abstract getTestType(): TestType | typeof MOCK_TYPE;
|
|
46
46
|
protected handleApiAnalysis(params: BaseTestParams): Promise<CallToolResult | null>;
|
|
47
47
|
private static readonly STANDARD_HEADERS;
|
|
48
48
|
private static simpleWildcardMatch;
|
package/build/tool-phases.js
CHANGED
|
@@ -10,6 +10,9 @@ export const TOOL_PHASE_MAP = {
|
|
|
10
10
|
skyramp_ui_test_generation: "generating",
|
|
11
11
|
skyramp_batch_scenario_test_generation: "generating",
|
|
12
12
|
skyramp_mock_generation: "generating",
|
|
13
|
+
skyramp_batch_mock_generation: "generating",
|
|
14
|
+
skyramp_generate_enriched_integration_test: "generating",
|
|
15
|
+
skyramp_enrich_test_with_mocks: "generating",
|
|
13
16
|
skyramp_execute_test: { before: "maintaining", after: "executing" },
|
|
14
17
|
skyramp_analyze_test_health: "maintaining",
|
|
15
18
|
skyramp_submit_report: "reporting",
|
|
@@ -36,4 +39,5 @@ export const TOOLS_WITHOUT_PHASE = new Set([
|
|
|
36
39
|
"skyramp_modularization",
|
|
37
40
|
"skyramp_reuse_code",
|
|
38
41
|
"skyramp_enhance_assertions",
|
|
42
|
+
"skyramp_preflight_mock_check",
|
|
39
43
|
]);
|
|
@@ -12,6 +12,37 @@ const TESTBOT_UI_CHECKS = `
|
|
|
12
12
|
- If no suitable selector exists in the generated file for an assertion you need to add, go back and call \`browser_assert\` on the live page to record it with a valid selector, then re-export and regenerate.
|
|
13
13
|
- **After executing a UI test that documents a bug from \`issuesFound\`**: if it passed when you expected it to fail, the assertions are too weak — add a stronger \`expect()\` that directly targets the buggy behavior. This counts as the single allowed retry under the 2-attempt cap — do NOT re-run more than once.
|
|
14
14
|
`;
|
|
15
|
+
function buildAssertionInstructions(testFile, testType, enhanceType) {
|
|
16
|
+
if (testType === TestType.UI) {
|
|
17
|
+
let instructions = getUIAssertionsPrompt(testFile, enhanceType);
|
|
18
|
+
if (isTestbotEnabled()) {
|
|
19
|
+
instructions += TESTBOT_UI_CHECKS;
|
|
20
|
+
}
|
|
21
|
+
return instructions;
|
|
22
|
+
}
|
|
23
|
+
if (testType === TestType.CONTRACT) {
|
|
24
|
+
return getContractProviderAssertionsPrompt(testFile, enhanceType);
|
|
25
|
+
}
|
|
26
|
+
if (testType === TestType.INTEGRATION) {
|
|
27
|
+
return getIntegrationAssertionsPrompt(testFile, enhanceType);
|
|
28
|
+
}
|
|
29
|
+
throw new Error(`Unsupported testType for ${TOOL_NAME}: ${testType}`);
|
|
30
|
+
}
|
|
31
|
+
function buildAutoApplyInstructions(testFile, testType, enhanceType) {
|
|
32
|
+
const typeSpecificInstructions = buildAssertionInstructions(testFile, testType, enhanceType);
|
|
33
|
+
return [
|
|
34
|
+
`Enhance response body assertions in: \`${testFile}\``,
|
|
35
|
+
`Test type: ${testType} | Context: ${enhanceType}`,
|
|
36
|
+
``,
|
|
37
|
+
`Read the file, apply the type-specific assertion guidance below, and write the file back directly.`,
|
|
38
|
+
`Add assertions after each send_request/sendRequest status-code assertion.`,
|
|
39
|
+
`Use SDK helper: Python \`skyramp.get_response_value(response, "json.path")\`, JS \`getValue(response, "json.path")\`.`,
|
|
40
|
+
`Do NOT restructure, reformat, add comments, or change imports. Only add assertion lines.`,
|
|
41
|
+
``,
|
|
42
|
+
`Type-specific assertion guidance:`,
|
|
43
|
+
typeSpecificInstructions,
|
|
44
|
+
].join("\n");
|
|
45
|
+
}
|
|
15
46
|
const enhanceAssertionsSchema = {
|
|
16
47
|
testFile: z
|
|
17
48
|
.string()
|
|
@@ -24,6 +55,12 @@ const enhanceAssertionsSchema = {
|
|
|
24
55
|
.describe("The context of the enhancement. " +
|
|
25
56
|
"Use 'generation' after generating a new test file (applies to every test function). " +
|
|
26
57
|
"Use 'maintenance' during drift UPDATE (applies only to new or diff-affected functions)."),
|
|
58
|
+
autoApply: z
|
|
59
|
+
.boolean()
|
|
60
|
+
.default(false)
|
|
61
|
+
.describe("When true, returns a compact instruction set (10 lines) that tells the agent to " +
|
|
62
|
+
"read the test file, enhance assertions per standard rules, and write it back directly. " +
|
|
63
|
+
"When false (default), returns the full verbose instruction set."),
|
|
27
64
|
};
|
|
28
65
|
export function registerEnhanceAssertionsTool(server) {
|
|
29
66
|
server.registerTool(TOOL_NAME, {
|
|
@@ -34,26 +71,13 @@ export function registerEnhanceAssertionsTool(server) {
|
|
|
34
71
|
- After updating an existing supported test file during maintenance`,
|
|
35
72
|
inputSchema: enhanceAssertionsSchema,
|
|
36
73
|
}, async (params) => {
|
|
37
|
-
const { testFile, testType, enhanceType } = params;
|
|
74
|
+
const { testFile, testType, enhanceType, autoApply } = params;
|
|
38
75
|
// Stage so testbot includes the generated files in its output commit.
|
|
39
76
|
await stageGeneratedPaths(testFile);
|
|
40
77
|
const enhanceCtx = enhanceType;
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
if (isTestbotEnabled()) {
|
|
45
|
-
instructions += TESTBOT_UI_CHECKS;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
else if (testType === TestType.CONTRACT) {
|
|
49
|
-
instructions = getContractProviderAssertionsPrompt(testFile, enhanceCtx);
|
|
50
|
-
}
|
|
51
|
-
else if (testType === TestType.INTEGRATION) {
|
|
52
|
-
instructions = getIntegrationAssertionsPrompt(testFile, enhanceCtx);
|
|
53
|
-
}
|
|
54
|
-
else {
|
|
55
|
-
throw new Error(`Unsupported testType for ${TOOL_NAME}: ${testType}`);
|
|
56
|
-
}
|
|
78
|
+
const instructions = autoApply
|
|
79
|
+
? buildAutoApplyInstructions(testFile, testType, enhanceCtx)
|
|
80
|
+
: buildAssertionInstructions(testFile, testType, enhanceCtx);
|
|
57
81
|
const result = {
|
|
58
82
|
content: [
|
|
59
83
|
{
|
|
@@ -63,7 +87,12 @@ export function registerEnhanceAssertionsTool(server) {
|
|
|
63
87
|
],
|
|
64
88
|
isError: false,
|
|
65
89
|
};
|
|
66
|
-
AnalyticsService.pushMCPToolEvent(TOOL_NAME, undefined,
|
|
90
|
+
AnalyticsService.pushMCPToolEvent(TOOL_NAME, undefined, {
|
|
91
|
+
testFile: params.testFile,
|
|
92
|
+
testType: params.testType,
|
|
93
|
+
enhanceType: params.enhanceType,
|
|
94
|
+
autoApply: params.autoApply,
|
|
95
|
+
}).catch(() => { });
|
|
67
96
|
return result;
|
|
68
97
|
});
|
|
69
98
|
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
+
import { ProgrammingLanguage, MockProtocol } from "../types/TestTypes.js";
|
|
3
|
+
/**
|
|
4
|
+
* skyramp_enrich_test_with_mocks
|
|
5
|
+
*
|
|
6
|
+
* Injects mock imports and apply_mock() calls into a generated test file.
|
|
7
|
+
* The mock files are generated by skyramp_mock_generation — this tool wires
|
|
8
|
+
* them into the test so the mocks are applied before the test runs.
|
|
9
|
+
*
|
|
10
|
+
* No data duplication — the test imports from the generated mock files.
|
|
11
|
+
*/
|
|
12
|
+
export declare function registerEnrichTestWithMocksTool(server: McpServer): void;
|
|
13
|
+
declare function injectMockImports(original: string, testFile: string, scenarioName: string, mockFiles: string[], traceComments?: string[], language?: ProgrammingLanguage): string;
|
|
14
|
+
declare function isSupportedMockEnrichmentLanguage(language: ProgrammingLanguage | string): language is ProgrammingLanguage;
|
|
15
|
+
type MockEntry = {
|
|
16
|
+
serviceName: string;
|
|
17
|
+
moduleName: string;
|
|
18
|
+
relativePath: string;
|
|
19
|
+
importPath: string;
|
|
20
|
+
importLabel: string;
|
|
21
|
+
mockFile: string;
|
|
22
|
+
className: string;
|
|
23
|
+
classReference: string;
|
|
24
|
+
targetUrl?: string;
|
|
25
|
+
protocol: MockProtocol;
|
|
26
|
+
};
|
|
27
|
+
declare function buildMockImportBlock(testFile: string, scenarioName: string, mockFiles: string[], traceComments?: string[], language?: ProgrammingLanguage, mockEntries?: MockEntry[]): string;
|
|
28
|
+
export { injectMockImports, buildMockImportBlock, isSupportedMockEnrichmentLanguage };
|