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 install-plugins --path ../../plugin
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
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "description": "Apply sizes to fonts",
3
3
  "name": "ep_font_size",
4
- "version": "0.4.59",
4
+ "version": "0.4.60",
5
5
  "license": "Apache-2.0",
6
6
  "author": {
7
7
  "name": "John McLear",
@@ -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?apikey=${apiKey}&padID=${padID}`)
13
- .end((err, res) => {
14
- if (err || (res.body.code !== 0)) callback(new Error('Unable to create new Pad'));
15
- callback(padID);
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?apikey=${apiKey}&padID=${padID}&html=${html}`)
21
- .end((err, res) => {
22
- if (err || (res.body.code !== 0)) callback(new Error('Unable to set pad HTML'));
23
- callback(null, padID);
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?apikey=${apiKey}&padID=${padID}`;
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 (done) {
76
- agent.get(getHTMLEndPointFor(padID))
77
- .expect(codeToBe0)
78
- .expect('Content-Type', /json/)
79
- .expect(200, done);
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 (done) {
83
- agent.get(getHTMLEndPointFor(padID))
84
- .expect((res) => {
85
- const expectedRegex = regexWithSize('8');
86
- const expectedsizes = new RegExp(expectedRegex);
87
- const html = res.body.data.html;
88
- const foundsize = html.match(expectedsizes);
89
- if (!foundsize) {
90
- throw new Error(
91
- `size not exported. Regex used: ${expectedRegex}, html exported: ${html}`);
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 (done) {
104
- agent.get(getHTMLEndPointFor(padID))
105
- .expect((res) => {
106
- const firstsize = regexWithSize('8');
107
- const secondsize = regexWithSize('9');
108
- const expectedRegex = `${firstsize}.*${secondsize}`;
109
- const expectedsizes = new RegExp(expectedRegex);
110
-
111
- const html = res.body.data.html;
112
- const foundsize = html.match(expectedsizes);
113
- if (!foundsize) {
114
- throw new Error(
115
- `size not exported. Regex used: ${expectedRegex}, html exported: ${html}`);
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 (done) {
128
- agent.get(getHTMLEndPointFor(padID))
129
- .expect((res) => {
130
- const expectedRegex = '.*empty pad.*';
131
- const nosize = new RegExp(expectedRegex);
132
-
133
- const html = res.body.data.html;
134
- const foundsize = html.match(nosize);
135
- if (!foundsize) {
136
- throw new Error('size exported, should not have any. ' +
137
- `Regex used: ${expectedRegex}, html exported: ${html}`);
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 (done) {
152
- agent.get(getHTMLEndPointFor(padID))
153
- .expect((res) => {
154
- const txt = 'this is size 8 and bold';
155
- const strongInside = new RegExp(regexWithSize('8', `<strong>${txt}</strong>`));
156
- const sizeInside = new RegExp(`<strong>${regexWithSize('8', txt)}</strong>`);
157
- const html = res.body.data.html;
158
- const foundsize = html.match(strongInside) || html.match(sizeInside);
159
- if (!foundsize) {
160
- throw new Error(`size not exported. Regex used: [${strongInside.source} || ` +
161
- `${sizeInside.source}], html exported: ${html}`);
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 (done) {
176
- agent.get(getHTMLEndPointFor(padID))
177
- .expect((res) => {
178
- const txt = 'this is size 8 and bold';
179
- const strongInside = new RegExp(regexWithSize('8', `<strong>${txt}</strong>`));
180
- const sizeInside = new RegExp(`<strong>${regexWithSize('8', txt)}</strong>`);
181
- const html = res.body.data.html;
182
- const foundsize = html.match(strongInside) || html.match(sizeInside);
183
- if (!foundsize) {
184
- throw new Error(`size not exported. Regex used: [${strongInside.source} || ` +
185
- `${sizeInside.source}], html exported: ${html}`);
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 (done) {
198
- agent.get(getHTMLEndPointFor(padID))
199
- .expect((res) => {
200
- const expectedRegex = `no size here ${regexWithSize('8')}`;
201
- const expectedsizes = new RegExp(expectedRegex);
202
- const html = res.body.data.html;
203
- const foundsize = html.match(expectedsizes);
204
- if (!foundsize) {
205
- throw new Error(
206
- `size not exported. Regex used: ${expectedRegex}, html exported: ${html}`);
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
  });