From 9dc096cb1588b2266ce9185c9fcd2d7493e3526b Mon Sep 17 00:00:00 2001 From: Naz Date: Thu, 2 Dec 2021 19:58:14 +0400 Subject: [PATCH] Fixed api vs frontend test suites refs https://github.com/ErisDS/Ghost/commit/3c7a8dead41c78fb1b251b42324387ccc53e3eed - The tests needed adjustments with the native boot mechanism. - The number of returned posts changed in the test resutls because duing native boot we also insert fixtures which add to the number of initial posts - The vhost regression suite is still failing and I had no strength to figure out why. The redirect it fails with makes no sense, the clue here is that the test doesn't fail when running in isolation, so probably has to do with some leftover overrides from the previous test cases. --- .../api-vs-frontend/canary.test.js | 4 +-- .../api-vs-frontend/v2.test.js | 26 +++++++++---------- .../api-vs-frontend/v3.test.js | 26 +++++++++---------- .../parent_app_vhosts.test.js | 10 +++---- 4 files changed, 33 insertions(+), 33 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 c16cc1afb5..8dc5a56ef4 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 @@ -1399,7 +1399,7 @@ describe('Integration - Web - Site canary', function () { response.statusCode.should.eql(200); response.template.should.eql('index'); - $('.post-card').length.should.equal(4); + $('.post-card').length.should.equal(10); }); }); @@ -1418,7 +1418,7 @@ describe('Integration - Web - Site canary', function () { response.statusCode.should.eql(200); response.template.should.eql('index'); - $('.post-card').length.should.equal(4); + $('.post-card').length.should.equal(10); }); }); 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 281d644f58..dc8fbc02b7 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 @@ -361,7 +361,7 @@ describe('Integration - Web - Site v2', function () { describe('extended routes.yaml: collections', function () { describe('2 collections', function () { before(async function () { - sinon.stub(routeSettingsService, 'loadRouteSettingsSync').get(() => () => ({ + sinon.stub(routeSettingsService, 'loadRouteSettings').get(() => () => ({ routes: { '/': {templates: ['home']} }, @@ -486,7 +486,7 @@ describe('Integration - Web - Site v2', function () { describe('no collections', function () { before(async function () { - sinon.stub(routeSettingsService, 'loadRouteSettingsSync').get(() => () => ({ + sinon.stub(routeSettingsService, 'loadRouteSettings').get(() => () => ({ routes: { '/something/': {templates: ['something']} }, @@ -531,7 +531,7 @@ describe('Integration - Web - Site v2', function () { describe('static permalink route', function () { before(async function () { - sinon.stub(routeSettingsService, 'loadRouteSettingsSync').get(() => () => ({ + sinon.stub(routeSettingsService, 'loadRouteSettings').get(() => () => ({ routes: {}, collections: { @@ -631,7 +631,7 @@ describe('Integration - Web - Site v2', function () { describe('primary author permalink', function () { before(async function () { - sinon.stub(routeSettingsService, 'loadRouteSettingsSync').get(() => () => ({ + sinon.stub(routeSettingsService, 'loadRouteSettings').get(() => () => ({ routes: {}, collections: { @@ -710,7 +710,7 @@ describe('Integration - Web - Site v2', function () { describe('primary tag permalink', function () { before(async function () { - sinon.stub(routeSettingsService, 'loadRouteSettingsSync').get(() => () => ({ + sinon.stub(routeSettingsService, 'loadRouteSettings').get(() => () => ({ routes: {}, collections: { @@ -804,7 +804,7 @@ describe('Integration - Web - Site v2', function () { describe('collection/routes with data key', function () { before(async function () { - sinon.stub(routeSettingsService, 'loadRouteSettingsSync').get(() => () => ({ + sinon.stub(routeSettingsService, 'loadRouteSettings').get(() => () => ({ routes: { '/my-page/': { data: { @@ -969,7 +969,7 @@ describe('Integration - Web - Site v2', function () { describe('extended routes.yaml: templates', function () { describe('default template, no template', function () { before(async function () { - sinon.stub(routeSettingsService, 'loadRouteSettingsSync').get(() => () => ({ + sinon.stub(routeSettingsService, 'loadRouteSettings').get(() => () => ({ routes: {}, collections: { @@ -1035,7 +1035,7 @@ describe('Integration - Web - Site v2', function () { describe('two templates', function () { before(async function () { - sinon.stub(routeSettingsService, 'loadRouteSettingsSync').get(() => () => ({ + sinon.stub(routeSettingsService, 'loadRouteSettings').get(() => () => ({ routes: {}, collections: { @@ -1083,7 +1083,7 @@ describe('Integration - Web - Site v2', function () { describe('home.hbs priority', function () { before(async function () { - sinon.stub(routeSettingsService, 'loadRouteSettingsSync').get(() => () => ({ + sinon.stub(routeSettingsService, 'loadRouteSettings').get(() => () => ({ routes: {}, collections: { @@ -1158,7 +1158,7 @@ describe('Integration - Web - Site v2', function () { before(async function () { localUtils.defaultMocks(sinon, {theme: 'test-theme-channels'}); - sinon.stub(routeSettingsService, 'loadRouteSettingsSync').get(() => () => ({ + sinon.stub(routeSettingsService, 'loadRouteSettings').get(() => () => ({ routes: { '/channel1/': { controller: 'channel', @@ -1402,7 +1402,7 @@ describe('Integration - Web - Site v2', function () { response.statusCode.should.eql(200); response.template.should.eql('index'); - $('.post-card').length.should.equal(4); + $('.post-card').length.should.equal(10); }); }); @@ -1421,7 +1421,7 @@ describe('Integration - Web - Site v2', function () { response.statusCode.should.eql(200); response.template.should.eql('index'); - $('.post-card').length.should.equal(4); + $('.post-card').length.should.equal(10); }); }); @@ -1487,7 +1487,7 @@ describe('Integration - Web - Site v2', function () { describe('extended routes.yaml (5): rss override', function () { before(async function () { - sinon.stub(routeSettingsService, 'loadRouteSettingsSync').get(() => () => ({ + sinon.stub(routeSettingsService, 'loadRouteSettings').get(() => () => ({ routes: { '/podcast/rss/': { templates: ['podcast/rss'], 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 55a73e6c0d..c7764c8e38 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 @@ -361,7 +361,7 @@ describe('Integration - Web - Site v3', function () { describe('extended routes.yaml: collections', function () { describe('2 collections', function () { before(async function () { - sinon.stub(routeSettingsService, 'loadRouteSettingsSync').get(() => () => ({ + sinon.stub(routeSettingsService, 'loadRouteSettings').get(() => () => ({ routes: { '/': { templates: ['home'] @@ -488,7 +488,7 @@ describe('Integration - Web - Site v3', function () { describe('no collections', function () { before(async function () { - sinon.stub(routeSettingsService, 'loadRouteSettingsSync').get(() => () => ({ + sinon.stub(routeSettingsService, 'loadRouteSettings').get(() => () => ({ routes: { '/something/': {templates: ['something']} }, @@ -533,7 +533,7 @@ describe('Integration - Web - Site v3', function () { describe('static permalink route', function () { before(async function () { - sinon.stub(routeSettingsService, 'loadRouteSettingsSync').get(() => () => ({ + sinon.stub(routeSettingsService, 'loadRouteSettings').get(() => () => ({ routes: {}, collections: { @@ -633,7 +633,7 @@ describe('Integration - Web - Site v3', function () { describe('primary author permalink', function () { before(async function () { - sinon.stub(routeSettingsService, 'loadRouteSettingsSync').get(() => () => ({ + sinon.stub(routeSettingsService, 'loadRouteSettings').get(() => () => ({ routes: {}, collections: { @@ -712,7 +712,7 @@ describe('Integration - Web - Site v3', function () { describe('primary tag permalink', function () { before(async function () { - sinon.stub(routeSettingsService, 'loadRouteSettingsSync').get(() => () => ({ + sinon.stub(routeSettingsService, 'loadRouteSettings').get(() => () => ({ routes: {}, collections: { @@ -805,7 +805,7 @@ describe('Integration - Web - Site v3', function () { describe('collection/routes with data key', function () { before(async function () { - sinon.stub(routeSettingsService, 'loadRouteSettingsSync').get(() => () => ({ + sinon.stub(routeSettingsService, 'loadRouteSettings').get(() => () => ({ routes: { '/my-page/': { data: { @@ -970,7 +970,7 @@ describe('Integration - Web - Site v3', function () { describe('extended routes.yaml: templates', function () { describe('default template, no template', function () { before(async function () { - sinon.stub(routeSettingsService, 'loadRouteSettingsSync').get(() => () => ({ + sinon.stub(routeSettingsService, 'loadRouteSettings').get(() => () => ({ routes: {}, collections: { @@ -1036,7 +1036,7 @@ describe('Integration - Web - Site v3', function () { describe('two templates', function () { before(async function () { - sinon.stub(routeSettingsService, 'loadRouteSettingsSync').get(() => () => ({ + sinon.stub(routeSettingsService, 'loadRouteSettings').get(() => () => ({ routes: {}, collections: { @@ -1084,7 +1084,7 @@ describe('Integration - Web - Site v3', function () { describe('home.hbs priority', function () { before(async function () { - sinon.stub(routeSettingsService, 'loadRouteSettingsSync').get(() => () => ({ + sinon.stub(routeSettingsService, 'loadRouteSettings').get(() => () => ({ routes: {}, collections: { @@ -1159,7 +1159,7 @@ describe('Integration - Web - Site v3', function () { before(async function () { localUtils.defaultMocks(sinon, {theme: 'test-theme-channels'}); - sinon.stub(routeSettingsService, 'loadRouteSettingsSync').get(() => () => ({ + sinon.stub(routeSettingsService, 'loadRouteSettings').get(() => () => ({ routes: { '/channel1/': { controller: 'channel', @@ -1404,7 +1404,7 @@ describe('Integration - Web - Site v3', function () { response.statusCode.should.eql(200); response.template.should.eql('index'); - $('.post-card').length.should.equal(4); + $('.post-card').length.should.equal(10); }); }); @@ -1423,7 +1423,7 @@ describe('Integration - Web - Site v3', function () { response.statusCode.should.eql(200); response.template.should.eql('index'); - $('.post-card').length.should.equal(4); + $('.post-card').length.should.equal(10); }); }); @@ -1489,7 +1489,7 @@ describe('Integration - Web - Site v3', function () { describe('extended routes.yaml (5): rss override', function () { before(async function () { - sinon.stub(routeSettingsService, 'loadRouteSettingsSync').get(() => () => ({ + sinon.stub(routeSettingsService, 'loadRouteSettings').get(() => () => ({ routes: { '/about/': 'about', '/podcast/rss/': { 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 0f4e14733d..9ae3377c23 100644 --- a/test/regression/mock-express-style/parent_app_vhosts.test.js +++ b/test/regression/mock-express-style/parent_app_vhosts.test.js @@ -30,7 +30,7 @@ describe('Integration - Web - vhosts', function () { configUtils.set('url', 'http://example.com'); configUtils.set('admin:url', null); - app = await localUtils.initGhost(); + app = await localUtils.initGhost({backend: true}); }); before(function () { @@ -139,10 +139,10 @@ describe('Integration - Web - vhosts', function () { configUtils.set('url', 'http://example.com'); configUtils.set('admin:url', 'https://admin.example.com'); + app = await localUtils.initGhost({backend: true}); + sinon.stub(themeEngine.getActive(), 'engine').withArgs('ghost-api').returns('v2'); sinon.stub(themeEngine.getActive(), 'config').withArgs('posts_per_page').returns(2); - - app = await localUtils.initGhost(); }); before(function () { @@ -297,7 +297,7 @@ describe('Integration - Web - vhosts', function () { sinon.stub(themeEngine.getActive(), 'engine').withArgs('ghost-api').returns('v2'); sinon.stub(themeEngine.getActive(), 'config').withArgs('posts_per_page').returns(2); - app = await localUtils.initGhost(); + app = await localUtils.initGhost({backend: true}); }); before(function () { @@ -337,7 +337,7 @@ describe('Integration - Web - vhosts', function () { sinon.stub(themeEngine.getActive(), 'engine').withArgs('ghost-api').returns('v2'); sinon.stub(themeEngine.getActive(), 'config').withArgs('posts_per_page').returns(2); - app = await localUtils.initGhost(); + app = await localUtils.initGhost({backend: true}); }); before(function () {