Skip to content

Commit 437a49d

Browse files
committed
test(claude): cover preview privacy and selection fallback
1 parent 9006f44 commit 437a49d

1 file changed

Lines changed: 20 additions & 3 deletions

File tree

‎apps/web/src/components/chat/ComposerPendingUserInputPanel.test.tsx‎

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const prompt: PendingUserInput = {
1717
{
1818
label: "Incremental",
1919
description: "Move one module at a time",
20-
preview: "**Safe rollout**\n\n```ts\nconst batchSize = 1;\n```",
20+
preview: "**Safe rollout**\n\n```ts\nconst batchSize = 1;\n```\n\n![remote](https://tracker.invalid/pixel.png)",
2121
},
2222
{ label: "Big bang", description: "Move everything in one release" },
2323
],
@@ -27,12 +27,15 @@ const prompt: PendingUserInput = {
2727
dismissible: true,
2828
};
2929

30-
function renderPanel(pendingUserInput: PendingUserInput = prompt) {
30+
function renderPanel(
31+
pendingUserInput: PendingUserInput = prompt,
32+
answers: Record<string, { selectedOptionValues?: string[]; customAnswer?: string }> = {},
33+
) {
3134
return renderToStaticMarkup(
3235
<ComposerPendingUserInputPanel
3336
pendingUserInputs={[pendingUserInput]}
3437
respondingRequestIds={[]}
35-
answers={{}}
38+
answers={answers}
3639
questionIndex={0}
3740
onToggleOption={() => {}}
3841
onAdvance={() => {}}
@@ -78,5 +81,19 @@ describe("ComposerPendingUserInputPanel", () => {
7881
expect(markup).toContain('data-pending-user-input-preview="Incremental"');
7982
expect(markup).toContain("<strong>Safe rollout</strong>");
8083
expect(markup).toContain("const batchSize = 1;");
84+
expect(markup).not.toContain("<img");
85+
expect(markup).not.toContain("tracker.invalid");
86+
});
87+
88+
it("keeps the preview clear when the last selected multi-option has no preview", () => {
89+
const multiPrompt: PendingUserInput = {
90+
...prompt,
91+
questions: [{ ...prompt.questions[0]!, multiSelect: true }],
92+
};
93+
const markup = renderPanel(multiPrompt, {
94+
"question-1": { selectedOptionValues: ["Incremental", "Big bang"] },
95+
});
96+
97+
expect(markup).not.toContain("data-pending-user-input-preview");
8198
});
8299
});

0 commit comments

Comments
 (0)