Skip to content

Commit e0922ee

Browse files
committed
e2e: editing earliest prompt hides downstream prompt
1 parent a3fde61 commit e0922ee

File tree

2 files changed

+51
-0
lines changed

2 files changed

+51
-0
lines changed

e2e-tests/edit_prompt.spec.ts

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import { test } from "./helpers/test_helper";
2+
import { expect } from "@playwright/test";
3+
import type { PageObject } from "./helpers/test_helper";
4+
5+
async function editFirstPrompt(po: PageObject, newContent: string) {
6+
// Find the edit button with Pencil icon within chat messages
7+
// The button contains a Pencil icon (lucide-react's Pencil component)
8+
const editButton = po.page.locator("button:has(.lucide-pencil)").first();
9+
await editButton.click();
10+
11+
// Wait for the textarea to be visible before trying to fill it
12+
const editTextarea = po.page.getByTestId("chat-message-edit-textarea");
13+
await editTextarea.waitFor({ state: "visible" });
14+
await editTextarea.fill(newContent);
15+
16+
await po.page.getByRole("button", { name: "Save" }).click();
17+
await po.waitForChatCompletion();
18+
}
19+
20+
test("editing earliest prompt hides downstream prompts until switching versions", async ({
21+
po,
22+
}) => {
23+
await po.setUp({ autoApprove: true });
24+
25+
await po.sendPrompt("Prompt 1 - original");
26+
await po.sendPrompt("Prompt 2 - follow-up");
27+
await po.sendPrompt("Prompt 3 - final context");
28+
29+
await expect(
30+
po.page.getByText("Prompt 2 - follow-up", { exact: true }),
31+
).toBeVisible();
32+
await expect(
33+
po.page.getByText("Prompt 3 - final context", { exact: true }),
34+
).toBeVisible();
35+
36+
await editFirstPrompt(po, "Prompt 1 - edited branch");
37+
38+
await expect(po.page.getByText("2/2", { exact: true })).toBeVisible();
39+
40+
await expect(
41+
po.page.getByText("Prompt 1 - original", { exact: true }),
42+
).toHaveCount(0);
43+
44+
await po.page.getByRole("button", { name: "Previous version" }).click();
45+
46+
await expect(po.page.getByText("1/2", { exact: true })).toBeVisible();
47+
await expect(
48+
po.page.getByText("Prompt 1 - original", { exact: true }),
49+
).toBeVisible();
50+
});

src/components/chat/ChatMessage.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ const ChatMessage = ({
150150
{isEditing ? (
151151
<div className="flex flex-col gap-2">
152152
<Textarea
153+
data-testid="chat-message-edit-textarea"
153154
className="w-full p-2 border rounded-md"
154155
value={editedContent}
155156
onChange={(event) => setEditedContent(event.target.value)}

0 commit comments

Comments
 (0)