From 126fc8cb813bbbaddee0c7da26662c937c213fa7 Mon Sep 17 00:00:00 2001 From: "Fabien \"egg\" O'Carroll" Date: Fri, 11 Feb 2022 15:42:35 +0200 Subject: [PATCH] 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. --- test/utils/e2e-framework.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/test/utils/e2e-framework.js b/test/utils/e2e-framework.js index 3baffd41da..0dd005ac45 100644 --- a/test/utils/e2e-framework.js +++ b/test/utils/e2e-framework.js @@ -23,6 +23,7 @@ const uuid = require('uuid'); const fixtureUtils = require('./fixture-utils'); const redirectsUtils = require('./redirects'); const configUtils = require('./configUtils'); +const urlServiceUtils = require('./url-service-utils'); const mockManager = require('./e2e-framework-mock-manager'); const boot = require('../../core/boot'); @@ -34,7 +35,7 @@ const db = require('./db-utils'); * @param {Boolean} [options.backend] Boot the backend * @param {Boolean} [options.frontend] Boot the frontend * @param {Boolean} [options.server] Start a server - * @returns {Express.Application} ghost + * @returns {Promise} ghost */ const startGhost = async (options = {}) => { /** @@ -56,7 +57,15 @@ const startGhost = async (options = {}) => { // Ensure the DB state 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; }; /**