test missing files and missing jsonp callbacks, currently failing

This commit is contained in:
webzwo0i 2020-12-23 17:34:26 +01:00
parent b1aced32a9
commit 8795c58235

View file

@ -129,6 +129,30 @@ describe(__filename, function () {
})); }));
}); });
it('should 200 for unknown resources with jsonp callback', async function() {
const missingResource = '/javascripts/lib/ep_etherpad-lite/static/js/ace2_inner2.js?callback=require.define';
const expectedResource = "require.define({\n \"ep_etherpad-lite/static/js/ace2_inner2.js\": null\n});\n";
await agent.get(missingResource)
.then((res) => {
assert.equal(expectedResource, res.text);
assert.equal(res.statusCode, 200);
});
});
// TODO should probably be 404
it('should 502 for unknown and known resources without jsonp callback', async function() {
const missingCallbackUnknownFile = '/javascripts/lib/ep_etherpad-lite/static/js/ace2_inner2.js';
const missingCallbackKnownFile = '/javascripts/lib/ep_etherpad-lite/static/js/ace2_inner.js';
await agent.get(missingCallbackUnknownFile)
.then((res) => {
assert.equal(res.statusCode, 502);
});
await agent.get(missingCallbackKnownFile)
.then((res) => {
assert.equal(res.statusCode, 502);
});
});
context('expiration', function(){ context('expiration', function(){
it('has date, last-modified and expires header', async function() { it('has date, last-modified and expires header', async function() {
await Promise.all(packages.map(async (resource) => await agent.get(resource) await Promise.all(packages.map(async (resource) => await agent.get(resource)
@ -238,6 +262,30 @@ describe(__filename, function () {
})); }));
}); });
it('should 200 for unknown resources with jsonp callback', async function() {
const missingResource = '/javascripts/lib/ep_etherpad-lite/static/js/ace2_inner2.js?callback=require.define';
const expectedResource = "require.define({\n \"ep_etherpad-lite/static/js/ace2_inner2.js\": null\n});\n";
await agent.get(missingResource)
.then((res) => {
assert.equal(expectedResource, res.text);
assert.equal(res.statusCode, 200);
});
});
// TODO should probably be 404
it('should 502 for unknown and known resources without jsonp callback', async function() {
const missingCallbackUnknownFile = '/javascripts/lib/ep_etherpad-lite/static/js/ace2_inner2.js';
const missingCallbackKnownFile = '/javascripts/lib/ep_etherpad-lite/static/js/ace2_inner.js';
await agent.get(missingCallbackUnknownFile)
.then((res) => {
assert.equal(res.statusCode, 502);
});
await agent.get(missingCallbackKnownFile)
.then((res) => {
assert.equal(res.statusCode, 502);
});
});
context('expiration', function(){ context('expiration', function(){
it('has date, last-modified and expires header', async function() { it('has date, last-modified and expires header', async function() {
await Promise.all(packages.map(async (resource) => await agent.get(resource) await Promise.all(packages.map(async (resource) => await agent.get(resource)