diff --git a/e2e-tests/chat_tabs.spec.ts b/e2e-tests/chat_tabs.spec.ts index 3d93a2b73..ea7e71f27 100644 --- a/e2e-tests/chat_tabs.spec.ts +++ b/e2e-tests/chat_tabs.spec.ts @@ -3,7 +3,7 @@ import { expect } from "@playwright/test"; test("tabs appear after navigating between chats", async ({ po }) => { await po.setUp({ autoApprove: true }); - await po.importApp("minimal"); + await po.importApp("minimal-with-ai-rules"); // Chat 1 await po.sendPrompt("[dump] build a todo app"); @@ -24,7 +24,7 @@ test("tabs appear after navigating between chats", async ({ po }) => { test("clicking a tab switches to that chat", async ({ po }) => { await po.setUp({ autoApprove: true }); - await po.importApp("minimal"); + await po.importApp("minimal-with-ai-rules"); // Chat 1 - send a unique message await po.sendPrompt("First chat unique message alpha"); @@ -57,7 +57,7 @@ test("clicking a tab switches to that chat", async ({ po }) => { test("closing a tab removes it and selects adjacent tab", async ({ po }) => { await po.setUp({ autoApprove: true }); - await po.importApp("minimal"); + await po.importApp("minimal-with-ai-rules"); // Chat 1 await po.sendPrompt("First chat message gamma"); @@ -99,7 +99,7 @@ test("closing a tab removes it and selects adjacent tab", async ({ po }) => { test("right-click context menu: Close other tabs", async ({ po }) => { await po.setUp({ autoApprove: true }); - await po.importApp("minimal"); + await po.importApp("minimal-with-ai-rules"); // Chat 1 await po.sendPrompt("[dump] Chat one context menu"); @@ -138,7 +138,7 @@ test("right-click context menu: Close other tabs", async ({ po }) => { test("right-click context menu: Close tabs to the right", async ({ po }) => { await po.setUp({ autoApprove: true }); - await po.importApp("minimal"); + await po.importApp("minimal-with-ai-rules"); // Chat 1 await po.sendPrompt("[dump] Left tab one"); @@ -182,7 +182,7 @@ test("right-click context menu: Close tabs to the right", async ({ po }) => { test("only shows tabs for chats opened in current session", async ({ po }) => { await po.setUp({ autoApprove: true }); - await po.importApp("minimal"); + await po.importApp("minimal-with-ai-rules"); // Initially no tabs should be visible (no chats opened yet in this session) const closeButtons = po.page.getByLabel(/^Close tab:/); diff --git a/e2e-tests/helpers/page-objects/components/ChatActions.ts b/e2e-tests/helpers/page-objects/components/ChatActions.ts index 4755d03a5..12c457d9f 100644 --- a/e2e-tests/helpers/page-objects/components/ChatActions.ts +++ b/e2e-tests/helpers/page-objects/components/ChatActions.ts @@ -88,9 +88,18 @@ export class ChatActions { timeout, }: { skipWaitForCompletion?: boolean; timeout?: number } = {}, ) { - await this.getChatInput().click(); - await this.getChatInput().fill(prompt); - await this.page.getByRole("button", { name: "Send message" }).click(); + const chatInput = this.getChatInput(); + const sendButton = this.page.getByRole("button", { name: "Send message" }); + + await expect(chatInput).toBeVisible(); + await expect(async () => { + await chatInput.click(); + await chatInput.fill(prompt); + await expect(chatInput).toContainText(prompt); + await expect(sendButton).toBeEnabled(); + }).toPass({ timeout: Timeout.MEDIUM }); + + await sendButton.click(); if (!skipWaitForCompletion) { await this.waitForChatCompletion({ timeout }); } diff --git a/rules/e2e-testing.md b/rules/e2e-testing.md index 1db799224..10105a129 100644 --- a/rules/e2e-testing.md +++ b/rules/e2e-testing.md @@ -61,6 +61,7 @@ The chat input uses a Lexical editor (contenteditable). Standard Playwright meth - **Clearing input**: `fill("")` doesn't reliably clear Lexical. Use keyboard shortcuts instead: `Meta+a` then `Backspace`. - **Timing issues**: Lexical may need time to update its internal state. Use `toPass()` with retries for resilient tests. +- **Avoid locator drift**: When both home/chat inputs may exist, scope the editor locator to the specific container (for example `chat-input-container`) and reuse one locator instance for click/fill/assertions. - **Helper methods**: Use `po.clearChatInput()` and `po.openChatHistoryMenu()` from test_helper.ts for reliable Lexical interactions. ```ts