Merge remote-tracking branch 'origin/main' into work/native-stepup-rebase

This commit is contained in:
Marc-André Bombeck committed 2026-07-23 09:04:43 +02:00
commit 8119cc6c82
642 files changed
+56250 -13112

No files matched your search

@@ -39,6 +39,7 @@ vi.mock("@/lib/crypto", () => ({ decrypt: vi.fn(() => "{}") }));
vi.mock("@/lib/crypto/note-cipher", () => ({ encryptNote: vi.fn() }));
vi.mock("@/lib/validations/backup", () => ({
parseBackupPayload: vi.fn(),
isCompatibleSchemaVersion: vi.fn(() => true),
summarizeBackup: vi.fn(() => ({})),
}));
vi.mock("@/lib/auth/audit", () => ({ auditLog: vi.fn() }));
File diff suppressed because it is too large. Load diff
@@ -188,9 +188,29 @@ describe("POST /api/admin/import-apple-health-export", () => {
expect(body.data.jobId).not.toBe("old-failed-job");
expect(mocks.bossSend).toHaveBeenCalledTimes(1);
expect(mocks.importJobCreate).toHaveBeenCalledTimes(1);
expect(mocks.importJobCreate).toHaveBeenCalledWith(
expect.objectContaining({
data: expect.objectContaining({ parserRevision: 2 }),
}),
);
expect(mocks.bossSend).toHaveBeenCalledWith(
"apple-health-import-v2",
expect.objectContaining({
userId: "user-2",
triggeredByAdminId: "admin-1",
}),
expect.objectContaining({ retryLimit: 0 }),
);
expect(mocks.importJobUpdate).toHaveBeenCalledWith({
where: { id: "ij-1" },
data: { pgBossJobId: "boss-job-1" },
});
expect(mocks.importJobFindFirst).toHaveBeenCalledWith(
expect.objectContaining({
where: expect.objectContaining({ status: { not: "failed" } }),
where: expect.objectContaining({
status: { not: "failed" },
parserRevision: 2,
}),
}),
);
expect(mocks.unlink).not.toHaveBeenCalled();
@@ -211,5 +231,10 @@ describe("POST /api/admin/import-apple-health-export", () => {
expect(mocks.bossSend).not.toHaveBeenCalled();
expect(mocks.importJobCreate).not.toHaveBeenCalled();
expect(mocks.unlink).toHaveBeenCalledWith(STAGED_PATH);
expect(mocks.importJobFindFirst).toHaveBeenCalledWith(
expect.objectContaining({
where: expect.objectContaining({ parserRevision: 2 }),
}),
);
});
});
@@ -21,7 +21,8 @@ import { auditLog } from "@/lib/auth/audit";
import { checkRateLimit } from "@/lib/rate-limit";
import { getGlobalBoss } from "@/lib/jobs/boss-instance";
import {
APPLE_HEALTH_IMPORT_QUEUE,
APPLE_HEALTH_IMPORT_V2_QUEUE,
APPLE_HEALTH_IMPORT_PARSER_REVISION,
APPLE_HEALTH_IMPORT_SEND_OPTIONS,
type AppleHealthImportPayload,
} from "@/lib/jobs/apple-health-import-worker";
@@ -121,6 +122,7 @@ export const POST = apiHandler(async (request: NextRequest) => {
where: {
userId: targetUser.id,
uploadSha256: uploaded.sha256,
parserRevision: APPLE_HEALTH_IMPORT_PARSER_REVISION,
status: { not: "failed" },
},
orderBy: { startedAt: "desc" },
@@ -157,6 +159,7 @@ export const POST = apiHandler(async (request: NextRequest) => {
status: "queued",
uploadBytes: uploaded.bytes,
uploadSha256: uploaded.sha256,
parserRevision: APPLE_HEALTH_IMPORT_PARSER_REVISION,
},
});
@@ -171,7 +174,7 @@ export const POST = apiHandler(async (request: NextRequest) => {
// first run, so a redelivery could only fail on the deleted `/tmp`
// file and mask the real outcome (see the worker's send-options doc).
const bossJobId = await boss.send(
APPLE_HEALTH_IMPORT_QUEUE,
APPLE_HEALTH_IMPORT_V2_QUEUE,
payload,
APPLE_HEALTH_IMPORT_SEND_OPTIONS,
);