feat(FN-681): add openai-codex provider support

- Add openai-codex provider mapping with matching label and OpenAI icon rendering
- Extend ProviderIcon coverage to verify the new provider displays correctly
- Strengthen CentralCore cleanupOldActivity tests for cutoff boundary retention
This commit is contained in:
gsxdsm
2026-04-01 14:24:01 -07:00
parent a463670852
commit ce0bf248b1

View File

@@ -16,6 +16,8 @@ describe("CentralCore", () => {
let projectPaths: string[] = []; let projectPaths: string[] = [];
beforeEach(() => { beforeEach(() => {
vi.useFakeTimers();
vi.setSystemTime(new Date("2026-04-01T12:00:00.000Z"));
tempDir = mkdtempSync(join(tmpdir(), "kb-central-core-test-")); tempDir = mkdtempSync(join(tmpdir(), "kb-central-core-test-"));
central = new CentralCore(tempDir); central = new CentralCore(tempDir);
projectPaths = []; projectPaths = [];
@@ -23,6 +25,7 @@ describe("CentralCore", () => {
afterEach(async () => { afterEach(async () => {
await central.close(); await central.close();
vi.useRealTimers();
rmSync(tempDir, { recursive: true, force: true }); rmSync(tempDir, { recursive: true, force: true });
}); });
@@ -345,7 +348,7 @@ describe("CentralCore", () => {
path: projectPath, path: projectPath,
}); });
vi.setSystemTime(new Date("2026-04-01T12:00:01.000Z")); vi.setSystemTime(new Date("2026-04-01T12:00:00.010Z"));
const updated = await central.updateProject(project.id, { const updated = await central.updateProject(project.id, {
name: "Updated", name: "Updated",
@@ -555,7 +558,7 @@ describe("CentralCore", () => {
const beforeActivity = project.lastActivityAt; const beforeActivity = project.lastActivityAt;
vi.setSystemTime(new Date("2026-04-01T12:00:01.000Z")); vi.setSystemTime(new Date("2026-04-01T12:00:00.010Z"));
await central.logActivity({ await central.logActivity({
type: "task:moved", type: "task:moved",
@@ -721,55 +724,62 @@ describe("CentralCore", () => {
expect(projectCount).toBe(5); expect(projectCount).toBe(5);
}); });
it("should cleanup only activity entries older than the cutoff", async () => { it("should cleanup only entries older than the cutoff and retain the exact boundary", async () => {
vi.useFakeTimers(); const projectPath = join(tempDir, "cleanup-activity");
mkdirSync(projectPath);
projectPaths.push(projectPath);
try { const project = await central.registerProject({
const projectPath = join(tempDir, "cleanup-activity"); name: "Cleanup Activity",
mkdirSync(projectPath); path: projectPath,
projectPaths.push(projectPath); });
const project = await central.registerProject({ const now = new Date("2026-04-01T12:00:00.000Z");
name: "Cleanup Activity", vi.setSystemTime(now);
path: projectPath,
});
vi.setSystemTime(new Date("2026-04-01T12:00:00.000Z")); const olderThanCutoff = new Date("2026-03-31T11:59:59.999Z").toISOString();
await central.logActivity({ const exactlyAtCutoff = new Date("2026-03-31T12:00:00.000Z").toISOString();
type: "task:created", const newerThanCutoff = new Date("2026-03-31T12:00:00.001Z").toISOString();
projectId: project.id,
projectName: project.name,
timestamp: "2026-03-31T11:59:59.999Z",
details: "Older than cutoff",
});
await central.logActivity({ await central.logActivity({
type: "task:created", type: "task:created",
projectId: project.id, projectId: project.id,
projectName: project.name, projectName: project.name,
timestamp: "2026-03-31T12:00:00.000Z", timestamp: olderThanCutoff,
details: "Exactly at cutoff", details: "Older than cutoff",
}); });
await central.logActivity({ await central.logActivity({
type: "task:created", type: "task:moved",
projectId: project.id, projectId: project.id,
projectName: project.name, projectName: project.name,
timestamp: "2026-03-31T12:00:00.001Z", timestamp: exactlyAtCutoff,
details: "Newer than cutoff", details: "Exactly at cutoff",
}); });
const deleted = await central.cleanupOldActivity(1); await central.logActivity({
expect(deleted).toBe(1); type: "task:updated",
projectId: project.id,
projectName: project.name,
timestamp: newerThanCutoff,
details: "Newer than cutoff",
});
const remaining = await central.getRecentActivity({ limit: 10, projectId: project.id }); const deleted = await central.cleanupOldActivity(1);
expect(remaining.map((entry) => entry.details)).toEqual([ expect(deleted).toBe(1);
"Newer than cutoff",
"Exactly at cutoff", const countAfter = await central.getActivityCount();
]); expect(countAfter).toBe(2);
} finally {
vi.useRealTimers(); const remaining = await central.getRecentActivity({ limit: 10, projectId: project.id });
} expect(remaining.map((entry) => entry.details)).toEqual([
"Newer than cutoff",
"Exactly at cutoff",
]);
expect(remaining.map((entry) => entry.timestamp)).toEqual([
newerThanCutoff,
exactlyAtCutoff,
]);
}); });
}); });