tests: Switch import/export tests to self-contained server

This makes it possible to test various settings combinations and
examine internal state to confirm correct behavior. Also, the user
doesn't need to start an Etherpad server before running these tests.
pull/4391/head
Richard Hansen 2020-10-01 17:32:45 -04:00 committed by John McLear
parent 32b6d8e37f
commit 2f17849b7b
1 changed files with 4 additions and 3 deletions

View File

@ -3,12 +3,10 @@
*/ */
const assert = require('assert').strict; const assert = require('assert').strict;
const common = require('../../common');
const superagent = require(__dirname+'/../../../../src/node_modules/superagent'); const superagent = require(__dirname+'/../../../../src/node_modules/superagent');
const supertest = require(__dirname+'/../../../../src/node_modules/supertest');
const fs = require('fs'); const fs = require('fs');
const settings = require(__dirname+'/../../../../src/node/utils/Settings'); const settings = require(__dirname+'/../../../../src/node/utils/Settings');
const host = 'http://127.0.0.1:'+settings.port;
const agent = supertest(`http://${settings.ip}:${settings.port}`);
const path = require('path'); const path = require('path');
const padText = fs.readFileSync("../tests/backend/specs/api/test.txt"); const padText = fs.readFileSync("../tests/backend/specs/api/test.txt");
const etherpadDoc = fs.readFileSync("../tests/backend/specs/api/test.etherpad"); const etherpadDoc = fs.readFileSync("../tests/backend/specs/api/test.etherpad");
@ -18,11 +16,14 @@ const odtDoc = fs.readFileSync("../tests/backend/specs/api/test.odt");
const pdfDoc = fs.readFileSync("../tests/backend/specs/api/test.pdf"); const pdfDoc = fs.readFileSync("../tests/backend/specs/api/test.pdf");
var filePath = path.join(__dirname, '../../../../APIKEY.txt'); var filePath = path.join(__dirname, '../../../../APIKEY.txt');
let agent;
var apiKey = fs.readFileSync(filePath, {encoding: 'utf-8'}); var apiKey = fs.readFileSync(filePath, {encoding: 'utf-8'});
apiKey = apiKey.replace(/\n$/, ""); apiKey = apiKey.replace(/\n$/, "");
var apiVersion = 1; var apiVersion = 1;
var testPadId = makeid(); var testPadId = makeid();
before(async function() { agent = await common.init(); });
describe('Connectivity', function(){ describe('Connectivity', function(){
it('can connect', async function() { it('can connect', async function() {
await agent.get('/api/') await agent.get('/api/')