From 2f17849b7bcd85623ac47a0fe3da9b67ddf03566 Mon Sep 17 00:00:00 2001 From: Richard Hansen Date: Thu, 1 Oct 2020 17:32:45 -0400 Subject: [PATCH] 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. --- tests/backend/specs/api/importexportGetPost.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/backend/specs/api/importexportGetPost.js b/tests/backend/specs/api/importexportGetPost.js index 3515d7776..065f6150a 100644 --- a/tests/backend/specs/api/importexportGetPost.js +++ b/tests/backend/specs/api/importexportGetPost.js @@ -3,12 +3,10 @@ */ const assert = require('assert').strict; +const common = require('../../common'); const superagent = require(__dirname+'/../../../../src/node_modules/superagent'); -const supertest = require(__dirname+'/../../../../src/node_modules/supertest'); const fs = require('fs'); 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 padText = fs.readFileSync("../tests/backend/specs/api/test.txt"); 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"); var filePath = path.join(__dirname, '../../../../APIKEY.txt'); +let agent; var apiKey = fs.readFileSync(filePath, {encoding: 'utf-8'}); apiKey = apiKey.replace(/\n$/, ""); var apiVersion = 1; var testPadId = makeid(); +before(async function() { agent = await common.init(); }); + describe('Connectivity', function(){ it('can connect', async function() { await agent.get('/api/')