From 52f2595838cb0a12f2d29d026ec5905b83dbda0b Mon Sep 17 00:00:00 2001 From: sophiamersmann Date: Thu, 3 Oct 2024 09:22:40 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=85=20add=20db=20tests?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- adminSiteServer/app.test.tsx | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/adminSiteServer/app.test.tsx b/adminSiteServer/app.test.tsx index 37a32cfb374..26b3cdca948 100644 --- a/adminSiteServer/app.test.tsx +++ b/adminSiteServer/app.test.tsx @@ -776,4 +776,36 @@ describe("OwidAdminApp: indicator-level chart configs", () => { expect(configAfterUpdate).not.toBeNull() expect(chartAfterUpdate).toEqual(configAfterUpdate) }) + + it("should return an error if the schema is missing", async () => { + const invalidConfig = { + title: "Title", + // note that the $schema field is missing + } + const json = await makeRequestAgainstAdminApi( + { + method: "PUT", + path: `/variables/${variableId}/grapherConfigETL`, + body: JSON.stringify(invalidConfig), + }, + { verifySuccess: false } + ) + expect(json.success).toBe(false) + }) + + it("should return an error if the schema is invalid", async () => { + const invalidConfig = { + $schema: "invalid", // note that the $schema field is invalid + title: "Title", + } + const json = await makeRequestAgainstAdminApi( + { + method: "PUT", + path: `/variables/${variableId}/grapherConfigETL`, + body: JSON.stringify(invalidConfig), + }, + { verifySuccess: false } + ) + expect(json.success).toBe(false) + }) })