From a44a9783c1a0d6afbe91ee7062b873bc9b62c9fd Mon Sep 17 00:00:00 2001 From: Will Chen Date: Mon, 2 Jun 2025 22:35:55 -0700 Subject: [PATCH] New chat e2e (#314) --- e2e-tests/fixtures/chat1.md | 3 +++ e2e-tests/fixtures/chat2.md | 3 +++ e2e-tests/helpers/test_helper.ts | 8 +++++++ e2e-tests/new_chat.spec.ts | 21 +++++++++++++++++++ ...t.spec.ts_new-chat-first-button-1.aria.yml | 4 ++++ ...t.spec.ts_new-chat-first-button-2.aria.yml | 1 + ...t.spec.ts_new-chat-first-button-3.aria.yml | 4 ++++ ....spec.ts_new-chat-second-button-1.aria.yml | 4 ++++ ....spec.ts_new-chat-second-button-2.aria.yml | 1 + ....spec.ts_new-chat-second-button-3.aria.yml | 4 ++++ 10 files changed, 53 insertions(+) create mode 100644 e2e-tests/fixtures/chat1.md create mode 100644 e2e-tests/fixtures/chat2.md create mode 100644 e2e-tests/new_chat.spec.ts create mode 100644 e2e-tests/snapshots/new_chat.spec.ts_new-chat-first-button-1.aria.yml create mode 100644 e2e-tests/snapshots/new_chat.spec.ts_new-chat-first-button-2.aria.yml create mode 100644 e2e-tests/snapshots/new_chat.spec.ts_new-chat-first-button-3.aria.yml create mode 100644 e2e-tests/snapshots/new_chat.spec.ts_new-chat-second-button-1.aria.yml create mode 100644 e2e-tests/snapshots/new_chat.spec.ts_new-chat-second-button-2.aria.yml create mode 100644 e2e-tests/snapshots/new_chat.spec.ts_new-chat-second-button-3.aria.yml diff --git a/e2e-tests/fixtures/chat1.md b/e2e-tests/fixtures/chat1.md new file mode 100644 index 0000000..bad12d4 --- /dev/null +++ b/e2e-tests/fixtures/chat1.md @@ -0,0 +1,3 @@ +chat1 + +Chat 1 diff --git a/e2e-tests/fixtures/chat2.md b/e2e-tests/fixtures/chat2.md new file mode 100644 index 0000000..fd0f067 --- /dev/null +++ b/e2e-tests/fixtures/chat2.md @@ -0,0 +1,3 @@ +chat2 + +Chat 2 diff --git a/e2e-tests/helpers/test_helper.ts b/e2e-tests/helpers/test_helper.ts index b9a3659..08526b2 100644 --- a/e2e-tests/helpers/test_helper.ts +++ b/e2e-tests/helpers/test_helper.ts @@ -163,6 +163,14 @@ class PageObject { return this.page.getByRole("textbox", { name: "Ask Dyad to build..." }); } + clickNewChat({ index = 0 }: { index?: number } = {}) { + // There is two new chat buttons... + return this.page + .getByRole("button", { name: "New Chat" }) + .nth(index) + .click(); + } + async sendPrompt(prompt: string) { await this.getChatInput().click(); await this.getChatInput().fill(prompt); diff --git a/e2e-tests/new_chat.spec.ts b/e2e-tests/new_chat.spec.ts new file mode 100644 index 0000000..867e9f9 --- /dev/null +++ b/e2e-tests/new_chat.spec.ts @@ -0,0 +1,21 @@ +import { test } from "./helpers/test_helper"; + +const newChatTestCases = [ + { name: "first button", clickOptions: undefined }, + { name: "second button", clickOptions: { index: 1 } }, +]; + +newChatTestCases.forEach(({ name, clickOptions }) => { + test(`new chat (${name})`, async ({ po }) => { + await po.setUp(); + await po.sendPrompt("tc=chat1"); + await po.snapshotMessages(); + await po.clickNewChat(clickOptions); + + // Make sure it's empty + await po.snapshotMessages(); + + await po.sendPrompt("tc=chat2"); + await po.snapshotMessages(); + }); +}); diff --git a/e2e-tests/snapshots/new_chat.spec.ts_new-chat-first-button-1.aria.yml b/e2e-tests/snapshots/new_chat.spec.ts_new-chat-first-button-1.aria.yml new file mode 100644 index 0000000..2460581 --- /dev/null +++ b/e2e-tests/snapshots/new_chat.spec.ts_new-chat-first-button-1.aria.yml @@ -0,0 +1,4 @@ +- paragraph: tc=chat1 +- paragraph: chat1 +- button "Retry": + - img \ No newline at end of file diff --git a/e2e-tests/snapshots/new_chat.spec.ts_new-chat-first-button-2.aria.yml b/e2e-tests/snapshots/new_chat.spec.ts_new-chat-first-button-2.aria.yml new file mode 100644 index 0000000..d46108c --- /dev/null +++ b/e2e-tests/snapshots/new_chat.spec.ts_new-chat-first-button-2.aria.yml @@ -0,0 +1 @@ +- text: No messages yet \ No newline at end of file diff --git a/e2e-tests/snapshots/new_chat.spec.ts_new-chat-first-button-3.aria.yml b/e2e-tests/snapshots/new_chat.spec.ts_new-chat-first-button-3.aria.yml new file mode 100644 index 0000000..dc1b5fc --- /dev/null +++ b/e2e-tests/snapshots/new_chat.spec.ts_new-chat-first-button-3.aria.yml @@ -0,0 +1,4 @@ +- paragraph: tc=chat2 +- paragraph: chat2 +- button "Retry": + - img \ No newline at end of file diff --git a/e2e-tests/snapshots/new_chat.spec.ts_new-chat-second-button-1.aria.yml b/e2e-tests/snapshots/new_chat.spec.ts_new-chat-second-button-1.aria.yml new file mode 100644 index 0000000..2460581 --- /dev/null +++ b/e2e-tests/snapshots/new_chat.spec.ts_new-chat-second-button-1.aria.yml @@ -0,0 +1,4 @@ +- paragraph: tc=chat1 +- paragraph: chat1 +- button "Retry": + - img \ No newline at end of file diff --git a/e2e-tests/snapshots/new_chat.spec.ts_new-chat-second-button-2.aria.yml b/e2e-tests/snapshots/new_chat.spec.ts_new-chat-second-button-2.aria.yml new file mode 100644 index 0000000..d46108c --- /dev/null +++ b/e2e-tests/snapshots/new_chat.spec.ts_new-chat-second-button-2.aria.yml @@ -0,0 +1 @@ +- text: No messages yet \ No newline at end of file diff --git a/e2e-tests/snapshots/new_chat.spec.ts_new-chat-second-button-3.aria.yml b/e2e-tests/snapshots/new_chat.spec.ts_new-chat-second-button-3.aria.yml new file mode 100644 index 0000000..dc1b5fc --- /dev/null +++ b/e2e-tests/snapshots/new_chat.spec.ts_new-chat-second-button-3.aria.yml @@ -0,0 +1,4 @@ +- paragraph: tc=chat2 +- paragraph: chat2 +- button "Retry": + - img \ No newline at end of file