From 72457ff7006c231787b9e1df725aeebb1e73ca9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dafydd=20Ll=C5=B7r=20Pearson?= Date: Mon, 20 May 2024 17:09:37 +0100 Subject: [PATCH] test: Hasura introspection tests --- .../tests/flow_status_history.test.js | 78 +++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 hasura.planx.uk/tests/flow_status_history.test.js diff --git a/hasura.planx.uk/tests/flow_status_history.test.js b/hasura.planx.uk/tests/flow_status_history.test.js new file mode 100644 index 0000000000..cee2e236d4 --- /dev/null +++ b/hasura.planx.uk/tests/flow_status_history.test.js @@ -0,0 +1,78 @@ +const { introspectAs } = require("./utils"); + +describe("flows status history", () => { + describe("public", () => { + let i; + beforeAll(async () => { + i = await introspectAs("public"); + }); + + test("cannot query flow_status_history", () => { + expect(i.queries).not.toContain("flow_status_history"); + }); + + test("cannot create, update, or delete flows or their associated operations", () => { + expect(i).toHaveNoMutationsFor("flow_status_history"); + }); + }); + + describe("admin", () => { + let i; + beforeAll(async () => { + i = await introspectAs("admin"); + }); + + test("has full access to flow_status_history", () => { + expect(i.queries).toContain("flow_status_history"); + expect(i.mutations).toContain("insert_flow_status_history"); + expect(i.mutations).toContain("insert_flow_status_history_one"); + expect(i.mutations).toContain("update_flow_status_history_by_pk"); + expect(i.mutations).toContain("delete_flow_status_history"); + }); + }); + + describe("platformAdmin", () => { + let i; + beforeAll(async () => { + i = await introspectAs("platformAdmin"); + }); + + test("cannot query flow_status_history", () => { + expect(i.queries).not.toContain("flow_status_history"); + }); + + test("cannot create, update, or delete flows or their associated operations", () => { + expect(i).toHaveNoMutationsFor("flow_status_history"); + }); + }); + + describe("teamEditor", () => { + let i; + beforeAll(async () => { + i = await introspectAs("teamEditor"); + }); + + test("cannot query flow_status_history", () => { + expect(i.queries).not.toContain("flow_status_history"); + }); + + test("cannot create, update, or delete flows or their associated operations", () => { + expect(i).toHaveNoMutationsFor("flow_status_history"); + }); + }); + + describe("api", () => { + let i; + beforeAll(async () => { + i = await introspectAs("api"); + }); + + test("cannot query flow_status_history", () => { + expect(i.queries).not.toContain("flow_status_history"); + }); + + test("cannot create, update, or delete flows or their associated operations", () => { + expect(i).toHaveNoMutationsFor("flow_status_history"); + }); + }); +});