test(fhir): pin the search parameters the CapabilityStatement declares

The statement already declares `date` and `code` on Observation beside
paging on every search; the route test now asserts that list per resource,
so a parameter the search honours cannot drop out of it unnoticed.
This commit is contained in:
Marc-André Bombeck committed 2026-10-25 12:12:14 +01:00
1 parent d6bb7bc905
commit a57d2ffe83
1 file changed
+18
+18
View File
@@ -313,6 +313,9 @@ describe("GET /api/fhir/metadata", () => {
z.looseObject({
type: z.string(),
interaction: z.array(z.object({ code: z.string() })),
searchParam: z.array(
z.object({ name: z.string(), type: z.string() }),
),
operation: z.array(z.object({ name: z.string() })).optional(),
}),
),
@@ -330,6 +333,21 @@ describe("GET /api/fhir/metadata", () => {
expect(patient).toHaveLength(1);
expect(patient[0].operation?.map((o) => o.name)).toEqual(["everything"]);
// Paging on every search; the Observation search alone honours the
// time-series range and the code filter, and says so.
for (const resource of resources) {
expect(resource.searchParam, resource.type).toEqual([
{ name: "_count", type: "number" },
{ name: "_offset", type: "number" },
...(resource.type === "Observation"
? [
{ name: "date", type: "date" },
{ name: "code", type: "token" },
]
: []),
]);
}
const root = path.join(process.cwd(), "src/app/api/fhir");
for (const resource of resources) {
for (const { code } of resource.interaction) {