diff --git a/js/tests/unit/specs/components/Comment/CommentTree.spec.ts b/js/tests/unit/specs/components/Comment/CommentTree.spec.ts index 8706f02ef..44d1b635b 100644 --- a/js/tests/unit/specs/components/Comment/CommentTree.spec.ts +++ b/js/tests/unit/specs/components/Comment/CommentTree.spec.ts @@ -37,7 +37,7 @@ describe("CommentTree", () => { let requestHandlers: Record; const generateWrapper = (handlers = {}, baseData = {}) => { - const cache = new InMemoryCache({ addTypename: false }); + const cache = new InMemoryCache({ addTypename: true }); mockClient = createMockClient({ cache, @@ -88,10 +88,13 @@ describe("CommentTree", () => { it("renders a comment tree", async () => { generateWrapper(); - expect(wrapper.findComponent({ name: "b-notification" }).text()).toBe( - "The organiser has chosen to close comments." - ); + 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(); }); 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 48a66f29d..6754048a5 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,21 +2,26 @@ exports[`CommentTree renders a comment tree 1`] = `
- The organiser has chosen to close comments. -

- Loading comments… -

-
-`; - -exports[`CommentTree renders a comment tree 2`] = ` -
- The organiser has chosen to close comments. + +
No comments yet
+
+
+`; + +exports[`CommentTree renders a comment tree 2`] = ` +
+ + + + + + +
No comments yet
`; diff --git a/js/tests/unit/specs/components/Participation/ParticipationSection.spec.ts b/js/tests/unit/specs/components/Participation/ParticipationSection.spec.ts index 2d6eb7657..2b20839bb 100644 --- a/js/tests/unit/specs/components/Participation/ParticipationSection.spec.ts +++ b/js/tests/unit/specs/components/Participation/ParticipationSection.spec.ts @@ -42,7 +42,7 @@ describe("ParticipationSection", () => { customProps: Record = {}, baseData: Record = {} ) => { - const cache = new InMemoryCache({ addTypename: false }); + const cache = new InMemoryCache({ addTypename: true }); mockClient = createMockClient({ cache, diff --git a/js/tests/unit/specs/components/Participation/ParticipationWithoutAccount.spec.ts b/js/tests/unit/specs/components/Participation/ParticipationWithoutAccount.spec.ts index f69fa7009..5c7923183 100644 --- a/js/tests/unit/specs/components/Participation/ParticipationWithoutAccount.spec.ts +++ b/js/tests/unit/specs/components/Participation/ParticipationWithoutAccount.spec.ts @@ -65,7 +65,7 @@ describe("ParticipationWithoutAccount", () => { customProps: Record = {}, baseData: Record = {} ) => { - const cache = new InMemoryCache({ addTypename: false }); + const cache = new InMemoryCache({ addTypename: true }); mockClient = createMockClient({ cache, diff --git a/js/tests/unit/specs/components/navbar.spec.ts b/js/tests/unit/specs/components/navbar.spec.ts index b96fa4124..f2123eed1 100644 --- a/js/tests/unit/specs/components/navbar.spec.ts +++ b/js/tests/unit/specs/components/navbar.spec.ts @@ -25,7 +25,7 @@ describe("App component", () => { let requestHandlers: Record; const createComponent = (handlers = {}, baseData = {}) => { - const cache = new InMemoryCache({ addTypename: false }); + const cache = new InMemoryCache({ addTypename: true }); mockClient = createMockClient({ cache, diff --git a/js/tests/unit/specs/mocks/config.ts b/js/tests/unit/specs/mocks/config.ts index 271d71ce3..856288302 100644 --- a/js/tests/unit/specs/mocks/config.ts +++ b/js/tests/unit/specs/mocks/config.ts @@ -1,37 +1,49 @@ export const configMock = { data: { config: { + __typename: "Config", anonymous: { + __typename: "Anonymous", actorId: "1", eventCreation: { + __typename: "AnonymousEventCreation", allowed: false, validation: { + __typename: "AnonymousEventCreationValidation", captcha: { + __typename: "AnonymousEventCreationValidationCaptcha", enabled: false, }, email: { + __typename: "AnonymousEventCreationValidationEmail", confirmationRequired: true, enabled: true, }, }, }, participation: { + __typename: "AnonymousParticipation", allowed: true, validation: { + __typename: "AnonymousParticipationValidation", captcha: { + __typename: "AnonymousParticipationValidationCaptcha", enabled: false, }, email: { + __typename: "AnonymousParticipationValidationEmail", confirmationRequired: true, enabled: true, }, }, }, reports: { + __typename: "AnonymousReports", allowed: false, }, }, auth: { + __typename: "Auth", ldap: false, oauthProviders: [], }, @@ -39,24 +51,30 @@ export const configMock = { demoMode: false, description: "Mobilizon.fr est l'instance Mobilizon de Framasoft.", features: { + __typename: "Features", eventCreation: true, groups: true, }, geocoding: { + __typename: "Geocoding", autocomplete: true, provider: "Elixir.Mobilizon.Service.Geospatial.Pelias", }, languages: ["fr"], location: { + __typename: "Lonlat", latitude: 48.8717, longitude: 2.32075, }, maps: { + __typename: "Maps", tiles: { + __typename: "Tiles", attribution: "© The OpenStreetMap Contributors", endpoint: "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", }, routing: { + __typename: "Routing", type: "OPENSTREETMAP", }, }, @@ -65,16 +83,19 @@ export const configMock = { registrationsOpen: true, resourceProviders: [ { + __typename: "ResourceProvider", endpoint: "https://lite.framacalc.org/", software: "calc", type: "ethercalc", }, { + __typename: "ResourceProvider", endpoint: "https://hebdo.framapad.org/p/", software: "pad", type: "etherpad", }, { + __typename: "ResourceProvider", endpoint: "https://framatalk.org/", software: "visio", type: "jitsi", diff --git a/js/tests/unit/specs/mocks/event.ts b/js/tests/unit/specs/mocks/event.ts index 5c284b037..5d74e8a8b 100644 --- a/js/tests/unit/specs/mocks/event.ts +++ b/js/tests/unit/specs/mocks/event.ts @@ -12,6 +12,7 @@ export const fetchEventBasicMock = { uuid: "f37910ea-fd5a-4756-9679-00971f3f4106", joinOptions: EventJoinOptions.FREE, participantStats: { + __typename: "ParticipantStats", notApproved: 0, notConfirmed: 0, rejected: 0, @@ -28,18 +29,26 @@ export const fetchEventBasicMock = { export const joinEventResponseMock = { data: { joinEvent: { + __typename: "Participant", id: "5", role: ParticipantRole.NOT_APPROVED, insertedAt: "2020-12-07T09:33:41Z", metadata: { + __typename: "ParticipantMetadata", cancellationToken: "some token", message: "a message long enough", }, event: { + __typename: "Event", id: "1", uuid: "f37910ea-fd5a-4756-9679-00971f3f4106", }, actor: { + __typename: "Person", + preferredUsername: "some_actor", + name: "Some actor", + avatar: null, + domain: null, id: "1", }, }, @@ -73,7 +82,9 @@ export const eventCommentThreadsMock = { totalReplies: 5, updatedAt: "2020-12-03T09:02:00Z", actor: { + __typename: "Person", avatar: { + __typename: "Media", id: "78", url: "http://someavatar.url.me", }, @@ -97,7 +108,9 @@ export const eventCommentThreadsMock = { totalReplies: 0, updatedAt: "2020-12-03T11:02:00Z", actor: { + __typename: "Person", avatar: { + __typename: "Media", id: "78", url: "http://someavatar.url.me", }, @@ -123,6 +136,7 @@ export const newCommentForEventMock = { export const newCommentForEventResponse: DataMock = { data: { createComment: { + __typename: "Comment", id: "79", uuid: "e37910ea-fd5a-4756-9679-01171f3f4444", url: @@ -134,8 +148,11 @@ export const newCommentForEventResponse: DataMock = { updatedAt: "2020-12-03T13:02:00Z", originComment: null, inReplyToComment: null, + replies: [], actor: { + __typename: "Person", avatar: { + __typename: "Media", id: "78", url: "http://someavatar.url.me", },