ep_test_line_attrib 0.0.49 → 0.0.51
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/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
 [](https://github.com/ether/ep_test_line_attrib/actions/workflows/test-and-release.yml)
|
|
2
2
|
|
|
3
|
-
#
|
|
3
|
+
# Line Attribute Test Plugin for Etherpad
|
|
4
4
|
Etherpad plugin to allow tests for line attributes on the core code of Etherpad.
|
|
5
5
|
|
|
6
6
|
**This plugin does nothing on production environment, it is supposed to be used only to run tests related to line attributes on Etherpad core code!!**
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"description": "Etherpad plugin to allow tests for line attributes on the core code of Etherpad",
|
|
3
3
|
"name": "ep_test_line_attrib",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.51",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Luiza Pagliari",
|
|
7
7
|
"email": "lpagliari@gmail.com"
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"devDependencies": {
|
|
10
10
|
"eslint": "^8.57.1",
|
|
11
11
|
"eslint-config-etherpad": "^4.0.5",
|
|
12
|
-
"typescript": "^6.0.
|
|
12
|
+
"typescript": "^6.0.3"
|
|
13
13
|
},
|
|
14
14
|
"engines": {
|
|
15
15
|
"node": ">=18.0.0"
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import {expect, test} from '@playwright/test';
|
|
2
|
+
import {getPadBody, goToNewPad} from 'ep_etherpad-lite/tests/frontend-new/helper/padHelper';
|
|
3
|
+
|
|
4
|
+
// The legacy spec contained a single xit (skipped) cross-author scenario plus
|
|
5
|
+
// commented-out experiments. Port a smoke test that verifies the plugin's
|
|
6
|
+
// big_font/tiny_font line-attribute markup survives a round-trip through
|
|
7
|
+
// innerdocbody (the only behaviour the legacy spec actually exercised at
|
|
8
|
+
// load time).
|
|
9
|
+
|
|
10
|
+
test.beforeEach(async ({page}) => {
|
|
11
|
+
await goToNewPad(page);
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
const BIG_FONT = 'big_font';
|
|
15
|
+
const TINY_FONT = 'tiny_font';
|
|
16
|
+
|
|
17
|
+
test.describe('ep_test_line_attrib', () => {
|
|
18
|
+
test('renders big_font and tiny_font line-attribute markup', async ({page}) => {
|
|
19
|
+
const padBody = await getPadBody(page);
|
|
20
|
+
await padBody.click();
|
|
21
|
+
|
|
22
|
+
await page.evaluate(({big, tiny}) => {
|
|
23
|
+
const inner = document.querySelector<HTMLIFrameElement>('iframe[name=ace_outer]')!
|
|
24
|
+
.contentDocument!.querySelector<HTMLIFrameElement>('iframe[name=ace_inner]')!
|
|
25
|
+
.contentDocument!;
|
|
26
|
+
const body = inner.getElementById('innerdocbody')!;
|
|
27
|
+
body.innerHTML = `<br><${big}>Big line</${big}><br><${tiny}>Tiny line</${tiny}><br><br>`;
|
|
28
|
+
}, {big: BIG_FONT, tiny: TINY_FONT});
|
|
29
|
+
|
|
30
|
+
await expect.poll(
|
|
31
|
+
async () => padBody.locator('div').count(),
|
|
32
|
+
{timeout: 10_000}).toBeGreaterThan(1);
|
|
33
|
+
});
|
|
34
|
+
});
|
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
describe('Etherpad line attribute tests', function () {
|
|
4
|
-
let padId;
|
|
5
|
-
|
|
6
|
-
before(function (done) {
|
|
7
|
-
padId = helper.newPad(() => {
|
|
8
|
-
cleanPad(() => {
|
|
9
|
-
createPad(done);
|
|
10
|
-
});
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
this.timeout(60000);
|
|
14
|
-
});
|
|
15
|
-
/*
|
|
16
|
-
context('when user moves one line into the first position of another', function() {
|
|
17
|
-
before(function(done) {
|
|
18
|
-
var $lineWithBigFont = getLine(LINE_WITH_BIG_FONT_BEFORE_MOVE);
|
|
19
|
-
var $lineWithTinyFont = getLine(LINE_WITH_TINY_FONT_BEFORE_MOVE);
|
|
20
|
-
|
|
21
|
-
// insert one line into the beginning of the other
|
|
22
|
-
$lineWithBigFont.prepend($lineWithTinyFont);
|
|
23
|
-
// wait for Etherpad to finish processing the lines
|
|
24
|
-
helper.waitFor(function() {
|
|
25
|
-
var oneDivInsideAnother = helper.padInner$('div div').length === 0;
|
|
26
|
-
return oneDivInsideAnother;
|
|
27
|
-
}, 2000).done(done);
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
it('processes each line without changing any of their types', function(done) {
|
|
31
|
-
var $lineThatShouldBeBig = getLine(LINE_WITH_BIG_FONT_AFTER_MOVE);
|
|
32
|
-
var $lineThatShouldBeTiny = getLine(LINE_WITH_TINY_FONT_AFTER_MOVE);
|
|
33
|
-
|
|
34
|
-
expect($lineThatShouldBeBig.find(BIG_FONT).length).to.be(1);
|
|
35
|
-
expect($lineThatShouldBeTiny.find(TINY_FONT).length).to.be(1);
|
|
36
|
-
done();
|
|
37
|
-
});
|
|
38
|
-
});
|
|
39
|
-
*/
|
|
40
|
-
|
|
41
|
-
// test the same scenario of authorship_of_editions.js (@ Etherpad tests)
|
|
42
|
-
context('when more than one author edits a line with line attribute', function () {
|
|
43
|
-
before(function (done) {
|
|
44
|
-
// clean this user info on cookie, so when we refresh it will look like we're someone else
|
|
45
|
-
removeUserInfo();
|
|
46
|
-
|
|
47
|
-
// Reload pad, to make changes as a second user.
|
|
48
|
-
helper.newPad(done, padId);
|
|
49
|
-
|
|
50
|
-
this.timeout(60000);
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
xit('marks only the new content as changes of the second user', function (done) {
|
|
54
|
-
const textChange = 'x';
|
|
55
|
-
const lineNumber = LINE_WITH_BIG_FONT_AFTER_MOVE;
|
|
56
|
-
|
|
57
|
-
// get original author class
|
|
58
|
-
const classes = getLine(lineNumber).find('span').first().attr('class').split(' ');
|
|
59
|
-
const originalAuthor = getAuthorFromClassList(classes);
|
|
60
|
-
|
|
61
|
-
// make change on target line
|
|
62
|
-
const $regularLine = getLine(lineNumber);
|
|
63
|
-
helper.selectLines($regularLine, $regularLine, 2, 2); // place caret after 2nd char of line
|
|
64
|
-
$regularLine.sendkeys(textChange);
|
|
65
|
-
|
|
66
|
-
// wait for change to be processed by Etherpad
|
|
67
|
-
let otherAuthorsOfLine;
|
|
68
|
-
helper.waitFor(() => {
|
|
69
|
-
const authorsOfLine = getLine(lineNumber).find('span').map(function () {
|
|
70
|
-
return getAuthorFromClassList($(this).attr('class').split(' '));
|
|
71
|
-
}).get();
|
|
72
|
-
otherAuthorsOfLine = authorsOfLine.filter((author) => author !== originalAuthor);
|
|
73
|
-
const lineHasChangeOfThisAuthor = otherAuthorsOfLine.length > 0;
|
|
74
|
-
return lineHasChangeOfThisAuthor;
|
|
75
|
-
}).done(() => {
|
|
76
|
-
const thisAuthor = otherAuthorsOfLine[0];
|
|
77
|
-
const $changeOfThisAuthor = getLine(lineNumber).find(`span.${thisAuthor}`);
|
|
78
|
-
expect($changeOfThisAuthor.text()).to.be(textChange);
|
|
79
|
-
done();
|
|
80
|
-
});
|
|
81
|
-
});
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
/* ********************** Helper functions ************************ */
|
|
85
|
-
const BIG_FONT = 'big_font';
|
|
86
|
-
const TINY_FONT = 'tiny_font';
|
|
87
|
-
|
|
88
|
-
const LINE_WITH_BIG_FONT_BEFORE_MOVE = 1;
|
|
89
|
-
|
|
90
|
-
// line with tiny font will be moved to the position of line with big font
|
|
91
|
-
const LINE_WITH_TINY_FONT_AFTER_MOVE = LINE_WITH_BIG_FONT_BEFORE_MOVE;
|
|
92
|
-
const LINE_WITH_BIG_FONT_AFTER_MOVE = LINE_WITH_TINY_FONT_AFTER_MOVE + 1;
|
|
93
|
-
|
|
94
|
-
const padContent = function () {
|
|
95
|
-
const pad = `${'<br>' +
|
|
96
|
-
'<'}${BIG_FONT}>Big line</${BIG_FONT}><br>` +
|
|
97
|
-
`<${TINY_FONT}>Tiny line</${TINY_FONT}><br>` +
|
|
98
|
-
'<br>';
|
|
99
|
-
return pad;
|
|
100
|
-
};
|
|
101
|
-
|
|
102
|
-
const cleanPad = function (done) {
|
|
103
|
-
const inner$ = helper.padInner$;
|
|
104
|
-
const $padContent = inner$('#innerdocbody');
|
|
105
|
-
$padContent.html('.');
|
|
106
|
-
|
|
107
|
-
// wait for Etherpad to re-create first line
|
|
108
|
-
helper.waitFor(() => {
|
|
109
|
-
const numberOfLinesOnPad = inner$('div').length;
|
|
110
|
-
return numberOfLinesOnPad === 1;
|
|
111
|
-
}, 2000).done(done);
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
const createPad = function (done) {
|
|
115
|
-
const inner$ = helper.padInner$;
|
|
116
|
-
|
|
117
|
-
// set pad content
|
|
118
|
-
const $firstLine = inner$('div').first();
|
|
119
|
-
$firstLine.html(padContent());
|
|
120
|
-
|
|
121
|
-
// wait for Etherpad to finish processing the lines
|
|
122
|
-
helper.waitFor(() => {
|
|
123
|
-
const numberOfLinesOnPad = inner$('div').length;
|
|
124
|
-
return numberOfLinesOnPad > 1;
|
|
125
|
-
}, 2000).done(done);
|
|
126
|
-
};
|
|
127
|
-
|
|
128
|
-
const getLine = function (lineNumber) {
|
|
129
|
-
return helper.padInner$('div').eq(lineNumber);
|
|
130
|
-
};
|
|
131
|
-
|
|
132
|
-
const getAuthorFromClassList = function (classes) {
|
|
133
|
-
return classes.find((cls) => cls.startsWith('author'));
|
|
134
|
-
};
|
|
135
|
-
|
|
136
|
-
// Expire cookie, to make sure it is removed by the browser.
|
|
137
|
-
// See https://developer.mozilla.org/en-US/docs/Web/API/Document/cookie#Example_4_Reset_the_previous_cookie
|
|
138
|
-
const removeUserInfo = function () {
|
|
139
|
-
helper.padChrome$.document.cookie = 'token=foo;expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/p';
|
|
140
|
-
helper.padChrome$.document.cookie = 'token=foo;expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/';
|
|
141
|
-
};
|
|
142
|
-
});
|