test(mcp): align completion checks with provider readiness

Exercise cold and warm completion through ordinary provider operations. Bind fixture observations to the selected analysis profile so the warm-up call satisfies session validation, and make package completion candidates explicit with useful failure diagnostics.
This commit is contained in:
morluto
2026-10-12 18:44:02 +08:00
parent abc8c6dadf
commit fe4b94a661
3 changed files with 48 additions and 31 deletions
+4 -4
View File
@@ -20,7 +20,7 @@ const execute = promisify(execFile);
const verifyMcpToolsAndPrompts = async (client, mcpOptions) => {
await verifyCompleteToolCatalog(client, mcpOptions);
await prompts.verifyPromptCatalog(client, mcpOptions, prompts.names);
await prompts.verifyPromptCompletion(client, mcpOptions, false);
await prompts.verifyPromptCompletion(client, mcpOptions, []);
};
const verifyMcpTargetFree = async (client, mcpOptions) => {
@@ -122,7 +122,7 @@ const verifyMcpNonLinuxCurrentDocument = async (
const verifyMcpBinaryLifecycle = async (client, mcpOptions) => {
await verifyMcpOpenAndBind(client, mcpOptions);
// Completion never starts a provider; only an ordinary operation readies it.
await prompts.verifyPromptCompletion(client, mcpOptions, false);
await prompts.verifyPromptCompletion(client, mcpOptions, []);
if (process.platform === "linux") {
await verifyMcpLinuxToolAvailability(client, mcpOptions);
} else {
@@ -130,8 +130,8 @@ const verifyMcpBinaryLifecycle = async (client, mcpOptions) => {
{ name: "current_document", arguments: {} },
mcpOptions,
);
await prompts.verifyPromptCompletion(client, mcpOptions, true);
await verifyMcpNonLinuxCurrentDocument(client, mcpOptions, current);
await prompts.verifyPromptCompletion(client, mcpOptions, ["fixture"]);
}
const closed = await client.callTool(
{ name: "close_binary", arguments: {} },
@@ -139,7 +139,7 @@ const verifyMcpBinaryLifecycle = async (client, mcpOptions) => {
);
if (closed.isError === true)
throw new Error("packaged MCP could not close its binary");
await prompts.verifyPromptCompletion(client, mcpOptions, false);
await prompts.verifyPromptCompletion(client, mcpOptions, []);
};
const verifyMcpEvidenceBundle = async (client, mcpOptions, evidenceRoot) => {
+5 -4
View File
@@ -36,9 +36,8 @@ export const verifyPromptCatalog = async (client, options, expectedNames) => {
throw new Error("packaged MCP guided prompt rendering failed");
};
/** Verify live completion through each installed stdio target state. */
export const verifyPromptCompletion = async (client, options, targetOpen) => {
const expected = targetOpen ? ["fixture"] : [];
/** Verify completion candidates for the installed provider readiness state. */
export const verifyPromptCompletion = async (client, options, expected) => {
const requests = [
{
ref: { type: "ref/prompt", name: "investigate_feature" },
@@ -57,6 +56,8 @@ export const verifyPromptCompletion = async (client, options, targetOpen) => {
result.completion.total !== expected.length ||
result.completion.hasMore !== false
)
throw new Error("packaged MCP prompt completion lifecycle failed");
throw new Error(
`packaged MCP ${request.argument.name} completion mismatch: expected ${JSON.stringify(expected)}, received ${JSON.stringify(result.completion)}`,
);
}
};