The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
test: clear restored composer drafts before typing
lord_Tyrion0c758b9ed832
diff --git a/app/test/playwright/helpers/chat-composer.ts b/app/test/playwright/helpers/chat-composer.tsnew file mode 100644index 0000000000..4a3a7c9fc5--- /dev/null+++ b/app/test/playwright/helpers/chat-composer.ts@@ -0,0 +1,24 @@+import { expect, type Locator } from '@playwright/test';++/** Read either the Lexical surface or a textarea composer. */+export function composerText(input: Locator): Promise<string> {+ return input.evaluate(node => {+ const field = node as HTMLTextAreaElement;+ return typeof field.value === 'string' ? field.value : (node.textContent ?? '');+ });+}++/** Clear the restored draft through the same keyboard events a user sends. */+export async function clearChatComposer(input: Locator): Promise<void> {+ await input.click();+ await input.press('ControlOrMeta+a');+ await input.press('Delete');+ await expect.poll(() => composerText(input), { timeout: 15_000 }).toBe('');+}++/** Start a test with exactly its prompt, including when a draft was restored. */+export async function replaceChatComposerText(input: Locator, text: string): Promise<void> {+ await clearChatComposer(input);+ await input.pressSequentially(text);+ await expect.poll(() => composerText(input), { timeout: 15_000 }).toBe(text);+}diff --git a/app/test/playwright/specs/chat-composer-caret.spec.ts b/app/test/playwright/specs/chat-composer-caret.spec.tsindex a8dfbd8b03..0d3e3f474b 100644--- a/app/test/playwright/specs/chat-composer-caret.spec.ts+++ b/app/test/playwright/specs/chat-composer-caret.spec.ts@@ -63,6 +63,7 @@*/import { expect, type Locator, type Page, test } from '@playwright/test';+import { clearChatComposer, composerText, replaceChatComposerText } from '../helpers/chat-composer';import {bootAuthenticatedPage,dismissWalkthroughIfPresent,@@ -87,14 +88,10 @@ async function openChat(page: Page): Promise<Locator> {await dismissWalkthroughIfPresent(page);const input = page.getByTestId('chat-message-input');await expect(input).toBeVisible();+ await clearChatComposer(input);return input;}-/** Composer text. `textContent`, because the element is a contenteditable div. */-function composerText(input: Locator): Promise<string> {- return input.evaluate(node => node.textContent ?? '');-}-/*** Caret offset in characters from the start of the composer.*@@ -124,24 +121,6 @@ async function placeCaret(page: Page, input: Locator, index: number): Promise<voawait page.waitForTimeout(100);}-/**- * Put exactly `text` in the composer, starting from empty.- *- * The clear is load-bearing: `Conversations` persists the draft per thread- * through redux-persist, so a second test booting as the same user can open- * with the previous test's text already in the composer. Typing on top of that- * silently produced a different string and the polls below just timed out —- * which reads as a hang, not as a data problem.- */-async function seed(page: Page, input: Locator, text: string): Promise<void> {- await input.click();- await page.keyboard.press('ControlOrMeta+a');- await page.keyboard.press('Delete');- await expect.poll(() => composerText(input), { timeout: 15_000 }).toBe('');- await page.keyboard.type(text);- await expect.poll(() => composerText(input), { timeout: 15_000 }).toBe(text);-}-test.describe('Chat composer — caret on mid-string edits', () => {test.beforeEach(async () => {await resetMock();@@ -154,7 +133,7 @@ test.describe('Chat composer — caret on mid-string edits', () => {*/test('moving the caret without editing keeps it where it was put', async ({ page }) => {const input = await openChat(page);- await seed(page, input, 'hello world');+ await replaceChatComposerText(input, 'hello world');await placeCaret(page, input, 5);expect(await caretOffset(input)).toBe(5);@@ -220,7 +199,7 @@ test.describe('Chat composer — caret on mid-string edits', () => {*/test('typing mid-string leaves the caret after the inserted character', async ({ page }) => {const input = await openChat(page);- await seed(page, input, 'hello world');+ await replaceChatComposerText(input, 'hello world');await placeCaret(page, input, 5);expect(@@ -248,7 +227,7 @@ test.describe('Chat composer — caret on mid-string edits', () => {page,}) => {const input = await openChat(page);- await seed(page, input, 'hello world');+ await replaceChatComposerText(input, 'hello world');await placeCaret(page, input, 5);await page.keyboard.type('A');@@ -282,7 +261,7 @@ test.describe('Chat composer — caret on mid-string edits', () => {page,}) => {const input = await openChat(page);- await seed(page, input, 'hello world');+ await replaceChatComposerText(input, 'hello world');await placeCaret(page, input, 5);await page.keyboard.press('Backspace');@@ -306,7 +285,7 @@ test.describe('Chat composer — caret on mid-string edits', () => {*/test('Shift+Enter inserts a newline mid-string without sending', async ({ page }) => {const input = await openChat(page);- await seed(page, input, 'hello world');+ await replaceChatComposerText(input, 'hello world');await placeCaret(page, input, 5);await page.keyboard.press('Shift+Enter');diff --git a/app/test/playwright/specs/chat-composer-edit-and-clipboard.spec.ts b/app/test/playwright/specs/chat-composer-edit-and-clipboard.spec.tsindex c111798128..96470b1183 100644--- a/app/test/playwright/specs/chat-composer-edit-and-clipboard.spec.ts+++ b/app/test/playwright/specs/chat-composer-edit-and-clipboard.spec.ts@@ -34,6 +34,7 @@*/import { expect, type Locator, type Page, test } from '@playwright/test';+import { clearChatComposer, replaceChatComposerText } from '../helpers/chat-composer';import {bootAuthenticatedPage,dismissWalkthroughIfPresent,@@ -67,6 +68,7 @@ async function openChat(page: Page): Promise<Locator> {await dismissWalkthroughIfPresent(page);const input = page.getByTestId('chat-message-input');await expect(input).toBeVisible();+ await clearChatComposer(input);return input;}@@ -113,15 +115,6 @@ function caretOf(el: Locator): Promise<number> {});}-async function clearAndType(page: Page, el: Locator, text: string): Promise<void> {- await el.click();- await page.keyboard.press('ControlOrMeta+a');- await page.keyboard.press('Delete');- await expect.poll(() => textOf(el), { timeout: 15_000 }).toBe('');- await page.keyboard.type(text);- await expect.poll(() => textOf(el), { timeout: 15_000 }).toBe(text);-}-async function placeCaret(page: Page, el: Locator, index: number): Promise<void> {await el.click();await page.keyboard.press('Home');@@ -177,7 +170,7 @@ test.describe('Composer — clipboard, history, and the edit composer', () => {// Put "ABC" on the clipboard by typing then cutting — no clipboard// permissions needed, and it exercises the surface a user would.- await clearAndType(page, input, 'ABC');+ await replaceChatComposerText(input, 'ABC');await page.keyboard.press('ControlOrMeta+a');await page.keyboard.press('ControlOrMeta+x');await expect.poll(() => textOf(input), { timeout: 15_000 }).toBe('');@@ -200,7 +193,7 @@ test.describe('Composer — clipboard, history, and the edit composer', () => {test('undo after a mid-string insertion restores the previous text', async ({ page }) => {const input = await openChat(page);- await clearAndType(page, input, 'hello world');+ await replaceChatComposerText(input, 'hello world');await placeCaret(page, input, 5);await page.keyboard.type('X');@@ -215,7 +208,7 @@ test.describe('Composer — clipboard, history, and the edit composer', () => {test('redo after undo re-applies the insertion', async ({ page }) => {const input = await openChat(page);- await clearAndType(page, input, 'hello world');+ await replaceChatComposerText(input, 'hello world');await placeCaret(page, input, 5);await page.keyboard.type('X');diff --git a/app/test/playwright/specs/chat-composer-helper.spec.ts b/app/test/playwright/specs/chat-composer-helper.spec.tsnew file mode 100644index 0000000000..2828b76f8b--- /dev/null+++ b/app/test/playwright/specs/chat-composer-helper.spec.ts@@ -0,0 +1,37 @@+import { expect, test } from '@playwright/test';++import { clearChatComposer, composerText, replaceChatComposerText } from '../helpers/chat-composer';++// Exercise the keyboard helper in Chromium with restored text in both surfaces.+// The product specs below use the same helper against the shipped composer.+test.describe('Composer draft isolation helper', () => {+ for (const surface of ['textarea', 'contenteditable'] as const) {+ test(`replaces a restored ${surface} draft and a second prompt`, async ({ page }) => {+ await page.setContent(+ surface === 'textarea'+ ? '<textarea data-testid="composer">draft from the previous test</textarea>'+ : '<div contenteditable="true" data-testid="composer">draft from the previous test</div>'+ );+ const input = page.getByTestId('composer');+ expect(await composerText(input)).toBe('draft from the previous test');++ await replaceChatComposerText(input, 'first prompt');+ expect(await composerText(input)).toBe('first prompt');+ await replaceChatComposerText(input, 'second prompt');+ expect(await composerText(input)).toBe('second prompt');++ await clearChatComposer(input);+ expect(await composerText(input)).toBe('');+ });+ }++ test('clears a multiline restored draft before an empty prompt', async ({ page }) => {+ await page.setContent(+ '<div contenteditable="true" data-testid="composer"><p>old</p><p>draft</p></div>'+ );+ const input = page.getByTestId('composer');+ await replaceChatComposerText(input, '');+ expect(await composerText(input)).toBe('');+ await expect(input).toBeFocused();+ });+});diff --git a/app/test/playwright/specs/chat-composer-primary-slot.spec.ts b/app/test/playwright/specs/chat-composer-primary-slot.spec.tsindex 566946f570..38963983c7 100644--- a/app/test/playwright/specs/chat-composer-primary-slot.spec.ts+++ b/app/test/playwright/specs/chat-composer-primary-slot.spec.ts@@ -40,6 +40,7 @@*/import { expect, type Locator, type Page, test } from '@playwright/test';+import { clearChatComposer } from '../helpers/chat-composer';import { bootAuthenticatedPage, dismissWalkthroughIfPresent } from '../helpers/core-rpc';const MOCK_ADMIN_BASE = `http://127.0.0.1:${process.env.E2E_MOCK_PORT || '18473'}`;@@ -81,6 +82,7 @@ async function openChat(page: Page): Promise<void> {await bootAuthenticatedPage(page, USER_ID, '/chat');await dismissWalkthroughIfPresent(page);await expect(page.getByTestId('chat-message-input')).toBeVisible({ timeout: 30_000 });+ await clearChatComposer(composer(page));}const composer = (page: Page): Locator => page.getByTestId('chat-message-input');@@ -95,9 +97,7 @@ async function typeIntoComposer(page: Page, text: string): Promise<void> {}async function clearComposer(page: Page): Promise<void> {- await composer(page).click();- await page.keyboard.press('ControlOrMeta+a');- await page.keyboard.press('Backspace');+ await clearChatComposer(composer(page));}async function beginStreamingTurn(page: Page, prompt: string): Promise<void> {diff --git a/gitbooks/developing/e2e-testing.md b/gitbooks/developing/e2e-testing.mdindex 93f61a8346..2b1d906541 100644--- a/gitbooks/developing/e2e-testing.md+++ b/gitbooks/developing/e2e-testing.md@@ -9,9 +9,9 @@ icon: vialsDesktop E2E tests use **WebDriverIO (WDIO)** to drive the app through a single `tauri-driver` (WebDriver) session against its native Wry/WebKit webview:-| Platform | Driver | Port | App format | Selectors |-| --------- | ------------------------------ | ---- | ------------- | --------- |-| **Linux** | tauri-driver + WebKitWebDriver | 4444 | Debug binary | CSS / DOM |+| Platform | Driver | Port | App format | Selectors |+| --------- | ------------------------------ | ---- | ------------ | --------- |+| **Linux** | tauri-driver + WebKitWebDriver | 4444 | Debug binary | CSS / DOM |The app moved from CEF to Tauri's native Wry webview in #5456. The old Appium Chromium-driver backend attached over CEF's remote-debugging port; CDP only exists under a Chromium engine, so that backend was removed in #5478 along with CEF itself. Linux CI now drives the debug binary under Xvfb through `tauri-driver`. macOS and Windows have no automated desktop E2E coverage until a native driver (Appium Mac2 / WinAppDriver) replaces the removed one; that work is tracked in #5485. `pnpm --filter openhuman-app test:e2e:build` still produces a `.app` bundle on macOS for manual testing, but there is no supported automated session there yet.@@ -78,7 +78,7 @@ active platform detection.`app/test/e2e/helpers/element-helpers.ts` provides a unified API over the WebView DOM:-| Helper | Behavior |+| Helper | Behavior || ------------------------- | -------------------------------------------- || `waitForText(text)` | XPath over DOM text content || `waitForButton(text)` | `button` / `[role="button"]` XPath |@@ -233,6 +233,19 @@ bash app/scripts/e2e-run-spec.sh test/e2e/specs/notifications.spec.ts notificati## Agent-observable artifact flow+### Starting a composer test++Chat drafts persist per thread. Before a spec types its initial prompt, call+`replaceChatComposerText(input, prompt)` from+`app/test/playwright/helpers/chat-composer.ts`. It selects and deletes the+restored draft, waits for the empty value, types through keyboard events, and+checks the exact prompt. Use `clearChatComposer(input)` when a case needs an+empty composer. These helpers support both textarea and Lexical surfaces.++Cases that exercise draft restoration or append a follow-up should keep their+draft and drive that behavior explicitly. The helper's browser regressions live+in `app/test/playwright/specs/chat-composer-helper.spec.ts`.+For a canonical, inspectable run that drops screenshots, page-source dumps, and mock request logs on disk:```bash