From 33a3e9b29f8b2867c74935dd1ca65ee77ec49787 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dafydd=20Ll=C5=B7r=20Pearson?= Date: Wed, 8 Nov 2023 18:42:37 +0000 Subject: [PATCH] fix: Analytics column permissions (#2403) * fix: Analytics column permissions * test: Fix Hasura tests --- hasura.planx.uk/metadata/tables.yaml | 9 +++++++++ hasura.planx.uk/tests/analytics.test.js | 14 ++++++++++---- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/hasura.planx.uk/metadata/tables.yaml b/hasura.planx.uk/metadata/tables.yaml index 08721faad7..92521ab7aa 100644 --- a/hasura.planx.uk/metadata/tables.yaml +++ b/hasura.planx.uk/metadata/tables.yaml @@ -18,6 +18,13 @@ columns: - id filter: {} + update_permissions: + - role: public + permission: + columns: + - ended_at + filter: {} + check: null - table: schema: public name: analytics_logs @@ -42,6 +49,7 @@ - analytics_id - created_at - id + - user_exit filter: {} update_permissions: - role: public @@ -51,6 +59,7 @@ - has_clicked_help - metadata - next_log_created_at + - user_exit filter: {} check: null - table: diff --git a/hasura.planx.uk/tests/analytics.test.js b/hasura.planx.uk/tests/analytics.test.js index 5147eb2a17..63b69a6d26 100644 --- a/hasura.planx.uk/tests/analytics.test.js +++ b/hasura.planx.uk/tests/analytics.test.js @@ -12,10 +12,16 @@ describe("analytics and analytics_logs", () => { expect(i.queries).toContain("analytics_logs"); }); - test("can create analytics but not update or delete them", () => { + test("can create analytics", () => { expect(i.mutations).toContain("insert_analytics_one"); - expect(i.mutations).not.toContain("update_analytics_by_pk"); - expect(i.mutations).not.toContain("update_analytics"); + }); + + test("can update analytics", () => { + expect(i.mutations).toContain("update_analytics_by_pk"); + expect(i.mutations).toContain("update_analytics"); + }); + + test("cannot delete analytics", () => { expect(i.mutations).not.toContain("delete_analytics"); expect(i.mutations).not.toContain("delete_analytics_by_pk"); }); @@ -25,7 +31,7 @@ describe("analytics and analytics_logs", () => { expect(i.mutations).toContain("update_analytics_logs_by_pk"); expect(i.mutations).not.toContain("delete_analytics_logs"); expect(i.mutations).not.toContain("delete_analytics_logs_by_pk"); - }) + }); }); describe("admin", () => {