mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-15 23:12:04 +00:00
test(export): integration test points at the new plain-segment endpoints
The integration suite that landed in commit 226cac4 still imported
the dotted-segment routes (`@/app/api/export/measurements.csv/route`)
that vitest can't resolve. Realign the import paths and request URLs
to the actually-shipped `/api/export/{kind}` segments. 9 tests pass.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
6520ae4e0f
commit
830b2b0c6b
1 file changed
+27
-28
@@ -2,10 +2,10 @@
|
|||||||
* Integration regression guard for the per-type export endpoints
|
* Integration regression guard for the per-type export endpoints
|
||||||
* (v1.4.16 phase B7):
|
* (v1.4.16 phase B7):
|
||||||
*
|
*
|
||||||
* GET /api/export/measurements.csv
|
* GET /api/export/measurements
|
||||||
* GET /api/export/medications.csv
|
* GET /api/export/medications
|
||||||
* GET /api/export/mood.csv
|
* GET /api/export/mood
|
||||||
* GET /api/export/full-backup.json
|
* GET /api/export/full-backup
|
||||||
*
|
*
|
||||||
* Each endpoint:
|
* Each endpoint:
|
||||||
* 1. Is gated by `requireAuth()`.
|
* 1. Is gated by `requireAuth()`.
|
||||||
@@ -73,11 +73,11 @@ async function seedUserSession(username = "export-user") {
|
|||||||
return user;
|
return user;
|
||||||
}
|
}
|
||||||
|
|
||||||
describe("GET /api/export/measurements.csv", () => {
|
describe("GET /api/export/measurements", () => {
|
||||||
it("returns 401 without a session", async () => {
|
it("returns 401 without a session", async () => {
|
||||||
const { GET } = await import("@/app/api/export/measurements.csv/route");
|
const { GET } = await import("@/app/api/export/measurements/route");
|
||||||
const res = await GET(
|
const res = await GET(
|
||||||
new Request("http://localhost/api/export/measurements.csv", {
|
new Request("http://localhost/api/export/measurements", {
|
||||||
method: "GET",
|
method: "GET",
|
||||||
}) as Parameters<typeof GET>[0],
|
}) as Parameters<typeof GET>[0],
|
||||||
);
|
);
|
||||||
@@ -116,9 +116,9 @@ describe("GET /api/export/measurements.csv", () => {
|
|||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
const { GET } = await import("@/app/api/export/measurements.csv/route");
|
const { GET } = await import("@/app/api/export/measurements/route");
|
||||||
const res = await GET(
|
const res = await GET(
|
||||||
new Request("http://localhost/api/export/measurements.csv", {
|
new Request("http://localhost/api/export/measurements", {
|
||||||
method: "GET",
|
method: "GET",
|
||||||
}) as Parameters<typeof GET>[0],
|
}) as Parameters<typeof GET>[0],
|
||||||
);
|
);
|
||||||
@@ -140,11 +140,11 @@ describe("GET /api/export/measurements.csv", () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("GET /api/export/medications.csv", () => {
|
describe("GET /api/export/medications", () => {
|
||||||
it("returns 401 without a session", async () => {
|
it("returns 401 without a session", async () => {
|
||||||
const { GET } = await import("@/app/api/export/medications.csv/route");
|
const { GET } = await import("@/app/api/export/medications/route");
|
||||||
const res = await GET(
|
const res = await GET(
|
||||||
new Request("http://localhost/api/export/medications.csv", {
|
new Request("http://localhost/api/export/medications", {
|
||||||
method: "GET",
|
method: "GET",
|
||||||
}) as Parameters<typeof GET>[0],
|
}) as Parameters<typeof GET>[0],
|
||||||
);
|
);
|
||||||
@@ -174,9 +174,9 @@ describe("GET /api/export/medications.csv", () => {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const { GET } = await import("@/app/api/export/medications.csv/route");
|
const { GET } = await import("@/app/api/export/medications/route");
|
||||||
const res = await GET(
|
const res = await GET(
|
||||||
new Request("http://localhost/api/export/medications.csv", {
|
new Request("http://localhost/api/export/medications", {
|
||||||
method: "GET",
|
method: "GET",
|
||||||
}) as Parameters<typeof GET>[0],
|
}) as Parameters<typeof GET>[0],
|
||||||
);
|
);
|
||||||
@@ -204,9 +204,9 @@ describe("GET /api/export/medications.csv", () => {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const { GET } = await import("@/app/api/export/medications.csv/route");
|
const { GET } = await import("@/app/api/export/medications/route");
|
||||||
const res = await GET(
|
const res = await GET(
|
||||||
new Request("http://localhost/api/export/medications.csv?intake=false", {
|
new Request("http://localhost/api/export/medications?intake=false", {
|
||||||
method: "GET",
|
method: "GET",
|
||||||
}) as Parameters<typeof GET>[0],
|
}) as Parameters<typeof GET>[0],
|
||||||
);
|
);
|
||||||
@@ -217,11 +217,11 @@ describe("GET /api/export/medications.csv", () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("GET /api/export/mood.csv", () => {
|
describe("GET /api/export/mood", () => {
|
||||||
it("returns 401 without a session", async () => {
|
it("returns 401 without a session", async () => {
|
||||||
const { GET } = await import("@/app/api/export/mood.csv/route");
|
const { GET } = await import("@/app/api/export/mood/route");
|
||||||
const res = await GET(
|
const res = await GET(
|
||||||
new Request("http://localhost/api/export/mood.csv", {
|
new Request("http://localhost/api/export/mood", {
|
||||||
method: "GET",
|
method: "GET",
|
||||||
}) as Parameters<typeof GET>[0],
|
}) as Parameters<typeof GET>[0],
|
||||||
);
|
);
|
||||||
@@ -237,16 +237,15 @@ describe("GET /api/export/mood.csv", () => {
|
|||||||
date: "2026-05-01",
|
date: "2026-05-01",
|
||||||
mood: "good",
|
mood: "good",
|
||||||
score: 4,
|
score: 4,
|
||||||
// MoodEntry.source is a plain string column; "WEB" matches the
|
// MoodEntry.source is a plain string column.
|
||||||
// values the rest of the suite uses.
|
|
||||||
source: "WEB",
|
source: "WEB",
|
||||||
moodLoggedAt: new Date("2026-05-01T20:00:00.000Z"),
|
moodLoggedAt: new Date("2026-05-01T20:00:00.000Z"),
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const { GET } = await import("@/app/api/export/mood.csv/route");
|
const { GET } = await import("@/app/api/export/mood/route");
|
||||||
const res = await GET(
|
const res = await GET(
|
||||||
new Request("http://localhost/api/export/mood.csv", {
|
new Request("http://localhost/api/export/mood", {
|
||||||
method: "GET",
|
method: "GET",
|
||||||
}) as Parameters<typeof GET>[0],
|
}) as Parameters<typeof GET>[0],
|
||||||
);
|
);
|
||||||
@@ -263,11 +262,11 @@ describe("GET /api/export/mood.csv", () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("GET /api/export/full-backup.json", () => {
|
describe("GET /api/export/full-backup", () => {
|
||||||
it("returns 401 without a session", async () => {
|
it("returns 401 without a session", async () => {
|
||||||
const { GET } = await import("@/app/api/export/full-backup.json/route");
|
const { GET } = await import("@/app/api/export/full-backup/route");
|
||||||
const res = await GET(
|
const res = await GET(
|
||||||
new Request("http://localhost/api/export/full-backup.json", {
|
new Request("http://localhost/api/export/full-backup", {
|
||||||
method: "GET",
|
method: "GET",
|
||||||
}) as Parameters<typeof GET>[0],
|
}) as Parameters<typeof GET>[0],
|
||||||
);
|
);
|
||||||
@@ -300,9 +299,9 @@ describe("GET /api/export/full-backup.json", () => {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const { GET } = await import("@/app/api/export/full-backup.json/route");
|
const { GET } = await import("@/app/api/export/full-backup/route");
|
||||||
const res = await GET(
|
const res = await GET(
|
||||||
new Request("http://localhost/api/export/full-backup.json", {
|
new Request("http://localhost/api/export/full-backup", {
|
||||||
method: "GET",
|
method: "GET",
|
||||||
}) as Parameters<typeof GET>[0],
|
}) as Parameters<typeof GET>[0],
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in new issue
Block a user