diff --git a/test/e2e-api/admin/pages.test.js b/test/e2e-api/admin/pages.test.js index 1c75fe1594..41b89711d2 100644 --- a/test/e2e-api/admin/pages.test.js +++ b/test/e2e-api/admin/pages.test.js @@ -116,9 +116,20 @@ describe('Pages API', function () { .set('Origin', config.get('url')) .expect(200); + const resProducts = await request + .get(localUtils.API.getApiQuery(`products/`)) + .set('Origin', config.get('url')) + .expect(200); + + const products = resProducts.body.products; page.updated_at = res.body.pages[0].updated_at; - page.visibility = 'filter'; - page.visibility_filter = 'product:default-product'; + page.visibility = 'tiers'; + const paidTiers = products.filter((p) => { + return p.type === 'paid'; + }).map((product) => { + return product; + }); + page.tiers = paidTiers; const res2 = await request.put(localUtils.API.getApiQuery('pages/' + testUtils.DataGenerator.Content.posts[5].id)) .set('Origin', config.get('url')) @@ -128,7 +139,8 @@ describe('Pages API', function () { .expect(200); should.exist(res2.headers['x-cache-invalidate']); - localUtils.API.checkResponse(res2.body.pages[0], 'page', ['visibility_filter']); + localUtils.API.checkResponse(res2.body.pages[0], 'page'); + res2.body.pages[0].tiers.length.should.eql(paidTiers.length); const model = await models.Post.findOne({ id: res2.body.pages[0].id diff --git a/test/e2e-api/admin/posts.test.js b/test/e2e-api/admin/posts.test.js index 4ed36b8933..e8f5128a6a 100644 --- a/test/e2e-api/admin/posts.test.js +++ b/test/e2e-api/admin/posts.test.js @@ -94,7 +94,7 @@ describe('Posts API', function () { jsonResponse.posts[0], 'post', null, - ['authors', 'primary_author', 'email'] + ['authors', 'primary_author', 'email', 'tiers'] ); localUtils.API.checkResponse(jsonResponse.meta.pagination, 'pagination'); @@ -179,7 +179,7 @@ describe('Posts API', function () { it('Can include relations for a single post', async function () { const res = await request - .get(localUtils.API.getApiQuery('posts/' + testUtils.DataGenerator.Content.posts[0].id + '/?include=authors,tags,email')) + .get(localUtils.API.getApiQuery('posts/' + testUtils.DataGenerator.Content.posts[0].id + '/?include=authors,tags,email,tiers')) .set('Origin', config.get('url')) .expect('Content-Type', /json/) .expect('Cache-Control', testUtils.cacheRules.private) diff --git a/test/e2e-api/admin/utils.js b/test/e2e-api/admin/utils.js index b46edbc91a..452a8054f6 100644 --- a/test/e2e-api/admin/utils.js +++ b/test/e2e-api/admin/utils.js @@ -70,7 +70,8 @@ const expectedProperties = { 'meta_description', 'email_subject', 'frontmatter', - 'email_only' + 'email_only', + 'tiers' ], page: [ @@ -108,7 +109,8 @@ const expectedProperties = { 'twitter_description', 'meta_title', 'meta_description', - 'frontmatter' + 'frontmatter', + 'tiers' ], user: _(schema.users) diff --git a/test/integration/exporter/exporter.test.js b/test/integration/exporter/exporter.test.js index 165af24a16..d6c6204b9b 100644 --- a/test/integration/exporter/exporter.test.js +++ b/test/integration/exporter/exporter.test.js @@ -55,10 +55,10 @@ describe('Exporter', function () { 'permissions_roles', 'permissions_users', 'posts', - 'posts_products', 'posts_authors', 'posts_meta', 'posts_tags', + 'posts_products', 'products', 'benefits', 'products_benefits', diff --git a/test/unit/api/canary/utils/serializers/output/pages.test.js b/test/unit/api/canary/utils/serializers/output/pages.test.js index 85d9be4395..49c34657c0 100644 --- a/test/unit/api/canary/utils/serializers/output/pages.test.js +++ b/test/unit/api/canary/utils/serializers/output/pages.test.js @@ -19,7 +19,7 @@ describe('Unit: canary/utils/serializers/output/pages', function () { sinon.restore(); }); - it('calls the mapper', function () { + it('calls the mapper', async function () { const apiConfig = {}; const frame = { options: { @@ -44,7 +44,7 @@ describe('Unit: canary/utils/serializers/output/pages', function () { meta: {} }; - serializers.output.pages.all(ctrlResponse, apiConfig, frame); + await serializers.output.pages.all(ctrlResponse, apiConfig, frame); mapper.mapPage.callCount.should.equal(2); mapper.mapPage.getCall(0).args.should.eql([ctrlResponse.data[0], frame]); diff --git a/test/unit/api/canary/utils/serializers/output/posts.test.js b/test/unit/api/canary/utils/serializers/output/posts.test.js index b090001245..e1b7a7d093 100644 --- a/test/unit/api/canary/utils/serializers/output/posts.test.js +++ b/test/unit/api/canary/utils/serializers/output/posts.test.js @@ -19,7 +19,7 @@ describe('Unit: canary/utils/serializers/output/posts', function () { sinon.restore(); }); - it('calls the mapper', function () { + it('calls the mapper', async function () { const apiConfig = {}; const frame = { options: { @@ -38,7 +38,7 @@ describe('Unit: canary/utils/serializers/output/posts', function () { meta: {} }; - serializers.output.posts.all(ctrlResponse, apiConfig, frame); + await serializers.output.posts.all(ctrlResponse, apiConfig, frame); mapper.mapPost.callCount.should.equal(2); mapper.mapPost.getCall(0).args.should.eql([ctrlResponse.data[0], frame]); diff --git a/test/unit/api/canary/utils/serializers/output/preview.test.js b/test/unit/api/canary/utils/serializers/output/preview.test.js index f5e083b559..a7ef09d617 100644 --- a/test/unit/api/canary/utils/serializers/output/preview.test.js +++ b/test/unit/api/canary/utils/serializers/output/preview.test.js @@ -19,7 +19,7 @@ describe('Unit: canary/utils/serializers/output/preview', function () { sinon.restore(); }); - it('calls the mapper', function () { + it('calls the mapper', async function () { const apiConfig = {}; const frame = { options: { @@ -35,7 +35,7 @@ describe('Unit: canary/utils/serializers/output/preview', function () { type: 'page' })); - serializers.output.preview.all(ctrlResponse, apiConfig, frame); + await serializers.output.preview.all(ctrlResponse, apiConfig, frame); mapper.mapPost.callCount.should.equal(1); mapper.mapPost.getCall(0).args.should.eql([ctrlResponse, frame]); diff --git a/test/unit/frontend/helpers/next_post.test.js b/test/unit/frontend/helpers/next_post.test.js index 36c24d2a7e..f4ccae05ad 100644 --- a/test/unit/frontend/helpers/next_post.test.js +++ b/test/unit/frontend/helpers/next_post.test.js @@ -65,7 +65,7 @@ describe('{{next_post}} helper', function () { fn.firstCall.args[0].should.have.properties('slug', 'title'); fn.firstCall.args[1].should.be.an.Object().and.have.property('data'); browsePostsStub.calledOnce.should.be.true(); - browsePostsStub.firstCall.args[0].include.should.eql('author,authors,tags'); + browsePostsStub.firstCall.args[0].include.should.eql('author,authors,tags,tiers'); done(); }) @@ -262,7 +262,7 @@ describe('{{next_post}} helper', function () { fn.firstCall.args[0].should.have.properties('slug', 'title'); fn.firstCall.args[1].should.be.an.Object().and.have.property('data'); browsePostsStub.calledOnce.should.be.true(); - browsePostsStub.firstCall.args[0].include.should.eql('author,authors,tags'); + browsePostsStub.firstCall.args[0].include.should.eql('author,authors,tags,tiers'); browsePostsStub.firstCall.args[0].filter.should.match(/\+primary_tag:test/); done(); @@ -294,7 +294,7 @@ describe('{{next_post}} helper', function () { fn.firstCall.args[0].should.have.properties('slug', 'title'); fn.firstCall.args[1].should.be.an.Object().and.have.property('data'); browsePostsStub.calledOnce.should.be.true(); - browsePostsStub.firstCall.args[0].include.should.eql('author,authors,tags'); + browsePostsStub.firstCall.args[0].include.should.eql('author,authors,tags,tiers'); browsePostsStub.firstCall.args[0].filter.should.match(/\+primary_author:hans/); done(); @@ -326,7 +326,7 @@ describe('{{next_post}} helper', function () { fn.firstCall.args[0].should.have.properties('slug', 'title'); fn.firstCall.args[1].should.be.an.Object().and.have.property('data'); browsePostsStub.calledOnce.should.be.true(); - browsePostsStub.firstCall.args[0].include.should.eql('author,authors,tags'); + browsePostsStub.firstCall.args[0].include.should.eql('author,authors,tags,tiers'); browsePostsStub.firstCall.args[0].filter.should.match(/\+author:author-name/); done(); @@ -357,7 +357,7 @@ describe('{{next_post}} helper', function () { fn.firstCall.args[0].should.have.properties('slug', 'title'); fn.firstCall.args[1].should.be.an.Object().and.have.property('data'); browsePostsStub.calledOnce.should.be.true(); - browsePostsStub.firstCall.args[0].include.should.eql('author,authors,tags'); + browsePostsStub.firstCall.args[0].include.should.eql('author,authors,tags,tiers'); browsePostsStub.firstCall.args[0].filter.should.not.match(/\+author:/); done(); @@ -389,7 +389,7 @@ describe('{{next_post}} helper', function () { fn.firstCall.args[0].should.have.properties('slug', 'title'); fn.firstCall.args[1].should.be.an.Object().and.have.property('data'); browsePostsStub.calledOnce.should.be.true(); - browsePostsStub.firstCall.args[0].include.should.eql('author,authors,tags'); + browsePostsStub.firstCall.args[0].include.should.eql('author,authors,tags,tiers'); browsePostsStub.firstCall.args[0].filter.should.not.match(/\+magic/); done(); diff --git a/test/unit/frontend/helpers/prev_post.test.js b/test/unit/frontend/helpers/prev_post.test.js index a96abf02ef..82be1d7e6a 100644 --- a/test/unit/frontend/helpers/prev_post.test.js +++ b/test/unit/frontend/helpers/prev_post.test.js @@ -65,7 +65,7 @@ describe('{{prev_post}} helper', function () { fn.firstCall.args[0].should.have.properties('slug', 'title'); fn.firstCall.args[1].should.be.an.Object().and.have.property('data'); browsePostsStub.calledOnce.should.be.true(); - browsePostsStub.firstCall.args[0].include.should.eql('author,authors,tags'); + browsePostsStub.firstCall.args[0].include.should.eql('author,authors,tags,tiers'); done(); }) @@ -260,7 +260,7 @@ describe('{{prev_post}} helper', function () { fn.firstCall.args[0].should.have.properties('slug', 'title'); fn.firstCall.args[1].should.be.an.Object().and.have.property('data'); browsePostsStub.calledOnce.should.be.true(); - browsePostsStub.firstCall.args[0].include.should.eql('author,authors,tags'); + browsePostsStub.firstCall.args[0].include.should.eql('author,authors,tags,tiers'); browsePostsStub.firstCall.args[0].filter.should.match(/\+primary_tag:test/); done(); @@ -292,7 +292,7 @@ describe('{{prev_post}} helper', function () { fn.firstCall.args[0].should.have.properties('slug', 'title'); fn.firstCall.args[1].should.be.an.Object().and.have.property('data'); browsePostsStub.calledOnce.should.be.true(); - browsePostsStub.firstCall.args[0].include.should.eql('author,authors,tags'); + browsePostsStub.firstCall.args[0].include.should.eql('author,authors,tags,tiers'); browsePostsStub.firstCall.args[0].filter.should.match(/\+primary_author:hans/); done(); @@ -324,7 +324,7 @@ describe('{{prev_post}} helper', function () { fn.firstCall.args[0].should.have.properties('slug', 'title'); fn.firstCall.args[1].should.be.an.Object().and.have.property('data'); browsePostsStub.calledOnce.should.be.true(); - browsePostsStub.firstCall.args[0].include.should.eql('author,authors,tags'); + browsePostsStub.firstCall.args[0].include.should.eql('author,authors,tags,tiers'); browsePostsStub.firstCall.args[0].filter.should.match(/\+author:author-name/); done(); @@ -355,7 +355,7 @@ describe('{{prev_post}} helper', function () { fn.firstCall.args[0].should.have.properties('slug', 'title'); fn.firstCall.args[1].should.be.an.Object().and.have.property('data'); browsePostsStub.calledOnce.should.be.true(); - browsePostsStub.firstCall.args[0].include.should.eql('author,authors,tags'); + browsePostsStub.firstCall.args[0].include.should.eql('author,authors,tags,tiers'); browsePostsStub.firstCall.args[0].filter.should.not.match(/\+author:/); done(); @@ -387,7 +387,7 @@ describe('{{prev_post}} helper', function () { fn.firstCall.args[0].should.have.properties('slug', 'title'); fn.firstCall.args[1].should.be.an.Object().and.have.property('data'); browsePostsStub.calledOnce.should.be.true(); - browsePostsStub.firstCall.args[0].include.should.eql('author,authors,tags'); + browsePostsStub.firstCall.args[0].include.should.eql('author,authors,tags,tiers'); browsePostsStub.firstCall.args[0].filter.should.not.match(/\+magic/); done(); diff --git a/test/unit/frontend/services/routing/controllers/preview.test.js b/test/unit/frontend/services/routing/controllers/preview.test.js index 50393f82d6..ffc61ef6d5 100644 --- a/test/unit/frontend/services/routing/controllers/preview.test.js +++ b/test/unit/frontend/services/routing/controllers/preview.test.js @@ -79,7 +79,7 @@ describe('Unit - services/routing/controllers/preview', function () { previewStub.withArgs({ uuid: req.params.uuid, status: 'all', - include: 'authors,tags' + include: 'authors,tags,tiers' }).resolves(apiResponse); sinon.stub(api, 'preview').get(() => { diff --git a/test/unit/frontend/services/routing/helpers/entry-lookup.test.js b/test/unit/frontend/services/routing/helpers/entry-lookup.test.js index 88f8044145..97563da550 100644 --- a/test/unit/frontend/services/routing/helpers/entry-lookup.test.js +++ b/test/unit/frontend/services/routing/helpers/entry-lookup.test.js @@ -30,7 +30,7 @@ describe('Unit - services/routing/helpers/entry-lookup', function () { postsReadStub = sinon.stub(); pagesReadStub = sinon.stub(); - pagesReadStub//.withArgs({slug: pages[0].slug, include: 'author,authors,tags'}) + pagesReadStub//.withArgs({slug: pages[0].slug, include: 'author,authors,tags,tiers'}) .resolves({ pages: pages }); @@ -81,7 +81,7 @@ describe('Unit - services/routing/helpers/entry-lookup', function () { postsReadStub = sinon.stub(); pagesReadStub = sinon.stub(); - postsReadStub//.withArgs({slug: posts[0].slug, include: 'author,authors,tags'}) + postsReadStub//.withArgs({slug: posts[0].slug, include: 'author,authors,tags,tiers'}) .resolves({ posts: posts }); diff --git a/test/unit/frontend/services/routing/helpers/fetch-data.test.js b/test/unit/frontend/services/routing/helpers/fetch-data.test.js index a67b017f4e..66a9a5a03a 100644 --- a/test/unit/frontend/services/routing/helpers/fetch-data.test.js +++ b/test/unit/frontend/services/routing/helpers/fetch-data.test.js @@ -113,7 +113,7 @@ describe('Unit - services/routing/helpers/fetch-data', function () { result.data.featured.length.should.eql(posts.length); browsePostsStub.calledTwice.should.be.true(); - browsePostsStub.firstCall.args[0].should.have.property('include', 'authors,tags'); + browsePostsStub.firstCall.args[0].should.have.property('include', 'authors,tags,tiers'); browsePostsStub.secondCall.args[0].should.have.property('filter', 'featured:true'); browsePostsStub.secondCall.args[0].should.have.property('limit', 3); done(); @@ -145,7 +145,7 @@ describe('Unit - services/routing/helpers/fetch-data', function () { result.data.featured.length.should.eql(posts.length); browsePostsStub.calledTwice.should.be.true(); - browsePostsStub.firstCall.args[0].should.have.property('include', 'authors,tags'); + browsePostsStub.firstCall.args[0].should.have.property('include', 'authors,tags,tiers'); browsePostsStub.firstCall.args[0].should.have.property('page', 2); browsePostsStub.secondCall.args[0].should.have.property('filter', 'featured:true'); browsePostsStub.secondCall.args[0].should.have.property('limit', 3);