mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-11 05:42:19 +00:00
style: apply prettier across the tree
One-shot prettier pass so the new format:check gate starts from a clean baseline. Formatting only — no behaviour change. Generator-owned and vendored artifacts stay untouched via .prettierignore.
This commit is contained in:
1 parent
b3fea2ef59
commit
1f4ba5939d
1000 files changed
+12130
-8385
No files matched your search
@@ -63,8 +63,13 @@ function makeRow(overrides: Partial<Record<string, unknown>> = {}) {
|
||||
exportedAt: null,
|
||||
startedAt: NOW,
|
||||
completedAt: null,
|
||||
progress: { currentPhase: "parsing", recordsRead: 100, rowsUpserted: 0,
|
||||
percent: null, elapsedMs: 1500 },
|
||||
progress: {
|
||||
currentPhase: "parsing",
|
||||
recordsRead: 100,
|
||||
rowsUpserted: 0,
|
||||
percent: null,
|
||||
elapsedMs: 1500,
|
||||
},
|
||||
result: null,
|
||||
...overrides,
|
||||
};
|
||||
@@ -78,10 +83,15 @@ describe("GET /api/import/apple-health-export/[jobId]/status", () => {
|
||||
it("returns the row envelope to the owning user", async () => {
|
||||
vi.mocked(getSession).mockResolvedValue(OWNER_SESSION as never);
|
||||
mocks.importJobFindUnique.mockResolvedValue(makeRow());
|
||||
const req = new NextRequest("http://localhost/api/import/apple-health-export/ij-1/status");
|
||||
const req = new NextRequest(
|
||||
"http://localhost/api/import/apple-health-export/ij-1/status",
|
||||
);
|
||||
const res = await GET(req, { params: Promise.resolve({ jobId: "ij-1" }) });
|
||||
expect(res.status).toBe(200);
|
||||
const body = (await res.json()) as { data: { status: string }; error: null };
|
||||
const body = (await res.json()) as {
|
||||
data: { status: string };
|
||||
error: null;
|
||||
};
|
||||
expect(body.error).toBeNull();
|
||||
expect(body.data.status).toBe("parsing");
|
||||
});
|
||||
@@ -89,7 +99,9 @@ describe("GET /api/import/apple-health-export/[jobId]/status", () => {
|
||||
it("returns 404 to a non-owner non-admin user", async () => {
|
||||
vi.mocked(getSession).mockResolvedValue(OTHER_SESSION as never);
|
||||
mocks.importJobFindUnique.mockResolvedValue(makeRow());
|
||||
const req = new NextRequest("http://localhost/api/import/apple-health-export/ij-1/status");
|
||||
const req = new NextRequest(
|
||||
"http://localhost/api/import/apple-health-export/ij-1/status",
|
||||
);
|
||||
const res = await GET(req, { params: Promise.resolve({ jobId: "ij-1" }) });
|
||||
expect(res.status).toBe(404);
|
||||
});
|
||||
@@ -99,7 +111,9 @@ describe("GET /api/import/apple-health-export/[jobId]/status", () => {
|
||||
mocks.importJobFindUnique.mockResolvedValue(
|
||||
makeRow({ triggeredByAdminId: "admin-1" }),
|
||||
);
|
||||
const req = new NextRequest("http://localhost/api/import/apple-health-export/ij-1/status");
|
||||
const req = new NextRequest(
|
||||
"http://localhost/api/import/apple-health-export/ij-1/status",
|
||||
);
|
||||
const res = await GET(req, { params: Promise.resolve({ jobId: "ij-1" }) });
|
||||
expect(res.status).toBe(200);
|
||||
});
|
||||
@@ -107,14 +121,18 @@ describe("GET /api/import/apple-health-export/[jobId]/status", () => {
|
||||
it("returns 404 when the job row is missing", async () => {
|
||||
vi.mocked(getSession).mockResolvedValue(OWNER_SESSION as never);
|
||||
mocks.importJobFindUnique.mockResolvedValue(null);
|
||||
const req = new NextRequest("http://localhost/api/import/apple-health-export/ij-1/status");
|
||||
const req = new NextRequest(
|
||||
"http://localhost/api/import/apple-health-export/ij-1/status",
|
||||
);
|
||||
const res = await GET(req, { params: Promise.resolve({ jobId: "ij-1" }) });
|
||||
expect(res.status).toBe(404);
|
||||
});
|
||||
|
||||
it("returns 401 when unauthenticated", async () => {
|
||||
vi.mocked(getSession).mockResolvedValue(null);
|
||||
const req = new NextRequest("http://localhost/api/import/apple-health-export/ij-1/status");
|
||||
const req = new NextRequest(
|
||||
"http://localhost/api/import/apple-health-export/ij-1/status",
|
||||
);
|
||||
const res = await GET(req, { params: Promise.resolve({ jobId: "ij-1" }) });
|
||||
expect(res.status).toBe(401);
|
||||
});
|
||||
|
||||
@@ -74,11 +74,14 @@ beforeEach(() => {
|
||||
describe("POST /api/import/apple-health-export", () => {
|
||||
it("returns 401 when unauthenticated", async () => {
|
||||
vi.mocked(getSession).mockResolvedValue(null);
|
||||
const req = new NextRequest("http://localhost/api/import/apple-health-export", {
|
||||
method: "POST",
|
||||
headers: { "content-type": "multipart/form-data; boundary=---x" },
|
||||
body: "stub",
|
||||
});
|
||||
const req = new NextRequest(
|
||||
"http://localhost/api/import/apple-health-export",
|
||||
{
|
||||
method: "POST",
|
||||
headers: { "content-type": "multipart/form-data; boundary=---x" },
|
||||
body: "stub",
|
||||
},
|
||||
);
|
||||
const res = await POST(req);
|
||||
expect(res.status).toBe(401);
|
||||
});
|
||||
@@ -89,11 +92,14 @@ describe("POST /api/import/apple-health-export", () => {
|
||||
"content-type": "multipart/form-data; boundary=---x",
|
||||
"content-length": String(2 * 1024 * 1024 * 1024),
|
||||
});
|
||||
const req = new NextRequest("http://localhost/api/import/apple-health-export", {
|
||||
method: "POST",
|
||||
headers,
|
||||
body: "stub",
|
||||
});
|
||||
const req = new NextRequest(
|
||||
"http://localhost/api/import/apple-health-export",
|
||||
{
|
||||
method: "POST",
|
||||
headers,
|
||||
body: "stub",
|
||||
},
|
||||
);
|
||||
const res = await POST(req);
|
||||
expect(res.status).toBe(413);
|
||||
});
|
||||
@@ -101,11 +107,14 @@ describe("POST /api/import/apple-health-export", () => {
|
||||
it("returns 429 when the rate-limit window is exhausted", async () => {
|
||||
vi.mocked(getSession).mockResolvedValue(SESSION_OK as never);
|
||||
mocks.checkRateLimit.mockResolvedValueOnce({ allowed: false });
|
||||
const req = new NextRequest("http://localhost/api/import/apple-health-export", {
|
||||
method: "POST",
|
||||
headers: { "content-type": "multipart/form-data; boundary=---x" },
|
||||
body: "stub",
|
||||
});
|
||||
const req = new NextRequest(
|
||||
"http://localhost/api/import/apple-health-export",
|
||||
{
|
||||
method: "POST",
|
||||
headers: { "content-type": "multipart/form-data; boundary=---x" },
|
||||
body: "stub",
|
||||
},
|
||||
);
|
||||
const res = await POST(req);
|
||||
expect(res.status).toBe(429);
|
||||
});
|
||||
|
||||
@@ -174,9 +174,7 @@ describe("POST /api/import/csv — write loop + per-row envelope", () => {
|
||||
);
|
||||
|
||||
const res = await POST(
|
||||
csvRequest(
|
||||
[HEADER, "WEIGHT,80.5,kg,2026-05-01T08:00:00Z,,,"].join("\n"),
|
||||
),
|
||||
csvRequest([HEADER, "WEIGHT,80.5,kg,2026-05-01T08:00:00Z,,,"].join("\n")),
|
||||
);
|
||||
const body = (await res.json()) as CsvEnvelope;
|
||||
expect(body.data?.inserted).toBe(0);
|
||||
|
||||
@@ -125,7 +125,8 @@ export const POST = apiHandler(async (request: NextRequest) => {
|
||||
unit: m.unit,
|
||||
measuredAt: m.measuredAt,
|
||||
notes: m.notes ?? null,
|
||||
glucoseContext: (m.glucoseContext as GlucoseContext | undefined) ?? null,
|
||||
glucoseContext:
|
||||
(m.glucoseContext as GlucoseContext | undefined) ?? null,
|
||||
},
|
||||
create: {
|
||||
userId,
|
||||
@@ -136,7 +137,8 @@ export const POST = apiHandler(async (request: NextRequest) => {
|
||||
externalId: m.externalId,
|
||||
measuredAt: m.measuredAt,
|
||||
notes: m.notes ?? null,
|
||||
glucoseContext: (m.glucoseContext as GlucoseContext | undefined) ?? null,
|
||||
glucoseContext:
|
||||
(m.glucoseContext as GlucoseContext | undefined) ?? null,
|
||||
},
|
||||
select: { createdAt: true, updatedAt: true },
|
||||
});
|
||||
@@ -159,7 +161,8 @@ export const POST = apiHandler(async (request: NextRequest) => {
|
||||
source: "IMPORT",
|
||||
measuredAt: m.measuredAt,
|
||||
notes: m.notes ?? null,
|
||||
glucoseContext: (m.glucoseContext as GlucoseContext | undefined) ?? null,
|
||||
glucoseContext:
|
||||
(m.glucoseContext as GlucoseContext | undefined) ?? null,
|
||||
},
|
||||
});
|
||||
inserted++;
|
||||
@@ -232,7 +235,11 @@ export const POST = apiHandler(async (request: NextRequest) => {
|
||||
}
|
||||
const outcome = writeOutcome.get(r.line);
|
||||
if (outcome === "duplicate") {
|
||||
return { line: r.line, status: "skipped" as const, reason: "duplicate" };
|
||||
return {
|
||||
line: r.line,
|
||||
status: "skipped" as const,
|
||||
reason: "duplicate",
|
||||
};
|
||||
}
|
||||
if (outcome === "updated") {
|
||||
return { line: r.line, status: "updated" as const };
|
||||
|
||||
Reference in new issue
Block a user