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
This commit is contained in:
parent
2352d9f52b
commit
09ff8a0662
|
@ -11,12 +11,12 @@ export default class StripeAPI extends BaseAPI {
|
||||||
}
|
}
|
||||||
|
|
||||||
async createCheckoutSession(
|
async createCheckoutSession(
|
||||||
priceId: string,
|
price: object,
|
||||||
opts: APIRequestOpts = { status: 200 }
|
opts: APIRequestOpts = { status: 200 }
|
||||||
) {
|
) {
|
||||||
return this.doRequest(() => {
|
return this.doRequest(() => {
|
||||||
return this.client.post(`/api/stripe/checkout-session`, {
|
return this.client.post(`/api/stripe/checkout-session`, {
|
||||||
body: { priceId },
|
body: { prices: [price] },
|
||||||
})
|
})
|
||||||
}, opts)
|
}, opts)
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,11 +36,11 @@ describe("license management", () => {
|
||||||
const [plansRes, planBody] = await config.api.licenses.getPlans()
|
const [plansRes, planBody] = await config.api.licenses.getPlans()
|
||||||
|
|
||||||
// Select priceId from premium plan
|
// Select priceId from premium plan
|
||||||
let premiumPriceId = null
|
let premiumPrice = null
|
||||||
let businessPriceId = ""
|
let businessPriceId: ""
|
||||||
for (const plan of planBody) {
|
for (const plan of planBody) {
|
||||||
if (plan.type === PlanType.PREMIUM_PLUS) {
|
if (plan.type === PlanType.PREMIUM_PLUS) {
|
||||||
premiumPriceId = plan.prices[0].priceId
|
premiumPrice = plan.prices[0]
|
||||||
}
|
}
|
||||||
if (plan.type === PlanType.ENTERPRISE_BASIC) {
|
if (plan.type === PlanType.ENTERPRISE_BASIC) {
|
||||||
businessPriceId = plan.prices[0].priceId
|
businessPriceId = plan.prices[0].priceId
|
||||||
|
@ -49,7 +49,7 @@ describe("license management", () => {
|
||||||
|
|
||||||
// Create checkout session for price
|
// Create checkout session for price
|
||||||
const checkoutSessionRes = await config.api.stripe.createCheckoutSession(
|
const checkoutSessionRes = await config.api.stripe.createCheckoutSession(
|
||||||
premiumPriceId
|
{ id: premiumPrice.priceId, type: premiumPrice.type }
|
||||||
)
|
)
|
||||||
const checkoutSessionUrl = checkoutSessionRes[1].url
|
const checkoutSessionUrl = checkoutSessionRes[1].url
|
||||||
expect(checkoutSessionUrl).toContain("checkout.stripe.com")
|
expect(checkoutSessionUrl).toContain("checkout.stripe.com")
|
||||||
|
@ -84,7 +84,7 @@ describe("license management", () => {
|
||||||
customer: customer.id,
|
customer: customer.id,
|
||||||
items: [
|
items: [
|
||||||
{
|
{
|
||||||
price: premiumPriceId,
|
price: premiumPrice.priceId,
|
||||||
quantity: 1,
|
quantity: 1,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
@ -105,6 +105,7 @@ describe("license management", () => {
|
||||||
expect(portalSessionBody.url).toContain("billing.stripe.com")
|
expect(portalSessionBody.url).toContain("billing.stripe.com")
|
||||||
|
|
||||||
// Update subscription from premium to business license
|
// Update subscription from premium to business license
|
||||||
|
//await config.api.licenses.updatePlan(businessPriceId.priceId)
|
||||||
await config.api.licenses.updatePlan(businessPriceId)
|
await config.api.licenses.updatePlan(businessPriceId)
|
||||||
|
|
||||||
// License updated to Business
|
// License updated to Business
|
||||||
|
|
Loading…
Reference in New Issue