feat(payment): confirm renewal only at checkout
Docker Image / Build and Push Docker Image (push) Successful in 2m9s
Docker Image / Build and Push Docker Image (push) Successful in 2m9s
This commit is contained in:
@@ -7,11 +7,9 @@ import {
|
||||
} from "@/data/schemas/payment";
|
||||
|
||||
import {
|
||||
canCheckoutSubscriptionPlan,
|
||||
findSelectedSubscriptionPlan,
|
||||
getDefaultSubscriptionPlanId,
|
||||
getFirstRechargeOfferView,
|
||||
requiresVipPlanConfirmation,
|
||||
toCoinsOfferPlanViews,
|
||||
toVipOfferPlanViews,
|
||||
} from "../subscription-screen.helpers";
|
||||
@@ -280,85 +278,4 @@ describe("subscription screen helpers", () => {
|
||||
).toBeNull();
|
||||
});
|
||||
|
||||
it("requires confirmation for each unconfirmed VIP plan", () => {
|
||||
const vipPlans = [
|
||||
{
|
||||
id: "vip_monthly",
|
||||
title: "Monthly",
|
||||
price: "19.90",
|
||||
currency: "usd",
|
||||
originalPrice: "",
|
||||
},
|
||||
{
|
||||
id: "vip_quarterly",
|
||||
title: "Quarterly",
|
||||
price: "49.90",
|
||||
currency: "usd",
|
||||
originalPrice: "",
|
||||
},
|
||||
];
|
||||
|
||||
expect(
|
||||
requiresVipPlanConfirmation({
|
||||
planId: "vip_monthly",
|
||||
vipPlans,
|
||||
confirmedVipPlanIds: new Set(),
|
||||
}),
|
||||
).toBe(true);
|
||||
expect(
|
||||
requiresVipPlanConfirmation({
|
||||
planId: "vip_monthly",
|
||||
vipPlans,
|
||||
confirmedVipPlanIds: new Set(["vip_monthly"]),
|
||||
}),
|
||||
).toBe(false);
|
||||
expect(
|
||||
requiresVipPlanConfirmation({
|
||||
planId: "coin_1000",
|
||||
vipPlans,
|
||||
confirmedVipPlanIds: new Set(),
|
||||
}),
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
it("allows checkout only after the selected VIP plan is confirmed", () => {
|
||||
const vipPlans = [
|
||||
{
|
||||
id: "vip_monthly",
|
||||
title: "Monthly",
|
||||
price: "19.90",
|
||||
currency: "usd",
|
||||
originalPrice: "",
|
||||
},
|
||||
];
|
||||
|
||||
expect(
|
||||
canCheckoutSubscriptionPlan({
|
||||
selectedPlanId: "vip_monthly",
|
||||
vipPlans,
|
||||
confirmedVipPlanIds: new Set(),
|
||||
}),
|
||||
).toBe(false);
|
||||
expect(
|
||||
canCheckoutSubscriptionPlan({
|
||||
selectedPlanId: "vip_monthly",
|
||||
vipPlans,
|
||||
confirmedVipPlanIds: new Set(["vip_monthly"]),
|
||||
}),
|
||||
).toBe(true);
|
||||
expect(
|
||||
canCheckoutSubscriptionPlan({
|
||||
selectedPlanId: "coin_1000",
|
||||
vipPlans,
|
||||
confirmedVipPlanIds: new Set(),
|
||||
}),
|
||||
).toBe(true);
|
||||
expect(
|
||||
canCheckoutSubscriptionPlan({
|
||||
selectedPlanId: "",
|
||||
vipPlans,
|
||||
confirmedVipPlanIds: new Set(),
|
||||
}),
|
||||
).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user