Fix js unit tests
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
parent
ca14745d40
commit
1a43bfb620
@ -37,7 +37,7 @@ describe("CommentTree", () => {
|
|||||||
let requestHandlers: Record<string, RequestHandler>;
|
let requestHandlers: Record<string, RequestHandler>;
|
||||||
|
|
||||||
const generateWrapper = (handlers = {}, baseData = {}) => {
|
const generateWrapper = (handlers = {}, baseData = {}) => {
|
||||||
const cache = new InMemoryCache({ addTypename: false });
|
const cache = new InMemoryCache({ addTypename: true });
|
||||||
|
|
||||||
mockClient = createMockClient({
|
mockClient = createMockClient({
|
||||||
cache,
|
cache,
|
||||||
@ -88,10 +88,13 @@ describe("CommentTree", () => {
|
|||||||
it("renders a comment tree", async () => {
|
it("renders a comment tree", async () => {
|
||||||
generateWrapper();
|
generateWrapper();
|
||||||
|
|
||||||
expect(wrapper.findComponent({ name: "b-notification" }).text()).toBe(
|
expect(wrapper.exists()).toBe(true);
|
||||||
"The organiser has chosen to close comments."
|
|
||||||
);
|
|
||||||
expect(wrapper.find(".loading").text()).toBe("Loading comments…");
|
expect(wrapper.find(".loading").text()).toBe("Loading comments…");
|
||||||
|
|
||||||
|
await wrapper.vm.$nextTick();
|
||||||
|
await wrapper.vm.$nextTick(); // because of the <transition>
|
||||||
|
|
||||||
|
expect(wrapper.find(".no-comments").text()).toBe("No comments yet");
|
||||||
expect(wrapper.html()).toMatchSnapshot();
|
expect(wrapper.html()).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -2,21 +2,26 @@
|
|||||||
|
|
||||||
exports[`CommentTree renders a comment tree 1`] = `
|
exports[`CommentTree renders a comment tree 1`] = `
|
||||||
<div>
|
<div>
|
||||||
<b-notification-stub active="true" duration="2000" animation="fade">The organiser has chosen to close comments.</b-notification-stub>
|
<!---->
|
||||||
<p class="loading has-text-centered">
|
|
||||||
Loading comments…
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`CommentTree renders a comment tree 2`] = `
|
|
||||||
<div>
|
|
||||||
<b-notification-stub active="true" duration="2000" animation="fade">The organiser has chosen to close comments.</b-notification-stub>
|
|
||||||
<transition-stub name="comment-empty-list" mode="out-in">
|
<transition-stub name="comment-empty-list" mode="out-in">
|
||||||
<transition-group-stub tag="ul" name="comment-list" class="comment-list">
|
<transition-group-stub tag="ul" name="comment-list" class="comment-list">
|
||||||
<comment-stub comment="[object Object]" event="[object Object]" class="root-comment"></comment-stub>
|
<comment-stub comment="[object Object]" event="[object Object]" class="root-comment"></comment-stub>
|
||||||
<comment-stub comment="[object Object]" event="[object Object]" class="root-comment"></comment-stub>
|
<comment-stub comment="[object Object]" event="[object Object]" class="root-comment"></comment-stub>
|
||||||
</transition-group-stub>
|
</transition-group-stub>
|
||||||
|
<div class="no-comments"><span>No comments yet</span></div>
|
||||||
|
</transition-stub>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`CommentTree renders a comment tree 2`] = `
|
||||||
|
<div>
|
||||||
|
<!---->
|
||||||
|
<transition-stub name="comment-empty-list" mode="out-in">
|
||||||
|
<transition-group-stub tag="ul" name="comment-list" class="comment-list">
|
||||||
|
<comment-stub comment="[object Object]" event="[object Object]" class="root-comment"></comment-stub>
|
||||||
|
<comment-stub comment="[object Object]" event="[object Object]" class="root-comment"></comment-stub>
|
||||||
|
</transition-group-stub>
|
||||||
|
<div class="no-comments"><span>No comments yet</span></div>
|
||||||
</transition-stub>
|
</transition-stub>
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
|
@ -42,7 +42,7 @@ describe("ParticipationSection", () => {
|
|||||||
customProps: Record<string, unknown> = {},
|
customProps: Record<string, unknown> = {},
|
||||||
baseData: Record<string, unknown> = {}
|
baseData: Record<string, unknown> = {}
|
||||||
) => {
|
) => {
|
||||||
const cache = new InMemoryCache({ addTypename: false });
|
const cache = new InMemoryCache({ addTypename: true });
|
||||||
|
|
||||||
mockClient = createMockClient({
|
mockClient = createMockClient({
|
||||||
cache,
|
cache,
|
||||||
|
@ -65,7 +65,7 @@ describe("ParticipationWithoutAccount", () => {
|
|||||||
customProps: Record<string, unknown> = {},
|
customProps: Record<string, unknown> = {},
|
||||||
baseData: Record<string, unknown> = {}
|
baseData: Record<string, unknown> = {}
|
||||||
) => {
|
) => {
|
||||||
const cache = new InMemoryCache({ addTypename: false });
|
const cache = new InMemoryCache({ addTypename: true });
|
||||||
|
|
||||||
mockClient = createMockClient({
|
mockClient = createMockClient({
|
||||||
cache,
|
cache,
|
||||||
|
@ -25,7 +25,7 @@ describe("App component", () => {
|
|||||||
let requestHandlers: Record<string, RequestHandler>;
|
let requestHandlers: Record<string, RequestHandler>;
|
||||||
|
|
||||||
const createComponent = (handlers = {}, baseData = {}) => {
|
const createComponent = (handlers = {}, baseData = {}) => {
|
||||||
const cache = new InMemoryCache({ addTypename: false });
|
const cache = new InMemoryCache({ addTypename: true });
|
||||||
|
|
||||||
mockClient = createMockClient({
|
mockClient = createMockClient({
|
||||||
cache,
|
cache,
|
||||||
|
@ -1,37 +1,49 @@
|
|||||||
export const configMock = {
|
export const configMock = {
|
||||||
data: {
|
data: {
|
||||||
config: {
|
config: {
|
||||||
|
__typename: "Config",
|
||||||
anonymous: {
|
anonymous: {
|
||||||
|
__typename: "Anonymous",
|
||||||
actorId: "1",
|
actorId: "1",
|
||||||
eventCreation: {
|
eventCreation: {
|
||||||
|
__typename: "AnonymousEventCreation",
|
||||||
allowed: false,
|
allowed: false,
|
||||||
validation: {
|
validation: {
|
||||||
|
__typename: "AnonymousEventCreationValidation",
|
||||||
captcha: {
|
captcha: {
|
||||||
|
__typename: "AnonymousEventCreationValidationCaptcha",
|
||||||
enabled: false,
|
enabled: false,
|
||||||
},
|
},
|
||||||
email: {
|
email: {
|
||||||
|
__typename: "AnonymousEventCreationValidationEmail",
|
||||||
confirmationRequired: true,
|
confirmationRequired: true,
|
||||||
enabled: true,
|
enabled: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
participation: {
|
participation: {
|
||||||
|
__typename: "AnonymousParticipation",
|
||||||
allowed: true,
|
allowed: true,
|
||||||
validation: {
|
validation: {
|
||||||
|
__typename: "AnonymousParticipationValidation",
|
||||||
captcha: {
|
captcha: {
|
||||||
|
__typename: "AnonymousParticipationValidationCaptcha",
|
||||||
enabled: false,
|
enabled: false,
|
||||||
},
|
},
|
||||||
email: {
|
email: {
|
||||||
|
__typename: "AnonymousParticipationValidationEmail",
|
||||||
confirmationRequired: true,
|
confirmationRequired: true,
|
||||||
enabled: true,
|
enabled: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
reports: {
|
reports: {
|
||||||
|
__typename: "AnonymousReports",
|
||||||
allowed: false,
|
allowed: false,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
auth: {
|
auth: {
|
||||||
|
__typename: "Auth",
|
||||||
ldap: false,
|
ldap: false,
|
||||||
oauthProviders: [],
|
oauthProviders: [],
|
||||||
},
|
},
|
||||||
@ -39,24 +51,30 @@ export const configMock = {
|
|||||||
demoMode: false,
|
demoMode: false,
|
||||||
description: "Mobilizon.fr est l'instance Mobilizon de Framasoft.",
|
description: "Mobilizon.fr est l'instance Mobilizon de Framasoft.",
|
||||||
features: {
|
features: {
|
||||||
|
__typename: "Features",
|
||||||
eventCreation: true,
|
eventCreation: true,
|
||||||
groups: true,
|
groups: true,
|
||||||
},
|
},
|
||||||
geocoding: {
|
geocoding: {
|
||||||
|
__typename: "Geocoding",
|
||||||
autocomplete: true,
|
autocomplete: true,
|
||||||
provider: "Elixir.Mobilizon.Service.Geospatial.Pelias",
|
provider: "Elixir.Mobilizon.Service.Geospatial.Pelias",
|
||||||
},
|
},
|
||||||
languages: ["fr"],
|
languages: ["fr"],
|
||||||
location: {
|
location: {
|
||||||
|
__typename: "Lonlat",
|
||||||
latitude: 48.8717,
|
latitude: 48.8717,
|
||||||
longitude: 2.32075,
|
longitude: 2.32075,
|
||||||
},
|
},
|
||||||
maps: {
|
maps: {
|
||||||
|
__typename: "Maps",
|
||||||
tiles: {
|
tiles: {
|
||||||
|
__typename: "Tiles",
|
||||||
attribution: "© The OpenStreetMap Contributors",
|
attribution: "© The OpenStreetMap Contributors",
|
||||||
endpoint: "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",
|
endpoint: "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",
|
||||||
},
|
},
|
||||||
routing: {
|
routing: {
|
||||||
|
__typename: "Routing",
|
||||||
type: "OPENSTREETMAP",
|
type: "OPENSTREETMAP",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -65,16 +83,19 @@ export const configMock = {
|
|||||||
registrationsOpen: true,
|
registrationsOpen: true,
|
||||||
resourceProviders: [
|
resourceProviders: [
|
||||||
{
|
{
|
||||||
|
__typename: "ResourceProvider",
|
||||||
endpoint: "https://lite.framacalc.org/",
|
endpoint: "https://lite.framacalc.org/",
|
||||||
software: "calc",
|
software: "calc",
|
||||||
type: "ethercalc",
|
type: "ethercalc",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
__typename: "ResourceProvider",
|
||||||
endpoint: "https://hebdo.framapad.org/p/",
|
endpoint: "https://hebdo.framapad.org/p/",
|
||||||
software: "pad",
|
software: "pad",
|
||||||
type: "etherpad",
|
type: "etherpad",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
__typename: "ResourceProvider",
|
||||||
endpoint: "https://framatalk.org/",
|
endpoint: "https://framatalk.org/",
|
||||||
software: "visio",
|
software: "visio",
|
||||||
type: "jitsi",
|
type: "jitsi",
|
||||||
|
@ -12,6 +12,7 @@ export const fetchEventBasicMock = {
|
|||||||
uuid: "f37910ea-fd5a-4756-9679-00971f3f4106",
|
uuid: "f37910ea-fd5a-4756-9679-00971f3f4106",
|
||||||
joinOptions: EventJoinOptions.FREE,
|
joinOptions: EventJoinOptions.FREE,
|
||||||
participantStats: {
|
participantStats: {
|
||||||
|
__typename: "ParticipantStats",
|
||||||
notApproved: 0,
|
notApproved: 0,
|
||||||
notConfirmed: 0,
|
notConfirmed: 0,
|
||||||
rejected: 0,
|
rejected: 0,
|
||||||
@ -28,18 +29,26 @@ export const fetchEventBasicMock = {
|
|||||||
export const joinEventResponseMock = {
|
export const joinEventResponseMock = {
|
||||||
data: {
|
data: {
|
||||||
joinEvent: {
|
joinEvent: {
|
||||||
|
__typename: "Participant",
|
||||||
id: "5",
|
id: "5",
|
||||||
role: ParticipantRole.NOT_APPROVED,
|
role: ParticipantRole.NOT_APPROVED,
|
||||||
insertedAt: "2020-12-07T09:33:41Z",
|
insertedAt: "2020-12-07T09:33:41Z",
|
||||||
metadata: {
|
metadata: {
|
||||||
|
__typename: "ParticipantMetadata",
|
||||||
cancellationToken: "some token",
|
cancellationToken: "some token",
|
||||||
message: "a message long enough",
|
message: "a message long enough",
|
||||||
},
|
},
|
||||||
event: {
|
event: {
|
||||||
|
__typename: "Event",
|
||||||
id: "1",
|
id: "1",
|
||||||
uuid: "f37910ea-fd5a-4756-9679-00971f3f4106",
|
uuid: "f37910ea-fd5a-4756-9679-00971f3f4106",
|
||||||
},
|
},
|
||||||
actor: {
|
actor: {
|
||||||
|
__typename: "Person",
|
||||||
|
preferredUsername: "some_actor",
|
||||||
|
name: "Some actor",
|
||||||
|
avatar: null,
|
||||||
|
domain: null,
|
||||||
id: "1",
|
id: "1",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -73,7 +82,9 @@ export const eventCommentThreadsMock = {
|
|||||||
totalReplies: 5,
|
totalReplies: 5,
|
||||||
updatedAt: "2020-12-03T09:02:00Z",
|
updatedAt: "2020-12-03T09:02:00Z",
|
||||||
actor: {
|
actor: {
|
||||||
|
__typename: "Person",
|
||||||
avatar: {
|
avatar: {
|
||||||
|
__typename: "Media",
|
||||||
id: "78",
|
id: "78",
|
||||||
url: "http://someavatar.url.me",
|
url: "http://someavatar.url.me",
|
||||||
},
|
},
|
||||||
@ -97,7 +108,9 @@ export const eventCommentThreadsMock = {
|
|||||||
totalReplies: 0,
|
totalReplies: 0,
|
||||||
updatedAt: "2020-12-03T11:02:00Z",
|
updatedAt: "2020-12-03T11:02:00Z",
|
||||||
actor: {
|
actor: {
|
||||||
|
__typename: "Person",
|
||||||
avatar: {
|
avatar: {
|
||||||
|
__typename: "Media",
|
||||||
id: "78",
|
id: "78",
|
||||||
url: "http://someavatar.url.me",
|
url: "http://someavatar.url.me",
|
||||||
},
|
},
|
||||||
@ -123,6 +136,7 @@ export const newCommentForEventMock = {
|
|||||||
export const newCommentForEventResponse: DataMock = {
|
export const newCommentForEventResponse: DataMock = {
|
||||||
data: {
|
data: {
|
||||||
createComment: {
|
createComment: {
|
||||||
|
__typename: "Comment",
|
||||||
id: "79",
|
id: "79",
|
||||||
uuid: "e37910ea-fd5a-4756-9679-01171f3f4444",
|
uuid: "e37910ea-fd5a-4756-9679-01171f3f4444",
|
||||||
url:
|
url:
|
||||||
@ -134,8 +148,11 @@ export const newCommentForEventResponse: DataMock = {
|
|||||||
updatedAt: "2020-12-03T13:02:00Z",
|
updatedAt: "2020-12-03T13:02:00Z",
|
||||||
originComment: null,
|
originComment: null,
|
||||||
inReplyToComment: null,
|
inReplyToComment: null,
|
||||||
|
replies: [],
|
||||||
actor: {
|
actor: {
|
||||||
|
__typename: "Person",
|
||||||
avatar: {
|
avatar: {
|
||||||
|
__typename: "Media",
|
||||||
id: "78",
|
id: "78",
|
||||||
url: "http://someavatar.url.me",
|
url: "http://someavatar.url.me",
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user