Skip to content

Commit

Permalink
test: Add permission tests for team_themes table
Browse files Browse the repository at this point in the history
  • Loading branch information
DafyddLlyr committed Dec 22, 2023
1 parent 34a9f57 commit 1852600
Showing 1 changed file with 95 additions and 0 deletions.
95 changes: 95 additions & 0 deletions hasura.planx.uk/tests/team_themes.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
const { introspectAs } = require("./utils");

describe("team_themes", () => {
describe("public", () => {
let i;
beforeAll(async () => {
i = await introspectAs("public");
});

test("can query team_themes", () => {
expect(i.queries).toContain("team_themes");
});

test("cannot create, update, or delete team_themes", () => {
expect(i).toHaveNoMutationsFor("team_themes");
});
});

describe("admin", () => {
let i;
beforeAll(async () => {
i = await introspectAs("admin");
});

test("can query team_themes and team members", () => {
expect(i.queries).toContain("team_themes");
});
});

describe("platformAdmin", () => {
let i;
beforeAll(async () => {
i = await introspectAs("platformAdmin");
});

test("can query team_themes", () => {
expect(i.queries).toContain("team_themes");
});

test("cannot insert team_themes", () => {
expect(i.queries).not.toContain("insert_team_themes");
});

test("can query team_themes", async () => {
expect(i.queries).toContain("team_themes");
});

test("can mutate team_themes", async () => {
expect(i.mutations).toContain("update_team_themes");
expect(i.mutations).toContain("update_team_themes_by_pk");
});

test("cannot delete team_themes", async () => {
expect(i.mutations).not.toContain("delete_team_themes");
});
});

describe("teamEditor", () => {
beforeAll(async () => {
i = await introspectAs("teamEditor");
});

test("can query team_themes", () => {
expect(i.queries).toContain("team_themes");
});

test("can update team_themes", () => {
expect(i.mutations).toContain("update_team_themes");
expect(i.mutations).toContain("update_team_themes_by_pk");
});

test("cannot delete team_themes", async () => {
expect(i.mutations).not.toContain("delete_team_themes");
});

test("cannot insert team_themes", async () => {
expect(i.mutations).not.toContain("insert_team_themes");
});
});

describe("api", () => {
let i;
beforeAll(async () => {
i = await introspectAs("api");
});

test("can query team_themes", () => {
expect(i.queries).toContain("team_themes");
});

test("cannot create, update, or delete team_themes", () => {
expect(i).toHaveNoMutationsFor("team_themes");
});
});
});

0 comments on commit 1852600

Please sign in to comment.