feat(chat): handle credit-gated send responses
This commit is contained in:
@@ -467,6 +467,11 @@ describe("chatMachine transitions", () => {
|
||||
limit: 3,
|
||||
},
|
||||
},
|
||||
canSendMessage: false,
|
||||
cannotSendReason: "insufficient_credits",
|
||||
creditBalance: 0,
|
||||
requiredCredits: 2,
|
||||
shortfallCredits: 2,
|
||||
}),
|
||||
reply: null,
|
||||
},
|
||||
@@ -474,11 +479,14 @@ describe("chatMachine transitions", () => {
|
||||
|
||||
expect(actor.getSnapshot().context.upgradePromptVisible).toBe(true);
|
||||
expect(actor.getSnapshot().context.upgradeReason).toBe("weekly_limit");
|
||||
expect(actor.getSnapshot().context.canSendMessage).toBe(false);
|
||||
|
||||
actor.send({ type: "ChatPaymentSucceeded" });
|
||||
|
||||
expect(actor.getSnapshot().context.upgradePromptVisible).toBe(false);
|
||||
expect(actor.getSnapshot().context.upgradeReason).toBeNull();
|
||||
expect(actor.getSnapshot().context.canSendMessage).toBe(true);
|
||||
expect(actor.getSnapshot().context.cannotSendReason).toBeNull();
|
||||
|
||||
actor.stop();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user