ledgerone_backend/test/google.service.spec.ts

43 lines
1.6 KiB
TypeScript

import { GoogleService } from "../src/google/google.service";
import { createPrismaMock } from "./utils/mock-prisma";
describe("GoogleService", () => {
it("reports the durable user-owned Google Drive mirror status", async () => {
const prisma = createPrismaMock();
prisma.googleConnection.findUnique.mockResolvedValue({
userId: "user_1",
googleEmail: "owner@example.com",
connectedAt: new Date("2026-01-01T00:00:00.000Z"),
spreadsheetId: "sheet_123",
driveMirrorEnabled: true,
driveMirrorStatus: "synced",
driveMirrorSpreadsheetUrl: "https://docs.google.com/spreadsheets/d/sheet_123",
driveMirrorLastSyncedAt: new Date("2026-01-02T00:00:00.000Z"),
lastSyncedAt: new Date("2026-01-02T00:00:00.000Z"),
dataSystemMode: "google_sheets_mirror",
isConnected: true,
});
const service = new GoogleService(prisma as any);
await expect(service.getStatus("user_1")).resolves.toEqual({
connected: true,
googleEmail: "owner@example.com",
connectedAt: new Date("2026-01-01T00:00:00.000Z"),
driveMirror: {
enabled: true,
status: "synced",
spreadsheetId: "sheet_123",
url: "https://docs.google.com/spreadsheets/d/sheet_123",
lastSyncedAt: new Date("2026-01-02T00:00:00.000Z"),
ownership: "user_google_drive",
},
dataSystem: {
mode: "google_sheets_mirror",
operationalSystemOfRecord: "ledgerone_backend_db",
userOwnedMirror: true,
note: "LedgerOne writes a best-effort user-owned Google Sheets mirror while the application database remains the operational store.",
},
});
});
});