fix(subscription): show payment methods outside production
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||
|
||||
import { PaymentPlan } from "@/data/dto/payment";
|
||||
|
||||
@@ -32,6 +32,10 @@ function makePlan(
|
||||
}
|
||||
|
||||
describe("subscription screen helpers", () => {
|
||||
afterEach(() => {
|
||||
vi.unstubAllEnvs();
|
||||
});
|
||||
|
||||
it("defaults Philippines users to Ezpay and other countries to Stripe", () => {
|
||||
expect(getDefaultPayChannelForCountryCode("PH")).toBe("ezpay");
|
||||
expect(getDefaultPayChannelForCountryCode("ph")).toBe("ezpay");
|
||||
@@ -40,14 +44,25 @@ describe("subscription screen helpers", () => {
|
||||
expect(getDefaultPayChannelForCountryCode(null)).toBe("stripe");
|
||||
});
|
||||
|
||||
it("only allows payment method switching for Philippines users", () => {
|
||||
it("only allows payment method switching for Philippines users in production", () => {
|
||||
vi.stubEnv("NEXT_PUBLIC_APP_ENV", "production");
|
||||
|
||||
expect(canChooseSubscriptionPayChannel("PH")).toBe(true);
|
||||
expect(canChooseSubscriptionPayChannel("ph")).toBe(true);
|
||||
expect(canChooseSubscriptionPayChannel("HK")).toBe(false);
|
||||
expect(canChooseSubscriptionPayChannel(null)).toBe(false);
|
||||
});
|
||||
|
||||
it("resolves subscription pay channel by country", () => {
|
||||
it("allows payment method switching in non-production", () => {
|
||||
vi.stubEnv("NEXT_PUBLIC_APP_ENV", "test");
|
||||
|
||||
expect(canChooseSubscriptionPayChannel("HK")).toBe(true);
|
||||
expect(canChooseSubscriptionPayChannel(null)).toBe(true);
|
||||
});
|
||||
|
||||
it("resolves subscription pay channel by country in production", () => {
|
||||
vi.stubEnv("NEXT_PUBLIC_APP_ENV", "production");
|
||||
|
||||
expect(
|
||||
resolveSubscriptionPayChannel({
|
||||
countryCode: "PH",
|
||||
@@ -68,6 +83,17 @@ describe("subscription screen helpers", () => {
|
||||
).toBe("stripe");
|
||||
});
|
||||
|
||||
it("keeps requested pay channel in non-production", () => {
|
||||
vi.stubEnv("NEXT_PUBLIC_APP_ENV", "test");
|
||||
|
||||
expect(
|
||||
resolveSubscriptionPayChannel({
|
||||
countryCode: "HK",
|
||||
requestedPayChannel: "ezpay",
|
||||
}),
|
||||
).toBe("ezpay");
|
||||
});
|
||||
|
||||
it("maps at most three VIP plans and all coin plans", () => {
|
||||
const plans = [
|
||||
makePlan({ planId: "vip_monthly", planName: "Monthly" }),
|
||||
|
||||
Reference in New Issue
Block a user