From 09ff8a06624c3c99ac0c5b5dfc046f6538a08a43 Mon Sep 17 00:00:00 2001 From: Mitch-Budibase Date: Wed, 31 Jan 2024 15:00:32 +0000 Subject: [PATCH 1/3] License Test Changes License.manage.spec.ts/StripeAPI.ts - Test updated and now successfully updates from Free plan to premium - createCheckoutSession updated to support this plan upgrade --- qa-core/src/account-api/api/apis/StripeAPI.ts | 4 ++-- .../tests/licensing/license.manage.spec.ts | 11 ++++++----- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/qa-core/src/account-api/api/apis/StripeAPI.ts b/qa-core/src/account-api/api/apis/StripeAPI.ts index 5a4e810655..aeb027f428 100644 --- a/qa-core/src/account-api/api/apis/StripeAPI.ts +++ b/qa-core/src/account-api/api/apis/StripeAPI.ts @@ -11,12 +11,12 @@ export default class StripeAPI extends BaseAPI { } async createCheckoutSession( - priceId: string, + price: object, opts: APIRequestOpts = { status: 200 } ) { return this.doRequest(() => { return this.client.post(`/api/stripe/checkout-session`, { - body: { priceId }, + body: { prices: [price] }, }) }, opts) } diff --git a/qa-core/src/account-api/tests/licensing/license.manage.spec.ts b/qa-core/src/account-api/tests/licensing/license.manage.spec.ts index 9a8662ea3b..2d5b9332c6 100644 --- a/qa-core/src/account-api/tests/licensing/license.manage.spec.ts +++ b/qa-core/src/account-api/tests/licensing/license.manage.spec.ts @@ -36,11 +36,11 @@ describe("license management", () => { const [plansRes, planBody] = await config.api.licenses.getPlans() // Select priceId from premium plan - let premiumPriceId = null - let businessPriceId = "" + let premiumPrice = null + let businessPriceId: "" for (const plan of planBody) { if (plan.type === PlanType.PREMIUM_PLUS) { - premiumPriceId = plan.prices[0].priceId + premiumPrice = plan.prices[0] } if (plan.type === PlanType.ENTERPRISE_BASIC) { businessPriceId = plan.prices[0].priceId @@ -49,7 +49,7 @@ describe("license management", () => { // Create checkout session for price const checkoutSessionRes = await config.api.stripe.createCheckoutSession( - premiumPriceId + { id: premiumPrice.priceId, type: premiumPrice.type } ) const checkoutSessionUrl = checkoutSessionRes[1].url expect(checkoutSessionUrl).toContain("checkout.stripe.com") @@ -84,7 +84,7 @@ describe("license management", () => { customer: customer.id, items: [ { - price: premiumPriceId, + price: premiumPrice.priceId, quantity: 1, }, ], @@ -105,6 +105,7 @@ describe("license management", () => { expect(portalSessionBody.url).toContain("billing.stripe.com") // Update subscription from premium to business license + //await config.api.licenses.updatePlan(businessPriceId.priceId) await config.api.licenses.updatePlan(businessPriceId) // License updated to Business From d7ae4c04b9e84e48ab3bc3553ed5e39aa6e3e414 Mon Sep 17 00:00:00 2001 From: Mitch-Budibase Date: Tue, 6 Feb 2024 17:15:11 +0000 Subject: [PATCH 2/3] Removing commented line --- qa-core/src/account-api/tests/licensing/license.manage.spec.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/qa-core/src/account-api/tests/licensing/license.manage.spec.ts b/qa-core/src/account-api/tests/licensing/license.manage.spec.ts index 2d5b9332c6..baed5734cf 100644 --- a/qa-core/src/account-api/tests/licensing/license.manage.spec.ts +++ b/qa-core/src/account-api/tests/licensing/license.manage.spec.ts @@ -105,7 +105,6 @@ describe("license management", () => { expect(portalSessionBody.url).toContain("billing.stripe.com") // Update subscription from premium to business license - //await config.api.licenses.updatePlan(businessPriceId.priceId) await config.api.licenses.updatePlan(businessPriceId) // License updated to Business From 3726e10f3a6bee0f40e9f3f86da6bd6d7c309af5 Mon Sep 17 00:00:00 2001 From: Mitch-Budibase Date: Tue, 6 Feb 2024 17:28:00 +0000 Subject: [PATCH 3/3] lint --- .../src/account-api/tests/licensing/license.manage.spec.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/qa-core/src/account-api/tests/licensing/license.manage.spec.ts b/qa-core/src/account-api/tests/licensing/license.manage.spec.ts index baed5734cf..85ee530bb7 100644 --- a/qa-core/src/account-api/tests/licensing/license.manage.spec.ts +++ b/qa-core/src/account-api/tests/licensing/license.manage.spec.ts @@ -48,9 +48,10 @@ describe("license management", () => { } // Create checkout session for price - const checkoutSessionRes = await config.api.stripe.createCheckoutSession( - { id: premiumPrice.priceId, type: premiumPrice.type } - ) + const checkoutSessionRes = await config.api.stripe.createCheckoutSession({ + id: premiumPrice.priceId, + type: premiumPrice.type, + }) const checkoutSessionUrl = checkoutSessionRes[1].url expect(checkoutSessionUrl).toContain("checkout.stripe.com")