ep_comments_page 11.0.26 → 11.0.28

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 (27) hide show
  1. package/package.json +1 -1
  2. package/static/js/index.js +16 -3
  3. package/static/tests/frontend-new/helper/comments.ts +193 -0
  4. package/static/tests/frontend-new/parked/commentDelete.spec.ts +57 -0
  5. package/static/tests/frontend-new/parked/commentEdit.spec.ts +113 -0
  6. package/static/tests/frontend-new/parked/commentIcons.spec.ts +131 -0
  7. package/static/tests/frontend-new/parked/commentReply.spec.ts +92 -0
  8. package/static/tests/frontend-new/parked/commentSuggestion.spec.ts +97 -0
  9. package/static/tests/frontend-new/parked/comment_l10n.spec.ts +63 -0
  10. package/static/tests/frontend-new/parked/comment_settings.spec.ts +47 -0
  11. package/static/tests/frontend-new/parked/newComment.spec.ts +25 -0
  12. package/static/tests/frontend-new/parked/preCommentMark.spec.ts +123 -0
  13. package/static/tests/frontend-new/parked/timeFormat.spec.ts +244 -0
  14. package/static/tests/frontend-new/parked/xcommentCopyPaste.spec.ts +29 -0
  15. package/static/tests/frontend-new/specs/smoke.spec.ts +32 -0
  16. package/static/tests/frontend/specs/commentDelete.js +0 -146
  17. package/static/tests/frontend/specs/commentEdit.js +0 -291
  18. package/static/tests/frontend/specs/commentIcons.js +0 -298
  19. package/static/tests/frontend/specs/commentReply.js +0 -200
  20. package/static/tests/frontend/specs/commentSuggestion.js +0 -100
  21. package/static/tests/frontend/specs/comment_l10n.js +0 -141
  22. package/static/tests/frontend/specs/comment_settings.js +0 -132
  23. package/static/tests/frontend/specs/newComment.js +0 -18
  24. package/static/tests/frontend/specs/preCommentMark.js +0 -241
  25. package/static/tests/frontend/specs/timeFormat.js +0 -266
  26. package/static/tests/frontend/specs/xcommentCopyPaste.js +0 -480
  27. package/static/tests/frontend/utils.js +0 -14
@@ -1,141 +0,0 @@
1
- 'use strict';
2
-
3
- const utils = require('../utils');
4
-
5
- const commentedText = 'This content will receive a comment';
6
- const suggestedText = 'Change to this suggestion';
7
-
8
- // create a new pad with comment before each test run
9
- beforeEach(async function () {
10
- this.timeout(60000);
11
- await utils.aNewPad();
12
- await createComment();
13
- await changeEtherpadLanguageTo('en');
14
- });
15
-
16
- // ensure we go back to English to avoid breaking other tests:
17
- after(async function () {
18
- await changeEtherpadLanguageTo('en');
19
- });
20
-
21
- it('uses default values when language was not localized yet', async function () {
22
- await changeEtherpadLanguageTo('oc');
23
- const outer$ = helper.padOuter$;
24
-
25
- // get the title of the comment
26
- const $changeToLabel = outer$('.comment-suggest').first();
27
- expect($changeToLabel.text()).to.be(
28
- ' Include suggested change ');
29
- });
30
-
31
- it('localizes comment when Etherpad language is changed', async function () {
32
- await changeEtherpadLanguageTo('pt-br');
33
- const outer$ = helper.padOuter$;
34
- const commentId = getCommentId();
35
-
36
- // get the 'Suggested Change' label
37
- const $changeToLabel = outer$(`#${commentId} .from-label`).first();
38
- expect($changeToLabel.text())
39
- .to.be(`Alteração sugerida de "${commentedText}" para "${suggestedText}"`);
40
- });
41
-
42
- it("localizes 'new comment' form when Etherpad language is changed", async function () {
43
- // make sure form was created before changing the language
44
- const inner$ = helper.padInner$;
45
- const outer$ = helper.padOuter$;
46
- const chrome$ = helper.padChrome$;
47
-
48
- // get the first text element out of the inner iframe
49
- const $firstTextElement = inner$('div').first();
50
-
51
- // get the comment button and click it
52
- $firstTextElement.sendkeys('{selectall}'); // needs to select content to add comment to
53
- const $commentButton = chrome$('.addComment');
54
- $commentButton.click();
55
-
56
- await changeEtherpadLanguageTo('pt-br');
57
- // get the 'Include suggested change' label
58
- const $changeToLabel = outer$('.new-comment label.label-suggestion-checkbox').first();
59
- expect($changeToLabel.text()).to.be('Incluir alteração sugerida');
60
- });
61
-
62
- /* ********** Helper functions ********** */
63
-
64
- const createComment = async () => {
65
- const inner$ = helper.padInner$;
66
- const chrome$ = helper.padChrome$;
67
-
68
- // Returns the first line div. Must be a function because Etherpad might replace the div with a
69
- // new div if the content changes.
70
- const $firstTextElement = () => {
71
- const $div = inner$('div').first();
72
- expect($div.length).to.be(1);
73
- return $div;
74
- };
75
-
76
- // simulate key presses to delete content
77
- $firstTextElement().sendkeys('{selectall}'); // select all
78
- $firstTextElement().sendkeys('{del}'); // clear the first line
79
- $firstTextElement().sendkeys(commentedText); // insert text
80
-
81
- // get the comment button and click it
82
- $firstTextElement().sendkeys('{selectall}'); // needs to select content to add comment to
83
- const $commentButton = chrome$('.addComment');
84
- expect($commentButton.length).to.be(1);
85
- $commentButton.click();
86
-
87
- // fill the comment form and submit it
88
- const $commentField = chrome$('textarea.comment-content');
89
- expect($commentField.length).to.be(1);
90
- $commentField.val('My comment');
91
- const $hasSuggestion = chrome$('#newComment .suggestion-checkbox');
92
- expect($hasSuggestion.length).to.be(1);
93
- $hasSuggestion.click();
94
- const $suggestionField = chrome$('textarea.to-value');
95
- expect($suggestionField.length).to.be(1);
96
- $suggestionField.val(suggestedText);
97
- const $submittButton = chrome$('.comment-buttons input[type=submit]');
98
- expect($submittButton.length).to.be(1);
99
- $submittButton.click();
100
-
101
- // wait until comment is created and comment id is set
102
- await helper.waitForPromise(() => getCommentId() != null);
103
- };
104
-
105
- const changeEtherpadLanguageTo = async (lang) => {
106
- const boldTitles = {
107
- 'en': 'Bold (Ctrl+B)',
108
- 'pt-br': 'Negrito (Ctrl-B)',
109
- 'oc': 'Gras (Ctrl-B)',
110
- };
111
- const chrome$ = helper.padChrome$;
112
-
113
- // click on the settings button to make settings visible
114
- const $settingsButton = chrome$('.buttonicon-settings');
115
- $settingsButton.click();
116
-
117
- // select the language
118
- const $language = chrome$('#languagemenu');
119
- const $languageoption = $language.find(`[value=${lang}]`);
120
- $languageoption.attr('selected', 'selected');
121
- $language.trigger('change');
122
-
123
- // hide settings again
124
- $settingsButton.click();
125
-
126
- await helper.waitForPromise(
127
- () => {
128
- console.log(chrome$('.buttonicon-bold').parent()[0].title);
129
- return chrome$('.buttonicon-bold').parent()[0].title === boldTitles[lang];
130
- });
131
- };
132
-
133
- const getCommentId = () => {
134
- const inner$ = helper.padInner$;
135
- const comment = inner$('.comment');
136
- if (comment.length === 0) return null;
137
- for (const cls of comment[0].classList) {
138
- if (cls.startsWith('c-')) return cls;
139
- }
140
- return null;
141
- };
@@ -1,132 +0,0 @@
1
- 'use strict';
2
-
3
- describe('ep_comments_page - Comment settings', function () {
4
- describe("when user unchecks 'Show Comments'", function () {
5
- // create a new pad and check "Show Comments" checkbox
6
- before(function (cb) {
7
- helper.newPad(() => {
8
- helper.waitFor(() => helper.padInner$).done(() => {
9
- chooseToShowComments(false, cb);
10
- });
11
- });
12
- this.timeout(60000);
13
- });
14
-
15
- xit('sidebar comments should not be visible when opening a new pad', function (done) {
16
- this.timeout(60000);
17
- // force to create a new pad, so validation would be on brand new pads
18
- helper.newPad(() => {
19
- const outer$ = helper.padOuter$;
20
- helper.waitFor(() => {
21
- const outer$ = helper.padOuter$;
22
- return outer$;
23
- }).done(() => {
24
- helper.waitFor(() => {
25
- const outer$ = helper.padOuter$;
26
- // hidden
27
- if (outer$('#comments').is(':visible') === false) {
28
- return true;
29
- }
30
- }).done(() => {
31
- expect(outer$('#comments').is(':visible')).to.be(false);
32
- done();
33
- });
34
- });
35
- });
36
- });
37
-
38
- xit('sidebar comments not visible when adding a new comment to a new pad', function (done) {
39
- this.timeout(60000);
40
- // force to create a new pad, so validation would be on brand new pads
41
- helper.newPad(() => {
42
- createComment(() => {
43
- const inner$ = helper.padInner$;
44
- const outer$ = helper.padOuter$;
45
- const chrome$ = helper.padChrome$;
46
-
47
- // get the first text element out of the inner iframe
48
- const $firstTextElement = inner$('div').first();
49
- $firstTextElement.sendkeys('{selectall}'); // needs to select content to add comment to
50
-
51
- // get the comment button and click it
52
- const $commentButton = chrome$('.addComment');
53
- $commentButton.click();
54
-
55
- expect(outer$('#comments:visible').length).to.be(0);
56
- done();
57
- });
58
- });
59
- });
60
- });
61
-
62
- /* ********** Helper functions ********** */
63
-
64
- const chooseToShowComments = (shouldShowComments, callback) => {
65
- const chrome$ = helper.padChrome$;
66
-
67
- // click on the settings button to make settings visible
68
- const $settingsButton = chrome$('.buttonicon-settings');
69
- console.log($settingsButton);
70
- $settingsButton.click();
71
-
72
- // check "Show Comments"
73
- const $showComments = chrome$('#options-comments');
74
- console.log($showComments);
75
- if ($showComments.is(':checked') !== shouldShowComments) {
76
- $showComments.click();
77
- console.log('clicking to disable');
78
- }
79
-
80
- // hide settings again
81
- $settingsButton.click();
82
-
83
- callback();
84
- };
85
-
86
- const createComment = (callback) => {
87
- const inner$ = helper.padInner$;
88
- const outer$ = helper.padOuter$;
89
- const chrome$ = helper.padChrome$;
90
-
91
- // get the first text element out of the inner iframe
92
- const $firstTextElement = inner$('div').first();
93
-
94
- // simulate key presses to delete content
95
- $firstTextElement.sendkeys('{selectall}'); // select all
96
- $firstTextElement.sendkeys('{del}'); // clear the first line
97
- $firstTextElement.sendkeys('This content will receive a comment'); // insert text
98
-
99
- // get the comment button and click it
100
- $firstTextElement.sendkeys('{selectall}'); // needs to select content to add comment to
101
- const $commentButton = chrome$('.addComment');
102
- $commentButton.click();
103
-
104
- // fill the comment form and submit it
105
- const $commentField = chrome$('textarea.comment-content');
106
- $commentField.val('My comment');
107
- const $hasSuggestion = outer$('.suggestion-checkbox');
108
- $hasSuggestion.click();
109
- const $suggestionField = outer$('textarea.to-value');
110
- $suggestionField.val('Change to this suggestion');
111
- const $submittButton = chrome$('.comment-buttons input[type=submit]');
112
- $submittButton.click();
113
-
114
- // wait until comment is created and comment id is set
115
- helper.waitFor(() => getCommentId() != null)
116
- .done(callback);
117
- };
118
-
119
- const getCommentId = () => {
120
- helper.waitFor(() => {
121
- const inner$ = helper.padInner$;
122
- if (inner$) return true;
123
- }).done(() => {
124
- const inner$ = helper.padInner$;
125
- const comment = inner$('.comment').first();
126
- const cls = comment.attr('class');
127
- const classCommentId = /(?:^| )(c-[A-Za-z0-9]*)/.exec(cls);
128
- const commentId = (classCommentId) ? classCommentId[1] : null;
129
- return commentId;
130
- });
131
- };
132
- });
@@ -1,18 +0,0 @@
1
- 'use strict';
2
-
3
- const utils = require('../utils');
4
-
5
- before(async function () {
6
- await utils.aNewPad();
7
- helper.padInner$('div').first()
8
- .sendkeys('{selectall}')
9
- .sendkeys('{del}')
10
- .text('commented text')
11
- .sendkeys('{selectall}');
12
- });
13
-
14
- it('new comment button focuses on comment textarea', async function () {
15
- helper.padChrome$('.addComment').click();
16
- expect(helper.padChrome$.document.activeElement)
17
- .to.be(helper.padChrome$('#newComment').find('.comment-content')[0]);
18
- });
@@ -1,241 +0,0 @@
1
- 'use strict';
2
-
3
- describe('ep_comments_page - Pre-comment text mark', function () {
4
- let padId;
5
-
6
- // create a new pad before each test run
7
- beforeEach(function (cb) {
8
- padId = helper.newPad(() => {
9
- createPadWithTwoLines(() => {
10
- selectLineAndOpenCommentForm(0, cb);
11
- });
12
- });
13
- this.timeout(60000);
14
- });
15
-
16
- it('marks selected text when New Comment form is opened', function (done) {
17
- if (textHighlightIsDisabled()) {
18
- return done();
19
- }
20
- const inner$ = helper.padInner$;
21
-
22
- // verify if text was marked with pre-comment class
23
- const $preCommentTextMarked = inner$('.pre-selected-comment');
24
- expect($preCommentTextMarked.length).to.be(1);
25
- expect($preCommentTextMarked.text()).to.be('Line 1');
26
-
27
- done();
28
- });
29
-
30
- context('when user reloads pad', function () {
31
- beforeEach(function (cb) {
32
- this.timeout(20000);
33
-
34
- // wait for changes to be saved as a revision before reloading the pad, otherwise
35
- // it won't have the text that we created on beforeEach after reload
36
- setTimeout(() => {
37
- helper.newPad(cb, padId);
38
- }, 5000);
39
- });
40
-
41
- it('does not have any marked text after pad is fully loaded', function (done) {
42
- if (textHighlightIsDisabled()) {
43
- return done();
44
- }
45
- const inner$ = helper.padInner$;
46
-
47
- // it takes some time for marks to be removed, so wait for it
48
- helper.waitFor(() => {
49
- const $preCommentTextMarked = inner$('.pre-selected-comment');
50
- return $preCommentTextMarked.length === 0;
51
- }).done(done);
52
- });
53
- });
54
-
55
- context('when user performs UNDO operation', function () {
56
- beforeEach(function (cb) {
57
- this.timeout(20000);
58
-
59
- // wait for changes to be saved as a revision and reload pad, otherwise
60
- // UNDO will remove the text that we created on beforeEach
61
- setTimeout(() => {
62
- helper.newPad(cb, padId);
63
- }, 5000);
64
- });
65
-
66
- it('keeps marked text', function (done) {
67
- if (textHighlightIsDisabled()) {
68
- return done();
69
- }
70
- const chrome$ = helper.padChrome$;
71
- const inner$ = helper.padInner$;
72
-
73
- // marks text
74
- selectLineAndOpenCommentForm(0, () => {
75
- // perform UNDO
76
- const $undoButton = chrome$('.buttonicon-undo');
77
- $undoButton.click();
78
-
79
- // verify if text was marked with pre-comment class
80
- const $preCommentTextMarked = inner$('.pre-selected-comment');
81
- expect($preCommentTextMarked.length).to.be(1);
82
- expect($preCommentTextMarked.text()).to.be('Line 1');
83
-
84
- done();
85
- });
86
- });
87
- });
88
-
89
- context('when user changes selected text', function () {
90
- beforeEach(function (cb) {
91
- const inner$ = helper.padInner$;
92
-
93
- // select second line of text
94
- const $secondLine = inner$('div').first().next();
95
- $secondLine.sendkeys('{selectall}');
96
-
97
- cb();
98
- });
99
-
100
- it('keeps marked text', function (done) {
101
- if (textHighlightIsDisabled()) {
102
- return done();
103
- }
104
- const inner$ = helper.padInner$;
105
-
106
- // verify if text was marked with pre-comment class
107
- const $preCommentTextMarked = inner$('.pre-selected-comment');
108
- expect($preCommentTextMarked.length).to.be(1);
109
- expect($preCommentTextMarked.text()).to.be('Line 1');
110
-
111
- done();
112
- });
113
- });
114
-
115
- context('when user closes the New Comment form', function () {
116
- beforeEach(function (cb) {
117
- const outer$ = helper.padOuter$;
118
-
119
- const $cancelButton = outer$('#comment-reset');
120
- $cancelButton.click();
121
-
122
- cb();
123
- });
124
-
125
- it('unmarks text', function (done) {
126
- if (textHighlightIsDisabled()) {
127
- return done();
128
- }
129
- const inner$ = helper.padInner$;
130
-
131
- // verify if there is no text marked with pre-comment class
132
- const $preCommentTextMarked = inner$('.pre-selected-comment');
133
- expect($preCommentTextMarked.length).to.be(0);
134
-
135
- done();
136
- });
137
- });
138
-
139
- context('when user submits the comment', function () {
140
- beforeEach(function (cb) {
141
- const outer$ = helper.padOuter$;
142
- const chrome$ = helper.padChrome$;
143
-
144
- // fill the comment form and submit it
145
- const $commentField = chrome$('textarea.comment-content');
146
- $commentField.val('My comment');
147
- const $hasSuggestion = outer$('.suggestion-checkbox');
148
- $hasSuggestion.click();
149
- const $suggestionField = outer$('textarea.to-value');
150
- $suggestionField.val('Change to this suggestion');
151
- const $submittButton = chrome$('.comment-buttons input[type=submit]');
152
- $submittButton.click();
153
-
154
- // wait until comment is created and comment id is set
155
- helper.waitFor(() => getCommentId() != null).done(cb);
156
- });
157
-
158
- it('unmarks text', function (done) {
159
- if (textHighlightIsDisabled()) {
160
- return done();
161
- }
162
- const inner$ = helper.padInner$;
163
-
164
- // verify if there is no text marked with pre-comment class
165
- const $preCommentTextMarked = inner$('.pre-selected-comment');
166
- expect($preCommentTextMarked.length).to.be(0);
167
-
168
- done();
169
- });
170
- });
171
-
172
- context('when user selects another text range and opens New Comment form for it', function () {
173
- beforeEach(function (cb) {
174
- selectLineAndOpenCommentForm(1, cb);
175
- });
176
-
177
- it('changes the marked text', function (done) {
178
- if (textHighlightIsDisabled()) {
179
- return done();
180
- }
181
- const inner$ = helper.padInner$;
182
-
183
- // verify if text was marked with pre-comment class
184
- const $preCommentTextMarked = inner$('.pre-selected-comment');
185
- expect($preCommentTextMarked.length).to.be(1);
186
- expect($preCommentTextMarked.text()).to.be('Line 2');
187
-
188
- done();
189
- });
190
- });
191
-
192
- /* ********** Helper functions ********** */
193
- const createPadWithTwoLines = (callback) => {
194
- const inner$ = helper.padInner$;
195
-
196
- // replace the first text element of pad with two lines
197
- const $firstLine = inner$('div').first();
198
- $firstLine.html('Line 1<br/>Line 2<br/>');
199
-
200
- // wait until the two lines are split into two divs
201
- helper.waitFor(() => {
202
- const $secondLine = inner$('div').first().next();
203
- return $secondLine.text() === 'Line 2';
204
- }).done(callback);
205
- };
206
-
207
- const selectLineAndOpenCommentForm = (lineNumber, callback) => {
208
- const chrome$ = helper.padChrome$;
209
-
210
- // select first line to add comment to
211
- const $targetLine = getLine(lineNumber);
212
- $targetLine.sendkeys('{selectall}');
213
-
214
- // get the comment button and click it
215
- const $commentButton = chrome$('.addComment');
216
- $commentButton.click();
217
-
218
- callback();
219
- };
220
-
221
- const getCommentId = () => {
222
- const inner$ = helper.padInner$;
223
- const comment = inner$('.comment').first();
224
- const cls = comment.attr('class');
225
- const classCommentId = /(?:^| )(c-[A-Za-z0-9]*)/.exec(cls);
226
- const commentId = (classCommentId) ? classCommentId[1] : null;
227
-
228
- return commentId;
229
- };
230
-
231
- const getLine = (lineNumber) => {
232
- const inner$ = helper.padInner$;
233
- let line = inner$('div').first();
234
- for (let i = lineNumber - 1; i >= 0; i--) {
235
- line = line.next();
236
- }
237
- return line;
238
- };
239
-
240
- const textHighlightIsDisabled = () => !helper.padChrome$.window.clientVars.highlightSelectedText;
241
- });