|
| 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 | +}); |
0 commit comments