fix(chat): clear limit prompt after payment
This commit is contained in:
@@ -354,4 +354,52 @@ describe("chatMachine transitions", () => {
|
||||
|
||||
actor.stop();
|
||||
});
|
||||
|
||||
it("clears the daily limit prompt after payment succeeds", async () => {
|
||||
const actor = createActor(createTestChatMachine()).start();
|
||||
|
||||
actor.send({ type: "ChatUserLogin", token: "token" });
|
||||
await waitFor(actor, (snapshot) =>
|
||||
snapshot.matches({ userSession: "ready" }),
|
||||
);
|
||||
|
||||
actor.send({
|
||||
type: "ChatQueuedHttpDone",
|
||||
output: {
|
||||
response: ChatSendResponse.from({
|
||||
reply: "",
|
||||
audioUrl: "",
|
||||
messageId: "",
|
||||
isGuest: false,
|
||||
timestamp: Date.now(),
|
||||
image: { type: null, url: null },
|
||||
lockDetail: {
|
||||
locked: true,
|
||||
showContent: false,
|
||||
showUpgrade: true,
|
||||
reason: "daily_limit",
|
||||
hint: "Free message limit reached.",
|
||||
detail: {
|
||||
type: "daily_msg_limit",
|
||||
usedToday: 3,
|
||||
limit: 3,
|
||||
},
|
||||
},
|
||||
}),
|
||||
reply: null,
|
||||
},
|
||||
});
|
||||
|
||||
expect(actor.getSnapshot().context.upgradePromptVisible).toBe(true);
|
||||
expect(actor.getSnapshot().context.upgradeReason).toBe("daily_limit");
|
||||
|
||||
actor.send({ type: "ChatPaymentSucceeded" });
|
||||
|
||||
expect(actor.getSnapshot().context.upgradePromptVisible).toBe(false);
|
||||
expect(actor.getSnapshot().context.upgradeReason).toBeNull();
|
||||
expect(actor.getSnapshot().context.upgradeHint).toBeNull();
|
||||
expect(actor.getSnapshot().context.upgradeDetail).toBeNull();
|
||||
|
||||
actor.stop();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user