From ab01e4fcbf4c8297cf7809b4c6f518cb7c56e31c Mon Sep 17 00:00:00 2001 From: Ronald Langeveld Date: Fri, 10 Mar 2023 11:34:05 +0800 Subject: [PATCH] Added new Tier e2e test refs https://github.com/TryGhost/Team/issues/1446 - Added a test for successfully creating a new tier. --- .../admin/__snapshots__/tiers.test.js.snap | 24 +++++++++++++++++++ ghost/core/test/e2e-api/admin/tiers.test.js | 23 ++++++++++++++++++ 2 files changed, 47 insertions(+) diff --git a/ghost/core/test/e2e-api/admin/__snapshots__/tiers.test.js.snap b/ghost/core/test/e2e-api/admin/__snapshots__/tiers.test.js.snap index ae9a9a1efb..5a2cc3c491 100644 --- a/ghost/core/test/e2e-api/admin/__snapshots__/tiers.test.js.snap +++ b/ghost/core/test/e2e-api/admin/__snapshots__/tiers.test.js.snap @@ -48,6 +48,30 @@ Object { } `; +exports[`Tiers API Can create a new tier 1: [body] 1`] = ` +Object { + "tiers": Array [ + Object { + "active": true, + "benefits": Array [], + "created_at": StringMatching /\\\\d\\{4\\}-\\\\d\\{2\\}-\\\\d\\{2\\}/, + "currency": "USD", + "description": null, + "id": StringMatching /\\[a-f0-9\\]\\{24\\}/, + "monthly_price": 100, + "name": "new premium tier", + "slug": "new-premium-tier", + "trial_days": 0, + "type": "paid", + "updated_at": null, + "visibility": "public", + "welcome_page_url": null, + "yearly_price": 5000, + }, + ], +} +`; + exports[`Tiers API Can edit tier properties and relations 1: [body] 1`] = ` Object { "meta": Object { diff --git a/ghost/core/test/e2e-api/admin/tiers.test.js b/ghost/core/test/e2e-api/admin/tiers.test.js index 5a4a523ca6..1c57da8265 100644 --- a/ghost/core/test/e2e-api/admin/tiers.test.js +++ b/ghost/core/test/e2e-api/admin/tiers.test.js @@ -166,4 +166,27 @@ describe('Tiers API', function () { }) }); }); + + it('Can create a new tier', async function () { + const tier = { + name: 'new premium tier', + monthly_price: 100, + currency: 'usd' + }; + + await agent + .post('/tiers/') + .body({tiers: [tier]}) + .expectStatus(201) + .matchBodySnapshot({ + tiers: Array(1).fill({ + id: matchers.anyObjectId, + created_at: matchers.anyISODate, + name: 'new premium tier', + slug: 'new-premium-tier', + monthly_price: 100, + currency: 'USD' + }) + }); + }); });