mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-25 03:44:29 +03:00
Optimized e2e-api tests using boot with no frontend
refs https://github.com/TryGhost/Toolbox/issues/135 - When running e2e-API test in most cases there's no need to boot Ghost instance with full frontend. This should improve the boot time which should reflect on the speed of running test suites - The tests where the "forceStart" and "withFrontend" are used together indicate that there's still some work to do to fully separate frontend/backend boot line. The force start is also unnecessary, but was needed to reinitialize all services properly - should be investigated!
This commit is contained in:
parent
3b390639c4
commit
008b6e0fae
@ -9,7 +9,11 @@ describe('Custom Theme Settings API', function () {
|
||||
let request;
|
||||
|
||||
before(async function () {
|
||||
await testUtils.startGhost();
|
||||
// NOTE: needs force start to be able to reinitialize Ghost process with frontend services - custom-theme-settings, to be specific
|
||||
await testUtils.startGhost({
|
||||
forceStart: true,
|
||||
withFrontend: true
|
||||
});
|
||||
request = supertest.agent(config.get('url'));
|
||||
await localUtils.doAuth(request, 'users:extra', 'custom_theme_settings');
|
||||
|
||||
|
@ -26,7 +26,10 @@ describe('Themes API', function () {
|
||||
};
|
||||
|
||||
before(async function () {
|
||||
await testUtils.startGhost();
|
||||
await testUtils.startGhost({
|
||||
forceStart: true, // NOTE: this flag should not be here! the URL service re-initialization should be fixe instead
|
||||
withFrontend: true
|
||||
});
|
||||
ownerRequest = supertest.agent(config.get('url'));
|
||||
await localUtils.doAuth(ownerRequest);
|
||||
});
|
||||
|
@ -96,7 +96,7 @@ const prepareContentFolder = (options) => {
|
||||
// - truncate database
|
||||
// - re-run default fixtures
|
||||
// - reload affected services
|
||||
const restartModeGhostStart = async () => {
|
||||
const restartModeGhostStart = async ({withFrontend}) => {
|
||||
debug('Reload Mode');
|
||||
// Teardown truncates all tables and also calls urlServiceUtils.reset();
|
||||
await dbUtils.teardown();
|
||||
@ -117,8 +117,12 @@ const restartModeGhostStart = async () => {
|
||||
// Reload the URL service & wait for it to be ready again
|
||||
// @TODO: why/how is this different to urlService.resetGenerators?
|
||||
urlServiceUtils.reset();
|
||||
urlServiceUtils.init();
|
||||
await urlServiceUtils.isFinished();
|
||||
urlServiceUtils.init({urlCache: !withFrontend});
|
||||
|
||||
if (withFrontend) {
|
||||
await urlServiceUtils.isFinished();
|
||||
}
|
||||
|
||||
debug('routes done');
|
||||
|
||||
await customRedirectsService.init();
|
||||
@ -127,8 +131,8 @@ const restartModeGhostStart = async () => {
|
||||
limits.init();
|
||||
};
|
||||
|
||||
const bootGhost = async () => {
|
||||
ghostServer = await boot();
|
||||
const bootGhost = async ({withBackend, withFrontend}) => {
|
||||
ghostServer = await boot({withBackend, withFrontend});
|
||||
};
|
||||
|
||||
// CASE: Ghost Server needs Starting
|
||||
@ -168,13 +172,17 @@ const freshModeGhostStart = async (options) => {
|
||||
await bootGhost(options);
|
||||
|
||||
// Wait for the URL service to be ready, which happens after bootYou
|
||||
await urlServiceUtils.isFinished();
|
||||
if (options.withFrontend) {
|
||||
await urlServiceUtils.isFinished();
|
||||
}
|
||||
};
|
||||
|
||||
const startGhost = async (options) => {
|
||||
const startTime = Date.now();
|
||||
debug('Start Ghost');
|
||||
options = _.merge({
|
||||
withBackend: true,
|
||||
withFrontend: false,
|
||||
redirectsFile: true,
|
||||
redirectsFileExt: '.json',
|
||||
forceStart: false,
|
||||
|
@ -17,8 +17,8 @@ module.exports.isFinished = async (options = {disableDbReadyEvent: false}) => {
|
||||
};
|
||||
|
||||
// @TODO: unify all the reset/softTeset helpers so they either work how the main code works or the reasons why they are different are clear
|
||||
module.exports.init = () => {
|
||||
urlService.init();
|
||||
module.exports.init = ({urlCache}) => {
|
||||
urlService.init({urlCache});
|
||||
};
|
||||
|
||||
module.exports.reset = () => {
|
||||
|
Loading…
Reference in New Issue
Block a user