Enabled frontend-only boot for mock-express tests

refs 3c7a8dead4

- Simplifies the state initialization code significantly and reuses native boot mechanism instead of mimicking it (it was a headache to maintain with all the internal services moving around)
This commit is contained in:
Naz 2021-12-02 12:16:28 +04:00 committed by naz
parent de121e1219
commit 51a4a65eec

View File

@ -2,14 +2,11 @@
const path = require('path'); const path = require('path');
// Ghost Internals // Ghost Internals
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 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 appService = require('../../../../core/frontend/services/apps');
const siteApp = require('../../../../core/server/web/parent/app'); const boot = require('../../../../core/boot');
// Other Test Utilities // Other Test Utilities
const configUtils = require('../../../utils/configUtils'); const configUtils = require('../../../utils/configUtils');
@ -48,25 +45,11 @@ module.exports = {
* @returns {object} express App * @returns {object} express App
*/ */
initGhost: async () => { initGhost: async () => {
models.init(); const app = await boot({
await settingsService.init(); server: false,
urlServiceUtils.init(); backend: false
const customRedirects = require('../../../../core/server/services/redirects');
await customRedirects.init();
const routeSettings = require('../../../../core/server/services/route-settings');
await routeSettings.init();
const customThemeSettingsService = require('../../../../core/server/services/custom-theme-settings');
customThemeSettingsService.init();
const themeService = require('../../../../core/server/services/themes');
await themeService.init();
const helperService = require('../../../../core/frontend/services/helpers');
await helperService.init();
const app = siteApp({
start: true
}); });
await appService.init();
await urlServiceUtils.isFinished(); await urlServiceUtils.isFinished();
return app; return app;