2021-02-16 18:25:15 -05:00
|
|
|
'use strict';
|
|
|
|
|
2019-12-03 23:14:00 +01:00
|
|
|
/*
|
|
|
|
* ACHTUNG: there is a copied & modified version of this file in
|
2021-02-04 18:43:27 -05:00
|
|
|
* <basedir>/src/tests/container/specs/api/pad.js
|
2019-12-03 23:14:00 +01:00
|
|
|
*
|
|
|
|
* TODO: unify those two files, and merge in a single one.
|
|
|
|
*/
|
|
|
|
|
2021-02-16 18:25:15 -05:00
|
|
|
const assert = require('assert').strict;
|
2020-10-08 01:37:17 -04:00
|
|
|
const common = require('../../common');
|
2021-11-22 15:16:00 -05:00
|
|
|
const padManager = require('../../../../node/db/PadManager');
|
2014-11-25 22:47:22 +00:00
|
|
|
|
2021-02-16 18:35:50 -05:00
|
|
|
let agent;
|
2020-10-08 01:37:17 -04:00
|
|
|
const apiKey = common.apiKey;
|
2020-11-23 13:21:51 -05:00
|
|
|
let apiVersion = 1;
|
|
|
|
const testPadId = makeid();
|
2021-10-03 20:06:30 -04:00
|
|
|
const newPadId = makeid();
|
|
|
|
const copiedPadId = makeid();
|
2020-11-23 13:21:51 -05:00
|
|
|
let lastEdited = '';
|
|
|
|
const text = generateLongText();
|
2018-08-06 23:15:48 +03:00
|
|
|
|
2021-02-16 18:25:15 -05:00
|
|
|
const endPoint = (point, version) => `/api/${version || apiVersion}/${point}?apikey=${apiKey}`;
|
|
|
|
|
2018-08-06 23:15:48 +03:00
|
|
|
/*
|
|
|
|
* Html document with nested lists of different types, to test its import and
|
|
|
|
* verify it is exported back correctly
|
|
|
|
*/
|
2020-11-23 13:21:51 -05:00
|
|
|
const ulHtml = '<!doctype html><html><body><ul class="bullet"><li>one</li><li>two</li><li>0</li><li>1</li><li>2<ul class="bullet"><li>3</li><li>4</li></ul></li></ul><ol class="number"><li>item<ol class="number"><li>item1</li><li>item2</li></ol></li></ol></body></html>';
|
2018-08-06 23:15:48 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* When exported back, Etherpad produces an html which is not exactly the same
|
|
|
|
* textually, but at least it remains standard compliant and has an equal DOM
|
|
|
|
* structure.
|
|
|
|
*/
|
2020-11-23 13:21:51 -05:00
|
|
|
const expectedHtml = '<!doctype html><html><body><ul class="bullet"><li>one</li><li>two</li><li>0</li><li>1</li><li>2<ul class="bullet"><li>3</li><li>4</ul></li></ul><ol start="1" class="number"><li>item<ol start="2" class="number"><li>item1</li><li>item2</ol></li></ol></body></html>';
|
2020-06-05 20:54:16 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Html document with space between list items, to test its import and
|
|
|
|
* verify it is exported back correctly
|
|
|
|
*/
|
2020-11-23 13:21:51 -05:00
|
|
|
const ulSpaceHtml = '<!doctype html><html><body><ul class="bullet"> <li>one</li></ul></body></html>';
|
2020-06-05 20:54:16 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
* When exported back, Etherpad produces an html which is not exactly the same
|
|
|
|
* textually, but at least it remains standard compliant and has an equal DOM
|
|
|
|
* structure.
|
|
|
|
*/
|
2020-11-23 13:21:51 -05:00
|
|
|
const expectedSpaceHtml = '<!doctype html><html><body><ul class="bullet"><li>one</ul></body></html>';
|
2014-11-25 22:47:22 +00:00
|
|
|
|
2020-11-23 13:21:51 -05:00
|
|
|
describe(__filename, function () {
|
2021-11-22 15:34:03 -05:00
|
|
|
before(async function () {
|
|
|
|
agent = await common.init();
|
|
|
|
const res = await agent.get('/api/')
|
|
|
|
.expect(200)
|
|
|
|
.expect('Content-Type', /json/);
|
|
|
|
apiVersion = res.body.currentVersion;
|
|
|
|
assert(apiVersion);
|
|
|
|
});
|
2021-02-16 18:35:50 -05:00
|
|
|
|
2021-10-03 20:06:30 -04:00
|
|
|
describe('Sanity checks', function () {
|
2021-10-02 19:17:47 -04:00
|
|
|
it('errors with invalid APIKey', async function () {
|
2020-10-09 18:19:46 -04:00
|
|
|
// This is broken because Etherpad doesn't handle HTTP codes properly see #2343
|
|
|
|
// If your APIKey is password you deserve to fail all tests anyway
|
2021-10-02 19:17:47 -04:00
|
|
|
await agent.get(`/api/${apiVersion}/createPad?apikey=password&padID=test`)
|
|
|
|
.expect(401);
|
2020-10-09 18:19:46 -04:00
|
|
|
});
|
2020-11-23 13:21:51 -05:00
|
|
|
});
|
2014-11-26 17:53:31 +00:00
|
|
|
|
2020-10-09 18:19:46 -04:00
|
|
|
/* Pad Tests Order of execution
|
|
|
|
-> deletePad -- This gives us a guaranteed clear environment
|
|
|
|
-> createPad
|
|
|
|
-> getRevisions -- Should be 0
|
|
|
|
-> getSavedRevisionsCount(padID) -- Should be 0
|
|
|
|
-> listSavedRevisions(padID) -- Should be an empty array
|
|
|
|
-> getHTML -- Should be the default pad text in HTML format
|
|
|
|
-> deletePad -- Should just delete a pad
|
|
|
|
-> getHTML -- Should return an error
|
|
|
|
-> createPad(withText)
|
|
|
|
-> getText -- Should have the text specified above as the pad text
|
|
|
|
-> setText
|
|
|
|
-> getText -- Should be the text set before
|
|
|
|
-> getRevisions -- Should be 0 still?
|
|
|
|
-> saveRevision
|
|
|
|
-> getSavedRevisionsCount(padID) -- Should be 0 still?
|
|
|
|
-> listSavedRevisions(padID) -- Should be an empty array still ?
|
|
|
|
-> padUsersCount -- Should be 0
|
|
|
|
-> getReadOnlyId -- Should be a value
|
|
|
|
-> listAuthorsOfPad(padID) -- should be empty array?
|
|
|
|
-> getLastEdited(padID) -- Should be when pad was made
|
|
|
|
-> setText(padId)
|
|
|
|
-> getLastEdited(padID) -- Should be when setText was performed
|
|
|
|
-> padUsers(padID) -- Should be when setText was performed
|
|
|
|
|
|
|
|
-> setText(padId, "hello world")
|
|
|
|
-> getLastEdited(padID) -- Should be when pad was made
|
|
|
|
-> getText(padId) -- Should be "hello world"
|
2021-02-03 00:30:07 +01:00
|
|
|
-> movePad(padID, newPadId) -- Should provide consistent pad data
|
2020-10-09 18:19:46 -04:00
|
|
|
-> getText(newPadId) -- Should be "hello world"
|
2021-02-03 00:30:07 +01:00
|
|
|
-> movePad(newPadID, originalPadId) -- Should provide consistent pad data
|
2020-10-09 18:19:46 -04:00
|
|
|
-> getText(originalPadId) -- Should be "hello world"
|
|
|
|
-> getLastEdited(padID) -- Should not be 0
|
|
|
|
-> appendText(padID, "hello")
|
|
|
|
-> getText(padID) -- Should be "hello worldhello"
|
2021-09-24 15:28:19 +01:00
|
|
|
-> getText(padID, rev=2) - should return "hello world"
|
2020-10-09 18:19:46 -04:00
|
|
|
-> setHTML(padID) -- Should fail on invalid HTML
|
|
|
|
-> setHTML(padID) *3 -- Should fail on invalid HTML
|
|
|
|
-> getHTML(padID) -- Should return HTML close to posted HTML
|
|
|
|
-> createPad -- Tries to create pads with bad url characters
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
2021-10-03 20:06:30 -04:00
|
|
|
describe('Tests', function () {
|
|
|
|
it('deletes a Pad that does not exist', async function () {
|
2021-10-02 19:17:47 -04:00
|
|
|
await agent.get(`${endPoint('deletePad')}&padID=${testPadId}`)
|
|
|
|
.expect(200) // @TODO: we shouldn't expect 200 here since the pad may not exist
|
|
|
|
.expect('Content-Type', /json/);
|
2020-10-09 18:19:46 -04:00
|
|
|
});
|
2015-02-25 01:05:58 +01:00
|
|
|
|
2021-10-02 19:17:47 -04:00
|
|
|
it('creates a new Pad', async function () {
|
|
|
|
const res = await agent.get(`${endPoint('createPad')}&padID=${testPadId}`)
|
|
|
|
.expect(200)
|
|
|
|
.expect('Content-Type', /json/);
|
2021-10-03 20:23:30 -04:00
|
|
|
assert.equal(res.body.code, 0);
|
2020-10-09 18:19:46 -04:00
|
|
|
});
|
2020-03-25 09:47:30 +01:00
|
|
|
|
2021-10-02 19:17:47 -04:00
|
|
|
it('gets revision count of Pad', async function () {
|
|
|
|
const res = await agent.get(`${endPoint('getRevisionsCount')}&padID=${testPadId}`)
|
|
|
|
.expect(200)
|
|
|
|
.expect('Content-Type', /json/);
|
2021-10-03 20:23:30 -04:00
|
|
|
assert.equal(res.body.code, 0);
|
|
|
|
assert.equal(res.body.data.revisions, 0);
|
2020-10-09 18:19:46 -04:00
|
|
|
});
|
2020-03-25 09:47:30 +01:00
|
|
|
|
2021-10-02 19:17:47 -04:00
|
|
|
it('gets saved revisions count of Pad', async function () {
|
|
|
|
const res = await agent.get(`${endPoint('getSavedRevisionsCount')}&padID=${testPadId}`)
|
|
|
|
.expect(200)
|
|
|
|
.expect('Content-Type', /json/);
|
2021-10-03 20:23:30 -04:00
|
|
|
assert.equal(res.body.code, 0);
|
|
|
|
assert.equal(res.body.data.savedRevisions, 0);
|
2020-10-09 18:19:46 -04:00
|
|
|
});
|
2014-11-26 17:53:31 +00:00
|
|
|
|
2021-10-02 19:17:47 -04:00
|
|
|
it('gets saved revision list of Pad', async function () {
|
|
|
|
const res = await agent.get(`${endPoint('listSavedRevisions')}&padID=${testPadId}`)
|
|
|
|
.expect(200)
|
|
|
|
.expect('Content-Type', /json/);
|
2021-10-03 20:23:30 -04:00
|
|
|
assert.equal(res.body.code, 0);
|
2021-10-02 19:17:47 -04:00
|
|
|
assert.deepEqual(res.body.data.savedRevisions, []);
|
2020-10-09 18:19:46 -04:00
|
|
|
});
|
2014-11-26 17:53:31 +00:00
|
|
|
|
2021-10-02 19:17:47 -04:00
|
|
|
it('get the HTML of Pad', async function () {
|
|
|
|
const res = await agent.get(`${endPoint('getHTML')}&padID=${testPadId}`)
|
|
|
|
.expect(200)
|
|
|
|
.expect('Content-Type', /json/);
|
2021-10-03 20:23:30 -04:00
|
|
|
assert(res.body.data.html.length > 1);
|
2020-10-09 18:19:46 -04:00
|
|
|
});
|
2014-11-26 17:53:31 +00:00
|
|
|
|
2021-10-02 19:17:47 -04:00
|
|
|
it('list all pads', async function () {
|
|
|
|
const res = await agent.get(endPoint('listAllPads'))
|
|
|
|
.expect(200)
|
|
|
|
.expect('Content-Type', /json/);
|
2021-10-03 20:23:30 -04:00
|
|
|
assert(res.body.data.padIDs.includes(testPadId));
|
2020-11-23 13:21:51 -05:00
|
|
|
});
|
2014-11-26 17:53:31 +00:00
|
|
|
|
2021-10-03 20:06:30 -04:00
|
|
|
it('deletes the Pad', async function () {
|
2021-10-02 19:17:47 -04:00
|
|
|
const res = await agent.get(`${endPoint('deletePad')}&padID=${testPadId}`)
|
|
|
|
.expect(200)
|
|
|
|
.expect('Content-Type', /json/);
|
2021-10-03 20:23:30 -04:00
|
|
|
assert.equal(res.body.code, 0);
|
2020-10-09 18:19:46 -04:00
|
|
|
});
|
2015-02-25 01:05:58 +01:00
|
|
|
|
2021-10-03 20:06:30 -04:00
|
|
|
it('list all pads again', async function () {
|
2021-10-02 19:17:47 -04:00
|
|
|
const res = await agent.get(endPoint('listAllPads'))
|
|
|
|
.expect(200)
|
|
|
|
.expect('Content-Type', /json/);
|
2021-10-03 20:23:30 -04:00
|
|
|
assert(!res.body.data.padIDs.includes(testPadId));
|
2020-11-23 13:21:51 -05:00
|
|
|
});
|
2014-11-26 17:53:31 +00:00
|
|
|
|
2021-10-02 19:17:47 -04:00
|
|
|
it('get the HTML of a Pad -- Should return a failure', async function () {
|
|
|
|
const res = await agent.get(`${endPoint('getHTML')}&padID=${testPadId}`)
|
|
|
|
.expect(200)
|
|
|
|
.expect('Content-Type', /json/);
|
2021-10-03 20:23:30 -04:00
|
|
|
assert.equal(res.body.code, 1);
|
2020-10-09 18:19:46 -04:00
|
|
|
});
|
2014-11-26 17:53:31 +00:00
|
|
|
|
2021-10-02 19:17:47 -04:00
|
|
|
it('creates a new Pad with text', async function () {
|
|
|
|
const res = await agent.get(`${endPoint('createPad')}&padID=${testPadId}&text=testText`)
|
|
|
|
.expect(200)
|
|
|
|
.expect('Content-Type', /json/);
|
2021-10-03 20:23:30 -04:00
|
|
|
assert.equal(res.body.code, 0);
|
2020-10-09 18:19:46 -04:00
|
|
|
});
|
2014-11-26 19:44:38 +00:00
|
|
|
|
2021-10-03 20:06:30 -04:00
|
|
|
it('gets the Pad text and expect it to be testText with trailing \\n', async function () {
|
2021-10-02 19:17:47 -04:00
|
|
|
const res = await agent.get(`${endPoint('getText')}&padID=${testPadId}`)
|
|
|
|
.expect(200)
|
|
|
|
.expect('Content-Type', /json/);
|
2021-10-03 20:23:30 -04:00
|
|
|
assert.equal(res.body.data.text, 'testText\n');
|
2020-10-09 18:19:46 -04:00
|
|
|
});
|
2014-12-24 04:01:18 +00:00
|
|
|
|
2021-10-03 20:06:30 -04:00
|
|
|
it('set text', async function () {
|
2021-10-02 19:17:47 -04:00
|
|
|
const res = await agent.post(endPoint('setText'))
|
2020-10-09 18:19:46 -04:00
|
|
|
.send({
|
2020-11-23 13:21:51 -05:00
|
|
|
padID: testPadId,
|
|
|
|
text: 'testTextTwo',
|
2020-10-09 18:19:46 -04:00
|
|
|
})
|
2021-10-02 19:17:47 -04:00
|
|
|
.expect(200)
|
|
|
|
.expect('Content-Type', /json/);
|
2021-10-03 20:23:30 -04:00
|
|
|
assert.equal(res.body.code, 0);
|
2020-10-09 18:19:46 -04:00
|
|
|
});
|
2014-12-29 15:08:30 +01:00
|
|
|
|
2021-10-02 19:17:47 -04:00
|
|
|
it('gets the Pad text', async function () {
|
|
|
|
const res = await agent.get(`${endPoint('getText')}&padID=${testPadId}`)
|
|
|
|
.expect(200)
|
|
|
|
.expect('Content-Type', /json/);
|
2021-10-03 20:23:30 -04:00
|
|
|
assert.equal(res.body.data.text, 'testTextTwo\n');
|
2020-10-09 18:19:46 -04:00
|
|
|
});
|
2014-12-29 15:08:30 +01:00
|
|
|
|
2021-10-02 19:17:47 -04:00
|
|
|
it('gets Revision Count of a Pad', async function () {
|
|
|
|
const res = await agent.get(`${endPoint('getRevisionsCount')}&padID=${testPadId}`)
|
|
|
|
.expect(200)
|
|
|
|
.expect('Content-Type', /json/);
|
2021-10-03 20:23:30 -04:00
|
|
|
assert.equal(res.body.data.revisions, 1);
|
2020-10-09 18:19:46 -04:00
|
|
|
});
|
2014-12-29 15:08:30 +01:00
|
|
|
|
2021-10-02 19:17:47 -04:00
|
|
|
it('saves Revision', async function () {
|
|
|
|
const res = await agent.get(`${endPoint('saveRevision')}&padID=${testPadId}`)
|
|
|
|
.expect(200)
|
|
|
|
.expect('Content-Type', /json/);
|
2021-10-03 20:23:30 -04:00
|
|
|
assert.equal(res.body.code, 0);
|
2020-10-09 18:19:46 -04:00
|
|
|
});
|
2014-12-29 15:08:30 +01:00
|
|
|
|
2021-10-03 20:06:30 -04:00
|
|
|
it('gets saved revisions count of Pad again', async function () {
|
2021-10-02 19:17:47 -04:00
|
|
|
const res = await agent.get(`${endPoint('getSavedRevisionsCount')}&padID=${testPadId}`)
|
|
|
|
.expect(200)
|
|
|
|
.expect('Content-Type', /json/);
|
2021-10-03 20:23:30 -04:00
|
|
|
assert.equal(res.body.code, 0);
|
|
|
|
assert.equal(res.body.data.savedRevisions, 1);
|
2020-10-09 18:19:46 -04:00
|
|
|
});
|
2014-12-29 15:08:30 +01:00
|
|
|
|
2021-10-03 20:06:30 -04:00
|
|
|
it('gets saved revision list of Pad again', async function () {
|
2021-10-02 19:17:47 -04:00
|
|
|
const res = await agent.get(`${endPoint('listSavedRevisions')}&padID=${testPadId}`)
|
|
|
|
.expect(200)
|
|
|
|
.expect('Content-Type', /json/);
|
2021-10-03 20:23:30 -04:00
|
|
|
assert.equal(res.body.code, 0);
|
2021-10-02 19:17:47 -04:00
|
|
|
assert.deepEqual(res.body.data.savedRevisions, [1]);
|
2020-10-09 18:19:46 -04:00
|
|
|
});
|
2021-10-02 19:17:47 -04:00
|
|
|
|
|
|
|
it('gets User Count of a Pad', async function () {
|
|
|
|
const res = await agent.get(`${endPoint('padUsersCount')}&padID=${testPadId}`)
|
|
|
|
.expect(200)
|
|
|
|
.expect('Content-Type', /json/);
|
2021-10-03 20:23:30 -04:00
|
|
|
assert.equal(res.body.data.padUsersCount, 0);
|
2020-10-09 18:19:46 -04:00
|
|
|
});
|
2014-12-29 15:08:30 +01:00
|
|
|
|
2021-10-02 19:17:47 -04:00
|
|
|
it('Gets the Read Only ID of a Pad', async function () {
|
|
|
|
const res = await agent.get(`${endPoint('getReadOnlyID')}&padID=${testPadId}`)
|
|
|
|
.expect(200)
|
|
|
|
.expect('Content-Type', /json/);
|
2021-10-03 20:23:30 -04:00
|
|
|
assert(res.body.data.readOnlyID);
|
2020-10-09 18:19:46 -04:00
|
|
|
});
|
2014-12-29 15:08:30 +01:00
|
|
|
|
2021-10-02 19:17:47 -04:00
|
|
|
it('Get Authors of the Pad', async function () {
|
|
|
|
const res = await agent.get(`${endPoint('listAuthorsOfPad')}&padID=${testPadId}`)
|
|
|
|
.expect(200)
|
|
|
|
.expect('Content-Type', /json/);
|
2021-10-03 20:23:30 -04:00
|
|
|
assert.equal(res.body.data.authorIDs.length, 0);
|
2020-10-09 18:19:46 -04:00
|
|
|
});
|
2014-12-24 04:01:18 +00:00
|
|
|
|
2021-10-02 19:17:47 -04:00
|
|
|
it('Get When Pad was left Edited', async function () {
|
|
|
|
const res = await agent.get(`${endPoint('getLastEdited')}&padID=${testPadId}`)
|
|
|
|
.expect(200)
|
|
|
|
.expect('Content-Type', /json/);
|
2021-10-03 20:23:30 -04:00
|
|
|
assert(res.body.data.lastEdited);
|
|
|
|
lastEdited = res.body.data.lastEdited;
|
2020-10-09 18:19:46 -04:00
|
|
|
});
|
2014-12-29 15:08:30 +01:00
|
|
|
|
2021-10-03 20:06:30 -04:00
|
|
|
it('set text again', async function () {
|
2021-10-02 19:17:47 -04:00
|
|
|
const res = await agent.post(endPoint('setText'))
|
2020-10-09 18:19:46 -04:00
|
|
|
.send({
|
2020-11-23 13:21:51 -05:00
|
|
|
padID: testPadId,
|
|
|
|
text: 'testTextTwo',
|
2020-10-09 18:19:46 -04:00
|
|
|
})
|
2021-10-02 19:17:47 -04:00
|
|
|
.expect(200)
|
|
|
|
.expect('Content-Type', /json/);
|
2021-10-03 20:23:30 -04:00
|
|
|
assert.equal(res.body.code, 0);
|
2020-10-09 18:19:46 -04:00
|
|
|
});
|
2015-10-19 12:58:47 -04:00
|
|
|
|
2021-10-03 20:06:30 -04:00
|
|
|
it('Get When Pad was left Edited again', async function () {
|
2021-10-02 19:17:47 -04:00
|
|
|
const res = await agent.get(`${endPoint('getLastEdited')}&padID=${testPadId}`)
|
|
|
|
.expect(200)
|
|
|
|
.expect('Content-Type', /json/);
|
2021-10-03 20:23:30 -04:00
|
|
|
assert(res.body.data.lastEdited > lastEdited);
|
2020-10-09 18:19:46 -04:00
|
|
|
});
|
|
|
|
|
2021-10-03 20:06:30 -04:00
|
|
|
it('gets User Count of a Pad again', async function () {
|
2021-10-02 19:17:47 -04:00
|
|
|
const res = await agent.get(`${endPoint('padUsers')}&padID=${testPadId}`)
|
|
|
|
.expect(200)
|
|
|
|
.expect('Content-Type', /json/);
|
2021-10-03 20:23:30 -04:00
|
|
|
assert.equal(res.body.data.padUsers.length, 0);
|
2020-10-09 18:19:46 -04:00
|
|
|
});
|
2015-10-19 12:58:47 -04:00
|
|
|
|
2021-10-02 19:17:47 -04:00
|
|
|
it('deletes a Pad', async function () {
|
|
|
|
const res = await agent.get(`${endPoint('deletePad')}&padID=${testPadId}`)
|
|
|
|
.expect(200)
|
|
|
|
.expect('Content-Type', /json/);
|
2021-10-03 20:23:30 -04:00
|
|
|
assert.equal(res.body.code, 0);
|
2020-10-09 18:19:46 -04:00
|
|
|
});
|
2015-10-19 12:58:47 -04:00
|
|
|
|
2021-10-03 20:06:30 -04:00
|
|
|
it('creates the Pad again', async function () {
|
2021-10-02 19:17:47 -04:00
|
|
|
const res = await agent.get(`${endPoint('createPad')}&padID=${testPadId}`)
|
|
|
|
.expect(200)
|
|
|
|
.expect('Content-Type', /json/);
|
2021-10-03 20:23:30 -04:00
|
|
|
assert.equal(res.body.code, 0);
|
2020-10-09 18:19:46 -04:00
|
|
|
});
|
|
|
|
|
2021-10-02 19:17:47 -04:00
|
|
|
it('Sets text on a pad Id', async function () {
|
|
|
|
const res = await agent.post(`${endPoint('setText')}&padID=${testPadId}`)
|
2020-11-23 13:21:51 -05:00
|
|
|
.field({text})
|
2021-10-02 19:17:47 -04:00
|
|
|
.expect(200)
|
|
|
|
.expect('Content-Type', /json/);
|
2021-10-03 20:23:30 -04:00
|
|
|
assert.equal(res.body.code, 0);
|
2020-10-09 18:19:46 -04:00
|
|
|
});
|
|
|
|
|
2021-10-02 19:17:47 -04:00
|
|
|
it('Gets text on a pad Id', async function () {
|
|
|
|
const res = await agent.get(`${endPoint('getText')}&padID=${testPadId}`)
|
|
|
|
.expect(200)
|
|
|
|
.expect('Content-Type', /json/);
|
2021-10-03 20:23:30 -04:00
|
|
|
assert.equal(res.body.code, 0);
|
|
|
|
assert.equal(res.body.data.text, `${text}\n`);
|
2020-10-09 18:19:46 -04:00
|
|
|
});
|
|
|
|
|
2021-10-02 19:17:47 -04:00
|
|
|
it('Sets text on a pad Id including an explicit newline', async function () {
|
|
|
|
const res = await agent.post(`${endPoint('setText')}&padID=${testPadId}`)
|
2020-11-23 13:21:51 -05:00
|
|
|
.field({text: `${text}\n`})
|
2021-10-02 19:17:47 -04:00
|
|
|
.expect(200)
|
|
|
|
.expect('Content-Type', /json/);
|
2021-10-03 20:23:30 -04:00
|
|
|
assert.equal(res.body.code, 0);
|
2020-10-09 18:19:46 -04:00
|
|
|
});
|
|
|
|
|
2021-10-02 19:17:47 -04:00
|
|
|
it("Gets text on a pad Id and doesn't have an excess newline", async function () {
|
|
|
|
const res = await agent.get(`${endPoint('getText')}&padID=${testPadId}`)
|
|
|
|
.expect(200)
|
|
|
|
.expect('Content-Type', /json/);
|
2021-10-03 20:23:30 -04:00
|
|
|
assert.equal(res.body.code, 0);
|
|
|
|
assert.equal(res.body.data.text, `${text}\n`);
|
2020-10-09 18:19:46 -04:00
|
|
|
});
|
|
|
|
|
2021-10-02 19:17:47 -04:00
|
|
|
it('Gets when pad was last edited', async function () {
|
|
|
|
const res = await agent.get(`${endPoint('getLastEdited')}&padID=${testPadId}`)
|
|
|
|
.expect(200)
|
|
|
|
.expect('Content-Type', /json/);
|
2021-10-03 20:23:30 -04:00
|
|
|
assert.notEqual(res.body.lastEdited, 0);
|
2020-10-09 18:19:46 -04:00
|
|
|
});
|
|
|
|
|
2021-10-02 19:17:47 -04:00
|
|
|
it('Move a Pad to a different Pad ID', async function () {
|
|
|
|
const res = await agent.get(
|
|
|
|
`${endPoint('movePad')}&sourceID=${testPadId}&destinationID=${newPadId}&force=true`)
|
|
|
|
.expect(200)
|
|
|
|
.expect('Content-Type', /json/);
|
2021-10-03 20:23:30 -04:00
|
|
|
assert.equal(res.body.code, 0);
|
2020-10-09 18:19:46 -04:00
|
|
|
});
|
|
|
|
|
2021-10-03 20:06:30 -04:00
|
|
|
it('Gets text from new pad', async function () {
|
2021-10-02 19:17:47 -04:00
|
|
|
const res = await agent.get(`${endPoint('getText')}&padID=${newPadId}`)
|
|
|
|
.expect(200)
|
|
|
|
.expect('Content-Type', /json/);
|
2021-10-03 20:23:30 -04:00
|
|
|
assert.equal(res.body.data.text, `${text}\n`);
|
2020-10-09 18:19:46 -04:00
|
|
|
});
|
|
|
|
|
2021-10-03 20:06:30 -04:00
|
|
|
it('Move pad back to original ID', async function () {
|
2021-10-02 19:17:47 -04:00
|
|
|
const res = await agent.get(
|
|
|
|
`${endPoint('movePad')}&sourceID=${newPadId}&destinationID=${testPadId}&force=false`)
|
|
|
|
.expect(200)
|
|
|
|
.expect('Content-Type', /json/);
|
2021-10-03 20:23:30 -04:00
|
|
|
assert.equal(res.body.code, 0);
|
2020-10-09 18:19:46 -04:00
|
|
|
});
|
|
|
|
|
2021-10-03 20:06:30 -04:00
|
|
|
it('Get text using original ID', async function () {
|
2021-10-02 19:17:47 -04:00
|
|
|
const res = await agent.get(`${endPoint('getText')}&padID=${testPadId}`)
|
|
|
|
.expect(200)
|
|
|
|
.expect('Content-Type', /json/);
|
2021-10-03 20:23:30 -04:00
|
|
|
assert.equal(res.body.data.text, `${text}\n`);
|
2020-10-09 18:19:46 -04:00
|
|
|
});
|
|
|
|
|
2021-10-03 20:06:30 -04:00
|
|
|
it('Get last edit of original ID', async function () {
|
2021-10-02 19:17:47 -04:00
|
|
|
const res = await agent.get(`${endPoint('getLastEdited')}&padID=${testPadId}`)
|
|
|
|
.expect(200)
|
|
|
|
.expect('Content-Type', /json/);
|
2021-10-03 20:23:30 -04:00
|
|
|
assert.notEqual(res.body.lastEdited, 0);
|
2020-10-09 18:19:46 -04:00
|
|
|
});
|
|
|
|
|
2021-10-02 19:17:47 -04:00
|
|
|
it('Append text to a pad Id', async function () {
|
2021-10-03 20:06:30 -04:00
|
|
|
let res = await agent.get(
|
2021-10-02 19:17:47 -04:00
|
|
|
`${endPoint('appendText', '1.2.13')}&padID=${testPadId}&text=hello`)
|
|
|
|
.expect(200)
|
|
|
|
.expect('Content-Type', /json/);
|
2021-10-03 20:23:30 -04:00
|
|
|
assert.equal(res.body.code, 0);
|
2021-10-03 20:06:30 -04:00
|
|
|
res = await agent.get(`${endPoint('getText')}&padID=${testPadId}`)
|
2021-10-02 19:17:47 -04:00
|
|
|
.expect(200)
|
|
|
|
.expect('Content-Type', /json/);
|
2021-10-03 20:23:30 -04:00
|
|
|
assert.equal(res.body.code, 0);
|
|
|
|
assert.equal(res.body.data.text, `${text}hello\n`);
|
2020-10-09 18:19:46 -04:00
|
|
|
});
|
2015-01-19 02:51:32 +00:00
|
|
|
|
2021-09-24 15:28:19 +01:00
|
|
|
it('getText of old revision', async function () {
|
|
|
|
let res = await agent.get(`${endPoint('getRevisionsCount')}&padID=${testPadId}`)
|
|
|
|
.expect(200)
|
|
|
|
.expect('Content-Type', /json/);
|
|
|
|
assert.equal(res.body.code, 0);
|
|
|
|
const rev = res.body.data.revisions;
|
|
|
|
assert(rev != null);
|
|
|
|
assert(Number.isInteger(rev));
|
|
|
|
assert(rev > 0);
|
|
|
|
res = await agent.get(`${endPoint('getText')}&padID=${testPadId}&rev=${rev - 1}`)
|
|
|
|
.expect(200)
|
|
|
|
.expect('Content-Type', /json/);
|
|
|
|
assert.equal(res.body.code, 0);
|
|
|
|
assert.equal(res.body.data.text, `${text}\n`);
|
|
|
|
});
|
|
|
|
|
2021-10-02 19:17:47 -04:00
|
|
|
it('Sets the HTML of a Pad attempting to pass ugly HTML', async function () {
|
2020-11-23 13:21:51 -05:00
|
|
|
const html = '<div><b>Hello HTML</title></head></div>';
|
2021-10-02 19:17:47 -04:00
|
|
|
const res = await agent.post(endPoint('setHTML'))
|
2020-10-09 18:19:46 -04:00
|
|
|
.send({
|
2020-11-23 13:21:51 -05:00
|
|
|
padID: testPadId,
|
|
|
|
html,
|
2020-10-09 18:19:46 -04:00
|
|
|
})
|
2021-10-02 19:17:47 -04:00
|
|
|
.expect(200)
|
|
|
|
.expect('Content-Type', /json/);
|
2021-10-03 20:23:30 -04:00
|
|
|
assert.equal(res.body.code, 0);
|
2020-10-09 18:19:46 -04:00
|
|
|
});
|
|
|
|
|
2021-10-03 20:06:30 -04:00
|
|
|
it('Pad with complex nested lists of different types', async function () {
|
|
|
|
let res = await agent.post(endPoint('setHTML'))
|
2020-10-09 18:19:46 -04:00
|
|
|
.send({
|
2020-11-23 13:21:51 -05:00
|
|
|
padID: testPadId,
|
|
|
|
html: ulHtml,
|
2020-10-09 18:19:46 -04:00
|
|
|
})
|
2021-10-02 19:17:47 -04:00
|
|
|
.expect(200)
|
|
|
|
.expect('Content-Type', /json/);
|
2021-10-03 20:23:30 -04:00
|
|
|
assert.equal(res.body.code, 0);
|
2021-10-03 20:06:30 -04:00
|
|
|
res = await agent.get(`${endPoint('getHTML')}&padID=${testPadId}`)
|
2021-10-02 19:17:47 -04:00
|
|
|
.expect(200)
|
|
|
|
.expect('Content-Type', /json/);
|
|
|
|
const receivedHtml = res.body.data.html.replace('<br></body>', '</body>').toLowerCase();
|
2021-10-03 20:23:30 -04:00
|
|
|
assert.equal(receivedHtml, expectedHtml);
|
2020-10-09 18:19:46 -04:00
|
|
|
});
|
2020-06-05 20:54:16 +01:00
|
|
|
|
2021-10-03 20:06:30 -04:00
|
|
|
it('Pad with white space between list items', async function () {
|
|
|
|
let res = await agent.get(`${endPoint('setHTML')}&padID=${testPadId}&html=${ulSpaceHtml}`)
|
2021-10-02 19:17:47 -04:00
|
|
|
.expect(200)
|
|
|
|
.expect('Content-Type', /json/);
|
2021-10-03 20:23:30 -04:00
|
|
|
assert.equal(res.body.code, 0);
|
2021-10-03 20:06:30 -04:00
|
|
|
res = await agent.get(`${endPoint('getHTML')}&padID=${testPadId}`)
|
2021-10-02 19:17:47 -04:00
|
|
|
.expect(200)
|
|
|
|
.expect('Content-Type', /json/);
|
|
|
|
const receivedHtml = res.body.data.html.replace('<br></body>', '</body>').toLowerCase();
|
2021-10-03 20:23:30 -04:00
|
|
|
assert.equal(receivedHtml, expectedSpaceHtml);
|
2020-10-09 18:19:46 -04:00
|
|
|
});
|
2015-04-11 15:50:51 +02:00
|
|
|
|
2021-10-02 19:17:47 -04:00
|
|
|
it('errors if pad can be created', async function () {
|
|
|
|
await Promise.all(['/', '%23', '%3F', '%26'].map(async (badUrlChar) => {
|
|
|
|
const res = await agent.get(`${endPoint('createPad')}&padID=${badUrlChar}`)
|
|
|
|
.expect('Content-Type', /json/);
|
2021-10-03 20:23:30 -04:00
|
|
|
assert.equal(res.body.code, 1);
|
2021-10-02 19:17:47 -04:00
|
|
|
}));
|
2020-10-09 18:19:46 -04:00
|
|
|
});
|
2020-09-16 15:24:09 -03:00
|
|
|
|
2021-10-02 19:17:47 -04:00
|
|
|
it('copies the content of a existent pad', async function () {
|
|
|
|
const res = await agent.get(
|
|
|
|
`${endPoint('copyPad')}&sourceID=${testPadId}&destinationID=${copiedPadId}&force=true`)
|
|
|
|
.expect(200)
|
|
|
|
.expect('Content-Type', /json/);
|
2021-10-03 20:23:30 -04:00
|
|
|
assert.equal(res.body.code, 0);
|
2020-10-09 18:19:46 -04:00
|
|
|
});
|
2021-10-29 00:53:36 +02:00
|
|
|
|
|
|
|
it('does not add an useless revision', async function () {
|
|
|
|
let res = await agent.post(`${endPoint('setText')}&padID=${testPadId}`)
|
|
|
|
.field({text: 'identical text\n'})
|
|
|
|
.expect(200)
|
|
|
|
.expect('Content-Type', /json/);
|
|
|
|
assert.equal(res.body.code, 0);
|
|
|
|
|
|
|
|
res = await agent.get(`${endPoint('getText')}&padID=${testPadId}`)
|
|
|
|
.expect(200)
|
|
|
|
.expect('Content-Type', /json/);
|
|
|
|
assert.equal(res.body.data.text, 'identical text\n');
|
|
|
|
|
|
|
|
res = await agent.get(`${endPoint('getRevisionsCount')}&padID=${testPadId}`)
|
|
|
|
.expect(200)
|
|
|
|
.expect('Content-Type', /json/);
|
|
|
|
const revCount = res.body.data.revisions;
|
|
|
|
|
|
|
|
res = await agent.post(`${endPoint('setText')}&padID=${testPadId}`)
|
|
|
|
.field({text: 'identical text\n'})
|
|
|
|
.expect(200)
|
|
|
|
.expect('Content-Type', /json/);
|
|
|
|
assert.equal(res.body.code, 0);
|
|
|
|
|
|
|
|
res = await agent.get(`${endPoint('getRevisionsCount')}&padID=${testPadId}`)
|
|
|
|
.expect(200)
|
|
|
|
.expect('Content-Type', /json/);
|
|
|
|
assert.equal(res.body.data.revisions, revCount);
|
|
|
|
});
|
2020-11-23 13:21:51 -05:00
|
|
|
});
|
2020-09-16 15:24:09 -03:00
|
|
|
|
2020-11-23 13:21:51 -05:00
|
|
|
describe('copyPadWithoutHistory', function () {
|
|
|
|
const sourcePadId = makeid();
|
|
|
|
let newPad;
|
2020-09-16 15:24:09 -03:00
|
|
|
|
2021-10-02 19:17:47 -04:00
|
|
|
before(async function () {
|
|
|
|
await createNewPadWithHtml(sourcePadId, ulHtml);
|
2020-10-09 18:19:46 -04:00
|
|
|
});
|
2020-09-16 15:24:09 -03:00
|
|
|
|
2021-02-16 18:25:15 -05:00
|
|
|
beforeEach(async function () {
|
2020-10-09 18:19:46 -04:00
|
|
|
newPad = makeid();
|
2020-11-23 13:21:51 -05:00
|
|
|
});
|
2020-09-16 15:24:09 -03:00
|
|
|
|
2021-10-02 19:17:47 -04:00
|
|
|
it('returns a successful response', async function () {
|
|
|
|
const res = await agent.get(`${endPoint('copyPadWithoutHistory')}&sourceID=${sourcePadId}` +
|
|
|
|
`&destinationID=${newPad}&force=false`)
|
|
|
|
.expect(200)
|
|
|
|
.expect('Content-Type', /json/);
|
2021-10-03 20:23:30 -04:00
|
|
|
assert.equal(res.body.code, 0);
|
2020-10-09 18:19:46 -04:00
|
|
|
});
|
2020-09-16 15:24:09 -03:00
|
|
|
|
2020-10-09 18:19:46 -04:00
|
|
|
// this test validates if the source pad's text and attributes are kept
|
2021-10-02 19:17:47 -04:00
|
|
|
it('creates a new pad with the same content as the source pad', async function () {
|
|
|
|
let res = await agent.get(`${endPoint('copyPadWithoutHistory')}&sourceID=${sourcePadId}` +
|
|
|
|
`&destinationID=${newPad}&force=false`);
|
2021-10-03 20:23:30 -04:00
|
|
|
assert.equal(res.body.code, 0);
|
2021-10-02 19:17:47 -04:00
|
|
|
res = await agent.get(`${endPoint('getHTML')}&padID=${newPad}`)
|
|
|
|
.expect(200);
|
|
|
|
const receivedHtml = res.body.data.html.replace('<br><br></body>', '</body>').toLowerCase();
|
2021-10-03 20:23:30 -04:00
|
|
|
assert.equal(receivedHtml, expectedHtml);
|
2020-10-09 18:19:46 -04:00
|
|
|
});
|
2020-09-16 15:24:09 -03:00
|
|
|
|
2021-11-22 15:34:03 -05:00
|
|
|
it('copying to a non-existent group throws an error', async function () {
|
|
|
|
const padWithNonExistentGroup = `notExistentGroup$${newPad}`;
|
|
|
|
const res = await agent.get(`${endPoint('copyPadWithoutHistory')}` +
|
|
|
|
`&sourceID=${sourcePadId}` +
|
|
|
|
`&destinationID=${padWithNonExistentGroup}&force=true`)
|
|
|
|
.expect(200);
|
|
|
|
assert.equal(res.body.code, 1);
|
2020-10-09 18:19:46 -04:00
|
|
|
});
|
2020-09-16 15:24:09 -03:00
|
|
|
|
2021-11-22 15:34:03 -05:00
|
|
|
describe('copying to an existing pad', function () {
|
|
|
|
beforeEach(async function () {
|
|
|
|
await createNewPadWithHtml(newPad, ulHtml);
|
2020-10-09 18:19:46 -04:00
|
|
|
});
|
2020-09-16 15:24:09 -03:00
|
|
|
|
2021-11-22 15:34:03 -05:00
|
|
|
it('force=false fails', async function () {
|
2021-10-03 20:06:30 -04:00
|
|
|
const res = await agent.get(`${endPoint('copyPadWithoutHistory')}` +
|
|
|
|
`&sourceID=${sourcePadId}` +
|
2021-11-22 15:34:03 -05:00
|
|
|
`&destinationID=${newPad}&force=false`)
|
2021-10-03 20:06:30 -04:00
|
|
|
.expect(200);
|
2021-10-03 20:23:30 -04:00
|
|
|
assert.equal(res.body.code, 1);
|
2020-09-16 15:24:09 -03:00
|
|
|
});
|
|
|
|
|
2021-11-22 15:34:03 -05:00
|
|
|
it('force=true succeeds', async function () {
|
2021-10-03 20:06:30 -04:00
|
|
|
const res = await agent.get(`${endPoint('copyPadWithoutHistory')}` +
|
|
|
|
`&sourceID=${sourcePadId}` +
|
2021-11-22 15:34:03 -05:00
|
|
|
`&destinationID=${newPad}&force=true`)
|
2021-10-03 20:06:30 -04:00
|
|
|
.expect(200);
|
2021-10-03 20:23:30 -04:00
|
|
|
assert.equal(res.body.code, 0);
|
2020-09-16 15:24:09 -03:00
|
|
|
});
|
2020-11-23 13:21:51 -05:00
|
|
|
});
|
2021-11-22 15:16:00 -05:00
|
|
|
|
|
|
|
// Regression test for https://github.com/ether/etherpad-lite/issues/5296
|
|
|
|
it('source and destination attribute pools are independent', async function () {
|
|
|
|
// Strategy for this test:
|
|
|
|
// 1. Create a new pad without bold or italic text
|
|
|
|
// 2. Use copyPadWithoutHistory to copy the pad.
|
|
|
|
// 3. Add some bold text (but no italic text!) to the source pad. This should add a bold
|
|
|
|
// attribute to the source pad's pool but not to the destination pad's pool.
|
|
|
|
// 4. Add some italic text (but no bold text!) to the destination pad. This should add an
|
|
|
|
// italic attribute to the destination pad's pool with the same number as the newly added
|
|
|
|
// bold attribute in the source pad's pool.
|
|
|
|
// 5. Add some more text (bold or plain) to the source pad. This will save the source pad to
|
|
|
|
// the database after the destination pad has had an opportunity to corrupt the source
|
|
|
|
// pad.
|
|
|
|
// 6. Export the source and destination pads. Make sure that <em> doesn't appear in the
|
|
|
|
// source pad's HTML, and that <strong> doesn't appear int he destination pad's HTML.
|
|
|
|
// 7. Force the server to re-init the pads from the database.
|
|
|
|
// 8. Repeat step 6.
|
|
|
|
// If <em> appears in the source pad, or <strong> appears in the destination pad, then shared
|
|
|
|
// state between the two attribute pools caused corruption.
|
|
|
|
|
|
|
|
const getHtml = async (padId) => {
|
|
|
|
const res = await agent.get(`${endPoint('getHTML')}&padID=${padId}`)
|
|
|
|
.expect(200)
|
|
|
|
.expect('Content-Type', /json/);
|
|
|
|
assert.equal(res.body.code, 0);
|
|
|
|
return res.body.data.html;
|
|
|
|
};
|
|
|
|
|
|
|
|
const setBody = async (padId, bodyHtml) => {
|
|
|
|
await agent.post(endPoint('setHTML'))
|
|
|
|
.send({padID: padId, html: `<!DOCTYPE HTML><html><body>${bodyHtml}</body></html>`})
|
|
|
|
.expect(200)
|
|
|
|
.expect('Content-Type', /json/)
|
|
|
|
.expect((res) => assert.equal(res.body.code, 0));
|
|
|
|
};
|
|
|
|
|
|
|
|
const origHtml = await getHtml(sourcePadId);
|
|
|
|
assert.doesNotMatch(origHtml, /<strong>/);
|
|
|
|
assert.doesNotMatch(origHtml, /<em>/);
|
|
|
|
await agent.get(`${endPoint('copyPadWithoutHistory')}&sourceID=${sourcePadId}` +
|
|
|
|
`&destinationID=${newPad}&force=false`)
|
|
|
|
.expect(200)
|
|
|
|
.expect('Content-Type', /json/)
|
|
|
|
.expect((res) => assert.equal(res.body.code, 0));
|
|
|
|
|
|
|
|
const newBodySrc = '<strong>bold</strong>';
|
|
|
|
const newBodyDst = '<em>italic</em>';
|
|
|
|
await setBody(sourcePadId, newBodySrc);
|
|
|
|
await setBody(newPad, newBodyDst);
|
|
|
|
await setBody(sourcePadId, `${newBodySrc} foo`);
|
|
|
|
|
|
|
|
let [srcHtml, dstHtml] = await Promise.all([getHtml(sourcePadId), getHtml(newPad)]);
|
|
|
|
assert.match(srcHtml, new RegExp(newBodySrc));
|
|
|
|
assert.match(dstHtml, new RegExp(newBodyDst));
|
|
|
|
|
|
|
|
// Force the server to re-read the pads from the database. This rebuilds the attribute pool
|
|
|
|
// objects from scratch, ensuring that an internally inconsistent attribute pool object did
|
|
|
|
// not cause the above tests to accidentally pass.
|
|
|
|
const reInitPad = async (padId) => {
|
|
|
|
const pad = await padManager.getPad(padId);
|
|
|
|
await pad.init();
|
|
|
|
};
|
|
|
|
await Promise.all([
|
|
|
|
reInitPad(sourcePadId),
|
|
|
|
reInitPad(newPad),
|
|
|
|
]);
|
|
|
|
|
|
|
|
[srcHtml, dstHtml] = await Promise.all([getHtml(sourcePadId), getHtml(newPad)]);
|
|
|
|
assert.match(srcHtml, new RegExp(newBodySrc));
|
|
|
|
assert.match(dstHtml, new RegExp(newBodyDst));
|
|
|
|
});
|
2020-11-23 13:21:51 -05:00
|
|
|
});
|
2020-10-09 18:19:46 -04:00
|
|
|
});
|
2015-01-19 02:51:32 +00:00
|
|
|
|
2014-12-29 15:08:30 +01:00
|
|
|
/*
|
|
|
|
-> movePadForce Test
|
|
|
|
|
|
|
|
*/
|
2014-11-26 19:44:38 +00:00
|
|
|
|
2021-10-02 19:17:47 -04:00
|
|
|
const createNewPadWithHtml = async (padId, html) => {
|
|
|
|
await agent.get(`${endPoint('createPad')}&padID=${padId}`);
|
|
|
|
await agent.post(endPoint('setHTML'))
|
|
|
|
.send({
|
|
|
|
padID: padId,
|
|
|
|
html,
|
2020-11-23 13:21:51 -05:00
|
|
|
});
|
|
|
|
};
|
2020-09-16 15:24:09 -03:00
|
|
|
|
2020-11-21 13:37:57 -05:00
|
|
|
function makeid() {
|
2020-11-23 13:21:51 -05:00
|
|
|
let text = '';
|
|
|
|
const possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
2014-11-26 01:11:42 +00:00
|
|
|
|
2020-11-23 13:21:51 -05:00
|
|
|
for (let i = 0; i < 5; i++) {
|
2014-11-26 01:11:42 +00:00
|
|
|
text += possible.charAt(Math.floor(Math.random() * possible.length));
|
|
|
|
}
|
|
|
|
return text;
|
|
|
|
}
|
2014-12-29 21:13:07 +01:00
|
|
|
|
2020-11-23 13:21:51 -05:00
|
|
|
function generateLongText() {
|
|
|
|
let text = '';
|
|
|
|
const possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
2014-12-29 21:13:07 +01:00
|
|
|
|
2020-11-23 13:21:51 -05:00
|
|
|
for (let i = 0; i < 80000; i++) {
|
2014-12-29 21:13:07 +01:00
|
|
|
text += possible.charAt(Math.floor(Math.random() * possible.length));
|
|
|
|
}
|
|
|
|
return text;
|
|
|
|
}
|