diff --git a/e2e-tests/fixtures/write-index-2.md b/e2e-tests/fixtures/write-index-2.md new file mode 100644 index 0000000..eca1b5a --- /dev/null +++ b/e2e-tests/fixtures/write-index-2.md @@ -0,0 +1,15 @@ +OK, I'm going to do some writing now... + + +const Index = () => { + return ( +
+ Testing:write-index(2)! +
+ ); +}; + +export default Index; +
+ +And it's done! diff --git a/e2e-tests/helpers/test_helper.ts b/e2e-tests/helpers/test_helper.ts index b63640a..bcd2545 100644 --- a/e2e-tests/helpers/test_helper.ts +++ b/e2e-tests/helpers/test_helper.ts @@ -73,10 +73,18 @@ class PageObject { await this.getRetryButton().click(); } + async clickUndo() { + await this.getUndoButton().click(); + } + private getRetryButton() { return this.page.getByRole("button", { name: "Retry" }); } + private getUndoButton() { + return this.page.getByRole("button", { name: "Undo" }); + } + async sendPrompt(prompt: string) { await this.page .getByRole("textbox", { name: "Ask Dyad to build..." }) @@ -84,7 +92,7 @@ class PageObject { await this.page .getByRole("textbox", { name: "Ask Dyad to build..." }) .fill(prompt); - await this.page.getByRole("button", { name: "Start new chat" }).click(); + await this.page.getByRole("button", { name: "Send message" }).click(); await this.waitForChatCompletion(); } diff --git a/e2e-tests/undo.spec.ts b/e2e-tests/undo.spec.ts new file mode 100644 index 0000000..d4ab487 --- /dev/null +++ b/e2e-tests/undo.spec.ts @@ -0,0 +1,25 @@ +import { test } from "./helpers/test_helper"; +import { expect } from "@playwright/test"; + +test("undo", async ({ po }) => { + await po.setUp({ autoApprove: true }); + await po.sendPrompt("tc=write-index"); + await po.sendPrompt("tc=write-index-2"); + + const iframe = po.getPreviewIframeElement(); + await expect( + iframe.contentFrame().getByText("Testing:write-index(2)!"), + ).toBeVisible({ + // This can be pretty slow because it's waiting for the app to build. + timeout: 15_000, + }); + + await po.clickUndo(); + + await expect( + iframe.contentFrame().getByText("Testing:write-index!"), + ).toBeVisible({ + // Also, could be slow. + timeout: 15_000, + }); +}); diff --git a/src/components/chat/ChatInput.tsx b/src/components/chat/ChatInput.tsx index 1436fc0..9086261 100644 --- a/src/components/chat/ChatInput.tsx +++ b/src/components/chat/ChatInput.tsx @@ -333,6 +333,7 @@ export function ChatInput({ chatId }: { chatId?: number }) { onClick={handleSubmit} disabled={!inputValue.trim() && attachments.length === 0} className="px-2 py-2 mt-1 mr-2 hover:bg-(--background-darkest) text-(--sidebar-accent-fg) rounded-lg disabled:opacity-50" + title="Send message" > diff --git a/src/components/chat/HomeChatInput.tsx b/src/components/chat/HomeChatInput.tsx index eca8c14..87f115a 100644 --- a/src/components/chat/HomeChatInput.tsx +++ b/src/components/chat/HomeChatInput.tsx @@ -139,7 +139,7 @@ export function HomeChatInput({ onClick={handleCustomSubmit} disabled={!inputValue.trim() && attachments.length === 0} className="px-2 py-2 mt-1 mr-2 hover:bg-(--background-darkest) text-(--sidebar-accent-fg) rounded-lg disabled:opacity-50" - title="Start new chat" + title="Send message" >