ep_comments_page 0.1.98 → 1.0.0
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.
- package/index.js +3 -9
- package/package.json +6 -6
- package/static/js/index.js +7 -3
- package/static/tests/frontend/specs/commentDelete.js +61 -121
- package/static/tests/frontend/specs/commentIcons.js +270 -306
- package/static/tests/frontend/specs/commentSuggestion.js +67 -50
- package/static/tests/frontend/specs/comment_l10n.js +127 -127
- package/static/tests/frontend/specs/timeFormat.js +202 -202
- package/static/tests/frontend/utils.js +14 -0
- package/templates/comments.html +1 -4
- package/locales/pt-BR.json +0 -26
|
@@ -1,334 +1,298 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
// create a new pad with comment before each test run
|
|
5
|
-
beforeEach(async function () {
|
|
6
|
-
await new Promise((resolve) => helper.newPad(resolve));
|
|
7
|
-
// make sure Etherpad has enough space to display comment icons
|
|
8
|
-
enlargeScreen();
|
|
9
|
-
// force sidebar comments to be shown
|
|
10
|
-
chooseToShowComments(true);
|
|
11
|
-
await createComment();
|
|
12
|
-
this.timeout(60000);
|
|
13
|
-
});
|
|
3
|
+
let freshPad = true;
|
|
14
4
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
5
|
+
before(async function () {
|
|
6
|
+
await helper.aNewPad();
|
|
7
|
+
// #commentIcons will only be inserted if icons are enabled
|
|
8
|
+
if (!helper.padChrome$.window.clientVars.displayCommentAsIcon) this.skip();
|
|
9
|
+
});
|
|
19
10
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
//
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
expect($commentIcons.length).to.be(0);
|
|
66
|
-
});
|
|
11
|
+
// create a new pad with comment before each test run
|
|
12
|
+
beforeEach(async function () {
|
|
13
|
+
this.timeout(60000);
|
|
14
|
+
if (!freshPad) await helper.aNewPad();
|
|
15
|
+
freshPad = false;
|
|
16
|
+
// make sure Etherpad has enough space to display comment icons
|
|
17
|
+
enlargeScreen();
|
|
18
|
+
// force sidebar comments to be shown
|
|
19
|
+
chooseToShowComments(true);
|
|
20
|
+
await createComment();
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
after(async function () {
|
|
24
|
+
// undo frame resize that was done on before()
|
|
25
|
+
$('#iframe-container iframe').css('max-width', '');
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it('adds a comment icon on the same height of commented text', async function () {
|
|
29
|
+
const inner$ = helper.padInner$;
|
|
30
|
+
const outer$ = helper.padOuter$;
|
|
31
|
+
const commentId = await getCommentId();
|
|
32
|
+
const $commentIcon = outer$(`#commentIcons #icon-${commentId}`);
|
|
33
|
+
|
|
34
|
+
// check icon exists
|
|
35
|
+
expect($commentIcon.length).to.be(1);
|
|
36
|
+
|
|
37
|
+
// check height is the same
|
|
38
|
+
const $commentedText = inner$(`.${commentId}`);
|
|
39
|
+
// all icons are +5px down to adjust position
|
|
40
|
+
const expectedTop = $commentedText.offset().top + 5;
|
|
41
|
+
expect($commentIcon.offset().top).to.be(expectedTop);
|
|
42
|
+
});
|
|
43
|
+
// TODO: Needs fixing
|
|
44
|
+
xit('does not show comment icon when commented text is removed', async function () {
|
|
45
|
+
const inner$ = helper.padInner$;
|
|
46
|
+
const outer$ = helper.padOuter$;
|
|
47
|
+
// remove commented text
|
|
48
|
+
const $commentedLine = inner$('div .comment').parent();
|
|
49
|
+
$commentedLine.sendkeys('{selectall}'); // select all
|
|
50
|
+
$commentedLine.sendkeys('{del}'); // clear the first line
|
|
51
|
+
// wait until comment deletion is done
|
|
52
|
+
await helper.waitForPromise(() => {
|
|
53
|
+
// check icon is not visible
|
|
54
|
+
const $commentIcons = outer$('#commentIcons .comment-icon:visible');
|
|
55
|
+
return $commentIcons.length === 0;
|
|
67
56
|
});
|
|
57
|
+
});
|
|
58
|
+
// TODO: Needs fixing
|
|
59
|
+
xit('does not show comment icon when comment is deleted', async function () {
|
|
60
|
+
const outer$ = helper.padOuter$;
|
|
61
|
+
|
|
62
|
+
await deleteComment();
|
|
63
|
+
// check icon is not visible
|
|
64
|
+
const $commentIcons = outer$('#commentIcons .comment-icon:visible');
|
|
65
|
+
expect($commentIcons.length).to.be(0);
|
|
66
|
+
});
|
|
68
67
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
if (ua.indexOf('
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
return this.skip();
|
|
79
|
-
}
|
|
68
|
+
it('updates comment icon height when commented text is moved to another line', async function () {
|
|
69
|
+
// don't run this test in safari. borrowed from
|
|
70
|
+
// https://stackoverflow.com/questions/7944460/detect-safari-browser
|
|
71
|
+
const ua = navigator.userAgent.toLowerCase();
|
|
72
|
+
if (ua.indexOf('safari') !== -1) {
|
|
73
|
+
if (ua.indexOf('chrome') > -1) {
|
|
74
|
+
// Chrome
|
|
75
|
+
} else {
|
|
76
|
+
return this.skip();
|
|
80
77
|
}
|
|
78
|
+
}
|
|
81
79
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
const commentId = await getCommentId();
|
|
86
|
-
|
|
87
|
-
// adds some new lines on the beginning of the text
|
|
88
|
-
const $firstTextElement = inner$('div').first();
|
|
89
|
-
$firstTextElement.sendkeys('{leftarrow}{enter}{enter}');
|
|
90
|
-
|
|
91
|
-
// wait until the new lines are split into separated .ace-line's
|
|
92
|
-
await helper.waitForPromise(() => inner$('div').length > 2);
|
|
93
|
-
|
|
94
|
-
// wait until comment is visible again
|
|
95
|
-
await helper.waitForPromise(() => {
|
|
96
|
-
const $commentIcons = outer$('#commentIcons .comment-icon:visible');
|
|
97
|
-
return $commentIcons.length !== 0;
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
// check height is the same
|
|
101
|
-
const $commentIcon = outer$(`#commentIcons #icon-${commentId}`);
|
|
102
|
-
const $commentedText = inner$(`.${commentId}`);
|
|
103
|
-
// all icons are +5px down to adjust position
|
|
104
|
-
const expectedTop = $commentedText.offset().top + 5;
|
|
105
|
-
expect($commentIcon.offset().top).to.be(expectedTop);
|
|
106
|
-
});
|
|
107
|
-
});
|
|
80
|
+
const inner$ = helper.padInner$;
|
|
81
|
+
const outer$ = helper.padOuter$;
|
|
82
|
+
const commentId = await getCommentId();
|
|
108
83
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
const outer$ = helper.padOuter$;
|
|
113
|
-
const commentId = await getCommentId();
|
|
84
|
+
// adds some new lines on the beginning of the text
|
|
85
|
+
const $firstTextElement = inner$('div').first();
|
|
86
|
+
$firstTextElement.sendkeys('{leftarrow}{enter}{enter}');
|
|
114
87
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
$commentIcon.click();
|
|
88
|
+
// wait until the new lines are split into separated .ace-line's
|
|
89
|
+
await helper.waitForPromise(() => inner$('div').length > 2);
|
|
118
90
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
91
|
+
// wait until comment is visible again
|
|
92
|
+
await helper.waitForPromise(() => {
|
|
93
|
+
const $commentIcons = outer$('#commentIcons .comment-icon:visible');
|
|
94
|
+
return $commentIcons.length !== 0;
|
|
123
95
|
});
|
|
124
96
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
97
|
+
// check height is the same
|
|
98
|
+
const $commentIcon = outer$(`#commentIcons #icon-${commentId}`);
|
|
99
|
+
const $commentedText = inner$(`.${commentId}`);
|
|
100
|
+
// all icons are +5px down to adjust position
|
|
101
|
+
const expectedTop = $commentedText.offset().top + 5;
|
|
102
|
+
expect($commentIcon.offset().top).to.be(expectedTop);
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
it('shows comment when user clicks on comment icon', async function () {
|
|
106
|
+
const outer$ = helper.padOuter$;
|
|
107
|
+
const commentId = await getCommentId();
|
|
108
|
+
|
|
109
|
+
// click on the icon
|
|
110
|
+
const $commentIcon = outer$(`#commentIcons #icon-${commentId}`).first();
|
|
111
|
+
$commentIcon.click();
|
|
112
|
+
|
|
113
|
+
// check sidebar comment is visible
|
|
114
|
+
const $openedSidebarComments = outer$('#comments .sidebar-comment:visible');
|
|
115
|
+
expect($openedSidebarComments.length).to.be(1);
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
it('hides comment when user clicks on comment icon twice', async function () {
|
|
119
|
+
// don't run this test in safari. borrowed from
|
|
120
|
+
// https://stackoverflow.com/questions/7944460/detect-safari-browser
|
|
121
|
+
const ua = navigator.userAgent.toLowerCase();
|
|
122
|
+
if (ua.indexOf('safari') !== -1) {
|
|
123
|
+
if (ua.indexOf('chrome') > -1) {
|
|
124
|
+
// Chrome
|
|
125
|
+
} else {
|
|
126
|
+
return this.skip();
|
|
135
127
|
}
|
|
128
|
+
}
|
|
136
129
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
const outer$ = helper.padOuter$;
|
|
140
|
-
const commentId = await getCommentId();
|
|
130
|
+
const outer$ = helper.padOuter$;
|
|
131
|
+
const commentId = await getCommentId();
|
|
141
132
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
133
|
+
// click on the icon to open, then click again to close
|
|
134
|
+
const $commentIcon = outer$(`#commentIcons #icon-${commentId}`).first();
|
|
135
|
+
$commentIcon.click();
|
|
136
|
+
$commentIcon.click();
|
|
146
137
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
});
|
|
138
|
+
// check sidebar comment is not visible
|
|
139
|
+
const $openedSidebarComments = outer$('#comments .sidebar-comment:visible');
|
|
140
|
+
expect($openedSidebarComments.length).to.be(0);
|
|
141
|
+
});
|
|
152
142
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
}
|
|
143
|
+
it('hides comment when user clicks outside of comment box', async function () {
|
|
144
|
+
// don't run this test in safari. borrowed from
|
|
145
|
+
// https://stackoverflow.com/questions/7944460/detect-safari-browser
|
|
146
|
+
const ua = navigator.userAgent.toLowerCase();
|
|
147
|
+
if (ua.indexOf('safari') !== -1) {
|
|
148
|
+
if (ua.indexOf('chrome') > -1) {
|
|
149
|
+
// Chrome
|
|
150
|
+
} else {
|
|
151
|
+
return this.skip();
|
|
163
152
|
}
|
|
153
|
+
}
|
|
164
154
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
const outer$ = helper.padOuter$;
|
|
168
|
-
const commentId = await getCommentId();
|
|
155
|
+
const outer$ = helper.padOuter$;
|
|
156
|
+
const commentId = await getCommentId();
|
|
169
157
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
158
|
+
// click on the icon to open
|
|
159
|
+
const $commentIcon = outer$(`#commentIcons #icon-${commentId}`).first();
|
|
160
|
+
$commentIcon.click();
|
|
173
161
|
|
|
174
|
-
|
|
175
|
-
|
|
162
|
+
// click outside the comment to hide it
|
|
163
|
+
outer$('#outerdocbody').click();
|
|
176
164
|
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
});
|
|
165
|
+
// check sidebar comment is not visible
|
|
166
|
+
const $openedSidebarComments = outer$('#comments .sidebar-comment:visible');
|
|
167
|
+
expect($openedSidebarComments.length).to.be(0);
|
|
168
|
+
});
|
|
182
169
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
}
|
|
170
|
+
it('hides 1st, shows 2nd comment when user clicks on one then another icon', async function () {
|
|
171
|
+
// don't run this test in safari. borrowed from
|
|
172
|
+
// https://stackoverflow.com/questions/7944460/detect-safari-browser
|
|
173
|
+
const ua = navigator.userAgent.toLowerCase();
|
|
174
|
+
if (ua.indexOf('safari') !== -1) {
|
|
175
|
+
if (ua.indexOf('chrome') > -1) {
|
|
176
|
+
// Chrome
|
|
177
|
+
} else {
|
|
178
|
+
return this.skip();
|
|
193
179
|
}
|
|
180
|
+
}
|
|
194
181
|
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
// wait until the new line is split into a separated .ace-line
|
|
205
|
-
await helper.waitForPromise(() => inner$('div').length > 2);
|
|
206
|
-
|
|
207
|
-
// ... then add a comment to second line
|
|
208
|
-
const $secondLine = inner$('div').eq(1);
|
|
209
|
-
$secondLine.sendkeys('{selectall}');
|
|
210
|
-
await addComment('Second Comment');
|
|
211
|
-
|
|
212
|
-
// click on the icon of first comment...
|
|
213
|
-
const $firstCommentIcon = outer$(`#commentIcons #icon-${await getCommentId(0)}`).first();
|
|
214
|
-
$firstCommentIcon.click();
|
|
215
|
-
// ... then click on the icon of last comment
|
|
216
|
-
const $secondCommentIcon = outer$(`#commentIcons #icon-${await getCommentId(1)}`).first();
|
|
217
|
-
$secondCommentIcon.click();
|
|
218
|
-
|
|
219
|
-
// check modal is visible
|
|
220
|
-
const $commentText = outer$('#comments .sidebar-comment:visible .comment-text').text();
|
|
221
|
-
expect($commentText).to.be('Second Comment');
|
|
222
|
-
});
|
|
223
|
-
});
|
|
182
|
+
const inner$ = helper.padInner$;
|
|
183
|
+
const outer$ = helper.padOuter$;
|
|
184
|
+
|
|
185
|
+
// add a second line...
|
|
186
|
+
const $lastTextElement = inner$('div').last();
|
|
187
|
+
$lastTextElement.sendkeys('Second line{enter}');
|
|
188
|
+
|
|
189
|
+
// wait until the new line is split into a separated .ace-line
|
|
190
|
+
await helper.waitForPromise(() => inner$('div').length > 2);
|
|
224
191
|
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
// add comment to last line of the text
|
|
241
|
-
const $lastTextElement = inner$('div').first();
|
|
242
|
-
$lastTextElement.sendkeys('{selectall}'); // need to select content to add comment to
|
|
243
|
-
|
|
244
|
-
await addComment('My comment');
|
|
245
|
-
};
|
|
246
|
-
|
|
247
|
-
// Assumes text is already selected, then add comment to the selected text
|
|
248
|
-
const addComment = async (commentText) => {
|
|
249
|
-
const inner$ = helper.padInner$;
|
|
250
|
-
const chrome$ = helper.padChrome$;
|
|
251
|
-
|
|
252
|
-
// get original number of comments, so can check if a new comment was created
|
|
253
|
-
const numberOfComments = inner$('.comment:visible').length;
|
|
254
|
-
|
|
255
|
-
// get the comment button and click it
|
|
256
|
-
const $commentButton = chrome$('.addComment');
|
|
257
|
-
$commentButton.click();
|
|
258
|
-
|
|
259
|
-
// fill the comment form and submit it
|
|
260
|
-
const $commentField = chrome$('textarea.comment-content');
|
|
261
|
-
$commentField.val(commentText);
|
|
262
|
-
// we don't need comment suggestion to be filled for these tests, but here's how to do it:
|
|
263
|
-
// var $hasSuggestion = outer$(".suggestion-checkbox");
|
|
264
|
-
// $hasSuggestion.click();
|
|
265
|
-
// var $suggestionField = outer$("textarea.to-value");
|
|
266
|
-
// $suggestionField.val("Change to this suggestion");
|
|
267
|
-
const $submittButton = chrome$('.comment-buttons input[type=submit]');
|
|
268
|
-
$submittButton.click();
|
|
269
|
-
|
|
270
|
-
// wait until comment is created and comment id is set
|
|
271
|
-
let running = false;
|
|
272
|
-
let success = false;
|
|
273
|
-
await helper.waitForPromise(() => {
|
|
274
|
-
if (success) return true;
|
|
275
|
-
if (!running) {
|
|
276
|
-
running = true;
|
|
277
|
-
getCommentId(numberOfComments).then((id) => {
|
|
278
|
-
running = false;
|
|
279
|
-
success = id != null;
|
|
280
|
-
});
|
|
281
|
-
}
|
|
282
|
-
return success;
|
|
283
|
-
});
|
|
284
|
-
};
|
|
285
|
-
|
|
286
|
-
const deleteComment = async () => {
|
|
287
|
-
const chrome$ = helper.padChrome$;
|
|
288
|
-
const outer$ = helper.padOuter$;
|
|
289
|
-
|
|
290
|
-
// click on the delete button
|
|
291
|
-
const $deleteButton = outer$('.comment-delete');
|
|
292
|
-
$deleteButton.click();
|
|
293
|
-
|
|
294
|
-
await helper.waitForPromise(() => chrome$('.sidebar-comment').is(':visible') === false);
|
|
295
|
-
};
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
const getCommentId = async (numberOfComments) => {
|
|
299
|
-
const nthComment = numberOfComments || 0;
|
|
300
|
-
const p = helper.waitFor(() => helper.padInner$);
|
|
301
|
-
p.fail(() => {}); // Prevent p from throwing an uncatchable exception on error.
|
|
302
|
-
await p;
|
|
303
|
-
const inner$ = helper.padInner$;
|
|
304
|
-
const comment = inner$('.comment').eq(nthComment);
|
|
305
|
-
const cls = comment.attr('class');
|
|
306
|
-
const classCommentId = /(?:^| )(c-[A-Za-z0-9]*)/.exec(cls);
|
|
307
|
-
const commentId = (classCommentId) ? classCommentId[1] : null;
|
|
308
|
-
return commentId;
|
|
309
|
-
};
|
|
310
|
-
|
|
311
|
-
const finishTestIfIconsAreNotEnabled = async (theTest) => {
|
|
312
|
-
// #commentIcons will only be inserted if icons are enabled
|
|
313
|
-
if (helper.padOuter$('#commentIcons').length !== 0) await theTest();
|
|
314
|
-
};
|
|
315
|
-
|
|
316
|
-
const chooseToShowComments = (shouldShowComments) => {
|
|
317
|
-
const chrome$ = helper.padChrome$;
|
|
318
|
-
|
|
319
|
-
// click on the settings button to make settings visible
|
|
320
|
-
const $settingsButton = chrome$('.buttonicon-settings');
|
|
321
|
-
$settingsButton.click();
|
|
322
|
-
|
|
323
|
-
// check "Show Comments"
|
|
324
|
-
const $showComments = chrome$('#options-comments');
|
|
325
|
-
if ($showComments.is(':checked') !== shouldShowComments) $showComments.click();
|
|
326
|
-
|
|
327
|
-
// hide settings again
|
|
328
|
-
$settingsButton.click();
|
|
329
|
-
};
|
|
330
|
-
|
|
331
|
-
const enlargeScreen = () => {
|
|
332
|
-
$('#iframe-container iframe').css('max-width', '1000px');
|
|
333
|
-
};
|
|
192
|
+
// ... then add a comment to second line
|
|
193
|
+
const $secondLine = inner$('div').eq(1);
|
|
194
|
+
$secondLine.sendkeys('{selectall}');
|
|
195
|
+
await addComment('Second Comment');
|
|
196
|
+
|
|
197
|
+
// click on the icon of first comment...
|
|
198
|
+
const $firstCommentIcon = outer$(`#commentIcons #icon-${await getCommentId(0)}`).first();
|
|
199
|
+
$firstCommentIcon.click();
|
|
200
|
+
// ... then click on the icon of last comment
|
|
201
|
+
const $secondCommentIcon = outer$(`#commentIcons #icon-${await getCommentId(1)}`).first();
|
|
202
|
+
$secondCommentIcon.click();
|
|
203
|
+
|
|
204
|
+
// check modal is visible
|
|
205
|
+
const $commentText = outer$('#comments .sidebar-comment:visible .comment-text').text();
|
|
206
|
+
expect($commentText).to.be('Second Comment');
|
|
334
207
|
});
|
|
208
|
+
|
|
209
|
+
/* ********** Helper functions ********** */
|
|
210
|
+
|
|
211
|
+
const createComment = async () => {
|
|
212
|
+
const inner$ = helper.padInner$;
|
|
213
|
+
|
|
214
|
+
// get the first text element out of the inner iframe
|
|
215
|
+
const $firstTextElement = inner$('div').first();
|
|
216
|
+
|
|
217
|
+
// simulate key presses to delete content
|
|
218
|
+
$firstTextElement.sendkeys('{selectall}'); // select all
|
|
219
|
+
$firstTextElement.sendkeys('{del}'); // clear the first line
|
|
220
|
+
$firstTextElement.sendkeys('This content will receive a comment{enter}'); // insert text
|
|
221
|
+
// wait until the two lines are split into two .ace-line's
|
|
222
|
+
await helper.waitForPromise(() => inner$('div').length > 1);
|
|
223
|
+
|
|
224
|
+
// add comment to last line of the text
|
|
225
|
+
const $lastTextElement = inner$('div').first();
|
|
226
|
+
$lastTextElement.sendkeys('{selectall}'); // need to select content to add comment to
|
|
227
|
+
|
|
228
|
+
await addComment('My comment');
|
|
229
|
+
};
|
|
230
|
+
|
|
231
|
+
// Assumes text is already selected, then add comment to the selected text
|
|
232
|
+
const addComment = async (commentText) => {
|
|
233
|
+
const inner$ = helper.padInner$;
|
|
234
|
+
const chrome$ = helper.padChrome$;
|
|
235
|
+
|
|
236
|
+
// get original number of comments, so can check if a new comment was created
|
|
237
|
+
const numberOfComments = inner$('.comment:visible').length;
|
|
238
|
+
|
|
239
|
+
// get the comment button and click it
|
|
240
|
+
const $commentButton = chrome$('.addComment');
|
|
241
|
+
$commentButton.click();
|
|
242
|
+
|
|
243
|
+
// fill the comment form and submit it
|
|
244
|
+
const $commentField = chrome$('textarea.comment-content');
|
|
245
|
+
$commentField.val(commentText);
|
|
246
|
+
// we don't need comment suggestion to be filled for these tests, but here's how to do it:
|
|
247
|
+
// var $hasSuggestion = outer$(".suggestion-checkbox");
|
|
248
|
+
// $hasSuggestion.click();
|
|
249
|
+
// var $suggestionField = outer$("textarea.to-value");
|
|
250
|
+
// $suggestionField.val("Change to this suggestion");
|
|
251
|
+
const $submittButton = chrome$('.comment-buttons input[type=submit]');
|
|
252
|
+
$submittButton.click();
|
|
253
|
+
|
|
254
|
+
// wait until comment is created and comment id is set
|
|
255
|
+
await helper.waitForPromise(async () => await getCommentId(numberOfComments) != null);
|
|
256
|
+
};
|
|
257
|
+
|
|
258
|
+
const deleteComment = async () => {
|
|
259
|
+
const chrome$ = helper.padChrome$;
|
|
260
|
+
const outer$ = helper.padOuter$;
|
|
261
|
+
|
|
262
|
+
// click on the delete button
|
|
263
|
+
const $deleteButton = outer$('.comment-delete');
|
|
264
|
+
$deleteButton.click();
|
|
265
|
+
|
|
266
|
+
await helper.waitForPromise(() => chrome$('.sidebar-comment').is(':visible') === false);
|
|
267
|
+
};
|
|
268
|
+
|
|
269
|
+
|
|
270
|
+
const getCommentId = async (numberOfComments) => {
|
|
271
|
+
const nthComment = numberOfComments || 0;
|
|
272
|
+
await helper.waitForPromise(() => helper.padInner$);
|
|
273
|
+
const inner$ = helper.padInner$;
|
|
274
|
+
const comment = inner$('.comment').eq(nthComment);
|
|
275
|
+
const cls = comment.attr('class');
|
|
276
|
+
const classCommentId = /(?:^| )(c-[A-Za-z0-9]*)/.exec(cls);
|
|
277
|
+
const commentId = (classCommentId) ? classCommentId[1] : null;
|
|
278
|
+
return commentId;
|
|
279
|
+
};
|
|
280
|
+
|
|
281
|
+
const chooseToShowComments = (shouldShowComments) => {
|
|
282
|
+
const chrome$ = helper.padChrome$;
|
|
283
|
+
|
|
284
|
+
// click on the settings button to make settings visible
|
|
285
|
+
const $settingsButton = chrome$('.buttonicon-settings');
|
|
286
|
+
$settingsButton.click();
|
|
287
|
+
|
|
288
|
+
// check "Show Comments"
|
|
289
|
+
const $showComments = chrome$('#options-comments');
|
|
290
|
+
if ($showComments.is(':checked') !== shouldShowComments) $showComments.click();
|
|
291
|
+
|
|
292
|
+
// hide settings again
|
|
293
|
+
$settingsButton.click();
|
|
294
|
+
};
|
|
295
|
+
|
|
296
|
+
const enlargeScreen = () => {
|
|
297
|
+
$('#iframe-container iframe').css('max-width', '1000px');
|
|
298
|
+
};
|