From 3c19a8f014466a58d0410c44239a06168e13c8ee Mon Sep 17 00:00:00 2001 From: Naz Date: Mon, 6 Dec 2021 11:07:09 +0400 Subject: [PATCH] Cleaned up mock-express tests from unnecessary inits refs https://github.com/TryGhost/Toolbox/issues/152 - Have skimmed through the test suites in hopes to find some quick performance wins to bring the runtime speed closer to the one in "main". Haven't been successful to identify major wins, cleaned up a couple of small bits. - We'll have to live with a tradeoff between maintainability/unified boot VS cost of mainitaining a fake boot process. Imo extra couple seconds of runtime is worth it. --- .../mock-express-style/api-vs-frontend/canary.test.js | 2 -- .../mock-express-style/api-vs-frontend/v2.test.js | 1 - .../mock-express-style/api-vs-frontend/v3.test.js | 1 - .../mock-express-style/parent_app_vhosts.test.js | 7 ------- 4 files changed, 11 deletions(-) diff --git a/test/regression/mock-express-style/api-vs-frontend/canary.test.js b/test/regression/mock-express-style/api-vs-frontend/canary.test.js index 8dc5a56ef4..c28eddff9f 100644 --- a/test/regression/mock-express-style/api-vs-frontend/canary.test.js +++ b/test/regression/mock-express-style/api-vs-frontend/canary.test.js @@ -21,11 +21,9 @@ describe('Integration - Web - Site canary', function () { describe('default routes.yaml', function () { before(async function () { - localUtils.urlService.resetGenerators(); localUtils.defaultMocks(sinon, {amp: true}); localUtils.overrideGhostConfig(configUtils); - await routeSettingsService.init(); app = await localUtils.initGhost(); }); diff --git a/test/regression/mock-express-style/api-vs-frontend/v2.test.js b/test/regression/mock-express-style/api-vs-frontend/v2.test.js index dc8fbc02b7..a1e3a0d79f 100644 --- a/test/regression/mock-express-style/api-vs-frontend/v2.test.js +++ b/test/regression/mock-express-style/api-vs-frontend/v2.test.js @@ -21,7 +21,6 @@ describe('Integration - Web - Site v2', function () { describe('default routes.yaml', function () { before(async function () { - localUtils.urlService.resetGenerators(); localUtils.defaultMocks(sinon, {amp: true}); localUtils.overrideGhostConfig(configUtils); diff --git a/test/regression/mock-express-style/api-vs-frontend/v3.test.js b/test/regression/mock-express-style/api-vs-frontend/v3.test.js index c7764c8e38..0f12cc17f4 100644 --- a/test/regression/mock-express-style/api-vs-frontend/v3.test.js +++ b/test/regression/mock-express-style/api-vs-frontend/v3.test.js @@ -21,7 +21,6 @@ describe('Integration - Web - Site v3', function () { describe('default routes.yaml', function () { before(async function () { - localUtils.urlService.resetGenerators(); localUtils.defaultMocks(sinon, {amp: true}); localUtils.overrideGhostConfig(configUtils); diff --git a/test/regression/mock-express-style/parent_app_vhosts.test.js b/test/regression/mock-express-style/parent_app_vhosts.test.js index 9ae3377c23..fbf1274d02 100644 --- a/test/regression/mock-express-style/parent_app_vhosts.test.js +++ b/test/regression/mock-express-style/parent_app_vhosts.test.js @@ -2,7 +2,6 @@ const should = require('should'); const sinon = require('sinon'); const testUtils = require('../../utils'); const localUtils = require('./utils'); -const adminUtils = require('../../utils/admin-utils'); const configUtils = require('../../utils/configUtils'); const urlUtils = require('../../utils/urlUtils'); const themeEngine = require('../../../core/frontend/services/theme-engine'); @@ -10,10 +9,7 @@ const themeEngine = require('../../../core/frontend/services/theme-engine'); describe('Integration - Web - vhosts', function () { let app; - before(localUtils.urlService.resetGenerators); before(testUtils.teardownDb); - before(testUtils.setup('users:roles', 'posts')); - before(adminUtils.stubClientFiles); after(function () { configUtils.restore(); @@ -23,7 +19,6 @@ describe('Integration - Web - vhosts', function () { describe('no separate admin', function () { before(async function () { - localUtils.urlService.resetGenerators(); localUtils.defaultMocks(sinon, {amp: true}); localUtils.overrideGhostConfig(configUtils); @@ -132,7 +127,6 @@ describe('Integration - Web - vhosts', function () { describe('separate admin host', function () { before(async function () { - localUtils.urlService.resetGenerators(); localUtils.defaultMocks(sinon, {amp: true}); localUtils.overrideGhostConfig(configUtils); @@ -286,7 +280,6 @@ describe('Integration - Web - vhosts', function () { describe('separate admin host w/ admin redirects disabled', function () { before(async function () { - localUtils.urlService.resetGenerators(); localUtils.defaultMocks(sinon, {amp: true}); localUtils.overrideGhostConfig(configUtils);