feat(confidence-engine): use server investigation persistence
This commit is contained in:
@@ -61,8 +61,14 @@ describe("server investigation persistence", () => {
|
||||
});
|
||||
|
||||
it("lists only RLS-visible persistence records", async () => {
|
||||
const snapshot = {
|
||||
scenario: "A situation",
|
||||
updatedAt: "2026-09-08T00:30:00Z",
|
||||
investigationRevision: 3,
|
||||
investigationReport: { generatedFromRevision: 2 },
|
||||
};
|
||||
const { client, query } = makeClient({
|
||||
data: [{ id: "investigation-1", created_at: "2026-09-08T00:00:00Z", updated_at: "2026-09-08T01:00:00Z" }],
|
||||
data: [{ id: "investigation-1", snapshot, created_at: "2026-09-08T00:00:00Z", updated_at: "2026-09-08T01:00:00Z" }],
|
||||
error: null,
|
||||
});
|
||||
mockGetAuthenticatedUser.mockResolvedValue({ id: "trusted-user" });
|
||||
@@ -71,11 +77,34 @@ describe("server investigation persistence", () => {
|
||||
|
||||
await expect(listInvestigations()).resolves.toEqual([{
|
||||
id: "investigation-1",
|
||||
createdAt: "2026-09-08T00:00:00Z",
|
||||
updatedAt: "2026-09-08T01:00:00Z",
|
||||
scenario: "A situation",
|
||||
updatedAt: "2026-09-08T00:30:00Z",
|
||||
investigationRevision: 3,
|
||||
reportExists: true,
|
||||
reportGeneratedFromRevision: 2,
|
||||
}]);
|
||||
expect(client.schema).toHaveBeenCalledWith("confidence_engine");
|
||||
expect(query.select).toHaveBeenCalledWith("id, created_at, updated_at");
|
||||
expect(query.select).toHaveBeenCalledWith("id, snapshot, created_at, updated_at");
|
||||
expect(query.order).toHaveBeenCalledWith("updated_at", { ascending: false });
|
||||
});
|
||||
|
||||
it("restarts an owned snapshot through the server path using the established transformation", async () => {
|
||||
const snapshot = {
|
||||
id: "investigation-1", scenario: "A situation", situationGraph: {}, selectedQuestion: "Question",
|
||||
summary: "Summary", focusedContributions: [{}], findings: [{}], investigationReport: {}, investigationRevision: 4,
|
||||
};
|
||||
const { client, query } = makeClient({ data: { snapshot }, error: null });
|
||||
mockGetAuthenticatedUser.mockResolvedValue({ id: "trusted-user" });
|
||||
mockCreateServerSupabaseClient.mockReturnValue(client);
|
||||
const { restartInvestigation } = await import("@/lib/storage/server-investigation-persistence.js");
|
||||
|
||||
await restartInvestigation("investigation-1");
|
||||
|
||||
expect(query.upsert).toHaveBeenCalledWith(expect.objectContaining({
|
||||
id: "investigation-1", user_id: "trusted-user", snapshot: expect.objectContaining({
|
||||
id: "investigation-1", scenario: "A situation", situationGraph: null, selectedQuestion: null,
|
||||
summary: null, focusedContributions: [], findings: [], investigationReport: null, investigationRevision: 0,
|
||||
}),
|
||||
}), { onConflict: "id" });
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user