Colocated mock-express style utilities

This commit is contained in:
Hannah Wolfe 2021-10-20 12:27:20 +01:00
parent 1146a42db3
commit 2756af83bb
No known key found for this signature in database
GPG Key ID: 9F8C7532D0A6BA55
9 changed files with 393 additions and 396 deletions

View File

@ -3,7 +3,7 @@ const sinon = require('sinon');
const _ = require('lodash'); const _ = require('lodash');
const cheerio = require('cheerio'); const cheerio = require('cheerio');
const testUtils = require('../../../utils'); const testUtils = require('../../../utils');
const mockUtils = require('../../../utils/mocks'); const localUtils = require('../utils');
const configUtils = require('../../../utils/configUtils'); const configUtils = require('../../../utils/configUtils');
const urlUtils = require('../../../utils/urlUtils'); const urlUtils = require('../../../utils/urlUtils');
@ -13,7 +13,7 @@ const themeEngine = require('../../../../core/frontend/services/theme-engine');
describe('Integration - Web - Site canary', function () { describe('Integration - Web - Site canary', function () {
let app; let app;
before(testUtils.integrationTesting.urlService.resetGenerators); before(localUtils.urlService.resetGenerators);
before(testUtils.teardownDb); before(testUtils.teardownDb);
before(testUtils.setup('users:roles', 'posts')); before(testUtils.setup('users:roles', 'posts'));
@ -21,11 +21,11 @@ describe('Integration - Web - Site canary', function () {
describe('default routes.yaml', function () { describe('default routes.yaml', function () {
before(async function () { before(async function () {
testUtils.integrationTesting.urlService.resetGenerators(); localUtils.urlService.resetGenerators();
testUtils.integrationTesting.defaultMocks(sinon, {amp: true}); localUtils.defaultMocks(sinon, {amp: true});
testUtils.integrationTesting.overrideGhostConfig(configUtils); localUtils.overrideGhostConfig(configUtils);
app = await testUtils.integrationTesting.initGhost(); app = await localUtils.initGhost();
}); });
before(function () { before(function () {
@ -60,7 +60,7 @@ describe('Integration - Web - Site canary', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(200); response.statusCode.should.eql(200);
response.template.should.eql('post'); response.template.should.eql('post');
@ -75,7 +75,7 @@ describe('Integration - Web - Site canary', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(200); response.statusCode.should.eql(200);
response.template.should.match(/amp\.hbs/); response.template.should.match(/amp\.hbs/);
@ -91,7 +91,7 @@ describe('Integration - Web - Site canary', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(404); response.statusCode.should.eql(404);
response.template.should.eql('error-404'); response.template.should.eql('error-404');
@ -106,7 +106,7 @@ describe('Integration - Web - Site canary', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(200); response.statusCode.should.eql(200);
response.template.should.eql('page'); response.template.should.eql('page');
@ -121,7 +121,7 @@ describe('Integration - Web - Site canary', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
const $ = cheerio.load(response.body); const $ = cheerio.load(response.body);
@ -140,7 +140,7 @@ describe('Integration - Web - Site canary', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(200); response.statusCode.should.eql(200);
response.template.should.eql('tag'); response.template.should.eql('tag');
@ -159,7 +159,7 @@ describe('Integration - Web - Site canary', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(200); response.statusCode.should.eql(200);
}); });
@ -173,7 +173,7 @@ describe('Integration - Web - Site canary', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
const $ = cheerio.load(response.body); const $ = cheerio.load(response.body);
@ -200,7 +200,7 @@ describe('Integration - Web - Site canary', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
const $ = cheerio.load(response.body); const $ = cheerio.load(response.body);
@ -221,7 +221,7 @@ describe('Integration - Web - Site canary', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(200); response.statusCode.should.eql(200);
}); });
@ -237,7 +237,7 @@ describe('Integration - Web - Site canary', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(301); response.statusCode.should.eql(301);
response.headers.location.should.eql('/prettify-me/'); response.headers.location.should.eql('/prettify-me/');
@ -255,7 +255,7 @@ describe('Integration - Web - Site canary', function () {
url: '/page/1/' url: '/page/1/'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(301); response.statusCode.should.eql(301);
response.headers.location.should.eql('/'); response.headers.location.should.eql('/');
@ -272,7 +272,7 @@ describe('Integration - Web - Site canary', function () {
url: '/feed/' url: '/feed/'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(301); response.statusCode.should.eql(301);
response.headers.location.should.eql('/rss/'); response.headers.location.should.eql('/rss/');
@ -302,7 +302,7 @@ describe('Integration - Web - Site canary', function () {
url: '/html-ipsum' url: '/html-ipsum'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(301); response.statusCode.should.eql(301);
response.headers.location.should.eql('https://example.com/html-ipsum/'); response.headers.location.should.eql('https://example.com/html-ipsum/');
@ -317,7 +317,7 @@ describe('Integration - Web - Site canary', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(301); response.statusCode.should.eql(301);
response.headers.location.should.eql('https://example.com/html-ipsum/'); response.headers.location.should.eql('https://example.com/html-ipsum/');
@ -334,7 +334,7 @@ describe('Integration - Web - Site canary', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(301); response.statusCode.should.eql(301);
response.headers.location.should.eql('https://example.com/favicon.png'); response.headers.location.should.eql('https://example.com/favicon.png');
@ -349,7 +349,7 @@ describe('Integration - Web - Site canary', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(301); response.statusCode.should.eql(301);
response.headers.location.should.eql('https://example.com/assets/css/main.css'); response.headers.location.should.eql('https://example.com/assets/css/main.css');
@ -384,14 +384,14 @@ describe('Integration - Web - Site canary', function () {
} }
}); });
testUtils.integrationTesting.urlService.resetGenerators(); localUtils.urlService.resetGenerators();
testUtils.integrationTesting.defaultMocks(sinon, {theme: 'test-theme'}); localUtils.defaultMocks(sinon, {theme: 'test-theme'});
app = await testUtils.integrationTesting.initGhost(); app = await localUtils.initGhost();
}); });
beforeEach(function () { beforeEach(function () {
testUtils.integrationTesting.overrideGhostConfig(configUtils); localUtils.overrideGhostConfig(configUtils);
}); });
afterEach(function () { afterEach(function () {
@ -411,7 +411,7 @@ describe('Integration - Web - Site canary', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(200); response.statusCode.should.eql(200);
response.template.should.eql('home'); response.template.should.eql('home');
@ -426,7 +426,7 @@ describe('Integration - Web - Site canary', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(200); response.statusCode.should.eql(200);
}); });
@ -440,7 +440,7 @@ describe('Integration - Web - Site canary', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(200); response.statusCode.should.eql(200);
response.template.should.eql('post'); response.template.should.eql('post');
@ -455,7 +455,7 @@ describe('Integration - Web - Site canary', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
const $ = cheerio.load(response.body); const $ = cheerio.load(response.body);
@ -474,7 +474,7 @@ describe('Integration - Web - Site canary', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
const $ = cheerio.load(response.body); const $ = cheerio.load(response.body);
@ -496,14 +496,14 @@ describe('Integration - Web - Site canary', function () {
taxonomies: {} taxonomies: {}
}); });
testUtils.integrationTesting.urlService.resetGenerators(); localUtils.urlService.resetGenerators();
testUtils.integrationTesting.defaultMocks(sinon, {theme: 'test-theme'}); localUtils.defaultMocks(sinon, {theme: 'test-theme'});
app = await testUtils.integrationTesting.initGhost(); app = await localUtils.initGhost();
}); });
beforeEach(function () { beforeEach(function () {
testUtils.integrationTesting.overrideGhostConfig(configUtils); localUtils.overrideGhostConfig(configUtils);
}); });
afterEach(function () { afterEach(function () {
@ -523,7 +523,7 @@ describe('Integration - Web - Site canary', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(200); response.statusCode.should.eql(200);
response.template.should.eql('something'); response.template.should.eql('something');
@ -550,14 +550,14 @@ describe('Integration - Web - Site canary', function () {
taxonomies: {} taxonomies: {}
}); });
testUtils.integrationTesting.urlService.resetGenerators(); localUtils.urlService.resetGenerators();
testUtils.integrationTesting.defaultMocks(sinon); localUtils.defaultMocks(sinon);
app = await testUtils.integrationTesting.initGhost(); app = await localUtils.initGhost();
}); });
beforeEach(function () { beforeEach(function () {
testUtils.integrationTesting.overrideGhostConfig(configUtils); localUtils.overrideGhostConfig(configUtils);
}); });
afterEach(function () { afterEach(function () {
@ -577,7 +577,7 @@ describe('Integration - Web - Site canary', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
// We can't find a post with the slug "featured" // We can't find a post with the slug "featured"
response.statusCode.should.eql(404); response.statusCode.should.eql(404);
@ -593,7 +593,7 @@ describe('Integration - Web - Site canary', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(200); response.statusCode.should.eql(200);
response.template.should.eql('post'); response.template.should.eql('post');
@ -608,7 +608,7 @@ describe('Integration - Web - Site canary', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(404); response.statusCode.should.eql(404);
response.template.should.eql('error-404'); response.template.should.eql('error-404');
@ -623,7 +623,7 @@ describe('Integration - Web - Site canary', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(404); response.statusCode.should.eql(404);
response.template.should.eql('error-404'); response.template.should.eql('error-404');
@ -645,14 +645,14 @@ describe('Integration - Web - Site canary', function () {
taxonomies: {} taxonomies: {}
}); });
testUtils.integrationTesting.urlService.resetGenerators(); localUtils.urlService.resetGenerators();
testUtils.integrationTesting.defaultMocks(sinon); localUtils.defaultMocks(sinon);
app = await testUtils.integrationTesting.initGhost(); app = await localUtils.initGhost();
}); });
beforeEach(function () { beforeEach(function () {
testUtils.integrationTesting.overrideGhostConfig(configUtils); localUtils.overrideGhostConfig(configUtils);
}); });
afterEach(function () { afterEach(function () {
@ -672,7 +672,7 @@ describe('Integration - Web - Site canary', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(200); response.statusCode.should.eql(200);
response.template.should.eql('post'); response.template.should.eql('post');
@ -687,7 +687,7 @@ describe('Integration - Web - Site canary', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(404); response.statusCode.should.eql(404);
response.template.should.eql('error-404'); response.template.should.eql('error-404');
@ -702,7 +702,7 @@ describe('Integration - Web - Site canary', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(200); response.statusCode.should.eql(200);
response.template.should.eql('page'); response.template.should.eql('page');
@ -724,14 +724,14 @@ describe('Integration - Web - Site canary', function () {
taxonomies: {} taxonomies: {}
}); });
testUtils.integrationTesting.urlService.resetGenerators(); localUtils.urlService.resetGenerators();
testUtils.integrationTesting.defaultMocks(sinon); localUtils.defaultMocks(sinon);
app = await testUtils.integrationTesting.initGhost(); app = await localUtils.initGhost();
}); });
beforeEach(function () { beforeEach(function () {
testUtils.integrationTesting.overrideGhostConfig(configUtils); localUtils.overrideGhostConfig(configUtils);
}); });
afterEach(function () { afterEach(function () {
@ -751,7 +751,7 @@ describe('Integration - Web - Site canary', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(200); response.statusCode.should.eql(200);
response.template.should.eql('post'); response.template.should.eql('post');
@ -766,7 +766,7 @@ describe('Integration - Web - Site canary', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(404); response.statusCode.should.eql(404);
response.template.should.eql('error-404'); response.template.should.eql('error-404');
@ -781,7 +781,7 @@ describe('Integration - Web - Site canary', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(404); response.statusCode.should.eql(404);
response.template.should.eql('error-404'); response.template.should.eql('error-404');
@ -796,7 +796,7 @@ describe('Integration - Web - Site canary', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(200); response.statusCode.should.eql(200);
response.template.should.eql('page'); response.template.should.eql('page');
@ -875,14 +875,14 @@ describe('Integration - Web - Site canary', function () {
} }
}); });
testUtils.integrationTesting.urlService.resetGenerators(); localUtils.urlService.resetGenerators();
testUtils.integrationTesting.defaultMocks(sinon); localUtils.defaultMocks(sinon);
app = await testUtils.integrationTesting.initGhost(); app = await localUtils.initGhost();
}); });
beforeEach(function () { beforeEach(function () {
testUtils.integrationTesting.overrideGhostConfig(configUtils); localUtils.overrideGhostConfig(configUtils);
}); });
afterEach(function () { afterEach(function () {
@ -902,7 +902,7 @@ describe('Integration - Web - Site canary', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(200); response.statusCode.should.eql(200);
response.template.should.eql('index'); response.template.should.eql('index');
@ -917,7 +917,7 @@ describe('Integration - Web - Site canary', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(301); response.statusCode.should.eql(301);
}); });
@ -931,7 +931,7 @@ describe('Integration - Web - Site canary', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(200); response.statusCode.should.eql(200);
response.template.should.eql('index'); response.template.should.eql('index');
@ -946,7 +946,7 @@ describe('Integration - Web - Site canary', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(200); response.statusCode.should.eql(200);
}); });
@ -960,7 +960,7 @@ describe('Integration - Web - Site canary', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(200); response.statusCode.should.eql(200);
}); });
@ -985,14 +985,14 @@ describe('Integration - Web - Site canary', function () {
} }
}); });
testUtils.integrationTesting.urlService.resetGenerators(); localUtils.urlService.resetGenerators();
testUtils.integrationTesting.defaultMocks(sinon); localUtils.defaultMocks(sinon);
app = await testUtils.integrationTesting.initGhost(); app = await localUtils.initGhost();
}); });
beforeEach(function () { beforeEach(function () {
testUtils.integrationTesting.overrideGhostConfig(configUtils); localUtils.overrideGhostConfig(configUtils);
}); });
afterEach(function () { afterEach(function () {
@ -1009,7 +1009,7 @@ describe('Integration - Web - Site canary', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(200); response.statusCode.should.eql(200);
response.template.should.eql('default'); response.template.should.eql('default');
@ -1024,7 +1024,7 @@ describe('Integration - Web - Site canary', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(200); response.statusCode.should.eql(200);
response.template.should.eql('index'); response.template.should.eql('index');
@ -1045,14 +1045,14 @@ describe('Integration - Web - Site canary', function () {
} }
}); });
testUtils.integrationTesting.urlService.resetGenerators(); localUtils.urlService.resetGenerators();
testUtils.integrationTesting.defaultMocks(sinon); localUtils.defaultMocks(sinon);
app = await testUtils.integrationTesting.initGhost(); app = await localUtils.initGhost();
}); });
beforeEach(function () { beforeEach(function () {
testUtils.integrationTesting.overrideGhostConfig(configUtils); localUtils.overrideGhostConfig(configUtils);
}); });
afterEach(function () { afterEach(function () {
@ -1072,7 +1072,7 @@ describe('Integration - Web - Site canary', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(200); response.statusCode.should.eql(200);
response.template.should.eql('default'); response.template.should.eql('default');
@ -1097,14 +1097,14 @@ describe('Integration - Web - Site canary', function () {
} }
}); });
testUtils.integrationTesting.urlService.resetGenerators(); localUtils.urlService.resetGenerators();
testUtils.integrationTesting.defaultMocks(sinon, {theme: 'test-theme'}); localUtils.defaultMocks(sinon, {theme: 'test-theme'});
app = await testUtils.integrationTesting.initGhost(); app = await localUtils.initGhost();
}); });
beforeEach(function () { beforeEach(function () {
testUtils.integrationTesting.overrideGhostConfig(configUtils); localUtils.overrideGhostConfig(configUtils);
}); });
afterEach(function () { afterEach(function () {
@ -1121,7 +1121,7 @@ describe('Integration - Web - Site canary', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(200); response.statusCode.should.eql(200);
response.template.should.eql('home'); response.template.should.eql('home');
@ -1136,7 +1136,7 @@ describe('Integration - Web - Site canary', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(200); response.statusCode.should.eql(200);
response.template.should.eql('something'); response.template.should.eql('something');
@ -1147,12 +1147,12 @@ describe('Integration - Web - Site canary', function () {
describe('extended routes.yaml: routes', function () { describe('extended routes.yaml: routes', function () {
describe('channels', function () { describe('channels', function () {
before(testUtils.integrationTesting.urlService.resetGenerators); before(localUtils.urlService.resetGenerators);
before(testUtils.teardownDb); before(testUtils.teardownDb);
before(testUtils.setup('users:roles', 'posts')); before(testUtils.setup('users:roles', 'posts'));
before(async function () { before(async function () {
testUtils.integrationTesting.defaultMocks(sinon, {theme: 'test-theme-channels'}); localUtils.defaultMocks(sinon, {theme: 'test-theme-channels'});
sinon.stub(routeSettingsService, 'loadRouteSettingsSync').returns({ sinon.stub(routeSettingsService, 'loadRouteSettingsSync').returns({
routes: { routes: {
@ -1276,12 +1276,12 @@ describe('Integration - Web - Site canary', function () {
} }
}); });
app = await testUtils.integrationTesting.initGhost(); app = await localUtils.initGhost();
sinon.stub(themeEngine.getActive(), 'config').withArgs('posts_per_page').returns(10); sinon.stub(themeEngine.getActive(), 'config').withArgs('posts_per_page').returns(10);
}); });
beforeEach(function () { beforeEach(function () {
testUtils.integrationTesting.overrideGhostConfig(configUtils); localUtils.overrideGhostConfig(configUtils);
}); });
afterEach(function () { afterEach(function () {
@ -1301,7 +1301,7 @@ describe('Integration - Web - Site canary', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
const $ = cheerio.load(response.body); const $ = cheerio.load(response.body);
@ -1320,7 +1320,7 @@ describe('Integration - Web - Site canary', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(200); response.statusCode.should.eql(200);
response.headers['content-type'].should.eql('text/xml; charset=UTF-8'); response.headers['content-type'].should.eql('text/xml; charset=UTF-8');
@ -1335,7 +1335,7 @@ describe('Integration - Web - Site canary', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
const $ = cheerio.load(response.body); const $ = cheerio.load(response.body);
@ -1355,7 +1355,7 @@ describe('Integration - Web - Site canary', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
const $ = cheerio.load(response.body); const $ = cheerio.load(response.body);
@ -1372,7 +1372,7 @@ describe('Integration - Web - Site canary', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
const $ = cheerio.load(response.body); const $ = cheerio.load(response.body);
@ -1391,7 +1391,7 @@ describe('Integration - Web - Site canary', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
const $ = cheerio.load(response.body); const $ = cheerio.load(response.body);
@ -1410,7 +1410,7 @@ describe('Integration - Web - Site canary', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
const $ = cheerio.load(response.body); const $ = cheerio.load(response.body);
@ -1429,7 +1429,7 @@ describe('Integration - Web - Site canary', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(301); response.statusCode.should.eql(301);
response.headers.location.should.eql('/channel1/'); response.headers.location.should.eql('/channel1/');
@ -1444,7 +1444,7 @@ describe('Integration - Web - Site canary', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(301); response.statusCode.should.eql(301);
response.headers.location.should.eql('/channel6/'); response.headers.location.should.eql('/channel6/');
@ -1459,7 +1459,7 @@ describe('Integration - Web - Site canary', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(200); response.statusCode.should.eql(200);
}); });
@ -1473,7 +1473,7 @@ describe('Integration - Web - Site canary', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(200); response.statusCode.should.eql(200);
}); });
@ -1517,14 +1517,14 @@ describe('Integration - Web - Site canary', function () {
taxonomies: {} taxonomies: {}
}); });
testUtils.integrationTesting.urlService.resetGenerators(); localUtils.urlService.resetGenerators();
testUtils.integrationTesting.defaultMocks(sinon, {theme: 'test-theme'}); localUtils.defaultMocks(sinon, {theme: 'test-theme'});
app = await testUtils.integrationTesting.initGhost(); app = await localUtils.initGhost();
}); });
beforeEach(function () { beforeEach(function () {
testUtils.integrationTesting.overrideGhostConfig(configUtils); localUtils.overrideGhostConfig(configUtils);
}); });
afterEach(function () { afterEach(function () {
@ -1544,7 +1544,7 @@ describe('Integration - Web - Site canary', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(200); response.statusCode.should.eql(200);
}); });
@ -1558,7 +1558,7 @@ describe('Integration - Web - Site canary', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(404); response.statusCode.should.eql(404);
}); });
@ -1572,7 +1572,7 @@ describe('Integration - Web - Site canary', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(404); response.statusCode.should.eql(404);
}); });
@ -1586,7 +1586,7 @@ describe('Integration - Web - Site canary', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(200); response.statusCode.should.eql(200);
}); });
@ -1600,7 +1600,7 @@ describe('Integration - Web - Site canary', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(200); response.statusCode.should.eql(200);
response.template.should.eql('podcast/rss'); response.template.should.eql('podcast/rss');
@ -1617,7 +1617,7 @@ describe('Integration - Web - Site canary', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
const $ = cheerio.load(response.body); const $ = cheerio.load(response.body);
response.statusCode.should.eql(200); response.statusCode.should.eql(200);

View File

@ -3,7 +3,7 @@ const sinon = require('sinon');
const _ = require('lodash'); const _ = require('lodash');
const cheerio = require('cheerio'); const cheerio = require('cheerio');
const testUtils = require('../../../utils'); const testUtils = require('../../../utils');
const mockUtils = require('../../../utils/mocks'); const localUtils = require('../utils');
const configUtils = require('../../../utils/configUtils'); const configUtils = require('../../../utils/configUtils');
const urlUtils = require('../../../utils/urlUtils'); const urlUtils = require('../../../utils/urlUtils');
@ -13,7 +13,7 @@ const themeEngine = require('../../../../core/frontend/services/theme-engine');
describe('Integration - Web - Site v2', function () { describe('Integration - Web - Site v2', function () {
let app; let app;
before(testUtils.integrationTesting.urlService.resetGenerators); before(localUtils.urlService.resetGenerators);
before(testUtils.teardownDb); before(testUtils.teardownDb);
before(testUtils.setup('users:roles', 'posts')); before(testUtils.setup('users:roles', 'posts'));
@ -21,11 +21,11 @@ describe('Integration - Web - Site v2', function () {
describe('default routes.yaml', function () { describe('default routes.yaml', function () {
before(async function () { before(async function () {
testUtils.integrationTesting.urlService.resetGenerators(); localUtils.urlService.resetGenerators();
testUtils.integrationTesting.defaultMocks(sinon, {amp: true}); localUtils.defaultMocks(sinon, {amp: true});
testUtils.integrationTesting.overrideGhostConfig(configUtils); localUtils.overrideGhostConfig(configUtils);
app = await testUtils.integrationTesting.initGhost(); app = await localUtils.initGhost();
}); });
before(function () { before(function () {
@ -60,7 +60,7 @@ describe('Integration - Web - Site v2', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(200); response.statusCode.should.eql(200);
response.template.should.eql('post'); response.template.should.eql('post');
@ -75,7 +75,7 @@ describe('Integration - Web - Site v2', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(200); response.statusCode.should.eql(200);
response.template.should.match(/amp\.hbs/); response.template.should.match(/amp\.hbs/);
@ -91,7 +91,7 @@ describe('Integration - Web - Site v2', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(404); response.statusCode.should.eql(404);
response.template.should.eql('error-404'); response.template.should.eql('error-404');
@ -106,7 +106,7 @@ describe('Integration - Web - Site v2', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(200); response.statusCode.should.eql(200);
response.template.should.eql('page'); response.template.should.eql('page');
@ -121,7 +121,7 @@ describe('Integration - Web - Site v2', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
const $ = cheerio.load(response.body); const $ = cheerio.load(response.body);
@ -140,7 +140,7 @@ describe('Integration - Web - Site v2', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(200); response.statusCode.should.eql(200);
response.template.should.eql('tag'); response.template.should.eql('tag');
@ -159,7 +159,7 @@ describe('Integration - Web - Site v2', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(200); response.statusCode.should.eql(200);
}); });
@ -173,7 +173,7 @@ describe('Integration - Web - Site v2', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
const $ = cheerio.load(response.body); const $ = cheerio.load(response.body);
@ -200,7 +200,7 @@ describe('Integration - Web - Site v2', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
const $ = cheerio.load(response.body); const $ = cheerio.load(response.body);
@ -221,7 +221,7 @@ describe('Integration - Web - Site v2', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(200); response.statusCode.should.eql(200);
}); });
@ -237,7 +237,7 @@ describe('Integration - Web - Site v2', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(301); response.statusCode.should.eql(301);
response.headers.location.should.eql('/prettify-me/'); response.headers.location.should.eql('/prettify-me/');
@ -255,7 +255,7 @@ describe('Integration - Web - Site v2', function () {
url: '/page/1/' url: '/page/1/'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(301); response.statusCode.should.eql(301);
response.headers.location.should.eql('/'); response.headers.location.should.eql('/');
@ -272,7 +272,7 @@ describe('Integration - Web - Site v2', function () {
url: '/feed/' url: '/feed/'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(301); response.statusCode.should.eql(301);
response.headers.location.should.eql('/rss/'); response.headers.location.should.eql('/rss/');
@ -302,7 +302,7 @@ describe('Integration - Web - Site v2', function () {
url: '/html-ipsum' url: '/html-ipsum'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(301); response.statusCode.should.eql(301);
response.headers.location.should.eql('https://example.com/html-ipsum/'); response.headers.location.should.eql('https://example.com/html-ipsum/');
@ -317,7 +317,7 @@ describe('Integration - Web - Site v2', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(301); response.statusCode.should.eql(301);
response.headers.location.should.eql('https://example.com/html-ipsum/'); response.headers.location.should.eql('https://example.com/html-ipsum/');
@ -334,7 +334,7 @@ describe('Integration - Web - Site v2', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(301); response.statusCode.should.eql(301);
response.headers.location.should.eql('https://example.com/favicon.png'); response.headers.location.should.eql('https://example.com/favicon.png');
@ -349,7 +349,7 @@ describe('Integration - Web - Site v2', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(301); response.statusCode.should.eql(301);
response.headers.location.should.eql('https://example.com/assets/css/main.css'); response.headers.location.should.eql('https://example.com/assets/css/main.css');
@ -384,14 +384,14 @@ describe('Integration - Web - Site v2', function () {
} }
}); });
testUtils.integrationTesting.urlService.resetGenerators(); localUtils.urlService.resetGenerators();
testUtils.integrationTesting.defaultMocks(sinon, {theme: 'test-theme'}); localUtils.defaultMocks(sinon, {theme: 'test-theme'});
app = await testUtils.integrationTesting.initGhost(); app = await localUtils.initGhost();
}); });
beforeEach(function () { beforeEach(function () {
testUtils.integrationTesting.overrideGhostConfig(configUtils); localUtils.overrideGhostConfig(configUtils);
}); });
afterEach(function () { afterEach(function () {
@ -411,7 +411,7 @@ describe('Integration - Web - Site v2', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(200); response.statusCode.should.eql(200);
response.template.should.eql('home'); response.template.should.eql('home');
@ -426,7 +426,7 @@ describe('Integration - Web - Site v2', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(200); response.statusCode.should.eql(200);
}); });
@ -440,7 +440,7 @@ describe('Integration - Web - Site v2', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(200); response.statusCode.should.eql(200);
response.template.should.eql('post'); response.template.should.eql('post');
@ -455,7 +455,7 @@ describe('Integration - Web - Site v2', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
const $ = cheerio.load(response.body); const $ = cheerio.load(response.body);
@ -474,7 +474,7 @@ describe('Integration - Web - Site v2', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
const $ = cheerio.load(response.body); const $ = cheerio.load(response.body);
@ -494,14 +494,14 @@ describe('Integration - Web - Site v2', function () {
taxonomies: {} taxonomies: {}
}); });
testUtils.integrationTesting.urlService.resetGenerators(); localUtils.urlService.resetGenerators();
testUtils.integrationTesting.defaultMocks(sinon, {theme: 'test-theme'}); localUtils.defaultMocks(sinon, {theme: 'test-theme'});
app = await testUtils.integrationTesting.initGhost(); app = await localUtils.initGhost();
}); });
beforeEach(function () { beforeEach(function () {
testUtils.integrationTesting.overrideGhostConfig(configUtils); localUtils.overrideGhostConfig(configUtils);
}); });
afterEach(function () { afterEach(function () {
@ -521,7 +521,7 @@ describe('Integration - Web - Site v2', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(200); response.statusCode.should.eql(200);
response.template.should.eql('something'); response.template.should.eql('something');
@ -548,14 +548,14 @@ describe('Integration - Web - Site v2', function () {
taxonomies: {} taxonomies: {}
}); });
testUtils.integrationTesting.urlService.resetGenerators(); localUtils.urlService.resetGenerators();
testUtils.integrationTesting.defaultMocks(sinon); localUtils.defaultMocks(sinon);
app = await testUtils.integrationTesting.initGhost(); app = await localUtils.initGhost();
}); });
beforeEach(function () { beforeEach(function () {
testUtils.integrationTesting.overrideGhostConfig(configUtils); localUtils.overrideGhostConfig(configUtils);
}); });
afterEach(function () { afterEach(function () {
@ -575,7 +575,7 @@ describe('Integration - Web - Site v2', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
// We can't find a post with the slug "featured" // We can't find a post with the slug "featured"
response.statusCode.should.eql(404); response.statusCode.should.eql(404);
@ -591,7 +591,7 @@ describe('Integration - Web - Site v2', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(200); response.statusCode.should.eql(200);
response.template.should.eql('post'); response.template.should.eql('post');
@ -606,7 +606,7 @@ describe('Integration - Web - Site v2', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(404); response.statusCode.should.eql(404);
response.template.should.eql('error-404'); response.template.should.eql('error-404');
@ -621,7 +621,7 @@ describe('Integration - Web - Site v2', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(404); response.statusCode.should.eql(404);
response.template.should.eql('error-404'); response.template.should.eql('error-404');
@ -643,14 +643,14 @@ describe('Integration - Web - Site v2', function () {
taxonomies: {} taxonomies: {}
}); });
testUtils.integrationTesting.urlService.resetGenerators(); localUtils.urlService.resetGenerators();
testUtils.integrationTesting.defaultMocks(sinon); localUtils.defaultMocks(sinon);
app = await testUtils.integrationTesting.initGhost(); app = await localUtils.initGhost();
}); });
beforeEach(function () { beforeEach(function () {
testUtils.integrationTesting.overrideGhostConfig(configUtils); localUtils.overrideGhostConfig(configUtils);
}); });
afterEach(function () { afterEach(function () {
@ -670,7 +670,7 @@ describe('Integration - Web - Site v2', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(200); response.statusCode.should.eql(200);
response.template.should.eql('post'); response.template.should.eql('post');
@ -685,7 +685,7 @@ describe('Integration - Web - Site v2', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(404); response.statusCode.should.eql(404);
response.template.should.eql('error-404'); response.template.should.eql('error-404');
@ -700,7 +700,7 @@ describe('Integration - Web - Site v2', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(200); response.statusCode.should.eql(200);
response.template.should.eql('page'); response.template.should.eql('page');
@ -722,14 +722,14 @@ describe('Integration - Web - Site v2', function () {
taxonomies: {} taxonomies: {}
}); });
testUtils.integrationTesting.urlService.resetGenerators(); localUtils.urlService.resetGenerators();
testUtils.integrationTesting.defaultMocks(sinon); localUtils.defaultMocks(sinon);
app = await testUtils.integrationTesting.initGhost(); app = await localUtils.initGhost();
}); });
beforeEach(function () { beforeEach(function () {
testUtils.integrationTesting.overrideGhostConfig(configUtils); localUtils.overrideGhostConfig(configUtils);
}); });
afterEach(function () { afterEach(function () {
@ -749,7 +749,7 @@ describe('Integration - Web - Site v2', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(200); response.statusCode.should.eql(200);
response.template.should.eql('post'); response.template.should.eql('post');
@ -764,7 +764,7 @@ describe('Integration - Web - Site v2', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(404); response.statusCode.should.eql(404);
response.template.should.eql('error-404'); response.template.should.eql('error-404');
@ -779,7 +779,7 @@ describe('Integration - Web - Site v2', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(404); response.statusCode.should.eql(404);
response.template.should.eql('error-404'); response.template.should.eql('error-404');
@ -794,7 +794,7 @@ describe('Integration - Web - Site v2', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(200); response.statusCode.should.eql(200);
response.template.should.eql('page'); response.template.should.eql('page');
@ -873,14 +873,14 @@ describe('Integration - Web - Site v2', function () {
} }
}); });
testUtils.integrationTesting.urlService.resetGenerators(); localUtils.urlService.resetGenerators();
testUtils.integrationTesting.defaultMocks(sinon); localUtils.defaultMocks(sinon);
app = await testUtils.integrationTesting.initGhost(); app = await localUtils.initGhost();
}); });
beforeEach(function () { beforeEach(function () {
testUtils.integrationTesting.overrideGhostConfig(configUtils); localUtils.overrideGhostConfig(configUtils);
}); });
afterEach(function () { afterEach(function () {
@ -900,7 +900,7 @@ describe('Integration - Web - Site v2', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(200); response.statusCode.should.eql(200);
response.template.should.eql('index'); response.template.should.eql('index');
@ -915,7 +915,7 @@ describe('Integration - Web - Site v2', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(301); response.statusCode.should.eql(301);
}); });
@ -929,7 +929,7 @@ describe('Integration - Web - Site v2', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(200); response.statusCode.should.eql(200);
response.template.should.eql('index'); response.template.should.eql('index');
@ -944,7 +944,7 @@ describe('Integration - Web - Site v2', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(200); response.statusCode.should.eql(200);
}); });
@ -958,7 +958,7 @@ describe('Integration - Web - Site v2', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(200); response.statusCode.should.eql(200);
}); });
@ -983,14 +983,14 @@ describe('Integration - Web - Site v2', function () {
} }
}); });
testUtils.integrationTesting.urlService.resetGenerators(); localUtils.urlService.resetGenerators();
testUtils.integrationTesting.defaultMocks(sinon); localUtils.defaultMocks(sinon);
app = await testUtils.integrationTesting.initGhost(); app = await localUtils.initGhost();
}); });
beforeEach(function () { beforeEach(function () {
testUtils.integrationTesting.overrideGhostConfig(configUtils); localUtils.overrideGhostConfig(configUtils);
}); });
afterEach(function () { afterEach(function () {
@ -1010,7 +1010,7 @@ describe('Integration - Web - Site v2', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(200); response.statusCode.should.eql(200);
response.template.should.eql('default'); response.template.should.eql('default');
@ -1025,7 +1025,7 @@ describe('Integration - Web - Site v2', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(200); response.statusCode.should.eql(200);
response.template.should.eql('index'); response.template.should.eql('index');
@ -1046,14 +1046,14 @@ describe('Integration - Web - Site v2', function () {
} }
}); });
testUtils.integrationTesting.urlService.resetGenerators(); localUtils.urlService.resetGenerators();
testUtils.integrationTesting.defaultMocks(sinon); localUtils.defaultMocks(sinon);
app = await testUtils.integrationTesting.initGhost(); app = await localUtils.initGhost();
}); });
beforeEach(function () { beforeEach(function () {
testUtils.integrationTesting.overrideGhostConfig(configUtils); localUtils.overrideGhostConfig(configUtils);
}); });
afterEach(function () { afterEach(function () {
@ -1073,7 +1073,7 @@ describe('Integration - Web - Site v2', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(200); response.statusCode.should.eql(200);
response.template.should.eql('default'); response.template.should.eql('default');
@ -1098,14 +1098,14 @@ describe('Integration - Web - Site v2', function () {
} }
}); });
testUtils.integrationTesting.urlService.resetGenerators(); localUtils.urlService.resetGenerators();
testUtils.integrationTesting.defaultMocks(sinon, {theme: 'test-theme'}); localUtils.defaultMocks(sinon, {theme: 'test-theme'});
app = await testUtils.integrationTesting.initGhost(); app = await localUtils.initGhost();
}); });
beforeEach(function () { beforeEach(function () {
testUtils.integrationTesting.overrideGhostConfig(configUtils); localUtils.overrideGhostConfig(configUtils);
}); });
afterEach(function () { afterEach(function () {
@ -1125,7 +1125,7 @@ describe('Integration - Web - Site v2', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(200); response.statusCode.should.eql(200);
response.template.should.eql('home'); response.template.should.eql('home');
@ -1140,7 +1140,7 @@ describe('Integration - Web - Site v2', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(200); response.statusCode.should.eql(200);
response.template.should.eql('something'); response.template.should.eql('something');
@ -1151,12 +1151,12 @@ describe('Integration - Web - Site v2', function () {
describe('extended routes.yaml: routes', function () { describe('extended routes.yaml: routes', function () {
describe('channels', function () { describe('channels', function () {
before(testUtils.integrationTesting.urlService.resetGenerators); before(localUtils.urlService.resetGenerators);
before(testUtils.teardownDb); before(testUtils.teardownDb);
before(testUtils.setup('users:roles', 'posts')); before(testUtils.setup('users:roles', 'posts'));
before(async function () { before(async function () {
testUtils.integrationTesting.defaultMocks(sinon, {theme: 'test-theme-channels'}); localUtils.defaultMocks(sinon, {theme: 'test-theme-channels'});
sinon.stub(routeSettingsService, 'loadRouteSettingsSync').returns({ sinon.stub(routeSettingsService, 'loadRouteSettingsSync').returns({
routes: { routes: {
@ -1280,12 +1280,12 @@ describe('Integration - Web - Site v2', function () {
} }
}); });
app = await testUtils.integrationTesting.initGhost(); app = await localUtils.initGhost();
sinon.stub(themeEngine.getActive(), 'config').withArgs('posts_per_page').returns(10); sinon.stub(themeEngine.getActive(), 'config').withArgs('posts_per_page').returns(10);
}); });
beforeEach(function () { beforeEach(function () {
testUtils.integrationTesting.overrideGhostConfig(configUtils); localUtils.overrideGhostConfig(configUtils);
}); });
afterEach(function () { afterEach(function () {
@ -1305,7 +1305,7 @@ describe('Integration - Web - Site v2', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
const $ = cheerio.load(response.body); const $ = cheerio.load(response.body);
@ -1324,7 +1324,7 @@ describe('Integration - Web - Site v2', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(200); response.statusCode.should.eql(200);
response.headers['content-type'].should.eql('text/xml; charset=UTF-8'); response.headers['content-type'].should.eql('text/xml; charset=UTF-8');
@ -1339,7 +1339,7 @@ describe('Integration - Web - Site v2', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
const $ = cheerio.load(response.body); const $ = cheerio.load(response.body);
@ -1359,7 +1359,7 @@ describe('Integration - Web - Site v2', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
const $ = cheerio.load(response.body); const $ = cheerio.load(response.body);
@ -1376,7 +1376,7 @@ describe('Integration - Web - Site v2', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
const $ = cheerio.load(response.body); const $ = cheerio.load(response.body);
@ -1395,7 +1395,7 @@ describe('Integration - Web - Site v2', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
const $ = cheerio.load(response.body); const $ = cheerio.load(response.body);
@ -1414,7 +1414,7 @@ describe('Integration - Web - Site v2', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
const $ = cheerio.load(response.body); const $ = cheerio.load(response.body);
@ -1433,7 +1433,7 @@ describe('Integration - Web - Site v2', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(301); response.statusCode.should.eql(301);
response.headers.location.should.eql('/channel1/'); response.headers.location.should.eql('/channel1/');
@ -1448,7 +1448,7 @@ describe('Integration - Web - Site v2', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(301); response.statusCode.should.eql(301);
response.headers.location.should.eql('/channel6/'); response.headers.location.should.eql('/channel6/');
@ -1463,7 +1463,7 @@ describe('Integration - Web - Site v2', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(200); response.statusCode.should.eql(200);
}); });
@ -1477,7 +1477,7 @@ describe('Integration - Web - Site v2', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(200); response.statusCode.should.eql(200);
}); });
@ -1521,14 +1521,14 @@ describe('Integration - Web - Site v2', function () {
taxonomies: {} taxonomies: {}
}); });
testUtils.integrationTesting.urlService.resetGenerators(); localUtils.urlService.resetGenerators();
testUtils.integrationTesting.defaultMocks(sinon, {theme: 'test-theme'}); localUtils.defaultMocks(sinon, {theme: 'test-theme'});
app = await testUtils.integrationTesting.initGhost(); app = await localUtils.initGhost();
}); });
beforeEach(function () { beforeEach(function () {
testUtils.integrationTesting.overrideGhostConfig(configUtils); localUtils.overrideGhostConfig(configUtils);
}); });
afterEach(function () { afterEach(function () {
@ -1548,7 +1548,7 @@ describe('Integration - Web - Site v2', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(200); response.statusCode.should.eql(200);
}); });
@ -1562,7 +1562,7 @@ describe('Integration - Web - Site v2', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(404); response.statusCode.should.eql(404);
}); });
@ -1576,7 +1576,7 @@ describe('Integration - Web - Site v2', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(404); response.statusCode.should.eql(404);
}); });
@ -1590,7 +1590,7 @@ describe('Integration - Web - Site v2', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(200); response.statusCode.should.eql(200);
}); });
@ -1604,7 +1604,7 @@ describe('Integration - Web - Site v2', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(200); response.statusCode.should.eql(200);
response.template.should.eql('podcast/rss'); response.template.should.eql('podcast/rss');
@ -1621,7 +1621,7 @@ describe('Integration - Web - Site v2', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
const $ = cheerio.load(response.body); const $ = cheerio.load(response.body);
response.statusCode.should.eql(200); response.statusCode.should.eql(200);

View File

@ -3,7 +3,7 @@ const sinon = require('sinon');
const _ = require('lodash'); const _ = require('lodash');
const cheerio = require('cheerio'); const cheerio = require('cheerio');
const testUtils = require('../../../utils'); const testUtils = require('../../../utils');
const mockUtils = require('../../../utils/mocks'); const localUtils = require('../utils');
const configUtils = require('../../../utils/configUtils'); const configUtils = require('../../../utils/configUtils');
const urlUtils = require('../../../utils/urlUtils'); const urlUtils = require('../../../utils/urlUtils');
@ -13,7 +13,7 @@ const themeEngine = require('../../../../core/frontend/services/theme-engine');
describe('Integration - Web - Site v3', function () { describe('Integration - Web - Site v3', function () {
let app; let app;
before(testUtils.integrationTesting.urlService.resetGenerators); before(localUtils.urlService.resetGenerators);
before(testUtils.teardownDb); before(testUtils.teardownDb);
before(testUtils.setup('users:roles', 'posts')); before(testUtils.setup('users:roles', 'posts'));
@ -21,11 +21,11 @@ describe('Integration - Web - Site v3', function () {
describe('default routes.yaml', function () { describe('default routes.yaml', function () {
before(async function () { before(async function () {
testUtils.integrationTesting.urlService.resetGenerators(); localUtils.urlService.resetGenerators();
testUtils.integrationTesting.defaultMocks(sinon, {amp: true}); localUtils.defaultMocks(sinon, {amp: true});
testUtils.integrationTesting.overrideGhostConfig(configUtils); localUtils.overrideGhostConfig(configUtils);
app = await testUtils.integrationTesting.initGhost(); app = await localUtils.initGhost();
}); });
before(function () { before(function () {
@ -60,7 +60,7 @@ describe('Integration - Web - Site v3', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(200); response.statusCode.should.eql(200);
response.template.should.eql('post'); response.template.should.eql('post');
@ -75,7 +75,7 @@ describe('Integration - Web - Site v3', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(200); response.statusCode.should.eql(200);
response.template.should.match(/amp\.hbs/); response.template.should.match(/amp\.hbs/);
@ -91,7 +91,7 @@ describe('Integration - Web - Site v3', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(404); response.statusCode.should.eql(404);
response.template.should.eql('error-404'); response.template.should.eql('error-404');
@ -106,7 +106,7 @@ describe('Integration - Web - Site v3', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(200); response.statusCode.should.eql(200);
response.template.should.eql('page'); response.template.should.eql('page');
@ -121,7 +121,7 @@ describe('Integration - Web - Site v3', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
const $ = cheerio.load(response.body); const $ = cheerio.load(response.body);
@ -140,7 +140,7 @@ describe('Integration - Web - Site v3', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(200); response.statusCode.should.eql(200);
response.template.should.eql('tag'); response.template.should.eql('tag');
@ -159,7 +159,7 @@ describe('Integration - Web - Site v3', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(200); response.statusCode.should.eql(200);
}); });
@ -173,7 +173,7 @@ describe('Integration - Web - Site v3', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
const $ = cheerio.load(response.body); const $ = cheerio.load(response.body);
@ -200,7 +200,7 @@ describe('Integration - Web - Site v3', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
const $ = cheerio.load(response.body); const $ = cheerio.load(response.body);
@ -221,7 +221,7 @@ describe('Integration - Web - Site v3', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(200); response.statusCode.should.eql(200);
}); });
@ -237,7 +237,7 @@ describe('Integration - Web - Site v3', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(301); response.statusCode.should.eql(301);
response.headers.location.should.eql('/prettify-me/'); response.headers.location.should.eql('/prettify-me/');
@ -255,7 +255,7 @@ describe('Integration - Web - Site v3', function () {
url: '/page/1/' url: '/page/1/'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(301); response.statusCode.should.eql(301);
response.headers.location.should.eql('/'); response.headers.location.should.eql('/');
@ -272,7 +272,7 @@ describe('Integration - Web - Site v3', function () {
url: '/feed/' url: '/feed/'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(301); response.statusCode.should.eql(301);
response.headers.location.should.eql('/rss/'); response.headers.location.should.eql('/rss/');
@ -302,7 +302,7 @@ describe('Integration - Web - Site v3', function () {
url: '/html-ipsum' url: '/html-ipsum'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(301); response.statusCode.should.eql(301);
response.headers.location.should.eql('https://example.com/html-ipsum/'); response.headers.location.should.eql('https://example.com/html-ipsum/');
@ -317,7 +317,7 @@ describe('Integration - Web - Site v3', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(301); response.statusCode.should.eql(301);
response.headers.location.should.eql('https://example.com/html-ipsum/'); response.headers.location.should.eql('https://example.com/html-ipsum/');
@ -334,7 +334,7 @@ describe('Integration - Web - Site v3', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(301); response.statusCode.should.eql(301);
response.headers.location.should.eql('https://example.com/favicon.png'); response.headers.location.should.eql('https://example.com/favicon.png');
@ -349,7 +349,7 @@ describe('Integration - Web - Site v3', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(301); response.statusCode.should.eql(301);
response.headers.location.should.eql('https://example.com/assets/css/main.css'); response.headers.location.should.eql('https://example.com/assets/css/main.css');
@ -386,14 +386,14 @@ describe('Integration - Web - Site v3', function () {
} }
}); });
testUtils.integrationTesting.urlService.resetGenerators(); localUtils.urlService.resetGenerators();
testUtils.integrationTesting.defaultMocks(sinon, {theme: 'test-theme'}); localUtils.defaultMocks(sinon, {theme: 'test-theme'});
app = await testUtils.integrationTesting.initGhost(); app = await localUtils.initGhost();
}); });
beforeEach(function () { beforeEach(function () {
testUtils.integrationTesting.overrideGhostConfig(configUtils); localUtils.overrideGhostConfig(configUtils);
}); });
afterEach(function () { afterEach(function () {
@ -413,7 +413,7 @@ describe('Integration - Web - Site v3', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(200); response.statusCode.should.eql(200);
response.template.should.eql('home'); response.template.should.eql('home');
@ -428,7 +428,7 @@ describe('Integration - Web - Site v3', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(200); response.statusCode.should.eql(200);
}); });
@ -442,7 +442,7 @@ describe('Integration - Web - Site v3', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(200); response.statusCode.should.eql(200);
response.template.should.eql('post'); response.template.should.eql('post');
@ -457,7 +457,7 @@ describe('Integration - Web - Site v3', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
const $ = cheerio.load(response.body); const $ = cheerio.load(response.body);
@ -476,7 +476,7 @@ describe('Integration - Web - Site v3', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
const $ = cheerio.load(response.body); const $ = cheerio.load(response.body);
@ -496,14 +496,14 @@ describe('Integration - Web - Site v3', function () {
taxonomies: {} taxonomies: {}
}); });
testUtils.integrationTesting.urlService.resetGenerators(); localUtils.urlService.resetGenerators();
testUtils.integrationTesting.defaultMocks(sinon, {theme: 'test-theme'}); localUtils.defaultMocks(sinon, {theme: 'test-theme'});
app = await testUtils.integrationTesting.initGhost(); app = await localUtils.initGhost();
}); });
beforeEach(function () { beforeEach(function () {
testUtils.integrationTesting.overrideGhostConfig(configUtils); localUtils.overrideGhostConfig(configUtils);
}); });
afterEach(function () { afterEach(function () {
@ -523,7 +523,7 @@ describe('Integration - Web - Site v3', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(200); response.statusCode.should.eql(200);
response.template.should.eql('something'); response.template.should.eql('something');
@ -550,14 +550,14 @@ describe('Integration - Web - Site v3', function () {
taxonomies: {} taxonomies: {}
}); });
testUtils.integrationTesting.urlService.resetGenerators(); localUtils.urlService.resetGenerators();
testUtils.integrationTesting.defaultMocks(sinon); localUtils.defaultMocks(sinon);
app = await testUtils.integrationTesting.initGhost(); app = await localUtils.initGhost();
}); });
beforeEach(function () { beforeEach(function () {
testUtils.integrationTesting.overrideGhostConfig(configUtils); localUtils.overrideGhostConfig(configUtils);
}); });
afterEach(function () { afterEach(function () {
@ -577,7 +577,7 @@ describe('Integration - Web - Site v3', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
// We can't find a post with the slug "featured" // We can't find a post with the slug "featured"
response.statusCode.should.eql(404); response.statusCode.should.eql(404);
@ -593,7 +593,7 @@ describe('Integration - Web - Site v3', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(200); response.statusCode.should.eql(200);
response.template.should.eql('post'); response.template.should.eql('post');
@ -608,7 +608,7 @@ describe('Integration - Web - Site v3', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(404); response.statusCode.should.eql(404);
response.template.should.eql('error-404'); response.template.should.eql('error-404');
@ -623,7 +623,7 @@ describe('Integration - Web - Site v3', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(404); response.statusCode.should.eql(404);
response.template.should.eql('error-404'); response.template.should.eql('error-404');
@ -645,14 +645,14 @@ describe('Integration - Web - Site v3', function () {
taxonomies: {} taxonomies: {}
}); });
testUtils.integrationTesting.urlService.resetGenerators(); localUtils.urlService.resetGenerators();
testUtils.integrationTesting.defaultMocks(sinon); localUtils.defaultMocks(sinon);
app = await testUtils.integrationTesting.initGhost(); app = await localUtils.initGhost();
}); });
beforeEach(function () { beforeEach(function () {
testUtils.integrationTesting.overrideGhostConfig(configUtils); localUtils.overrideGhostConfig(configUtils);
}); });
afterEach(function () { afterEach(function () {
@ -672,7 +672,7 @@ describe('Integration - Web - Site v3', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(200); response.statusCode.should.eql(200);
response.template.should.eql('post'); response.template.should.eql('post');
@ -687,7 +687,7 @@ describe('Integration - Web - Site v3', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(404); response.statusCode.should.eql(404);
response.template.should.eql('error-404'); response.template.should.eql('error-404');
@ -702,7 +702,7 @@ describe('Integration - Web - Site v3', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(200); response.statusCode.should.eql(200);
response.template.should.eql('page'); response.template.should.eql('page');
@ -724,13 +724,13 @@ describe('Integration - Web - Site v3', function () {
taxonomies: {} taxonomies: {}
}); });
testUtils.integrationTesting.urlService.resetGenerators(); localUtils.urlService.resetGenerators();
testUtils.integrationTesting.defaultMocks(sinon); localUtils.defaultMocks(sinon);
app = await testUtils.integrationTesting.initGhost(); app = await localUtils.initGhost();
}); });
beforeEach(function () { beforeEach(function () {
testUtils.integrationTesting.overrideGhostConfig(configUtils); localUtils.overrideGhostConfig(configUtils);
}); });
afterEach(function () { afterEach(function () {
@ -750,7 +750,7 @@ describe('Integration - Web - Site v3', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(200); response.statusCode.should.eql(200);
response.template.should.eql('post'); response.template.should.eql('post');
@ -765,7 +765,7 @@ describe('Integration - Web - Site v3', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(404); response.statusCode.should.eql(404);
response.template.should.eql('error-404'); response.template.should.eql('error-404');
@ -780,7 +780,7 @@ describe('Integration - Web - Site v3', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(404); response.statusCode.should.eql(404);
response.template.should.eql('error-404'); response.template.should.eql('error-404');
@ -795,7 +795,7 @@ describe('Integration - Web - Site v3', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(200); response.statusCode.should.eql(200);
response.template.should.eql('page'); response.template.should.eql('page');
@ -874,14 +874,14 @@ describe('Integration - Web - Site v3', function () {
} }
}); });
testUtils.integrationTesting.urlService.resetGenerators(); localUtils.urlService.resetGenerators();
testUtils.integrationTesting.defaultMocks(sinon); localUtils.defaultMocks(sinon);
app = await testUtils.integrationTesting.initGhost(); app = await localUtils.initGhost();
}); });
beforeEach(function () { beforeEach(function () {
testUtils.integrationTesting.overrideGhostConfig(configUtils); localUtils.overrideGhostConfig(configUtils);
}); });
afterEach(function () { afterEach(function () {
@ -901,7 +901,7 @@ describe('Integration - Web - Site v3', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(200); response.statusCode.should.eql(200);
response.template.should.eql('index'); response.template.should.eql('index');
@ -916,7 +916,7 @@ describe('Integration - Web - Site v3', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(301); response.statusCode.should.eql(301);
}); });
@ -930,7 +930,7 @@ describe('Integration - Web - Site v3', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(200); response.statusCode.should.eql(200);
response.template.should.eql('index'); response.template.should.eql('index');
@ -945,7 +945,7 @@ describe('Integration - Web - Site v3', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(200); response.statusCode.should.eql(200);
}); });
@ -959,7 +959,7 @@ describe('Integration - Web - Site v3', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(200); response.statusCode.should.eql(200);
}); });
@ -984,14 +984,14 @@ describe('Integration - Web - Site v3', function () {
} }
}); });
testUtils.integrationTesting.urlService.resetGenerators(); localUtils.urlService.resetGenerators();
testUtils.integrationTesting.defaultMocks(sinon); localUtils.defaultMocks(sinon);
app = await testUtils.integrationTesting.initGhost(); app = await localUtils.initGhost();
}); });
beforeEach(function () { beforeEach(function () {
testUtils.integrationTesting.overrideGhostConfig(configUtils); localUtils.overrideGhostConfig(configUtils);
}); });
afterEach(function () { afterEach(function () {
@ -1011,7 +1011,7 @@ describe('Integration - Web - Site v3', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(200); response.statusCode.should.eql(200);
response.template.should.eql('default'); response.template.should.eql('default');
@ -1026,7 +1026,7 @@ describe('Integration - Web - Site v3', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(200); response.statusCode.should.eql(200);
response.template.should.eql('index'); response.template.should.eql('index');
@ -1047,14 +1047,14 @@ describe('Integration - Web - Site v3', function () {
} }
}); });
testUtils.integrationTesting.urlService.resetGenerators(); localUtils.urlService.resetGenerators();
testUtils.integrationTesting.defaultMocks(sinon); localUtils.defaultMocks(sinon);
app = await testUtils.integrationTesting.initGhost(); app = await localUtils.initGhost();
}); });
beforeEach(function () { beforeEach(function () {
testUtils.integrationTesting.overrideGhostConfig(configUtils); localUtils.overrideGhostConfig(configUtils);
}); });
afterEach(function () { afterEach(function () {
@ -1074,7 +1074,7 @@ describe('Integration - Web - Site v3', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(200); response.statusCode.should.eql(200);
response.template.should.eql('default'); response.template.should.eql('default');
@ -1099,14 +1099,14 @@ describe('Integration - Web - Site v3', function () {
} }
}); });
testUtils.integrationTesting.urlService.resetGenerators(); localUtils.urlService.resetGenerators();
testUtils.integrationTesting.defaultMocks(sinon, {theme: 'test-theme'}); localUtils.defaultMocks(sinon, {theme: 'test-theme'});
app = await testUtils.integrationTesting.initGhost(); app = await localUtils.initGhost();
}); });
beforeEach(function () { beforeEach(function () {
testUtils.integrationTesting.overrideGhostConfig(configUtils); localUtils.overrideGhostConfig(configUtils);
}); });
afterEach(function () { afterEach(function () {
@ -1126,7 +1126,7 @@ describe('Integration - Web - Site v3', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(200); response.statusCode.should.eql(200);
response.template.should.eql('home'); response.template.should.eql('home');
@ -1141,7 +1141,7 @@ describe('Integration - Web - Site v3', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(200); response.statusCode.should.eql(200);
response.template.should.eql('something'); response.template.should.eql('something');
@ -1152,12 +1152,12 @@ describe('Integration - Web - Site v3', function () {
describe('extended routes.yaml: routes', function () { describe('extended routes.yaml: routes', function () {
describe('channels', function () { describe('channels', function () {
before(testUtils.integrationTesting.urlService.resetGenerators); before(localUtils.urlService.resetGenerators);
before(testUtils.teardownDb); before(testUtils.teardownDb);
before(testUtils.setup('users:roles', 'posts')); before(testUtils.setup('users:roles', 'posts'));
before(async function () { before(async function () {
testUtils.integrationTesting.defaultMocks(sinon, {theme: 'test-theme-channels'}); localUtils.defaultMocks(sinon, {theme: 'test-theme-channels'});
sinon.stub(routeSettingsService, 'loadRouteSettingsSync').returns({ sinon.stub(routeSettingsService, 'loadRouteSettingsSync').returns({
routes: { routes: {
@ -1281,13 +1281,13 @@ describe('Integration - Web - Site v3', function () {
} }
}); });
app = await testUtils.integrationTesting.initGhost(); app = await localUtils.initGhost();
sinon.stub(themeEngine.getActive(), 'config').withArgs('posts_per_page').returns(10); sinon.stub(themeEngine.getActive(), 'config').withArgs('posts_per_page').returns(10);
}); });
beforeEach(function () { beforeEach(function () {
testUtils.integrationTesting.overrideGhostConfig(configUtils); localUtils.overrideGhostConfig(configUtils);
}); });
afterEach(function () { afterEach(function () {
@ -1307,7 +1307,7 @@ describe('Integration - Web - Site v3', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
const $ = cheerio.load(response.body); const $ = cheerio.load(response.body);
@ -1326,7 +1326,7 @@ describe('Integration - Web - Site v3', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(200); response.statusCode.should.eql(200);
response.headers['content-type'].should.eql('text/xml; charset=UTF-8'); response.headers['content-type'].should.eql('text/xml; charset=UTF-8');
@ -1341,7 +1341,7 @@ describe('Integration - Web - Site v3', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
const $ = cheerio.load(response.body); const $ = cheerio.load(response.body);
@ -1361,7 +1361,7 @@ describe('Integration - Web - Site v3', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
const $ = cheerio.load(response.body); const $ = cheerio.load(response.body);
@ -1378,7 +1378,7 @@ describe('Integration - Web - Site v3', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
const $ = cheerio.load(response.body); const $ = cheerio.load(response.body);
@ -1397,7 +1397,7 @@ describe('Integration - Web - Site v3', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
const $ = cheerio.load(response.body); const $ = cheerio.load(response.body);
@ -1416,7 +1416,7 @@ describe('Integration - Web - Site v3', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
const $ = cheerio.load(response.body); const $ = cheerio.load(response.body);
@ -1435,7 +1435,7 @@ describe('Integration - Web - Site v3', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(301); response.statusCode.should.eql(301);
response.headers.location.should.eql('/channel1/'); response.headers.location.should.eql('/channel1/');
@ -1450,7 +1450,7 @@ describe('Integration - Web - Site v3', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(301); response.statusCode.should.eql(301);
response.headers.location.should.eql('/channel6/'); response.headers.location.should.eql('/channel6/');
@ -1465,7 +1465,7 @@ describe('Integration - Web - Site v3', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(200); response.statusCode.should.eql(200);
}); });
@ -1479,7 +1479,7 @@ describe('Integration - Web - Site v3', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(200); response.statusCode.should.eql(200);
}); });
@ -1524,14 +1524,14 @@ describe('Integration - Web - Site v3', function () {
taxonomies: {} taxonomies: {}
}); });
testUtils.integrationTesting.urlService.resetGenerators(); localUtils.urlService.resetGenerators();
testUtils.integrationTesting.defaultMocks(sinon, {theme: 'test-theme'}); localUtils.defaultMocks(sinon, {theme: 'test-theme'});
app = await testUtils.integrationTesting.initGhost(); app = await localUtils.initGhost();
}); });
beforeEach(function () { beforeEach(function () {
testUtils.integrationTesting.overrideGhostConfig(configUtils); localUtils.overrideGhostConfig(configUtils);
}); });
afterEach(function () { afterEach(function () {
@ -1551,7 +1551,7 @@ describe('Integration - Web - Site v3', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(200); response.statusCode.should.eql(200);
}); });
@ -1565,7 +1565,7 @@ describe('Integration - Web - Site v3', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(404); response.statusCode.should.eql(404);
}); });
@ -1579,7 +1579,7 @@ describe('Integration - Web - Site v3', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(404); response.statusCode.should.eql(404);
}); });
@ -1593,7 +1593,7 @@ describe('Integration - Web - Site v3', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(200); response.statusCode.should.eql(200);
}); });
@ -1607,7 +1607,7 @@ describe('Integration - Web - Site v3', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(200); response.statusCode.should.eql(200);
response.template.should.eql('podcast/rss'); response.template.should.eql('podcast/rss');
@ -1624,7 +1624,7 @@ describe('Integration - Web - Site v3', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
const $ = cheerio.load(response.body); const $ = cheerio.load(response.body);
response.statusCode.should.eql(200); response.statusCode.should.eql(200);

View File

@ -2,18 +2,16 @@ const should = require('should');
const sinon = require('sinon'); const sinon = require('sinon');
const _ = require('lodash'); const _ = require('lodash');
const testUtils = require('../../utils'); const testUtils = require('../../utils');
const localUtils = require('./utils');
const adminUtils = require('../../utils/admin-utils'); const adminUtils = require('../../utils/admin-utils');
const mockUtils = require('../../utils/mocks');
const configUtils = require('../../utils/configUtils'); const configUtils = require('../../utils/configUtils');
const urlUtils = require('../../utils/urlUtils'); const urlUtils = require('../../utils/urlUtils');
const appService = require('../../../core/frontend/services/apps');
const themeEngine = require('../../../core/frontend/services/theme-engine'); const themeEngine = require('../../../core/frontend/services/theme-engine');
const siteApp = require('../../../core/server/web/parent/app');
describe('Integration - Web - vhosts', function () { describe('Integration - Web - vhosts', function () {
let app; let app;
before(testUtils.integrationTesting.urlService.resetGenerators); before(localUtils.urlService.resetGenerators);
before(testUtils.teardownDb); before(testUtils.teardownDb);
before(testUtils.setup('users:roles', 'posts')); before(testUtils.setup('users:roles', 'posts'));
before(adminUtils.stubClientFiles); before(adminUtils.stubClientFiles);
@ -26,9 +24,9 @@ describe('Integration - Web - vhosts', function () {
describe('no separate admin', function () { describe('no separate admin', function () {
before(async function () { before(async function () {
testUtils.integrationTesting.urlService.resetGenerators(); localUtils.urlService.resetGenerators();
testUtils.integrationTesting.defaultMocks(sinon, {amp: true}); localUtils.defaultMocks(sinon, {amp: true});
testUtils.integrationTesting.overrideGhostConfig(configUtils); localUtils.overrideGhostConfig(configUtils);
configUtils.set('url', 'http://example.com'); configUtils.set('url', 'http://example.com');
configUtils.set('admin:url', null); configUtils.set('admin:url', null);
@ -36,7 +34,7 @@ describe('Integration - Web - vhosts', function () {
sinon.stub(themeEngine.getActive(), 'engine').withArgs('ghost-api').returns('v2'); sinon.stub(themeEngine.getActive(), 'engine').withArgs('ghost-api').returns('v2');
sinon.stub(themeEngine.getActive(), 'config').withArgs('posts_per_page').returns(2); sinon.stub(themeEngine.getActive(), 'config').withArgs('posts_per_page').returns(2);
app = await testUtils.integrationTesting.initGhost(); app = await localUtils.initGhost();
}); });
before(function () { before(function () {
@ -59,7 +57,7 @@ describe('Integration - Web - vhosts', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(200); response.statusCode.should.eql(200);
}); });
@ -73,7 +71,7 @@ describe('Integration - Web - vhosts', function () {
host: 'localhost' host: 'localhost'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(200); response.statusCode.should.eql(200);
}); });
@ -87,7 +85,7 @@ describe('Integration - Web - vhosts', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(200); response.statusCode.should.eql(200);
}); });
@ -101,7 +99,7 @@ describe('Integration - Web - vhosts', function () {
host: 'localhost' host: 'localhost'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(200); response.statusCode.should.eql(200);
}); });
@ -115,7 +113,7 @@ describe('Integration - Web - vhosts', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(200); response.statusCode.should.eql(200);
}); });
@ -129,7 +127,7 @@ describe('Integration - Web - vhosts', function () {
host: 'localhost' host: 'localhost'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(200); response.statusCode.should.eql(200);
}); });
@ -138,9 +136,9 @@ describe('Integration - Web - vhosts', function () {
describe('separate admin host', function () { describe('separate admin host', function () {
before(async function () { before(async function () {
testUtils.integrationTesting.urlService.resetGenerators(); localUtils.urlService.resetGenerators();
testUtils.integrationTesting.defaultMocks(sinon, {amp: true}); localUtils.defaultMocks(sinon, {amp: true});
testUtils.integrationTesting.overrideGhostConfig(configUtils); localUtils.overrideGhostConfig(configUtils);
configUtils.set('url', 'http://example.com'); configUtils.set('url', 'http://example.com');
configUtils.set('admin:url', 'https://admin.example.com'); configUtils.set('admin:url', 'https://admin.example.com');
@ -148,7 +146,7 @@ describe('Integration - Web - vhosts', function () {
sinon.stub(themeEngine.getActive(), 'engine').withArgs('ghost-api').returns('v2'); sinon.stub(themeEngine.getActive(), 'engine').withArgs('ghost-api').returns('v2');
sinon.stub(themeEngine.getActive(), 'config').withArgs('posts_per_page').returns(2); sinon.stub(themeEngine.getActive(), 'config').withArgs('posts_per_page').returns(2);
app = await testUtils.integrationTesting.initGhost(); app = await localUtils.initGhost();
}); });
before(function () { before(function () {
@ -169,7 +167,7 @@ describe('Integration - Web - vhosts', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(200); response.statusCode.should.eql(200);
}); });
@ -183,7 +181,7 @@ describe('Integration - Web - vhosts', function () {
host: 'localhost' host: 'localhost'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(200); response.statusCode.should.eql(200);
}); });
@ -197,7 +195,7 @@ describe('Integration - Web - vhosts', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(301); response.statusCode.should.eql(301);
response.headers.location.should.eql('https://admin.example.com/ghost/'); response.headers.location.should.eql('https://admin.example.com/ghost/');
@ -212,7 +210,7 @@ describe('Integration - Web - vhosts', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(404); response.statusCode.should.eql(404);
}); });
@ -226,7 +224,7 @@ describe('Integration - Web - vhosts', function () {
host: 'localhost' host: 'localhost'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(404); response.statusCode.should.eql(404);
}); });
@ -240,7 +238,7 @@ describe('Integration - Web - vhosts', function () {
host: 'admin.example.com' host: 'admin.example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(200); response.statusCode.should.eql(200);
}); });
@ -254,7 +252,7 @@ describe('Integration - Web - vhosts', function () {
host: 'admin.example.com' host: 'admin.example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(200); response.statusCode.should.eql(200);
}); });
@ -268,7 +266,7 @@ describe('Integration - Web - vhosts', function () {
host: 'admin.example.com' host: 'admin.example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(301); response.statusCode.should.eql(301);
response.headers.location.should.eql('https://admin.example.com/ghost/'); response.headers.location.should.eql('https://admin.example.com/ghost/');
@ -283,7 +281,7 @@ describe('Integration - Web - vhosts', function () {
host: 'admin.example.com' host: 'admin.example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(404); response.statusCode.should.eql(404);
}); });
@ -292,9 +290,9 @@ describe('Integration - Web - vhosts', function () {
describe('separate admin host w/ admin redirects disabled', function () { describe('separate admin host w/ admin redirects disabled', function () {
before(async function () { before(async function () {
testUtils.integrationTesting.urlService.resetGenerators(); localUtils.urlService.resetGenerators();
testUtils.integrationTesting.defaultMocks(sinon, {amp: true}); localUtils.defaultMocks(sinon, {amp: true});
testUtils.integrationTesting.overrideGhostConfig(configUtils); localUtils.overrideGhostConfig(configUtils);
configUtils.set('url', 'http://example.com'); configUtils.set('url', 'http://example.com');
configUtils.set('admin:url', 'https://admin.example.com'); configUtils.set('admin:url', 'https://admin.example.com');
@ -303,7 +301,7 @@ describe('Integration - Web - vhosts', function () {
sinon.stub(themeEngine.getActive(), 'engine').withArgs('ghost-api').returns('v2'); sinon.stub(themeEngine.getActive(), 'engine').withArgs('ghost-api').returns('v2');
sinon.stub(themeEngine.getActive(), 'config').withArgs('posts_per_page').returns(2); sinon.stub(themeEngine.getActive(), 'config').withArgs('posts_per_page').returns(2);
app = await testUtils.integrationTesting.initGhost(); app = await localUtils.initGhost();
}); });
before(function () { before(function () {
@ -324,7 +322,7 @@ describe('Integration - Web - vhosts', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(404); response.statusCode.should.eql(404);
}); });
@ -333,9 +331,9 @@ describe('Integration - Web - vhosts', function () {
describe('same host separate protocol', function () { describe('same host separate protocol', function () {
before(async function () { before(async function () {
testUtils.integrationTesting.urlService.resetGenerators(); localUtils.urlService.resetGenerators();
testUtils.integrationTesting.defaultMocks(sinon, {amp: true}); localUtils.defaultMocks(sinon, {amp: true});
testUtils.integrationTesting.overrideGhostConfig(configUtils); localUtils.overrideGhostConfig(configUtils);
configUtils.set('url', 'http://example.com'); configUtils.set('url', 'http://example.com');
configUtils.set('admin:url', 'https://example.com'); configUtils.set('admin:url', 'https://example.com');
@ -343,7 +341,7 @@ describe('Integration - Web - vhosts', function () {
sinon.stub(themeEngine.getActive(), 'engine').withArgs('ghost-api').returns('v2'); sinon.stub(themeEngine.getActive(), 'engine').withArgs('ghost-api').returns('v2');
sinon.stub(themeEngine.getActive(), 'config').withArgs('posts_per_page').returns(2); sinon.stub(themeEngine.getActive(), 'config').withArgs('posts_per_page').returns(2);
app = await testUtils.integrationTesting.initGhost(); app = await localUtils.initGhost();
}); });
before(function () { before(function () {
@ -358,7 +356,7 @@ describe('Integration - Web - vhosts', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(200); response.statusCode.should.eql(200);
}); });
@ -372,7 +370,7 @@ describe('Integration - Web - vhosts', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(200); response.statusCode.should.eql(200);
}); });
@ -386,7 +384,7 @@ describe('Integration - Web - vhosts', function () {
host: 'localhost' host: 'localhost'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(200); response.statusCode.should.eql(200);
}); });
@ -400,7 +398,7 @@ describe('Integration - Web - vhosts', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(301); response.statusCode.should.eql(301);
response.headers.location.should.eql('https://example.com/ghost/'); response.headers.location.should.eql('https://example.com/ghost/');
@ -415,7 +413,7 @@ describe('Integration - Web - vhosts', function () {
host: 'localhost' host: 'localhost'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(301); response.statusCode.should.eql(301);
response.headers.location.should.eql('https://example.com/ghost/'); response.headers.location.should.eql('https://example.com/ghost/');
@ -430,7 +428,7 @@ describe('Integration - Web - vhosts', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(301); response.statusCode.should.eql(301);
response.headers.location.should.eql('https://example.com/ghost/api/v2/admin/site/'); response.headers.location.should.eql('https://example.com/ghost/api/v2/admin/site/');
@ -445,7 +443,7 @@ describe('Integration - Web - vhosts', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(200); response.statusCode.should.eql(200);
}); });
@ -459,7 +457,7 @@ describe('Integration - Web - vhosts', function () {
host: 'localhost' host: 'localhost'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(301); response.statusCode.should.eql(301);
response.headers.location.should.eql('https://example.com/ghost/'); response.headers.location.should.eql('https://example.com/ghost/');
@ -474,7 +472,7 @@ describe('Integration - Web - vhosts', function () {
host: 'example.com' host: 'example.com'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(200); response.statusCode.should.eql(200);
}); });
@ -488,7 +486,7 @@ describe('Integration - Web - vhosts', function () {
host: 'localhost' host: 'localhost'
}; };
return mockUtils.express.invoke(app, req) return localUtils.mockExpress.invoke(app, req)
.then(function (response) { .then(function (response) {
response.statusCode.should.eql(301); response.statusCode.should.eql(301);
response.headers.location.should.eql('https://example.com/ghost/api/v2/admin/site/'); response.headers.location.should.eql('https://example.com/ghost/api/v2/admin/site/');

View File

@ -0,0 +1,2 @@
module.exports = require('./setup');
module.exports.mockExpress = require('./mock-express');

View File

@ -2,31 +2,31 @@
const path = require('path'); const path = require('path');
// Ghost Internals // Ghost Internals
const models = require('../../core/server/models'); const models = require('../../../../core/server/models');
const routingService = require('../../core/frontend/services/routing'); const routingService = require('../../../../core/frontend/services/routing');
const settingsService = require('../../core/server/services/settings'); const settingsService = require('../../../../core/server/services/settings');
const settingsCache = require('../../core/shared/settings-cache'); const settingsCache = require('../../../../core/shared/settings-cache');
const imageLib = require('../../core/server/lib/image'); const imageLib = require('../../../../core/server/lib/image');
const themeService = require('../../core/server/services/themes'); const themeService = require('../../../../core/server/services/themes');
const helperService = require('../../core/frontend/services/helpers'); const helperService = require('../../../../core/frontend/services/helpers');
const appService = require('../../core/frontend/services/apps'); const appService = require('../../../../core/frontend/services/apps');
const siteApp = require('../../core/server/web/parent/app'); const siteApp = require('../../../../core/server/web/parent/app');
// Other Test Utilities // Other Test Utilities
const configUtils = require('./configUtils'); const configUtils = require('../../../utils/configUtils');
const urlServiceUtils = require('./url-service-utils'); const urlServiceUtils = require('../../../utils/url-service-utils');
module.exports = { module.exports = {
overrideGhostConfig: (utils) => { overrideGhostConfig: (utils) => {
utils.set('paths:contentPath', path.join(__dirname, 'fixtures')); utils.set('paths:contentPath', path.join(__dirname, '../../../utils/fixtures'));
utils.set('times:getImageSizeTimeoutInMS', 1); utils.set('times:getImageSizeTimeoutInMS', 1);
}, },
defaultMocks: (sandbox, options) => { defaultMocks: (sandbox, options) => {
options = options || {}; options = options || {};
configUtils.set('paths:contentPath', path.join(__dirname, 'fixtures')); configUtils.set('paths:contentPath', path.join(__dirname, '../../../utils/fixtures'));
const cacheStub = sandbox.stub(settingsCache, 'get'); const cacheStub = sandbox.stub(settingsCache, 'get');

View File

@ -12,7 +12,7 @@ const e2eUtils = require('./e2e-utils');
const APIUtils = require('./api'); const APIUtils = require('./api');
const dbUtils = require('./db-utils'); const dbUtils = require('./db-utils');
const fixtureUtils = require('./fixture-utils'); const fixtureUtils = require('./fixture-utils');
const oldIntegrationUtils = require('./old-integration-utils'); const oldIntegrationUtils = require('../regression/mock-express-style/utils/setup');
const redirects = require('./redirects'); const redirects = require('./redirects');
const cacheRules = require('./fixtures/cache-rules'); const cacheRules = require('./fixtures/cache-rules');
const context = require('./fixtures/context'); const context = require('./fixtures/context');
@ -104,8 +104,6 @@ module.exports = {
createPost: createPost, createPost: createPost,
createEmailedPost, createEmailedPost,
integrationTesting: oldIntegrationUtils,
/** /**
* renderObject: res.render(view, dbResponse) * renderObject: res.render(view, dbResponse)
* templateOptions: hbs.updateTemplateOptions(...) * templateOptions: hbs.updateTemplateOptions(...)

View File

@ -1,2 +1 @@
exports.modules = require('./modules'); exports.modules = require('./modules');
exports.express = require('./express');