test: fix qmd and discord ci regressions

This commit is contained in:
Shakker
2026-03-30 20:22:27 +01:00
committed by Shakker
parent a8ba6f2c03
commit 020858647d
2 changed files with 19 additions and 14 deletions

View File

@@ -699,14 +699,16 @@ describe("discord component interactions", () => {
await button.run(interaction, { cid: "btn_1" } as ComponentData);
expect(dispatchPluginInteractiveHandlerMock).toHaveBeenCalledWith(
expect.objectContaining({
ctx: expect.objectContaining({
conversationId: "channel:group-dm-1",
senderId: "123456789",
await vi.waitFor(() => {
expect(dispatchPluginInteractiveHandlerMock).toHaveBeenCalledWith(
expect.objectContaining({
ctx: expect.objectContaining({
conversationId: "channel:group-dm-1",
senderId: "123456789",
}),
}),
}),
);
);
});
expect(dispatchReplyMock).not.toHaveBeenCalled();
});

View File

@@ -110,7 +110,7 @@ describe("QmdMemoryManager slugified path resolution", () => {
if (!manager) {
throw new Error("manager missing");
}
return { manager };
return { manager, resolved };
}
function installIndexedPathStub(params: {
@@ -259,6 +259,11 @@ describe("QmdMemoryManager slugified path resolution", () => {
await fs.mkdir(path.dirname(actualFile), { recursive: true });
await fs.writeFile(actualFile, "vault memory", "utf-8");
const { manager, resolved } = await createManager({ cfg });
const collectionName =
resolved.qmd?.collections.find((collection) => collection.path === extraRoot)?.name ??
"vault";
spawnMock.mockImplementation((_cmd: string, args: string[]) => {
if (args[0] === "search") {
const child = createMockChild({ autoClose: false });
@@ -267,7 +272,7 @@ describe("QmdMemoryManager slugified path resolution", () => {
"stdout",
JSON.stringify([
{
file: "qmd://vault/topics/sub-category/topic-name.md",
file: `qmd://${collectionName}/topics/sub-category/topic-name.md`,
score: 0.81,
snippet: "@@ -1,1\nvault memory",
},
@@ -277,11 +282,9 @@ describe("QmdMemoryManager slugified path resolution", () => {
}
return createMockChild();
});
const { manager } = await createManager({ cfg });
installIndexedPathStub({
manager,
collection: "vault",
collection: collectionName,
normalizedPath: "topics/sub-category/topic-name.md",
actualPath: actualRelative,
});
@@ -291,7 +294,7 @@ describe("QmdMemoryManager slugified path resolution", () => {
});
expect(results).toEqual([
{
path: `qmd/vault/${actualRelative}`,
path: `qmd/${collectionName}/${actualRelative}`,
startLine: 1,
endLine: 1,
score: 0.81,
@@ -301,7 +304,7 @@ describe("QmdMemoryManager slugified path resolution", () => {
]);
await expect(manager.readFile({ relPath: results[0]!.path })).resolves.toEqual({
path: `qmd/vault/${actualRelative}`,
path: `qmd/${collectionName}/${actualRelative}`,
text: "vault memory",
});
});