Skip to content

Commit 760771a

Browse files
committed
Fix draft e2e hover actions
Signed-off-by: morgmart <98432065+morgmart@users.noreply.github.com>
1 parent 675f5d6 commit 760771a

1 file changed

Lines changed: 26 additions & 9 deletions

File tree

ui/goose2/tests/e2e/drafts.spec.ts

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,20 @@
11
import { test, expect, waitForHome } from "./fixtures/tauri-mock";
22

3+
async function clickNewChatInProject(
4+
page: Parameters<typeof waitForHome>[0],
5+
projectName: string,
6+
) {
7+
const projectButton = page.getByRole("button", {
8+
name: projectName,
9+
exact: true,
10+
});
11+
await projectButton.hover();
12+
await projectButton
13+
.locator("xpath=..")
14+
.getByTitle("New chat in project")
15+
.click();
16+
}
17+
318
test.describe("Draft persistence", () => {
419
test("home screen draft persists across navigation", async ({
520
tauriMocked: page,
@@ -51,7 +66,7 @@ test.describe("Draft persistence", () => {
5166

5267
// Create a new chat in project Alpha
5368
await page.getByRole("button", { name: "Alpha" }).click();
54-
await page.getByTitle("New chat in project").first().click();
69+
await clickNewChatInProject(page, "Alpha");
5570

5671
// Type a draft
5772
const chatInput = page.getByLabel("Chat message input");
@@ -65,11 +80,11 @@ test.describe("Draft persistence", () => {
6580
await waitForHome(page);
6681

6782
await page.getByRole("button", { name: "Beta" }).click();
68-
await page.getByTitle("New chat in project").last().click();
83+
await clickNewChatInProject(page, "Beta");
6984
await expect(page.getByLabel("Chat message input")).toHaveValue("");
7085

7186
// Go back to project Alpha's draft via its + button
72-
await page.getByTitle("New chat in project").first().click();
87+
await clickNewChatInProject(page, "Alpha");
7388

7489
// Draft should be restored
7590
await expect(page.getByLabel("Chat message input")).toHaveValue(
@@ -87,15 +102,17 @@ test.describe("Draft persistence", () => {
87102
await page.getByRole("button", { name: "Alpha" }).click();
88103

89104
// Click the "+" for Alpha to create a new chat
90-
await page.getByTitle("New chat in project").first().click();
105+
await clickNewChatInProject(page, "Alpha");
91106

92107
// We should be in chat view now
93108
const chatInput = page.getByLabel("Chat message input");
94109
await expect(chatInput).toBeVisible();
95110

96111
// The draft session should NOT appear in the sidebar
97112
const sidebar = page.locator("nav");
98-
await expect(sidebar.getByText("New Chat")).not.toBeVisible();
113+
await expect(
114+
sidebar.getByRole("button", { name: "New Chat", exact: true }),
115+
).not.toBeVisible();
99116
});
100117

101118
test("empty draft cleans up when navigating away", async ({
@@ -106,7 +123,7 @@ test.describe("Draft persistence", () => {
106123

107124
// Open project and create a new chat
108125
await page.getByRole("button", { name: "Alpha" }).click();
109-
await page.getByTitle("New chat in project").first().click();
126+
await clickNewChatInProject(page, "Alpha");
110127

111128
// Don't type anything — leave it empty
112129
await expect(page.getByLabel("Chat message input")).toBeVisible();
@@ -116,7 +133,7 @@ test.describe("Draft persistence", () => {
116133
await waitForHome(page);
117134

118135
// Create another new chat in the same project
119-
await page.getByTitle("New chat in project").first().click();
136+
await clickNewChatInProject(page, "Alpha");
120137

121138
// Should get a fresh chat (the old empty one was cleaned up)
122139
await expect(page.getByLabel("Chat message input")).toHaveValue("");
@@ -130,7 +147,7 @@ test.describe("Draft persistence", () => {
130147

131148
// Open project and create a new chat
132149
await page.getByRole("button", { name: "Alpha" }).click();
133-
await page.getByTitle("New chat in project").first().click();
150+
await clickNewChatInProject(page, "Alpha");
134151

135152
// Type a draft
136153
const chatInput = page.getByLabel("Chat message input");
@@ -140,7 +157,7 @@ test.describe("Draft persistence", () => {
140157
await page.waitForTimeout(500);
141158

142159
// Click new chat in the same project again
143-
await page.getByTitle("New chat in project").first().click();
160+
await clickNewChatInProject(page, "Alpha");
144161

145162
// Should reuse the existing draft instead of creating a new one
146163
await expect(page.getByLabel("Chat message input")).toHaveValue(

0 commit comments

Comments
 (0)