diff --git a/js/src/apollo/utils.ts b/js/src/apollo/utils.ts index a7071218..838ff718 100644 --- a/js/src/apollo/utils.ts +++ b/js/src/apollo/utils.ts @@ -59,7 +59,7 @@ export const typePolicies: TypePolicies = { Event: { fields: { participants: paginatedLimitPagination(["roles"]), - commnents: pageLimitPagination(), + comments: pageLimitPagination(), relatedEvents: pageLimitPagination(), }, }, diff --git a/js/tests/unit/specs/components/Comment/CommentTree.spec.ts b/js/tests/unit/specs/components/Comment/CommentTree.spec.ts index 6c0568aa..d3c32adf 100644 --- a/js/tests/unit/specs/components/Comment/CommentTree.spec.ts +++ b/js/tests/unit/specs/components/Comment/CommentTree.spec.ts @@ -15,6 +15,7 @@ import { CommentModeration } from "@/types/enums"; import { IEvent } from "@/types/event.model"; import { eventCommentThreadsMock, + eventNoCommentThreadsMock, newCommentForEventMock, newCommentForEventResponse, } from "../../mocks/event"; @@ -35,7 +36,7 @@ const eventData = { }; describe("CommentTree", () => { let wrapper: Wrapper; - let mockClient: MockApolloClient; + let mockClient: MockApolloClient | null; let apolloProvider; let requestHandlers: Record; const cache = new InMemoryCache({ addTypename: false }); @@ -83,24 +84,10 @@ describe("CommentTree", () => { }); }; - it("renders an empty comment tree", async () => { - generateWrapper(); - - expect(wrapper.exists()).toBe(true); - expect(wrapper.find(".loading").text()).toBe("Loading comments…"); - - await wrapper.vm.$nextTick(); - await wrapper.vm.$nextTick(); // because of the - - expect(wrapper.find(".no-comments").text()).toBe("No comments yet"); - expect(wrapper.html()).toMatchSnapshot(); - }); - it("renders a comment tree with comments", async () => { generateWrapper(); - await wrapper.vm.$nextTick(); - await wrapper.vm.$nextTick(); // because of the + await flushPromises(); expect(wrapper.exists()).toBe(true); expect( @@ -150,4 +137,21 @@ describe("CommentTree", () => { } } }); + + it("renders an empty comment tree", async () => { + generateWrapper({ + eventCommentThreadsQueryHandler: jest + .fn() + .mockResolvedValue(eventNoCommentThreadsMock), + }); + expect(requestHandlers.eventCommentThreadsQueryHandler).toHaveBeenCalled(); + + expect(wrapper.exists()).toBe(true); + expect(wrapper.find(".loading").text()).toBe("Loading comments…"); + + await flushPromises(); + + expect(wrapper.find(".no-comments").text()).toBe("No comments yet"); + expect(wrapper.html()).toMatchSnapshot(); + }); }); diff --git a/js/tests/unit/specs/components/Comment/__snapshots__/CommentTree.spec.ts.snap b/js/tests/unit/specs/components/Comment/__snapshots__/CommentTree.spec.ts.snap index e8311c62..63520cf4 100644 --- a/js/tests/unit/specs/components/Comment/__snapshots__/CommentTree.spec.ts.snap +++ b/js/tests/unit/specs/components/Comment/__snapshots__/CommentTree.spec.ts.snap @@ -2,25 +2,62 @@ exports[`CommentTree renders a comment tree with comments 1`] = `
- +
+ +
+
+ +
+
+
+
+

+ +

+ +
+ +
+
+
+ +
+
+
-
No comments yet
`; exports[`CommentTree renders an empty comment tree 1`] = `
- +
+ +
+
+ +
+
+
+
+

+ +

+ +
+ +
+
+
+ +
+
+
- - - -
No comments yet
diff --git a/js/tests/unit/specs/mocks/event.ts b/js/tests/unit/specs/mocks/event.ts index 55c3dc42..39f37708 100644 --- a/js/tests/unit/specs/mocks/event.ts +++ b/js/tests/unit/specs/mocks/event.ts @@ -63,6 +63,17 @@ export const joinEventMock = { locale: "en_US", }; +export const eventNoCommentThreadsMock = { + data: { + event: { + __typename: "Event", + id: "1", + uuid: "f37910ea-fd5a-4756-9679-00971f3f4106", + comments: [], + }, + }, +}; + export const eventCommentThreadsMock = { data: { event: {