mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-21 16:06:16 -04:00
Dropped require-kernel and etherpad-yamsl (#6520)
* Dropped require-kernel and etherpad-yamsl * Removed tests --------- Co-authored-by: SamTv12345 <samtv12345@samtv12345.com>
This commit is contained in:
parent
983b799231
commit
b1139e1aff
8 changed files with 0 additions and 212 deletions
|
@ -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<any> = {};
|
||||
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));
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
|
@ -14,7 +14,6 @@
|
|||
<div id="iframe-container"></div>
|
||||
</div>
|
||||
|
||||
<script src="../../static/js/require-kernel.js"></script>
|
||||
<script src="../../static/js/vendors/jquery.js"></script>
|
||||
<script src="lib/sendkeys.js"></script>
|
||||
<script src="../../static/js/vendors/browser.js"></script>
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue