diff --git a/test/e2e-api/admin/settings.test.js b/test/e2e-api/admin/settings.test.js index 5e72dca61f..5c46d0bce4 100644 --- a/test/e2e-api/admin/settings.test.js +++ b/test/e2e-api/admin/settings.test.js @@ -12,7 +12,10 @@ describe('Settings API', function () { let request; before(async function () { - await localUtils.startGhost(); + await localUtils.startGhost({ + redirectsFile: true, + copySettings: true + }); request = supertest.agent(config.get('url')); await localUtils.doAuth(request); }); diff --git a/test/e2e-api/admin/themes.test.js b/test/e2e-api/admin/themes.test.js index b153dd8003..9fda25aa9d 100644 --- a/test/e2e-api/admin/themes.test.js +++ b/test/e2e-api/admin/themes.test.js @@ -5,7 +5,6 @@ const fs = require('fs'); const _ = require('lodash'); const supertest = require('supertest'); const nock = require('nock'); -const testUtils = require('../../utils'); const config = require('../../../core/shared/config'); const localUtils = require('./utils'); const settingsCache = require('../../../core/shared/settings-cache'); @@ -26,10 +25,9 @@ describe('Themes API', function () { }; before(async function () { - // NOTE: this flag should not be here! the URL service re-initialization should be fixed instead - // The reason why this init doesn't work without "forceStart" is because during the "restartModeGhostStart" - // the routing.routerManager is never called with "start". That's why a full boot is needed - await localUtils.startGhost(); + await localUtils.startGhost({ + copyThemes: true + }); ownerRequest = supertest.agent(config.get('url')); await localUtils.doAuth(ownerRequest); }); diff --git a/test/e2e-frontend/members.test.js b/test/e2e-frontend/members.test.js index 6f7647f53f..4a9ab37157 100644 --- a/test/e2e-frontend/members.test.js +++ b/test/e2e-frontend/members.test.js @@ -51,7 +51,9 @@ describe('Front-end members behaviour', function () { return originalSettingsCacheGetFn(key, options); }); - await testUtils.startGhost(); + await testUtils.startGhost({ + copyThemes: true + }); await testUtils.initFixtures('members'); request = supertest.agent(configUtils.config.get('url')); }); diff --git a/test/utils/e2e-utils.js b/test/utils/e2e-utils.js index aa0566d1f4..55abf5b145 100644 --- a/test/utils/e2e-utils.js +++ b/test/utils/e2e-utils.js @@ -81,6 +81,9 @@ const prepareContentFolder = (options) => { if (options.copyThemes) { // Copy all themes into the new test content folder. Default active theme is always casper. If you want to use a different theme, you have to set the active theme (e.g. stub) fs.copySync(path.join(__dirname, 'fixtures', 'themes'), path.join(contentFolderForTests, 'themes')); + } else if (options.frontend) { + // Just copy Casper + fs.copySync(path.join(__dirname, 'fixtures', 'themes', 'casper'), path.join(contentFolderForTests, 'themes', 'casper')); } if (options.redirectsFile) { @@ -99,7 +102,7 @@ const prepareContentFolder = (options) => { // - truncate database // - re-run default fixtures // - reload affected services -const restartModeGhostStart = async ({frontend}) => { +const restartModeGhostStart = async ({frontend, copyThemes, copySettings}) => { debug('Reload Mode'); // TODO: figure out why we need this if we reset again later? @@ -113,11 +116,12 @@ const restartModeGhostStart = async ({frontend}) => { await settingsService.init(); debug('settings done'); - if (frontend) { - // Load the frontend-related components + if (copySettings) { await routeSettingsService.init(); + } + if (copyThemes) { await themeService.init(); - debug('frontend done'); + await themeService.loadInactiveThemes(); } // Reload the URL service & wait for it to be ready again @@ -195,19 +199,17 @@ const startGhost = async (options) => { options = _.merge({ backend: true, frontend: true, - redirectsFile: true, + redirectsFile: false, redirectsFileExt: '.json', forceStart: false, - copyThemes: true, - copySettings: true, + copyThemes: false, + copySettings: false, contentFolder: path.join(os.tmpdir(), uuid.v4(), 'ghost-test'), subdir: false }, options); - // Ensure we have tmp content folders populated ready for testing - // @TODO: tidy up the tmp folders after tests prepareContentFolder(options); - + if (ghostServer && ghostServer.httpServer && !options.forceStart) { await restartModeGhostStart(options); } else {