fix(payment): inherit chat recipient without selector

This commit is contained in:
Codex
2026-07-28 19:33:59 +08:00
parent 187de82eaf
commit f6c75dcb86
7 changed files with 78 additions and 129 deletions
@@ -105,25 +105,28 @@ describe("payment order flow", () => {
actor.stop();
});
it("binds a default VIP or credit order to the selected support character", async () => {
const createOrderSpy = vi.fn<CreateOrderSpy>();
const actor = createActor(
createTestPaymentMachine({ createOrderSpy }),
).start();
actor.send({ type: "PaymentInit", characterId: "maya-tan" });
await waitFor(actor, (snapshot) => snapshot.matches("ready"));
it.each(["elio", "maya-tan", "nayeli-cervantes"])(
"binds a default VIP or credit order to the source chat character %s",
async (characterId) => {
const createOrderSpy = vi.fn<CreateOrderSpy>();
const actor = createActor(
createTestPaymentMachine({ createOrderSpy }),
).start();
actor.send({ type: "PaymentInit", characterId });
await waitFor(actor, (snapshot) => snapshot.matches("ready"));
actor.send({ type: "PaymentCreateOrderSubmitted" });
await waitFor(actor, (snapshot) => snapshot.matches("paid"));
actor.send({ type: "PaymentCreateOrderSubmitted" });
await waitFor(actor, (snapshot) => snapshot.matches("paid"));
expect(createOrderSpy).toHaveBeenCalledWith({
planId: "vip_monthly",
payChannel: "stripe",
autoRenew: true,
recipientCharacterId: "maya-tan",
});
actor.stop();
});
expect(createOrderSpy).toHaveBeenCalledWith({
planId: "vip_monthly",
payChannel: "stripe",
autoRenew: true,
recipientCharacterId: characterId,
});
actor.stop();
},
);
it("carries the originating chat action into order creation", async () => {
const createOrderSpy = vi.fn<CreateOrderSpy>();