feat(chat): tailor insufficient credits guidance

This commit is contained in:
2026-07-08 11:15:32 +08:00
parent 43e5cc95af
commit 6b8345e318
5 changed files with 91 additions and 6 deletions
@@ -0,0 +1,35 @@
import { describe, expect, it } from "vitest";
import { getInsufficientCreditsMessageLimitView } from "../chat-screen.helpers";
describe("getInsufficientCreditsMessageLimitView", () => {
it("asks guests to log in for more free chats", () => {
expect(getInsufficientCreditsMessageLimitView("guest")).toEqual({
title: "Log in to get more free chats",
description: "Free chats refresh every day. Log in to get more chances.",
ctaLabel: "Log in to continue",
action: "auth",
});
});
it("treats the transient not logged in state like guest", () => {
expect(getInsufficientCreditsMessageLimitView("notLoggedIn")).toEqual({
title: "Log in to get more free chats",
description: "Free chats refresh every day. Log in to get more chances.",
ctaLabel: "Log in to continue",
action: "auth",
});
});
it.each(["email", "facebook", "google", "apple"] as const)(
"asks %s users to top up credits",
(loginStatus) => {
expect(getInsufficientCreditsMessageLimitView(loginStatus)).toEqual({
title: "Insufficient credits\nTop up to continue chatting",
description: "Free chats refresh every day. You can also top up credits now.",
ctaLabel: "Top up credits to continue",
action: "topup",
});
},
);
});