Merge branch 'fix/v1437-r2-jobs' into release/v1.43.7

This commit is contained in:
Marc-André Bombeck committed 2026-10-20 10:17:01 +02:00
commit e5b7eebe64
62 files changed
+1745 -774

No files matched your search

@@ -31,6 +31,11 @@ vi.mock("@/lib/db", () => ({
},
}));
vi.mock("@/lib/logging/signal", () => ({
emitSignal: vi.fn(),
logCaught: vi.fn(),
}));
vi.mock("@/lib/auth/audit", () => ({
auditLog: vi.fn().mockResolvedValue(undefined),
}));
@@ -52,6 +57,7 @@ vi.mock("@/lib/crypto", () => ({
import { formatAdminAlertPayload, parkIntegrationAtReauth } from "../status";
import { prisma } from "@/lib/db";
import { auditLog } from "@/lib/auth/audit";
import { emitSignal } from "@/lib/logging/signal";
import { dispatchNotification } from "@/lib/notifications/dispatcher";
beforeEach(() => {
@@ -246,9 +252,8 @@ describe("parkIntegrationAtReauth — silent scope-skip park (v1.4.27 F20)", ()
}),
}),
);
expect(auditLog).not.toHaveBeenCalledWith(
"integrations.sync.failed",
expect.anything(),
expect(emitSignal).not.toHaveBeenCalledWith(
expect.objectContaining({ action: "integrations.sync.failed" }),
);
});
@@ -32,6 +32,16 @@ describe("walkPages", () => {
expect(walk.items).toEqual([0, 1, 2, 3]);
});
it("ends on an empty cursor instead of following it back to the first page", async () => {
const fetchPage = vi.fn(async (cursor: string | undefined) => ({
items: [cursor ?? "first"],
next: "",
}));
const walk = await walkPages<string, string>("test.empty", 10, fetchPage);
expect(walk).toEqual({ items: ["first"], pages: 1, truncated: false });
expect(fetchPage).toHaveBeenCalledTimes(1);
});
it("stops on a cursor it already followed, the first one included", async () => {
const fetchPage = vi.fn(async () => ({ items: [1], next: 0 }));
const walk = await walkPages<number, number>(
+34 -21
View File
@@ -36,6 +36,11 @@ vi.mock("@/lib/db", () => ({
},
}));
vi.mock("@/lib/logging/signal", () => ({
emitSignal: vi.fn(),
logCaught: vi.fn(),
}));
vi.mock("@/lib/auth/audit", () => ({
auditLog: vi.fn().mockResolvedValue(undefined),
}));
@@ -66,6 +71,7 @@ import {
} from "../status";
import { prisma } from "@/lib/db";
import { auditLog } from "@/lib/auth/audit";
import { emitSignal } from "@/lib/logging/signal";
import { dispatchNotification } from "@/lib/notifications/dispatcher";
beforeEach(() => {
@@ -148,17 +154,24 @@ describe("recordSyncFailure — under threshold", () => {
});
expect(prisma.integrationStatus.upsert).toHaveBeenCalledOnce();
expect(auditLog).toHaveBeenCalledWith(
"integrations.sync.failed",
expect(emitSignal).toHaveBeenCalledWith(
expect.objectContaining({
userId: "u1",
details: expect.objectContaining({
action: "integrations.sync.failed",
meta: expect.objectContaining({
integration: "withings",
attemptNumber: 1,
attempt_number: 1,
state: "error_transient",
}),
}),
);
// A provider failure is not something a person did to the account: no
// audit row, and the provider's message stays sealed on the status row.
expect(auditLog).not.toHaveBeenCalledWith(
"integrations.sync.failed",
expect.anything(),
);
const [signal] = vi.mocked(emitSignal).mock.calls[0]!;
expect(JSON.stringify(signal)).not.toContain("upstream");
expect(dispatchNotification).not.toHaveBeenCalled();
});
});
@@ -456,12 +469,12 @@ describe("recordSyncFailure — reauth_required", () => {
const upsertArgs = vi.mocked(prisma.integrationStatus.upsert).mock
.calls[0][0];
expect(upsertArgs.update).toMatchObject({ state: "error_reauth" });
expect(auditLog).toHaveBeenCalledWith(
"integrations.sync.failed",
expect(emitSignal).toHaveBeenCalledWith(
expect.objectContaining({
details: expect.objectContaining({
action: "integrations.sync.failed",
meta: expect.objectContaining({
kind: "reauth_required",
errorCode: "100",
error_code: "100",
}),
}),
);
@@ -489,12 +502,12 @@ describe("recordSyncFailure — persistent (v1.4.42 W6)", () => {
const upsertArgs = vi.mocked(prisma.integrationStatus.upsert).mock
.calls[0][0];
expect(upsertArgs.update).toMatchObject({ state: "error_transient" });
expect(auditLog).toHaveBeenCalledWith(
"integrations.sync.failed",
expect(emitSignal).toHaveBeenCalledWith(
expect.objectContaining({
details: expect.objectContaining({
action: "integrations.sync.failed",
meta: expect.objectContaining({
kind: "persistent",
errorCode: "293",
error_code: "293",
}),
}),
);
@@ -1089,12 +1102,12 @@ describe("transient-streak escalation", () => {
persistent: 1,
});
expect(upsertUpdate().persistentFailureStartedAt).toBeInstanceOf(Date);
expect(auditLog).toHaveBeenCalledWith(
"integrations.sync.failed",
expect(emitSignal).toHaveBeenCalledWith(
expect.objectContaining({
details: expect.objectContaining({
action: "integrations.sync.failed",
meta: expect.objectContaining({
kind: "persistent",
escalatedFrom: "transient",
escalated_from: "transient",
}),
}),
);
@@ -1116,12 +1129,12 @@ describe("transient-streak escalation", () => {
persistent: 0,
});
expect(upsertUpdate().persistentFailureStartedAt).toBeNull();
expect(auditLog).toHaveBeenCalledWith(
"integrations.sync.failed",
expect(emitSignal).toHaveBeenCalledWith(
expect.objectContaining({
details: expect.objectContaining({
action: "integrations.sync.failed",
meta: expect.objectContaining({
kind: "transient",
escalatedFrom: null,
escalated_from: null,
}),
}),
);