Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ datasets/
tools/seeder/datasets/*
!tools/seeder/datasets/e2e/
!tools/seeder/datasets/e2e/**
!tools/seeder/datasets/minecraft/
!tools/seeder/datasets/minecraft/**
!tools/seeder/datasets/markdown-context-test/
!tools/seeder/datasets/markdown-context-test/**

Expand Down
26 changes: 17 additions & 9 deletions apps/app-api/src/__tests__/recall-routes.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { beforeEach, describe, expect, it, vi } from "vitest";
import type { Context } from "@/utils/context";

const opMocks = vi.hoisted(() => ({
collectMemoryRecallOp: vi.fn(),
collectEffectiveMemoryRecallOp: vi.fn(),
recallContextRerankOp: vi.fn(),
rerankTermRecallOp: vi.fn(),
termRecallOp: vi.fn(),
Expand Down Expand Up @@ -36,7 +36,7 @@ vi.mock("@cat/operations", async () => {

return {
...actual,
collectMemoryRecallOp: opMocks.collectMemoryRecallOp,
collectEffectiveMemoryRecallOp: opMocks.collectEffectiveMemoryRecallOp,
recallContextRerankOp: opMocks.recallContextRerankOp,
rerankTermRecallOp: opMocks.rerankTermRecallOp,
termRecallOp: opMocks.termRecallOp,
Expand All @@ -59,8 +59,8 @@ vi.mock("@cat/permissions", async () => {

import {
getElementWithChunkIds,
listEffectiveMemoryIdsByProject,
listAllLanguages,
listMemoryIdsByProject,
listProjectGlossaryIds,
} from "@cat/domain";

Expand Down Expand Up @@ -193,8 +193,12 @@ describe("recall routes", () => {
domainMocks.getElementWithChunkIds.mockResolvedValue(element);
vi.mocked(executeQuery).mockImplementation(async (_ctx, query) => {
if (query === getElementWithChunkIds) return element;
if (query === listMemoryIdsByProject)
return ["22222222-2222-4222-8222-222222222222"];
if (query === listEffectiveMemoryIdsByProject)
return {
projectMemoryIds: ["22222222-2222-4222-8222-222222222222"],
personalMemoryIds: [],
allMemoryIds: ["22222222-2222-4222-8222-222222222222"],
};
return [];
});

Expand Down Expand Up @@ -225,7 +229,7 @@ describe("recall routes", () => {
},
];

opMocks.collectMemoryRecallOp.mockResolvedValue(memories);
opMocks.collectEffectiveMemoryRecallOp.mockResolvedValue(memories);
opMocks.recallContextRerankOp.mockResolvedValue(memories);

const stream = await call(
Expand Down Expand Up @@ -260,8 +264,12 @@ describe("recall routes", () => {
domainMocks.getElementWithChunkIds.mockResolvedValue(element);
vi.mocked(executeQuery).mockImplementation(async (_ctx, query) => {
if (query === getElementWithChunkIds) return element;
if (query === listMemoryIdsByProject)
return ["22222222-2222-4222-8222-222222222222"];
if (query === listEffectiveMemoryIdsByProject)
return {
projectMemoryIds: ["22222222-2222-4222-8222-222222222222"],
personalMemoryIds: [],
allMemoryIds: ["22222222-2222-4222-8222-222222222222"],
};
return [];
});

Expand All @@ -279,7 +287,7 @@ describe("recall routes", () => {
evidences: [],
};

opMocks.collectMemoryRecallOp.mockResolvedValue([exactMemory]);
opMocks.collectEffectiveMemoryRecallOp.mockResolvedValue([exactMemory]);
opMocks.recallContextRerankOp.mockResolvedValue([exactMemory]);

const stream = await call(
Expand Down
25 changes: 17 additions & 8 deletions apps/app-api/src/__tests__/suggestion-route.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import type { Context } from "@/utils/context";
// ─── Mocks ──────────────────────────────────────────────────────────────────

const opMocks = vi.hoisted(() => ({
collectMemoryRecallOp: vi.fn(),
collectEffectiveMemoryRecallOp: vi.fn(),
termRecallOp: vi.fn(),
llmTranslateOp: vi.fn(),
}));
Expand Down Expand Up @@ -40,7 +40,7 @@ vi.mock("@cat/operations", async () => {
await vi.importActual<typeof import("@cat/operations")>("@cat/operations");
return {
...actual,
collectMemoryRecallOp: opMocks.collectMemoryRecallOp,
collectEffectiveMemoryRecallOp: opMocks.collectEffectiveMemoryRecallOp,
termRecallOp: opMocks.termRecallOp,
llmTranslateOp: opMocks.llmTranslateOp,
};
Expand Down Expand Up @@ -75,7 +75,7 @@ import { executeQuery } from "@cat/domain";
import {
findOpenAutoTranslatePR,
getElementWithChunkIds,
listMemoryIdsByProject,
listEffectiveMemoryIdsByProject,
listProjectGlossaryIds,
} from "@cat/domain";

Expand Down Expand Up @@ -161,11 +161,16 @@ describe("suggestion.onNew", () => {
vi.mocked(executeQuery).mockImplementation(async (_ctx, query) => {
if (query === getElementWithChunkIds) return MOCK_ELEMENT;
if (query === listProjectGlossaryIds) return [];
if (query === listMemoryIdsByProject) return [];
if (query === listEffectiveMemoryIdsByProject)
return {
projectMemoryIds: [],
personalMemoryIds: [],
allMemoryIds: [],
};
return []; // listNeighborElements fallback
});

opMocks.collectMemoryRecallOp.mockResolvedValue([]);
opMocks.collectEffectiveMemoryRecallOp.mockResolvedValue([]);
opMocks.termRecallOp.mockResolvedValue({ terms: [] });
opMocks.llmTranslateOp.mockResolvedValue({ suggestion: null });
});
Expand Down Expand Up @@ -250,12 +255,16 @@ describe("suggestion.onNew", () => {
vi.mocked(executeQuery).mockImplementation(async (_ctx, query) => {
if (query === getElementWithChunkIds) return MOCK_ELEMENT;
if (query === listProjectGlossaryIds) return [];
if (query === listMemoryIdsByProject)
return ["aaaaaaaa-aaaa-4aaa-8aaa-aaaaaaaaaaaa"];
if (query === listEffectiveMemoryIdsByProject)
return {
projectMemoryIds: ["aaaaaaaa-aaaa-4aaa-8aaa-aaaaaaaaaaaa"],
personalMemoryIds: [],
allMemoryIds: ["aaaaaaaa-aaaa-4aaa-8aaa-aaaaaaaaaaaa"],
};
return [];
});

opMocks.collectMemoryRecallOp.mockResolvedValue([memory]);
opMocks.collectEffectiveMemoryRecallOp.mockResolvedValue([memory]);
opMocks.llmTranslateOp.mockResolvedValue({ suggestion: null });

const stream = await call(
Expand Down
Loading
Loading