ep_font_size 0.4.59 → 0.4.60
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.
|
@@ -69,7 +69,7 @@ jobs:
|
|
|
69
69
|
working-directory: ./etherpad-lite
|
|
70
70
|
run: |
|
|
71
71
|
pnpm link --global $PLUGIN_NAME
|
|
72
|
-
pnpm run
|
|
72
|
+
pnpm run plugins i --path ../../plugin
|
|
73
73
|
env:
|
|
74
74
|
PLUGIN_NAME: ${{ steps.plugin_name.outputs.plugin_name }}
|
|
75
75
|
- name: Link ep_etherpad-lite
|
package/package.json
CHANGED
|
@@ -2,30 +2,32 @@
|
|
|
2
2
|
|
|
3
3
|
const common = require('ep_etherpad-lite/tests/backend/common');
|
|
4
4
|
const randomString = require('ep_etherpad-lite/static/js/pad_utils').randomString;
|
|
5
|
+
import {generateJWTToken, generateJWTTokenUser} from "ep_etherpad-lite/tests/backend/common";
|
|
5
6
|
|
|
6
7
|
let agent;
|
|
7
8
|
const apiVersion = 1;
|
|
8
|
-
const apiKey = common.apiKey;
|
|
9
9
|
|
|
10
10
|
// Creates a pad and returns the pad id. Calls the callback when finished.
|
|
11
|
-
const createPad = (padID, callback) => {
|
|
12
|
-
agent.get(`/api/${apiVersion}/createPad?
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
const createPad = async (padID, callback) => {
|
|
12
|
+
agent.get(`/api/${apiVersion}/createPad?padID=${padID}`)
|
|
13
|
+
.set("Authorization", await generateJWTToken())
|
|
14
|
+
.end((err, res) => {
|
|
15
|
+
if (err || (res.body.code !== 0)) callback(new Error('Unable to create new Pad'));
|
|
16
|
+
callback(padID);
|
|
17
|
+
});
|
|
17
18
|
};
|
|
18
19
|
|
|
19
|
-
const setHTML = (padID, html, callback) => {
|
|
20
|
-
agent.get(`/api/${apiVersion}/setHTML?
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
20
|
+
const setHTML = async (padID, html, callback) => {
|
|
21
|
+
agent.get(`/api/${apiVersion}/setHTML?padID=${padID}&html=${html}`)
|
|
22
|
+
.set("Authorization", await generateJWTToken())
|
|
23
|
+
.end((err, res) => {
|
|
24
|
+
if (err || (res.body.code !== 0)) callback(new Error('Unable to set pad HTML'));
|
|
25
|
+
callback(null, padID);
|
|
26
|
+
});
|
|
25
27
|
};
|
|
26
28
|
|
|
27
29
|
const getHTMLEndPointFor =
|
|
28
|
-
(padID, callback) => `/api/${apiVersion}/getHTML
|
|
30
|
+
(padID, callback) => `/api/${apiVersion}/getHTML?&padID=${padID}`;
|
|
29
31
|
|
|
30
32
|
const codeToBe = (expectedCode, res) => {
|
|
31
33
|
if (res.body.code !== expectedCode) {
|
|
@@ -72,26 +74,25 @@ describe('ep_font_size - export size styles to HTML', function () {
|
|
|
72
74
|
html = () => buildHTML(textWithSize('8'));
|
|
73
75
|
});
|
|
74
76
|
|
|
75
|
-
it('returns ok', function (
|
|
76
|
-
agent.get(getHTMLEndPointFor(padID))
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
77
|
+
it('returns ok', async function () {
|
|
78
|
+
await agent.get(getHTMLEndPointFor(padID))
|
|
79
|
+
.set("Authorization", await generateJWTToken())
|
|
80
|
+
.expect(codeToBe0)
|
|
81
|
+
.expect('Content-Type', /json/)
|
|
82
|
+
.expect(200);
|
|
80
83
|
});
|
|
81
84
|
|
|
82
|
-
it('returns HTML with size class', function (
|
|
83
|
-
agent.get(getHTMLEndPointFor(padID))
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
})
|
|
94
|
-
.end(done);
|
|
85
|
+
it('returns HTML with size class', async function () {
|
|
86
|
+
const res = await agent.get(getHTMLEndPointFor(padID))
|
|
87
|
+
.set("Authorization", await generateJWTToken());
|
|
88
|
+
const expectedRegex = regexWithSize('8');
|
|
89
|
+
const expectedsizes = new RegExp(expectedRegex);
|
|
90
|
+
const html = res.body.data.html;
|
|
91
|
+
const foundsize = html.match(expectedsizes);
|
|
92
|
+
if (!foundsize) {
|
|
93
|
+
throw new Error(
|
|
94
|
+
`size not exported. Regex used: ${expectedRegex}, html exported: ${html}`);
|
|
95
|
+
}
|
|
95
96
|
});
|
|
96
97
|
});
|
|
97
98
|
|
|
@@ -100,22 +101,20 @@ describe('ep_font_size - export size styles to HTML', function () {
|
|
|
100
101
|
html = () => buildHTML(textWithSize('8') + textWithSize('9'));
|
|
101
102
|
});
|
|
102
103
|
|
|
103
|
-
it('returns HTML with two size spans', function (
|
|
104
|
-
agent.get(getHTMLEndPointFor(padID))
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
})
|
|
118
|
-
.end(done);
|
|
104
|
+
it('returns HTML with two size spans', async function () {
|
|
105
|
+
const res = await agent.get(getHTMLEndPointFor(padID))
|
|
106
|
+
.set("Authorization", await generateJWTToken());
|
|
107
|
+
const firstsize = regexWithSize('8');
|
|
108
|
+
const secondsize = regexWithSize('9');
|
|
109
|
+
const expectedRegex = `${firstsize}.*${secondsize}`;
|
|
110
|
+
const expectedsizes = new RegExp(expectedRegex);
|
|
111
|
+
|
|
112
|
+
const html = res.body.data.html;
|
|
113
|
+
const foundsize = html.match(expectedsizes);
|
|
114
|
+
if (!foundsize) {
|
|
115
|
+
throw new Error(
|
|
116
|
+
`size not exported. Regex used: ${expectedRegex}, html exported: ${html}`);
|
|
117
|
+
}
|
|
119
118
|
});
|
|
120
119
|
});
|
|
121
120
|
|
|
@@ -124,20 +123,18 @@ describe('ep_font_size - export size styles to HTML', function () {
|
|
|
124
123
|
html = () => buildHTML('empty pad');
|
|
125
124
|
});
|
|
126
125
|
|
|
127
|
-
it('returns HTML with no size', function (
|
|
128
|
-
agent.get(getHTMLEndPointFor(padID))
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
})
|
|
140
|
-
.end(done);
|
|
126
|
+
it('returns HTML with no size', async function () {
|
|
127
|
+
const res = await agent.get(getHTMLEndPointFor(padID))
|
|
128
|
+
.set("Authorization", await generateJWTToken());
|
|
129
|
+
const expectedRegex = '.*empty pad.*';
|
|
130
|
+
const nosize = new RegExp(expectedRegex);
|
|
131
|
+
|
|
132
|
+
const html = res.body.data.html;
|
|
133
|
+
const foundsize = html.match(nosize);
|
|
134
|
+
if (!foundsize) {
|
|
135
|
+
throw new Error('size exported, should not have any. ' +
|
|
136
|
+
`Regex used: ${expectedRegex}, html exported: ${html}`);
|
|
137
|
+
}
|
|
141
138
|
});
|
|
142
139
|
});
|
|
143
140
|
|
|
@@ -148,20 +145,18 @@ describe('ep_font_size - export size styles to HTML', function () {
|
|
|
148
145
|
|
|
149
146
|
// Etherpad exports tags using the order they are defined on the array (bold is always inside
|
|
150
147
|
// size)
|
|
151
|
-
it('returns HTML with strong and size, in any order', function (
|
|
152
|
-
agent.get(getHTMLEndPointFor(padID))
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
})
|
|
164
|
-
.end(done);
|
|
148
|
+
it('returns HTML with strong and size, in any order', async function () {
|
|
149
|
+
const res = await agent.get(getHTMLEndPointFor(padID))
|
|
150
|
+
.set("Authorization", await generateJWTToken());
|
|
151
|
+
const txt = 'this is size 8 and bold';
|
|
152
|
+
const strongInside = new RegExp(regexWithSize('8', `<strong>${txt}</strong>`));
|
|
153
|
+
const sizeInside = new RegExp(`<strong>${regexWithSize('8', txt)}</strong>`);
|
|
154
|
+
const html = res.body.data.html;
|
|
155
|
+
const foundsize = html.match(strongInside) || html.match(sizeInside);
|
|
156
|
+
if (!foundsize) {
|
|
157
|
+
throw new Error(`size not exported. Regex used: [${strongInside.source} || ` +
|
|
158
|
+
`${sizeInside.source}], html exported: ${html}`);
|
|
159
|
+
}
|
|
165
160
|
});
|
|
166
161
|
});
|
|
167
162
|
|
|
@@ -172,20 +167,18 @@ describe('ep_font_size - export size styles to HTML', function () {
|
|
|
172
167
|
|
|
173
168
|
// Etherpad exports tags using the order they are defined on the array (bold is always inside
|
|
174
169
|
// size)
|
|
175
|
-
it('returns HTML with strong and size, in any order', function (
|
|
176
|
-
agent.get(getHTMLEndPointFor(padID))
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
})
|
|
188
|
-
.end(done);
|
|
170
|
+
it('returns HTML with strong and size, in any order', async function () {
|
|
171
|
+
const res = await agent.get(getHTMLEndPointFor(padID))
|
|
172
|
+
.set("Authorization", await generateJWTToken())
|
|
173
|
+
const txt = 'this is size 8 and bold';
|
|
174
|
+
const strongInside = new RegExp(regexWithSize('8', `<strong>${txt}</strong>`));
|
|
175
|
+
const sizeInside = new RegExp(`<strong>${regexWithSize('8', txt)}</strong>`);
|
|
176
|
+
const html = res.body.data.html;
|
|
177
|
+
const foundsize = html.match(strongInside) || html.match(sizeInside);
|
|
178
|
+
if (!foundsize) {
|
|
179
|
+
throw new Error(`size not exported. Regex used: [${strongInside.source} || ` +
|
|
180
|
+
`${sizeInside.source}], html exported: ${html}`);
|
|
181
|
+
}
|
|
189
182
|
});
|
|
190
183
|
});
|
|
191
184
|
|
|
@@ -194,19 +187,17 @@ describe('ep_font_size - export size styles to HTML', function () {
|
|
|
194
187
|
html = () => buildHTML(`no size here ${textWithSize('8')}`);
|
|
195
188
|
});
|
|
196
189
|
|
|
197
|
-
it('returns HTML with part with size and part without it', function (
|
|
198
|
-
agent.get(getHTMLEndPointFor(padID))
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
})
|
|
209
|
-
.end(done);
|
|
190
|
+
it('returns HTML with part with size and part without it', async function () {
|
|
191
|
+
const res = await agent.get(getHTMLEndPointFor(padID))
|
|
192
|
+
.set("Authorization", await generateJWTToken());
|
|
193
|
+
const expectedRegex = `no size here ${regexWithSize('8')}`;
|
|
194
|
+
const expectedsizes = new RegExp(expectedRegex);
|
|
195
|
+
const html = res.body.data.html;
|
|
196
|
+
const foundsize = html.match(expectedsizes);
|
|
197
|
+
if (!foundsize) {
|
|
198
|
+
throw new Error(
|
|
199
|
+
`size not exported. Regex used: ${expectedRegex}, html exported: ${html}`);
|
|
200
|
+
}
|
|
210
201
|
});
|
|
211
202
|
});
|
|
212
203
|
});
|