decidim-comments 0.23.3 → 0.24.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/decidim/comments/bundle.js.map +1 -1
- data/app/assets/javascripts/decidim/comments/comments.component.js.es6 +292 -0
- data/app/assets/javascripts/decidim/comments/comments.component.test.js +581 -0
- data/app/assets/javascripts/decidim/comments/comments.js.erb +1 -1
- data/app/cells/decidim/comments/comment/actions.erb +7 -0
- data/app/cells/decidim/comments/comment/alignment_badge.erb +4 -0
- data/app/cells/decidim/comments/comment/author.erb +1 -0
- data/app/cells/decidim/comments/comment/show.erb +40 -0
- data/app/cells/decidim/comments/comment/utilities.erb +13 -0
- data/app/cells/decidim/comments/comment/votes.erb +25 -0
- data/app/cells/decidim/comments/comment_card_cell.rb +22 -0
- data/app/cells/decidim/comments/comment_cell.rb +142 -8
- data/app/cells/decidim/comments/comment_form/comment_as.erb +10 -0
- data/app/cells/decidim/comments/comment_form/show.erb +24 -0
- data/app/cells/decidim/comments/comment_form_cell.rb +94 -0
- data/app/cells/decidim/comments/comment_m/top.erb +1 -1
- data/app/cells/decidim/comments/comment_thread/show.erb +6 -0
- data/app/cells/decidim/comments/comment_thread/title.erb +3 -0
- data/app/cells/decidim/comments/comment_thread_cell.rb +30 -0
- data/app/cells/decidim/comments/comments/add_comment.erb +30 -0
- data/app/cells/decidim/comments/comments/blocked_comments_warning.erb +3 -0
- data/app/cells/decidim/comments/comments/order_control.erb +37 -0
- data/app/cells/decidim/comments/comments/show.erb +32 -0
- data/app/cells/decidim/comments/comments/single_comment_warning.erb +9 -0
- data/app/cells/decidim/comments/comments/user_comments_blocked_warning.erb +3 -0
- data/app/cells/decidim/comments/comments_cell.rb +134 -0
- data/app/commands/decidim/comments/vote_comment.rb +34 -10
- data/app/controllers/decidim/comments/application_controller.rb +16 -0
- data/app/controllers/decidim/comments/comments_controller.rb +122 -0
- data/app/controllers/decidim/comments/votes_controller.rb +41 -0
- data/app/events/decidim/comments/comment_created_event.rb +1 -1
- data/app/events/decidim/comments/comment_downvoted_event.rb +8 -0
- data/app/events/decidim/comments/comment_upvoted_event.rb +8 -0
- data/app/events/decidim/comments/comment_voted_event.rb +26 -0
- data/app/forms/decidim/comments/comment_form.rb +6 -2
- data/app/models/decidim/comments/comment.rb +22 -6
- data/app/models/decidim/comments/seed.rb +1 -1
- data/app/permissions/decidim/comments/permissions.rb +59 -0
- data/app/queries/decidim/comments/metrics/comment_participants_metric_measure.rb +2 -2
- data/app/queries/decidim/comments/metrics/comments_metric_manage.rb +5 -6
- data/app/queries/decidim/comments/sorted_comments.rb +18 -14
- data/app/views/decidim/comments/comments/_comment.html.erb +5 -0
- data/app/views/decidim/comments/comments/_comments.html.erb +1 -0
- data/app/views/decidim/comments/comments/create.js.erb +16 -0
- data/app/views/decidim/comments/comments/error.js.erb +1 -0
- data/app/views/decidim/comments/comments/index.js.erb +24 -0
- data/app/views/decidim/comments/comments/reload.js.erb +21 -0
- data/app/views/decidim/comments/votes/create.js.erb +23 -0
- data/app/views/decidim/comments/votes/error.js.erb +1 -0
- data/config/locales/ar.yml +0 -2
- data/config/locales/ca.yml +17 -2
- data/config/locales/cs.yml +24 -7
- data/config/locales/de.yml +17 -2
- data/config/locales/el.yml +0 -2
- data/config/locales/en.yml +17 -2
- data/config/locales/es-MX.yml +17 -2
- data/config/locales/es-PY.yml +17 -2
- data/config/locales/es.yml +17 -2
- data/config/locales/eu.yml +0 -2
- data/config/locales/fi-plain.yml +17 -2
- data/config/locales/fi.yml +17 -2
- data/config/locales/fr-CA.yml +17 -2
- data/config/locales/fr.yml +17 -2
- data/config/locales/gl.yml +7 -2
- data/config/locales/hu.yml +0 -2
- data/config/locales/id-ID.yml +0 -2
- data/config/locales/is-IS.yml +0 -1
- data/config/locales/it.yml +4 -2
- data/config/locales/ja.yml +8 -4
- data/config/locales/lv.yml +0 -2
- data/config/locales/nl.yml +0 -2
- data/config/locales/no.yml +0 -2
- data/config/locales/pl.yml +21 -4
- data/config/locales/pt-BR.yml +0 -2
- data/config/locales/pt.yml +0 -2
- data/config/locales/ro-RO.yml +19 -2
- data/config/locales/ru.yml +0 -2
- data/config/locales/sk.yml +0 -2
- data/config/locales/sv.yml +17 -2
- data/config/locales/tr-TR.yml +7 -2
- data/config/locales/uk.yml +0 -1
- data/config/locales/zh-CN.yml +0 -2
- data/lib/decidim/api/add_comment_type.rb +13 -0
- data/lib/decidim/api/comment_mutation_type.rb +22 -0
- data/lib/decidim/api/comment_type.rb +89 -0
- data/lib/decidim/api/commentable_interface.rb +50 -0
- data/lib/decidim/api/commentable_mutation_type.rb +30 -0
- data/{app/types/decidim/comments → lib/decidim/api}/commentable_type.rb +2 -5
- data/lib/decidim/comments.rb +1 -3
- data/lib/decidim/comments/api.rb +12 -0
- data/lib/decidim/comments/comments_helper.rb +10 -52
- data/lib/decidim/comments/engine.rb +9 -7
- data/lib/decidim/comments/mutation_extensions.rb +22 -22
- data/lib/decidim/comments/query_extensions.rb +12 -14
- data/lib/decidim/comments/test.rb +1 -0
- data/lib/decidim/comments/test/shared_examples/comment_voted_event.rb +65 -0
- data/lib/decidim/comments/version.rb +1 -1
- metadata +65 -64
- data/app/assets/javascripts/decidim/comments/bundle.js +0 -268
- data/app/frontend/application/apollo_client.ts +0 -12
- data/app/frontend/application/application.component.test.tsx +0 -23
- data/app/frontend/application/application.component.tsx +0 -35
- data/app/frontend/application/icon.component.test.tsx +0 -38
- data/app/frontend/application/icon.component.tsx +0 -46
- data/app/frontend/comments/add_comment_form.component.test.tsx +0 -265
- data/app/frontend/comments/add_comment_form.component.tsx +0 -482
- data/app/frontend/comments/comment.component.test.tsx +0 -490
- data/app/frontend/comments/comment.component.tsx +0 -677
- data/app/frontend/comments/comment_order_selector.component.test.tsx +0 -29
- data/app/frontend/comments/comment_order_selector.component.tsx +0 -106
- data/app/frontend/comments/comment_thread.component.test.tsx +0 -82
- data/app/frontend/comments/comment_thread.component.tsx +0 -81
- data/app/frontend/comments/comments.component.test.tsx +0 -150
- data/app/frontend/comments/comments.component.tsx +0 -289
- data/app/frontend/comments/down_vote_button.component.test.tsx +0 -59
- data/app/frontend/comments/down_vote_button.component.tsx +0 -133
- data/app/frontend/comments/up_vote_button.component.test.tsx +0 -59
- data/app/frontend/comments/up_vote_button.component.tsx +0 -133
- data/app/frontend/comments/vote_button.component.tsx +0 -50
- data/app/frontend/comments/vote_button_component.test.tsx +0 -64
- data/app/frontend/entry.ts +0 -38
- data/app/frontend/entry_test.ts +0 -6
- data/app/frontend/fragments/add_comment_form_commentable.fragment.graphql +0 -4
- data/app/frontend/fragments/add_comment_form_session.fragment.graphql +0 -6
- data/app/frontend/fragments/comment.fragment.graphql +0 -14
- data/app/frontend/fragments/comment_data.fragment.graphql +0 -27
- data/app/frontend/fragments/comment_thread.fragment.graphql +0 -6
- data/app/frontend/fragments/down_vote_button.fragment.graphql +0 -6
- data/app/frontend/fragments/up_vote_button.fragment.graphql +0 -6
- data/app/frontend/mutations/add_comment.mutation.graphql +0 -9
- data/app/frontend/mutations/down_vote.mutation.graphql +0 -9
- data/app/frontend/mutations/up_vote.mutation.graphql +0 -9
- data/app/frontend/queries/comments.query.graphql +0 -26
- data/app/frontend/support/asset_url.ts +0 -11
- data/app/frontend/support/generate_comments_data.ts +0 -49
- data/app/frontend/support/generate_user_data.ts +0 -14
- data/app/frontend/support/generate_user_group_data.ts +0 -14
- data/app/frontend/support/graphql_transformer.js +0 -32
- data/app/frontend/support/load_translations.ts +0 -48
- data/app/frontend/support/require_all.ts +0 -10
- data/app/frontend/support/resolve_graphql_query.ts +0 -37
- data/app/frontend/support/schema.ts +0 -2026
- data/app/types/decidim/comments/commentable_interface.rb +0 -61
- data/app/types/decidim/comments/commentable_mutation_type.rb +0 -33
- data/lib/decidim/comments/api/add_comment_type.rb +0 -13
- data/lib/decidim/comments/api/comment_mutation_type.rb +0 -20
- data/lib/decidim/comments/api/comment_type.rb +0 -89
@@ -1,490 +0,0 @@
|
|
1
|
-
import {mount, shallow} from "enzyme";
|
2
|
-
import * as $ from "jquery";
|
3
|
-
import * as React from "react";
|
4
|
-
|
5
|
-
import {CommentFragment} from "../support/schema";
|
6
|
-
import AddCommentForm from "./add_comment_form.component";
|
7
|
-
import Comment from "./comment.component";
|
8
|
-
import DownVoteButton from "./down_vote_button.component";
|
9
|
-
import UpVoteButton from "./up_vote_button.component";
|
10
|
-
|
11
|
-
import generateCommentsData from "../support/generate_comments_data";
|
12
|
-
import generateUserData from "../support/generate_user_data";
|
13
|
-
|
14
|
-
import {loadLocaleTranslations} from "../support/load_translations";
|
15
|
-
|
16
|
-
describe("<Comment />", () => {
|
17
|
-
const commentsMaxLength: number = 1000;
|
18
|
-
const orderBy = "older";
|
19
|
-
const rootCommentable = {
|
20
|
-
id: "1",
|
21
|
-
type: "Decidim::DummyResources::DummyResource",
|
22
|
-
commentsMaxLength: 1000
|
23
|
-
};
|
24
|
-
let comment: CommentFragment;
|
25
|
-
let session: any = null;
|
26
|
-
|
27
|
-
beforeEach(() => {
|
28
|
-
loadLocaleTranslations("en");
|
29
|
-
const commentsData = generateCommentsData(1);
|
30
|
-
commentsData[0].comments = generateCommentsData(3);
|
31
|
-
|
32
|
-
comment = commentsData[0];
|
33
|
-
session = {
|
34
|
-
user: generateUserData()
|
35
|
-
};
|
36
|
-
|
37
|
-
window.DecidimComments = {
|
38
|
-
assets: {
|
39
|
-
"icons.svg": "/assets/icons.svg"
|
40
|
-
}
|
41
|
-
};
|
42
|
-
|
43
|
-
window.$ = $;
|
44
|
-
});
|
45
|
-
|
46
|
-
it("should render an article with class comment", () => {
|
47
|
-
const wrapper = shallow(
|
48
|
-
<Comment
|
49
|
-
comment={comment}
|
50
|
-
session={session}
|
51
|
-
rootCommentable={rootCommentable}
|
52
|
-
orderBy={orderBy}
|
53
|
-
commentsMaxLength={commentsMaxLength}
|
54
|
-
/>
|
55
|
-
);
|
56
|
-
expect(wrapper.find(".comment").exists()).toBeTruthy();
|
57
|
-
});
|
58
|
-
|
59
|
-
it("should render a time tag with comment's created at", () => {
|
60
|
-
const wrapper = shallow(
|
61
|
-
<Comment
|
62
|
-
comment={comment}
|
63
|
-
session={session}
|
64
|
-
rootCommentable={rootCommentable}
|
65
|
-
orderBy={orderBy}
|
66
|
-
commentsMaxLength={commentsMaxLength}
|
67
|
-
/>
|
68
|
-
);
|
69
|
-
expect(wrapper.find("time").prop("dateTime")).toEqual(comment.createdAt);
|
70
|
-
});
|
71
|
-
|
72
|
-
it("should render author's name in a link with class author__name", () => {
|
73
|
-
const wrapper = shallow(
|
74
|
-
<Comment
|
75
|
-
comment={comment}
|
76
|
-
session={session}
|
77
|
-
rootCommentable={rootCommentable}
|
78
|
-
orderBy={orderBy}
|
79
|
-
commentsMaxLength={commentsMaxLength}
|
80
|
-
/>
|
81
|
-
);
|
82
|
-
expect(wrapper.find("span.author__name").text()).toEqual(
|
83
|
-
comment.author.name
|
84
|
-
);
|
85
|
-
});
|
86
|
-
|
87
|
-
it("should render author's nickname in a link with class author__nickname", () => {
|
88
|
-
const wrapper = shallow(
|
89
|
-
<Comment
|
90
|
-
comment={comment}
|
91
|
-
session={session}
|
92
|
-
rootCommentable={rootCommentable}
|
93
|
-
orderBy={orderBy}
|
94
|
-
commentsMaxLength={commentsMaxLength}
|
95
|
-
/>
|
96
|
-
);
|
97
|
-
expect(wrapper.find("span.author__nickname").text()).toEqual(
|
98
|
-
comment.author.nickname
|
99
|
-
);
|
100
|
-
});
|
101
|
-
|
102
|
-
describe("when the author's account has been deleted", () => {
|
103
|
-
beforeEach(() => {
|
104
|
-
comment.author.deleted = true;
|
105
|
-
});
|
106
|
-
|
107
|
-
it("should render 'Deleted participant' inside a badge", () => {
|
108
|
-
const wrapper = shallow(
|
109
|
-
<Comment
|
110
|
-
comment={comment}
|
111
|
-
session={session}
|
112
|
-
rootCommentable={rootCommentable}
|
113
|
-
orderBy={orderBy}
|
114
|
-
commentsMaxLength={commentsMaxLength}
|
115
|
-
/>
|
116
|
-
);
|
117
|
-
expect(
|
118
|
-
wrapper.find("span.label.label--small.label--basic").text()
|
119
|
-
).toEqual("Deleted participant");
|
120
|
-
});
|
121
|
-
});
|
122
|
-
|
123
|
-
it("should render author's avatar as a image tag", () => {
|
124
|
-
const wrapper = shallow(
|
125
|
-
<Comment
|
126
|
-
comment={comment}
|
127
|
-
session={session}
|
128
|
-
rootCommentable={rootCommentable}
|
129
|
-
orderBy={orderBy}
|
130
|
-
commentsMaxLength={commentsMaxLength}
|
131
|
-
/>
|
132
|
-
);
|
133
|
-
expect(wrapper.find(".author__avatar img").prop("src")).toEqual(
|
134
|
-
comment.author.avatarUrl
|
135
|
-
);
|
136
|
-
});
|
137
|
-
|
138
|
-
it("should render formatted comment's body on a div with class comment__content", () => {
|
139
|
-
const wrapper = shallow(
|
140
|
-
<Comment
|
141
|
-
comment={comment}
|
142
|
-
session={session}
|
143
|
-
rootCommentable={rootCommentable}
|
144
|
-
orderBy={orderBy}
|
145
|
-
commentsMaxLength={commentsMaxLength}
|
146
|
-
/>
|
147
|
-
);
|
148
|
-
expect(wrapper.find("div.comment__content").html()).toContain(
|
149
|
-
comment.formattedBody
|
150
|
-
);
|
151
|
-
});
|
152
|
-
|
153
|
-
it("should initialize with a state property showReplyForm as false", () => {
|
154
|
-
const wrapper = shallow(
|
155
|
-
<Comment
|
156
|
-
comment={comment}
|
157
|
-
session={session}
|
158
|
-
rootCommentable={rootCommentable}
|
159
|
-
orderBy={orderBy}
|
160
|
-
commentsMaxLength={commentsMaxLength}
|
161
|
-
/>
|
162
|
-
);
|
163
|
-
expect(wrapper.state()).toHaveProperty("showReplyForm", false);
|
164
|
-
});
|
165
|
-
|
166
|
-
it("should render a AddCommentForm component with the correct props when clicking the reply button", () => {
|
167
|
-
const wrapper = shallow(
|
168
|
-
<Comment
|
169
|
-
comment={comment}
|
170
|
-
session={session}
|
171
|
-
rootCommentable={rootCommentable}
|
172
|
-
orderBy={orderBy}
|
173
|
-
commentsMaxLength={commentsMaxLength}
|
174
|
-
/>
|
175
|
-
);
|
176
|
-
expect(wrapper.find(AddCommentForm).exists()).toBeFalsy();
|
177
|
-
wrapper.find("button.comment__reply").simulate("click");
|
178
|
-
expect(wrapper.find(AddCommentForm).prop("session")).toEqual(session);
|
179
|
-
expect(wrapper.find(AddCommentForm).prop("commentable")).toEqual(comment);
|
180
|
-
expect(wrapper.find(AddCommentForm).prop("showTitle")).toBeFalsy();
|
181
|
-
expect(wrapper.find(AddCommentForm).prop("submitButtonClassName")).toEqual(
|
182
|
-
"button small hollow"
|
183
|
-
);
|
184
|
-
});
|
185
|
-
|
186
|
-
it("should not render the additional reply button if the parent comment has no comments and isRootcomment", () => {
|
187
|
-
comment.hasComments = false;
|
188
|
-
const wrapper = shallow(
|
189
|
-
<Comment
|
190
|
-
comment={comment}
|
191
|
-
session={session}
|
192
|
-
isRootComment={true}
|
193
|
-
rootCommentable={rootCommentable}
|
194
|
-
orderBy={orderBy}
|
195
|
-
commentsMaxLength={commentsMaxLength}
|
196
|
-
/>
|
197
|
-
);
|
198
|
-
expect(wrapper.find("div.comment__additionalreply").exists()).toBeFalsy();
|
199
|
-
});
|
200
|
-
|
201
|
-
it("should not render the additional reply button if the parent comment has comments and not isRootcomment", () => {
|
202
|
-
comment.hasComments = true;
|
203
|
-
const wrapper = shallow(
|
204
|
-
<Comment
|
205
|
-
comment={comment}
|
206
|
-
session={session}
|
207
|
-
rootCommentable={rootCommentable}
|
208
|
-
orderBy={orderBy}
|
209
|
-
commentsMaxLength={commentsMaxLength}
|
210
|
-
/>
|
211
|
-
);
|
212
|
-
expect(wrapper.find("div.comment__additionalreply").exists()).toBeFalsy();
|
213
|
-
});
|
214
|
-
|
215
|
-
it("should render the additional reply button if the parent comment has comments and isRootcomment", () => {
|
216
|
-
comment.hasComments = true;
|
217
|
-
const wrapper = shallow(
|
218
|
-
<Comment
|
219
|
-
comment={comment}
|
220
|
-
session={session}
|
221
|
-
isRootComment={true}
|
222
|
-
rootCommentable={rootCommentable}
|
223
|
-
orderBy={orderBy}
|
224
|
-
commentsMaxLength={commentsMaxLength}
|
225
|
-
/>
|
226
|
-
);
|
227
|
-
expect(wrapper.find("div.comment__additionalreply").exists()).toBeTruthy();
|
228
|
-
});
|
229
|
-
|
230
|
-
it("should render comment's comments as a separate Comment components", () => {
|
231
|
-
const wrapper = shallow(
|
232
|
-
<Comment
|
233
|
-
comment={comment}
|
234
|
-
session={session}
|
235
|
-
votable={true}
|
236
|
-
rootCommentable={rootCommentable}
|
237
|
-
orderBy={orderBy}
|
238
|
-
commentsMaxLength={commentsMaxLength}
|
239
|
-
/>
|
240
|
-
);
|
241
|
-
wrapper.find(Comment).forEach((node, idx) => {
|
242
|
-
expect(node.prop("comment")).toEqual(comment.comments[idx]);
|
243
|
-
expect(node.prop("session")).toEqual(session);
|
244
|
-
expect(node.prop("articleClassName")).toEqual("comment comment--nested");
|
245
|
-
expect(node.prop("votable")).toBeTruthy();
|
246
|
-
});
|
247
|
-
});
|
248
|
-
|
249
|
-
it("should render comment's comments with articleClassName as 'comment comment--nested comment--nested--alt' when articleClassName is 'comment comment--nested'", () => {
|
250
|
-
const wrapper = shallow(
|
251
|
-
<Comment
|
252
|
-
comment={comment}
|
253
|
-
session={session}
|
254
|
-
articleClassName="comment comment--nested"
|
255
|
-
rootCommentable={rootCommentable}
|
256
|
-
orderBy={orderBy}
|
257
|
-
commentsMaxLength={commentsMaxLength}
|
258
|
-
/>
|
259
|
-
);
|
260
|
-
wrapper.find(Comment).forEach(node => {
|
261
|
-
expect(node.prop("articleClassName")).toEqual(
|
262
|
-
"comment comment--nested comment--nested--alt"
|
263
|
-
);
|
264
|
-
});
|
265
|
-
});
|
266
|
-
|
267
|
-
it("should have a default prop articleClassName with value 'comment'", () => {
|
268
|
-
const wrapper = mount(
|
269
|
-
<Comment
|
270
|
-
comment={comment}
|
271
|
-
session={session}
|
272
|
-
rootCommentable={rootCommentable}
|
273
|
-
orderBy={orderBy}
|
274
|
-
commentsMaxLength={commentsMaxLength}
|
275
|
-
/>
|
276
|
-
);
|
277
|
-
expect(wrapper.prop("articleClassName")).toEqual("comment");
|
278
|
-
});
|
279
|
-
|
280
|
-
it("should have a default prop isRootComment with value false", () => {
|
281
|
-
const wrapper = mount(
|
282
|
-
<Comment
|
283
|
-
comment={comment}
|
284
|
-
session={session}
|
285
|
-
rootCommentable={rootCommentable}
|
286
|
-
orderBy={orderBy}
|
287
|
-
commentsMaxLength={commentsMaxLength}
|
288
|
-
/>
|
289
|
-
);
|
290
|
-
expect(wrapper.prop("isRootComment")).toBeFalsy();
|
291
|
-
});
|
292
|
-
|
293
|
-
describe("when the comment cannot accept new comments", () => {
|
294
|
-
beforeEach(() => {
|
295
|
-
comment.acceptsNewComments = false;
|
296
|
-
});
|
297
|
-
|
298
|
-
it("should not render the reply button", () => {
|
299
|
-
const wrapper = shallow(
|
300
|
-
<Comment
|
301
|
-
comment={comment}
|
302
|
-
session={session}
|
303
|
-
rootCommentable={rootCommentable}
|
304
|
-
orderBy={orderBy}
|
305
|
-
commentsMaxLength={commentsMaxLength}
|
306
|
-
/>
|
307
|
-
);
|
308
|
-
expect(wrapper.find("button.comment__reply").exists()).toBeFalsy();
|
309
|
-
});
|
310
|
-
});
|
311
|
-
|
312
|
-
describe("when user is not logged in", () => {
|
313
|
-
beforeEach(() => {
|
314
|
-
session = null;
|
315
|
-
});
|
316
|
-
|
317
|
-
it("should not render reply button", () => {
|
318
|
-
const wrapper = shallow(
|
319
|
-
<Comment
|
320
|
-
comment={comment}
|
321
|
-
session={session}
|
322
|
-
rootCommentable={rootCommentable}
|
323
|
-
orderBy={orderBy}
|
324
|
-
commentsMaxLength={commentsMaxLength}
|
325
|
-
/>
|
326
|
-
);
|
327
|
-
expect(wrapper.find("button.comment__reply").exists()).toBeFalsy();
|
328
|
-
});
|
329
|
-
|
330
|
-
it("should not render the flag modal", () => {
|
331
|
-
const wrapper = shallow(
|
332
|
-
<Comment
|
333
|
-
comment={comment}
|
334
|
-
session={session}
|
335
|
-
rootCommentable={rootCommentable}
|
336
|
-
orderBy={orderBy}
|
337
|
-
commentsMaxLength={commentsMaxLength}
|
338
|
-
/>
|
339
|
-
);
|
340
|
-
expect(wrapper.find(".flag-modal").exists()).toBeFalsy();
|
341
|
-
});
|
342
|
-
});
|
343
|
-
|
344
|
-
it("should render a 'in favor' badge if comment's alignment is 1", () => {
|
345
|
-
comment.alignment = 1;
|
346
|
-
const wrapper = shallow(
|
347
|
-
<Comment
|
348
|
-
comment={comment}
|
349
|
-
session={session}
|
350
|
-
rootCommentable={rootCommentable}
|
351
|
-
orderBy={orderBy}
|
352
|
-
commentsMaxLength={commentsMaxLength}
|
353
|
-
/>
|
354
|
-
);
|
355
|
-
expect(wrapper.find("span.alignment.label").text()).toEqual("In favor");
|
356
|
-
});
|
357
|
-
|
358
|
-
it("should render a 'against' badge if comment's alignment is -1", () => {
|
359
|
-
comment.alignment = -1;
|
360
|
-
const wrapper = shallow(
|
361
|
-
<Comment
|
362
|
-
comment={comment}
|
363
|
-
session={session}
|
364
|
-
rootCommentable={rootCommentable}
|
365
|
-
orderBy={orderBy}
|
366
|
-
commentsMaxLength={commentsMaxLength}
|
367
|
-
/>
|
368
|
-
);
|
369
|
-
expect(wrapper.find("span.alert.label").text()).toEqual("Against");
|
370
|
-
});
|
371
|
-
|
372
|
-
it("should render the flag modal", () => {
|
373
|
-
const wrapper = shallow(
|
374
|
-
<Comment
|
375
|
-
comment={comment}
|
376
|
-
session={session}
|
377
|
-
rootCommentable={rootCommentable}
|
378
|
-
orderBy={orderBy}
|
379
|
-
commentsMaxLength={commentsMaxLength}
|
380
|
-
/>
|
381
|
-
);
|
382
|
-
expect(wrapper.find(".flag-modal").exists()).toBeTruthy();
|
383
|
-
});
|
384
|
-
|
385
|
-
describe("when user has already reported the comment", () => {
|
386
|
-
it("should not render the flag form", () => {
|
387
|
-
comment.alreadyReported = true;
|
388
|
-
const wrapper = shallow(
|
389
|
-
<Comment
|
390
|
-
comment={comment}
|
391
|
-
session={session}
|
392
|
-
rootCommentable={rootCommentable}
|
393
|
-
orderBy={orderBy}
|
394
|
-
commentsMaxLength={commentsMaxLength}
|
395
|
-
/>
|
396
|
-
);
|
397
|
-
expect(wrapper.find(".flag-modal form").exists()).toBeFalsy();
|
398
|
-
});
|
399
|
-
});
|
400
|
-
|
401
|
-
describe("when the comment is votable", () => {
|
402
|
-
it("should render an UpVoteButton component", () => {
|
403
|
-
const wrapper = shallow(
|
404
|
-
<Comment
|
405
|
-
comment={comment}
|
406
|
-
session={session}
|
407
|
-
votable={true}
|
408
|
-
rootCommentable={rootCommentable}
|
409
|
-
orderBy={orderBy}
|
410
|
-
commentsMaxLength={commentsMaxLength}
|
411
|
-
/>
|
412
|
-
);
|
413
|
-
expect(wrapper.find(UpVoteButton).prop("comment")).toEqual(comment);
|
414
|
-
});
|
415
|
-
|
416
|
-
it("should render an DownVoteButton component", () => {
|
417
|
-
const wrapper = shallow(
|
418
|
-
<Comment
|
419
|
-
comment={comment}
|
420
|
-
session={session}
|
421
|
-
votable={true}
|
422
|
-
rootCommentable={rootCommentable}
|
423
|
-
orderBy={orderBy}
|
424
|
-
commentsMaxLength={commentsMaxLength}
|
425
|
-
/>
|
426
|
-
);
|
427
|
-
expect(wrapper.find(DownVoteButton).prop("comment")).toEqual(comment);
|
428
|
-
});
|
429
|
-
});
|
430
|
-
|
431
|
-
describe("when user is not allowed to comment", () => {
|
432
|
-
beforeEach(() => {
|
433
|
-
comment.userAllowedToComment = false;
|
434
|
-
});
|
435
|
-
|
436
|
-
it("should not render reply button", () => {
|
437
|
-
const wrapper = shallow(
|
438
|
-
<Comment
|
439
|
-
comment={comment}
|
440
|
-
session={session}
|
441
|
-
rootCommentable={rootCommentable}
|
442
|
-
orderBy={orderBy}
|
443
|
-
commentsMaxLength={commentsMaxLength}
|
444
|
-
/>
|
445
|
-
);
|
446
|
-
expect(wrapper.find("button.comment__reply").exists()).toBeFalsy();
|
447
|
-
});
|
448
|
-
|
449
|
-
it("should not render the flag modal", () => {
|
450
|
-
const wrapper = shallow(
|
451
|
-
<Comment
|
452
|
-
comment={comment}
|
453
|
-
session={session}
|
454
|
-
rootCommentable={rootCommentable}
|
455
|
-
orderBy={orderBy}
|
456
|
-
commentsMaxLength={commentsMaxLength}
|
457
|
-
/>
|
458
|
-
);
|
459
|
-
expect(wrapper.find(".flag-modal").exists()).toBeFalsy();
|
460
|
-
});
|
461
|
-
|
462
|
-
it("should not render an UpVoteButton component", () => {
|
463
|
-
const wrapper = shallow(
|
464
|
-
<Comment
|
465
|
-
comment={comment}
|
466
|
-
session={session}
|
467
|
-
votable={true}
|
468
|
-
rootCommentable={rootCommentable}
|
469
|
-
orderBy={orderBy}
|
470
|
-
commentsMaxLength={commentsMaxLength}
|
471
|
-
/>
|
472
|
-
);
|
473
|
-
expect(wrapper.find(".comment__votes--up").exists()).toBeFalsy();
|
474
|
-
});
|
475
|
-
|
476
|
-
it("should not render an DownVoteButton component", () => {
|
477
|
-
const wrapper = shallow(
|
478
|
-
<Comment
|
479
|
-
comment={comment}
|
480
|
-
session={session}
|
481
|
-
votable={true}
|
482
|
-
rootCommentable={rootCommentable}
|
483
|
-
orderBy={orderBy}
|
484
|
-
commentsMaxLength={commentsMaxLength}
|
485
|
-
/>
|
486
|
-
);
|
487
|
-
expect(wrapper.find(".comment__votes--down").exists()).toBeFalsy();
|
488
|
-
});
|
489
|
-
});
|
490
|
-
});
|