test(memory): stabilize windows qmd spawn expectation

This commit is contained in:
Peter Steinberger
2026-03-02 18:06:01 +00:00
parent 1c9deeda97
commit 602f6439bd

View File

@@ -886,7 +886,7 @@ describe("QmdMemoryManager", () => {
await manager.close();
});
it("uses qmd.cmd on Windows when qmd command is bare", async () => {
it("resolves bare qmd command to a Windows-compatible spawn invocation", async () => {
const platformSpy = vi.spyOn(process, "platform", "get").mockReturnValue("win32");
try {
const { manager } = await createManager({ mode: "status" });
@@ -894,13 +894,23 @@ describe("QmdMemoryManager", () => {
const qmdCalls = spawnMock.mock.calls.filter((call: unknown[]) => {
const args = call[1] as string[] | undefined;
return Array.isArray(args) && args.length > 0;
return (
Array.isArray(args) &&
args.some((token) => token === "update" || token === "search" || token === "query")
);
});
expect(qmdCalls.length).toBeGreaterThan(0);
for (const call of qmdCalls) {
expect(call[0]).toBe("qmd.cmd");
const command = String(call[0]);
const options = call[2] as { shell?: boolean } | undefined;
expect(options?.shell).toBe(true);
if (/(^|[\\/])qmd(?:\.cmd)?$/i.test(command)) {
// Wrapper unresolved: keep `.cmd` and use shell for PATHEXT lookup.
expect(command.toLowerCase().endsWith("qmd.cmd")).toBe(true);
expect(options?.shell).toBe(true);
} else {
// Wrapper resolved to node/exe entrypoint: shell fallback should not be used.
expect(options?.shell).not.toBe(true);
}
}
await manager.close();