From d1eaff9b2d4d13b526b2a19f07318aacaf284ed7 Mon Sep 17 00:00:00 2001 From: davelopez <46503462+davelopez@users.noreply.github.com> Date: Mon, 22 Jan 2024 16:39:38 +0100 Subject: [PATCH] Disable tag editing on non-owned Pages --- client/src/components/Page/PageList.test.js | 42 ++++++++++----------- client/src/components/Page/PageList.vue | 10 ++++- 2 files changed, 29 insertions(+), 23 deletions(-) diff --git a/client/src/components/Page/PageList.test.js b/client/src/components/Page/PageList.test.js index 7497cc6df93f..bfd0e945a21a 100644 --- a/client/src/components/Page/PageList.test.js +++ b/client/src/components/Page/PageList.test.js @@ -7,6 +7,7 @@ import flushPromises from "flush-promises"; import { PiniaVuePlugin } from "pinia"; import { createTestingPinia } from "@pinia/testing"; import { parseISO, formatDistanceToNow } from "date-fns"; +import { useUserStore } from "stores/userStore"; jest.mock("app"); @@ -95,13 +96,26 @@ describe("PgeList.vue", () => { const mockPublishedPageData = [publishedPage]; const mockTwoPageData = [privatePage, pageA]; - function mountPersonalGrid() { + function mountGrid(propsData) { + const pinia = createTestingPinia(); + const userStore = useUserStore(); + userStore.currentUser = { username: "jimmyPage", tags_used: [] }; + wrapper = mount(PageList, { - propsData: propsDataPersonalGrid, + propsData, localVue, + pinia, }); } + function mountPersonalGrid() { + mountGrid(propsDataPersonalGrid); + } + + function mountPublishedGrid() { + mountGrid(propsDataPublishedGrid); + } + describe(" with empty page list", () => { beforeEach(async () => { axiosMock.onAny().reply(200, [], { total_matches: "0" }); @@ -135,11 +149,7 @@ describe("PgeList.vue", () => { jest.spyOn(PageList.methods, "decorateData").mockImplementation((page) => { page.shared = false; }); - wrapper = mount(PageList, { - propsData: propsDataPersonalGrid, - localVue, - pinia: createTestingPinia(), - }); + mountPersonalGrid(); await flushPromises(); }); @@ -202,11 +212,7 @@ describe("PgeList.vue", () => { jest.spyOn(PageList.methods, "decorateData").mockImplementation((page) => { page.shared = true; }); - wrapper = mount(PageList, { - propsData: propsDataPersonalGrid, - localVue, - pinia: createTestingPinia(), - }); + mountPersonalGrid(); await flushPromises(); }); it("updates filter when published icon is clicked", async () => { @@ -241,11 +247,7 @@ describe("PgeList.vue", () => { jest.spyOn(PageList.methods, "decorateData").mockImplementation((page) => { page.shared = false; }); - wrapper = mount(PageList, { - propsData: propsDataPublishedGrid, - localVue, - pinia: createTestingPinia(), - }); + mountPublishedGrid(); await flushPromises(); }); @@ -282,11 +284,7 @@ describe("PgeList.vue", () => { jest.spyOn(PageList.methods, "decorateData").mockImplementation((page) => { page.shared = false; }); - wrapper = mount(PageList, { - propsData: propsDataPublishedGrid, - localVue, - pinia: createTestingPinia(), - }); + mountPublishedGrid(); await flushPromises(); }); diff --git a/client/src/components/Page/PageList.vue b/client/src/components/Page/PageList.vue index f801faf67208..39b0e756ffb1 100644 --- a/client/src/components/Page/PageList.vue +++ b/client/src/components/Page/PageList.vue @@ -37,7 +37,7 @@ @@ -80,6 +80,7 @@