feat(chat): restore image viewer after payment
This commit is contained in:
@@ -322,6 +322,64 @@ describe("chatMachine transitions", () => {
|
||||
actor.stop();
|
||||
});
|
||||
|
||||
it("auto unlocks a single locked image message after payment", async () => {
|
||||
const actor = createActor(
|
||||
createTestChatMachine({
|
||||
historyMessages: [
|
||||
{
|
||||
id: "msg-image-locked",
|
||||
content: "",
|
||||
isFromAI: true,
|
||||
date: "2026-06-29",
|
||||
imageUrl: "https://example.com/locked.jpg",
|
||||
imagePaywalled: true,
|
||||
locked: true,
|
||||
lockReason: "image",
|
||||
},
|
||||
],
|
||||
unlockHistoryOutput: {
|
||||
unlocked: true,
|
||||
reason: "ok",
|
||||
shortfallCredits: 0,
|
||||
messages: [
|
||||
{
|
||||
id: "msg-image-locked",
|
||||
content: "",
|
||||
isFromAI: true,
|
||||
date: "2026-06-29",
|
||||
imageUrl: "https://example.com/unlocked.jpg",
|
||||
locked: false,
|
||||
lockReason: null,
|
||||
},
|
||||
],
|
||||
hasMore: false,
|
||||
newOffset: 1,
|
||||
},
|
||||
}),
|
||||
).start();
|
||||
|
||||
actor.send({ type: "ChatUserLogin", token: "token" });
|
||||
await waitFor(actor, (snapshot) =>
|
||||
snapshot.matches({ userSession: "ready" }),
|
||||
);
|
||||
|
||||
actor.send({ type: "ChatPaymentSucceeded" });
|
||||
await waitFor(actor, (snapshot) =>
|
||||
snapshot.matches({ userSession: "ready" }),
|
||||
);
|
||||
|
||||
expect(actor.getSnapshot().context.unlockHistoryPromptVisible).toBe(false);
|
||||
expect(actor.getSnapshot().context.messages).toMatchObject([
|
||||
{
|
||||
id: "msg-image-locked",
|
||||
imageUrl: "https://example.com/unlocked.jpg",
|
||||
locked: false,
|
||||
},
|
||||
]);
|
||||
|
||||
actor.stop();
|
||||
});
|
||||
|
||||
it("unlocks history after the prompt is confirmed", async () => {
|
||||
const actor = createActor(
|
||||
createTestChatMachine({
|
||||
|
||||
Reference in New Issue
Block a user