Files
cozsweet-frontend-nextjs/src/lib/analytics/__tests__/payment_analytics_context.test.ts
T
admin 9deb320cf6 feat(profile)!: replace sidebar and add avatar navigation
Rename the global Sidebar route, UI, assets, analytics, and payment return context to Profile. Add accessible message-avatar navigation and preserve the source character across auth and logout flows.

BREAKING CHANGE: /sidebar has been removed; use /profile instead.
2026-07-21 18:08:12 +08:00

40 lines
1.0 KiB
TypeScript

import { describe, expect, it } from "vitest";
import {
getDefaultPaymentAnalyticsContext,
parsePaymentAnalyticsContext,
} from "../payment_analytics_context";
describe("payment analytics context", () => {
it("keeps supported payment entry and reason values", () => {
expect(
parsePaymentAnalyticsContext({
entryPoint: "chat_unlock",
triggerReason: "ad_landing",
subscriptionType: "topup",
}),
).toEqual({
entryPoint: "chat_unlock",
triggerReason: "ad_landing",
});
});
it("falls back independently for invalid query values", () => {
expect(
parsePaymentAnalyticsContext({
entryPoint: "unsafe-entry",
triggerReason: "unsafe-reason",
subscriptionType: "topup",
}),
).toEqual(getDefaultPaymentAnalyticsContext("topup"));
expect(
parsePaymentAnalyticsContext({
entryPoint: "profile",
triggerReason: null,
subscriptionType: "vip",
}),
).toEqual({ entryPoint: "profile", triggerReason: "vip_cta" });
});
});