0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-06 22:40:14 -05:00

Fixed e2e-framework not waiting for Ghost to start

no-issue

Because we were returning the call to `boot`, rather than awaiting it,
it meant that once a test was provided with an API Agent the Ghost
application hadn't necessarily started. This was noticed whilst working
on the Members API which requires the frontend to be loaded.

When the frontend is loaded we must also wait for the url service to
have finished initialising, so that we do not run into 503 maintenance
errors when hitting the frontend.
This commit is contained in:
Fabien "egg" O'Carroll 2022-02-11 15:42:35 +02:00 committed by Fabien 'egg' O'Carroll
parent af66ab02c8
commit 126fc8cb81

View file

@ -23,6 +23,7 @@ const uuid = require('uuid');
const fixtureUtils = require('./fixture-utils'); const fixtureUtils = require('./fixture-utils');
const redirectsUtils = require('./redirects'); const redirectsUtils = require('./redirects');
const configUtils = require('./configUtils'); const configUtils = require('./configUtils');
const urlServiceUtils = require('./url-service-utils');
const mockManager = require('./e2e-framework-mock-manager'); const mockManager = require('./e2e-framework-mock-manager');
const boot = require('../../core/boot'); const boot = require('../../core/boot');
@ -34,7 +35,7 @@ const db = require('./db-utils');
* @param {Boolean} [options.backend] Boot the backend * @param {Boolean} [options.backend] Boot the backend
* @param {Boolean} [options.frontend] Boot the frontend * @param {Boolean} [options.frontend] Boot the frontend
* @param {Boolean} [options.server] Start a server * @param {Boolean} [options.server] Start a server
* @returns {Express.Application} ghost * @returns {Promise<Express.Application>} ghost
*/ */
const startGhost = async (options = {}) => { const startGhost = async (options = {}) => {
/** /**
@ -56,7 +57,15 @@ const startGhost = async (options = {}) => {
// Ensure the DB state // Ensure the DB state
await resetDb(); await resetDb();
return boot(Object.assign({}, defaults, options)); const bootOptions = Object.assign({}, defaults, options);
const ghostServer = await boot(bootOptions);
if (bootOptions.frontend) {
await urlServiceUtils.isFinished();
}
return ghostServer;
}; };
/** /**