2021-02-17 20:36:27 +03:00
|
|
|
// Utility Packages
|
|
|
|
const path = require('path');
|
|
|
|
|
|
|
|
// Ghost Internals
|
|
|
|
const models = require('../../core/server/models');
|
|
|
|
const routingService = require('../../core/frontend/services/routing');
|
|
|
|
const settingsService = require('../../core/server/services/settings');
|
|
|
|
const settingsCache = require('../../core/server/services/settings/cache');
|
|
|
|
const imageLib = require('../../core/server/lib/image');
|
2021-04-27 15:28:04 +03:00
|
|
|
const themeService = require('../../core/server/services/themes');
|
2021-02-17 20:36:27 +03:00
|
|
|
|
|
|
|
// Other Test Utilities
|
|
|
|
const configUtils = require('./configUtils');
|
|
|
|
const urlServiceUtils = require('./url-service-utils');
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
overrideGhostConfig: (utils) => {
|
|
|
|
utils.set('paths:contentPath', path.join(__dirname, 'fixtures'));
|
|
|
|
utils.set('times:getImageSizeTimeoutInMS', 1);
|
|
|
|
},
|
|
|
|
|
|
|
|
defaultMocks: (sandbox, options) => {
|
|
|
|
options = options || {};
|
|
|
|
|
|
|
|
configUtils.set('paths:contentPath', path.join(__dirname, 'fixtures'));
|
|
|
|
|
|
|
|
const cacheStub = sandbox.stub(settingsCache, 'get');
|
|
|
|
|
|
|
|
cacheStub.withArgs('active_theme').returns(options.theme || 'casper');
|
|
|
|
cacheStub.withArgs('timezone').returns('Etc/UTC');
|
|
|
|
cacheStub.withArgs('permalinks').returns('/:slug/');
|
|
|
|
cacheStub.withArgs('ghost_private_key').returns('-----BEGIN RSA PRIVATE KEY-----\nMB8CAQACAgPBAgMBAAECAgMFAgEfAgEfAgEXAgEXAgEA\n-----END RSA PRIVATE KEY-----\n');
|
|
|
|
cacheStub.withArgs('ghost_public_key').returns('-----BEGIN RSA PUBLIC KEY-----\nMAkCAgPBAgMBAAE=\n-----END RSA PUBLIC KEY-----\n');
|
|
|
|
|
|
|
|
if (options.amp) {
|
|
|
|
cacheStub.withArgs('amp').returns(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
sandbox.stub(imageLib.imageSize, 'getImageSizeFromUrl').resolves();
|
|
|
|
},
|
|
|
|
|
|
|
|
initGhost: () => {
|
|
|
|
models.init();
|
|
|
|
|
|
|
|
settingsCache.shutdown();
|
|
|
|
|
|
|
|
return settingsService.init()
|
|
|
|
.then(() => {
|
2021-04-20 17:34:51 +03:00
|
|
|
return themeService.init();
|
2021-02-17 20:36:27 +03:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
routing: {
|
|
|
|
reset: function () {
|
|
|
|
routingService.registry.resetAll();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2021-02-22 17:09:39 +03:00
|
|
|
// Temporary function just for test/regression/site/site_spec.js
|
|
|
|
async urlServiceInitAndWait() {
|
|
|
|
urlServiceUtils.init();
|
|
|
|
return await urlServiceUtils.isFinished();
|
|
|
|
},
|
|
|
|
|
2021-02-17 20:36:27 +03:00
|
|
|
urlService: urlServiceUtils
|
|
|
|
};
|