From 3e5b263454c4f63dc17983d4b43b4ba1b60722ff Mon Sep 17 00:00:00 2001 From: SamTv12345 Date: Thu, 18 Jul 2024 09:43:27 +0200 Subject: [PATCH] Removed tests --- src/tests/backend/specs/caching_middleware.ts | 125 ------------------ src/tests/frontend/index.html | 1 - src/tests/frontend/runner.js | 1 - 3 files changed, 127 deletions(-) delete mode 100644 src/tests/backend/specs/caching_middleware.ts diff --git a/src/tests/backend/specs/caching_middleware.ts b/src/tests/backend/specs/caching_middleware.ts deleted file mode 100644 index 3051ee1e7..000000000 --- a/src/tests/backend/specs/caching_middleware.ts +++ /dev/null @@ -1,125 +0,0 @@ -'use strict'; - -import {MapArrayType} from "../../../node/types/MapType"; - -/** - * caching_middleware is responsible for serving everything under path `/javascripts/` - * That includes packages as defined in `src/node/utils/tar.json` and probably also plugin code - * - */ - -const common = require('../common'); -import {strict as assert} from 'assert'; -import queryString from 'querystring'; -const settings = require('../../../node/utils/Settings'); -import {it, describe} from 'mocha' - -let agent: any; - -/** - * Hack! Returns true if the resource is not plaintext - * The file should start with the callback method, so we need the - * URL. - * - * @param {string} fileContent the response body - * @param {URL} resource resource URI - * @returns {boolean} if it is plaintext - */ -const isPlaintextResponse = (fileContent: string, resource:string): boolean => { - // callback=require.define&v=1234 - const query = (new URL(resource, 'http://localhost')).search.slice(1); - // require.define - const jsonp = queryString.parse(query).callback; - - // returns true if the first letters in fileContent equal the content of `jsonp` - return fileContent.substring(0, jsonp!.length) === jsonp; -}; - - -type RequestType = { - _shouldUnzip: () => boolean; -} - -/** - * A hack to disable `superagent`'s auto unzip functionality - * - * @param {Request} request - */ -const disableAutoDeflate = (request: RequestType) => { - request._shouldUnzip = () => false; -}; - -describe(__filename, function () { - const backups:MapArrayType = {}; - const fantasyEncoding = 'brainwaves'; // non-working encoding until https://github.com/visionmedia/superagent/pull/1560 is resolved - const packages = [ - '/javascripts/lib/ep_etherpad-lite/static/js/ace2_common.js?callback=require.define', - '/javascripts/lib/ep_etherpad-lite/static/js/ace2_inner.js?callback=require.define', - '/javascripts/lib/ep_etherpad-lite/static/js/pad.js?callback=require.define', - '/javascripts/lib/ep_etherpad-lite/static/js/timeslider.js?callback=require.define', - ]; - - before(async function () { - agent = await common.init(); - backups.settings = {}; - backups.settings.minify = settings.minify; - }); - after(async function () { - Object.assign(settings, backups.settings); - }); - - for (const minify of [false, true]) { - context(`when minify is ${minify}`, function () { - before(async function () { - settings.minify = minify; - }); - - describe('gets packages uncompressed without Accept-Encoding gzip', function () { - for (const resource of packages) { - it(resource, async function () { - await agent.get(resource) - .set('Accept-Encoding', fantasyEncoding) - .use(disableAutoDeflate) - .expect(200) - .expect('Content-Type', /application\/javascript/) - .expect((res:any) => { - assert.equal(res.header['content-encoding'], undefined); - assert(isPlaintextResponse(res.text, resource)); - }); - }); - } - }); - - describe('gets packages compressed with Accept-Encoding gzip', function () { - for (const resource of packages) { - it(resource, async function () { - await agent.get(resource) - .set('Accept-Encoding', 'gzip') - .use(disableAutoDeflate) - .expect(200) - .expect('Content-Type', /application\/javascript/) - .expect('Content-Encoding', 'gzip') - .expect((res:any) => { - assert(!isPlaintextResponse(res.text, resource)); - }); - }); - } - }); - - it('does not cache content-encoding headers', async function () { - await agent.get(packages[0]) - .set('Accept-Encoding', fantasyEncoding) - .expect(200) - .expect((res:any) => assert.equal(res.header['content-encoding'], undefined)); - await agent.get(packages[0]) - .set('Accept-Encoding', 'gzip') - .expect(200) - .expect('Content-Encoding', 'gzip'); - await agent.get(packages[0]) - .set('Accept-Encoding', fantasyEncoding) - .expect(200) - .expect((res:any) => assert.equal(res.header['content-encoding'], undefined)); - }); - }); - } -}); diff --git a/src/tests/frontend/index.html b/src/tests/frontend/index.html index c3b7a4633..a03677b26 100644 --- a/src/tests/frontend/index.html +++ b/src/tests/frontend/index.html @@ -14,7 +14,6 @@
- diff --git a/src/tests/frontend/runner.js b/src/tests/frontend/runner.js index 3e512d4d1..b2c76d00a 100644 --- a/src/tests/frontend/runner.js +++ b/src/tests/frontend/runner.js @@ -187,7 +187,6 @@ $(() => (async () => { // mutates the module definition function to temporarily replace Mocha's functions with // placeholders. The placeholders make it possible to defer the actual Mocha function calls until // after the modules are all loaded in parallel. require.setGlobalKeyPath() is used to coax - // require-kernel into using the wrapper define() method instead of require.define(). // Per-module log of attempted Mocha function calls. Key is module path, value is an array of // [functionName, argsArray] arrays.