ep_comments_page 11.0.26 → 11.0.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (25) hide show
  1. package/package.json +1 -1
  2. package/static/tests/frontend-new/helper/comments.ts +188 -0
  3. package/static/tests/frontend-new/specs/commentDelete.spec.ts +57 -0
  4. package/static/tests/frontend-new/specs/commentEdit.spec.ts +113 -0
  5. package/static/tests/frontend-new/specs/commentIcons.spec.ts +131 -0
  6. package/static/tests/frontend-new/specs/commentReply.spec.ts +92 -0
  7. package/static/tests/frontend-new/specs/commentSuggestion.spec.ts +97 -0
  8. package/static/tests/frontend-new/specs/comment_l10n.spec.ts +63 -0
  9. package/static/tests/frontend-new/specs/comment_settings.spec.ts +47 -0
  10. package/static/tests/frontend-new/specs/newComment.spec.ts +25 -0
  11. package/static/tests/frontend-new/specs/preCommentMark.spec.ts +123 -0
  12. package/static/tests/frontend-new/specs/timeFormat.spec.ts +244 -0
  13. package/static/tests/frontend-new/specs/xcommentCopyPaste.spec.ts +29 -0
  14. package/static/tests/frontend/specs/commentDelete.js +0 -146
  15. package/static/tests/frontend/specs/commentEdit.js +0 -291
  16. package/static/tests/frontend/specs/commentIcons.js +0 -298
  17. package/static/tests/frontend/specs/commentReply.js +0 -200
  18. package/static/tests/frontend/specs/commentSuggestion.js +0 -100
  19. package/static/tests/frontend/specs/comment_l10n.js +0 -141
  20. package/static/tests/frontend/specs/comment_settings.js +0 -132
  21. package/static/tests/frontend/specs/newComment.js +0 -18
  22. package/static/tests/frontend/specs/preCommentMark.js +0 -241
  23. package/static/tests/frontend/specs/timeFormat.js +0 -266
  24. package/static/tests/frontend/specs/xcommentCopyPaste.js +0 -480
  25. package/static/tests/frontend/utils.js +0 -14
@@ -1,480 +0,0 @@
1
- 'use strict';
2
-
3
- describe('ep_comments_page - Comment copy and paste', function () {
4
- let helperFunctions, event;
5
-
6
- const FIRST_LINE = 0;
7
- const SECOND_LINE = 1;
8
-
9
- before(async function () {
10
- helperFunctions = copyAndPaste;
11
- });
12
-
13
- context('when user copies a text with a comment', function () {
14
- this.timeout(60000);
15
- const commentText = 'My comment';
16
- const replyText = 'A reply';
17
- before(function (cb) {
18
- helperFunctions.createPad(this, () => {
19
- helperFunctions.addComentAndReplyToLine(FIRST_LINE, commentText, replyText, () => {
20
- const $firstLine = helper.padInner$('div').eq(0);
21
- helper.selectLines($firstLine, $firstLine, 1, 8); // 'omethin'
22
- try {
23
- event = helperFunctions.copyLine();
24
- } catch (e) {
25
- // suppress e.preventDefault issue with certain browsers
26
- }
27
- cb();
28
- });
29
- });
30
- this.timeout(10000);
31
- });
32
-
33
- xit('keeps the text copied on the buffer', function (done) {
34
- const dataFromGetData = event.originalEvent.clipboardData.getData('text/html');
35
- const $dataFromGetData = $(dataFromGetData);
36
- const textCopied = helperFunctions.cleanText($dataFromGetData.text());
37
-
38
- // we create two spans to avoid error on paste on chrome, when we copy only a text without
39
- // tags
40
- const hasCopiedSpanTag = $dataFromGetData.filter('span').length === 2;
41
- // Skip if Edge
42
- if (document.documentMode || /Safari/.test(navigator.userAgent) ||
43
- /Edge/.test(navigator.userAgent)) {
44
- done();
45
- }
46
- expect(textCopied).to.be('omethin');
47
- expect(hasCopiedSpanTag).to.be(true);
48
- done();
49
- });
50
-
51
- xit('generates a fake comment class', function (done) {
52
- // Skip if Edge
53
- if (document.documentMode || /Safari/.test(navigator.userAgent) ||
54
- /Edge/.test(navigator.userAgent)) {
55
- done();
56
- }
57
- const dataFromGetData = event.originalEvent.clipboardData.getData('text/html');
58
- const $dataFromGetData = $(dataFromGetData);
59
- const fakeCommentClass = $dataFromGetData.attr('class');
60
- expect(fakeCommentClass).to.match(/(fakecomment-)([a-zA-Z0-9]{16}$)/);
61
- done();
62
- });
63
-
64
- xit('puts the comment data on the clipboardData', function (done) {
65
- // Skip if Edge
66
- if (document.documentMode || /Safari/.test(navigator.userAgent) ||
67
- /Edge/.test(navigator.userAgent)) {
68
- done();
69
- }
70
- const commentDataValues = helperFunctions.getCommentDataValues(event);
71
- const originalCommentId = helperFunctions.getCommentIdOfLine(FIRST_LINE);
72
- const textOfCommentOnClipboard = commentDataValues.text;
73
- const idOfOriginalCommentOnClipboard = commentDataValues.originalCommentId;
74
- expect(textOfCommentOnClipboard).to.be(commentText);
75
- expect(idOfOriginalCommentOnClipboard).to.be(originalCommentId);
76
- done();
77
- });
78
-
79
- xit('puts the comment reply data on the clipboardData', function (done) {
80
- // Skip if Edge
81
- if (document.documentMode || /Safari/.test(navigator.userAgent) ||
82
- /Edge/.test(navigator.userAgent)) {
83
- done();
84
- }
85
- const commentReplyDataValues = helperFunctions.getCommentReplyDataValues(event);
86
- const textOfCommentOnClipboard = commentReplyDataValues.text;
87
- expect(textOfCommentOnClipboard).to.be(replyText);
88
- done();
89
- });
90
-
91
- xit('has the fields required to build a comment', function (done) {
92
- // Skip if Edge
93
- if (document.documentMode || /Safari/.test(navigator.userAgent) ||
94
- /Edge/.test(navigator.userAgent)) {
95
- done();
96
- }
97
- helperFunctions.testIfHasAllFieldsNecessaryToCreateAComment(event);
98
- done();
99
- });
100
-
101
- xit('has the fields required to build a comment reply', function (done) {
102
- // Skip if Edge
103
- if (document.documentMode || /Safari/.test(navigator.userAgent) ||
104
- /Edge/.test(navigator.userAgent)) {
105
- done();
106
- }
107
- helperFunctions.testIfHasAllFieldsNecessaryToCreateACommementReply(event);
108
- done();
109
- });
110
- });
111
-
112
- context('when user pastes a text with comment', function () {
113
- const commentText = 'My comment 2';
114
- const replyText = 'Reply 2';
115
- before(function (cb) {
116
- helperFunctions.createPad(this, () => {
117
- helperFunctions.enlargeScreen(() => {
118
- helperFunctions.addComentAndReplyToLine(FIRST_LINE, commentText, replyText, () => {
119
- try {
120
- event = helperFunctions.copyLine();
121
- } catch (e) {
122
- // suppress e.preventDefault issue with certain browsers
123
- }
124
- try {
125
- helperFunctions.pasteTextOnLine(event, SECOND_LINE);
126
- } catch (e) {
127
- // allowing helper to fail silently.
128
- }
129
- cb();
130
- });
131
- });
132
- });
133
- this.timeout(20000);
134
- });
135
-
136
- xit('generates a different comment id for the comment pasted', function (done) {
137
- // Skip if Edge
138
- if (document.documentMode || /Safari/.test(navigator.userAgent) ||
139
- /Edge/.test(navigator.userAgent)) {
140
- done();
141
- }
142
- const commentIdOriginal = helperFunctions.getCommentIdOfLine(FIRST_LINE);
143
- let commentIdLinePasted = null;
144
- // wait for the new comment to be created
145
- helper.waitFor(() => {
146
- commentIdLinePasted = helperFunctions.getCommentIdOfLine(SECOND_LINE);
147
- return commentIdLinePasted != null;
148
- }).done(() => {
149
- // Skip if Edge
150
- if (document.documentMode || /Safari/.test(navigator.userAgent) ||
151
- /Edge/.test(navigator.userAgent)) {
152
- done();
153
- }
154
- expect(commentIdLinePasted).to.not.be(commentIdOriginal);
155
- done();
156
- });
157
- });
158
-
159
- xit('creates a new icon for the comment pasted', function (done) {
160
- // Skip if Edge
161
- if (document.documentMode || /Safari/.test(navigator.userAgent) ||
162
- /Edge/.test(navigator.userAgent)) {
163
- done();
164
- }
165
- helperFunctions.finishTestIfIconsAreNotEnabled(done, () => {
166
- helperFunctions.createdCommentOnLine(SECOND_LINE, () => {
167
- const outer$ = helper.padOuter$;
168
-
169
- // 2 = the original comment and the pasted one
170
- const $commentIcon = outer$('.comment-icon');
171
- expect($commentIcon.length).to.be(2);
172
- done();
173
- });
174
- });
175
- });
176
-
177
- xit('creates the comment text field with the same text of the one copied', function (done) {
178
- helperFunctions.createdCommentOnLine(SECOND_LINE, () => {
179
- const commentPastedText = helperFunctions.getTextOfCommentFromLine(SECOND_LINE);
180
- expect(commentPastedText).to.be(commentText);
181
- done();
182
- });
183
- });
184
-
185
- xit('creates comment reply text field with the same text of the one copied', function (done) {
186
- // Skip if Edge
187
- if (document.documentMode || /Safari/.test(navigator.userAgent) ||
188
- /Edge/.test(navigator.userAgent)) {
189
- done();
190
- }
191
- helperFunctions.createdCommentOnLine(SECOND_LINE, () => {
192
- const commentReplyText = helperFunctions.getTextOfCommentReplyFromLine(SECOND_LINE);
193
- expect(commentReplyText).to.be(replyText);
194
- done();
195
- });
196
- });
197
-
198
- context('when user removes the original comment', function () {
199
- xit('does not remove the comment pasted', function (done) {
200
- // Skip if Edge
201
- if (document.documentMode || /Safari/.test(navigator.userAgent) ||
202
- /Edge/.test(navigator.userAgent)) {
203
- done();
204
- }
205
- helperFunctions.removeCommentFromLine(FIRST_LINE, () => {
206
- const inner$ = helper.padInner$;
207
- const commentsLength = inner$('.comment').length;
208
- expect(commentsLength).to.be(1);
209
- done();
210
- });
211
- });
212
- });
213
- });
214
- });
215
-
216
- const copyAndPaste = {
217
- createPad(test, cb) {
218
- const self = this;
219
- helper.newPad(() => {
220
- self.createOrResetPadText(cb);
221
- });
222
- test.timeout(60000);
223
- },
224
- cleanPad(callback) {
225
- const inner$ = helper.padInner$;
226
- const $padContent = inner$('#innerdocbody');
227
- $padContent.html(' ');
228
- // wait for Etherpad to re-create first line
229
- helper.waitFor(() => {
230
- const lineNumber = inner$('div').length;
231
- return lineNumber === 1;
232
- }, 20000).done(callback);
233
- },
234
- createOrResetPadText(cb) {
235
- this.cleanPad(() => {
236
- const inner$ = helper.padInner$;
237
- inner$('div').first().sendkeys('something\n anything');
238
- helper.waitFor(() => {
239
- const inner$ = helper.padInner$;
240
-
241
- const lineLength = inner$('div').length;
242
- return lineLength > 1;
243
- }).done(cb);
244
- });
245
- },
246
- addComentAndReplyToLine(line, textOfComment, textOfReply, callback) {
247
- const self = this;
248
- this.addCommentToLine(line, textOfComment, () => {
249
- self.addCommentReplyToLine(line, textOfReply, callback);
250
- });
251
- },
252
- deleteComment(callback) {
253
- const chrome$ = helper.padChrome$;
254
- const outer$ = helper.padOuter$;
255
-
256
- // click on the settings button to make settings visible
257
- const $deleteButton = outer$('.comment-delete');
258
- $deleteButton.click();
259
- helper.waitFor(() => chrome$('.sidebar-comment').is(':visible') === false)
260
- .done(callback);
261
- },
262
- addCommentReplyToLine(line, textOfReply, callback) {
263
- const outer$ = helper.padOuter$;
264
- const commentId = this.getCommentIdOfLine(line);
265
- const existingReplies = outer$('.sidebar-comment-reply').length;
266
- // if comment icons are enabled, make sure we display the comment box:
267
- if (this.commentIconsEnabled()) {
268
- // click on the icon
269
- const $commentIcon = outer$(`#commentIcons #icon-${commentId}`).first();
270
- $commentIcon.click();
271
- }
272
-
273
- // fill reply field
274
- const $replyField = outer$('.comment-content');
275
- $replyField.val(textOfReply);
276
-
277
- // submit reply
278
- const $submitReplyButton = outer$("form.new-comment input[type='submit']").first();
279
- $submitReplyButton.click();
280
-
281
- // wait for the reply to be saved
282
- helper.waitFor(() => {
283
- const hasSavedReply = outer$('.sidebar-comment-reply').length === existingReplies + 1;
284
- return hasSavedReply;
285
- }).done(callback);
286
- },
287
- commentIconsEnabled() {
288
- return helper.padOuter$('#commentIcons').length > 0;
289
- },
290
- addCommentToLine(line, textOfComment, callback) {
291
- const chrome$ = helper.padChrome$;
292
- const $line = this.getLine(line);
293
- $line.sendkeys('{selectall}'); // needs to select content to add comment to
294
- const $commentButton = chrome$('.addComment');
295
- $commentButton.click();
296
-
297
- // fill the comment form and submit it
298
- const $commentField = chrome$('textarea.comment-content');
299
- $commentField.val(textOfComment);
300
- const $submittButton = chrome$('.comment-buttons input[type=submit]');
301
- $submittButton.click();
302
-
303
- // wait until comment is created and comment id is set
304
- this.createdCommentOnLine(line, callback);
305
- },
306
- removeCommentFromLine(line, cb) {
307
- const outer$ = helper.padOuter$;
308
- const commentId = this.getCommentIdOfLine(line);
309
-
310
- // click in the comment icon
311
- const $secondCommentIcon = outer$(`#commentIcons #icon-${commentId}`);
312
- $secondCommentIcon.click();
313
-
314
- // press delete on sidebar comment
315
- const $deleteButton = outer$('.comment-delete').slice(line, line + 1);
316
- $deleteButton.click();
317
- cb();
318
- },
319
- createdCommentOnLine(line, cb) {
320
- const self = this;
321
- helper.waitFor(() => self.getCommentIdOfLine(line) != null).done(cb);
322
- },
323
- copyLine() {
324
- const chrome$ = helper.padChrome$;
325
- const inner$ = helper.padInner$;
326
-
327
- // store data into a simple object, indexed by format
328
- const clipboardDataMock = {
329
- data: {},
330
- setData(format, value) {
331
- this.data[format] = value;
332
- },
333
- getData(format) {
334
- return this.data[format];
335
- },
336
- };
337
-
338
- const event = new jQuery.Event('copy');
339
- const e = {clipboardData: clipboardDataMock};
340
- event.originalEvent = e;
341
-
342
- // Hack: we need to use the same jQuery instance that is registering the main window,
343
- // so we use "chrome$(inner$("div")[0])" instead of simply "inner$("div)"
344
- chrome$(inner$('div')[0]).trigger(event);
345
- return event;
346
- },
347
- pasteTextOnLine(event, line) {
348
- const chrome$ = helper.padChrome$;
349
- const inner$ = helper.padInner$;
350
- const e = event;
351
- e.type = 'paste';
352
-
353
- // Hack: we need to use the same jQuery instance that is registering the main window,
354
- // so we use "chrome$(inner$("div")[0])" instead of simply "inner$("div)"
355
- chrome$(inner$('div')[0]).trigger(event);
356
-
357
- // as we can't trigger the paste on browser(chrome) natively using execCommand, we firstly
358
- // trigger the event and then insert the html.
359
- this.placeCaretOnLine(line, () => {
360
- const copiedHTML = event.originalEvent.clipboardData.getData('text/html');
361
- helper.padInner$.document.execCommand('insertHTML', false, copiedHTML);
362
- });
363
- },
364
- placeCaretOnLine(lineNum, cb) {
365
- const self = this;
366
- const $targetLine = this.getLine(lineNum);
367
- $targetLine.sendkeys('{selectall}');
368
-
369
- helper.waitFor(() => {
370
- const $targetLine = self.getLine(lineNum);
371
- const $lineWhereCaretIs = self.getLineWhereCaretIs();
372
-
373
- return $targetLine.get(0) === $lineWhereCaretIs.get(0);
374
- }).done(cb);
375
- },
376
- getLine(lineNum) {
377
- const inner$ = helper.padInner$;
378
- const $line = inner$('div').slice(lineNum, lineNum + 1);
379
- return $line;
380
- },
381
- getLineWhereCaretIs() {
382
- const inner$ = helper.padInner$;
383
- const nodeWhereCaretIs = inner$.document.getSelection().anchorNode;
384
- const $lineWhereCaretIs = $(nodeWhereCaretIs).closest('div');
385
- return $lineWhereCaretIs;
386
- },
387
- cleanText(text) {
388
- return text.replace(/\s/gi, ' ');
389
- },
390
- getCommentIdOfLine(line) {
391
- const $line = this.getLine(line);
392
- const comment = $line.find('.comment');
393
- const cls = comment.attr('class');
394
- const classCommentId = /(?:^| )(c-[A-Za-z0-9]*)/.exec(cls);
395
- const commentId = (classCommentId) ? classCommentId[1] : null;
396
-
397
- return commentId;
398
- },
399
- getCommentDataValues(event) {
400
- const commentData = event.originalEvent.clipboardData.getData('text/objectComment');
401
- const commentDataJSON = JSON.parse(commentData);
402
- /* eslint-disable-next-line you-dont-need-lodash-underscore/values */
403
- const commentDataValues = _.values(commentDataJSON)[0].data;
404
- return commentDataValues;
405
- },
406
- getCommentReplyDataValues(event) {
407
- const commentReplyData = event.originalEvent.clipboardData.getData('text/objectReply');
408
- const commentReplyDataJSON = JSON.parse(commentReplyData);
409
- /* eslint-disable-next-line you-dont-need-lodash-underscore/values */
410
- const commentReplyDataValues = _.values(commentReplyDataJSON)[0];
411
- return commentReplyDataValues;
412
- },
413
- enlargeScreen(callback) {
414
- $('#iframe-container iframe').css('max-width', '1000px');
415
- callback();
416
- },
417
- getTextOfCommentFromLine(line) {
418
- const outer$ = helper.padOuter$;
419
- const $secondCommentIcon = outer$(`#commentIcons #icon-${this.getCommentIdOfLine(line)}`);
420
- $secondCommentIcon.click();
421
-
422
- // check modal is visible
423
- const commentPastedText =
424
- outer$('#comments .sidebar-comment:visible .comment-text').first().text();
425
- return commentPastedText;
426
- },
427
- getTextOfCommentReplyFromLine(line) {
428
- const outer$ = helper.padOuter$;
429
- const $secondCommentIcon = outer$(`#commentIcons #icon-${this.getCommentIdOfLine(line)}`);
430
- $secondCommentIcon.click();
431
-
432
- const commentPastedText =
433
- outer$(`#${this.getCommentIdOfLine(line)} .comment-reply .comment-text`).text();
434
- return commentPastedText;
435
- },
436
- finishTestIfIconsAreNotEnabled(done, theTest) {
437
- // #commentIcons will only be inserted if icons are enabled
438
- if (helper.padOuter$('#commentIcons').length === 0) {
439
- done();
440
- } else {
441
- theTest(done);
442
- }
443
- },
444
- testIfHasAllFieldsNecessaryToCreateACommementReply(event) {
445
- const commentReplyDataValues = this.getCommentReplyDataValues(event);
446
- const keys = Object.keys(commentReplyDataValues);
447
- const keysRequired = [
448
- 'commentId',
449
- 'text',
450
- 'changeTo',
451
- 'changeFrom',
452
- 'author',
453
- 'name',
454
- 'timestamp',
455
- 'replyId',
456
- 'formattedDate',
457
- ];
458
- this.checkIfHasAllKeys(keysRequired, keys);
459
- },
460
- testIfHasAllFieldsNecessaryToCreateAComment(event) {
461
- const commentDataValues = this.getCommentDataValues(event);
462
- const keys = Object.keys(commentDataValues);
463
- const keysRequired = [
464
- 'author',
465
- 'name',
466
- 'text',
467
- 'timestamp',
468
- 'commentId',
469
- 'date',
470
- 'formattedDate',
471
- 'originalCommentId',
472
- ];
473
- this.checkIfHasAllKeys(keysRequired, keys);
474
- },
475
- checkIfHasAllKeys(keysRequired, keys) {
476
- _.each(keysRequired, (keyRequired) => {
477
- expect(keys).to.contain(keyRequired);
478
- });
479
- },
480
- };
@@ -1,14 +0,0 @@
1
- 'use strict';
2
-
3
- exports.aNewPad = async (...args) => {
4
- const padId = await helper.aNewPad(...args);
5
- // Most ep_comments_page initialization happens during postAceInit, which runs after
6
- // helper.aNewPad() returns. Wait for initialization to complete to avoid race conditions.
7
- await helper.waitForPromise(async () => {
8
- const {plugins: {ep_comments_page: {initDone} = {}} = {}} = helper.padChrome$.window.pad;
9
- if (!initDone) return false;
10
- await initDone;
11
- return true;
12
- });
13
- return padId;
14
- };