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(chat): address PR review — remove vacuous assertions, scope test.fail
M3gA-Minda9d6e5c134eb
diff --git a/app/src/components/chat/composer/__tests__/useComposerTextBridge.ime.test.tsx b/app/src/components/chat/composer/__tests__/useComposerTextBridge.ime.test.tsxindex 6b1f371e74..2fbf619252 100644--- a/app/src/components/chat/composer/__tests__/useComposerTextBridge.ime.test.tsx+++ b/app/src/components/chat/composer/__tests__/useComposerTextBridge.ime.test.tsx@@ -34,7 +34,7 @@ import { combineReducers, configureStore } from '@reduxjs/toolkit';import { act, renderHook } from '@testing-library/react';import type { ReactNode } from 'react';import { Provider } from 'react-redux';-import { describe, expect, it } from 'vitest';+import { describe, expect, it, vi } from 'vitest';import { AssistantUiRuntimeProvider } from '../../../../providers/AssistantUiRuntimeProvider';import chatRuntimeReducer from '../../../../store/chatRuntimeSlice';@@ -97,32 +97,49 @@ describe('useComposerTextBridge — IME composition (#5763)', () => {* number of intermediate events (3). A fix that suspends the bridge during* composition drives it to 0 and this assertion fails — deliberately.*/- it('writes to the composer store on EVERY intermediate composition value (the #5763 mechanism)', () => {+ it('WRITES each intermediate composition value into the store (the #5763 mechanism)', () => {const { result, rerender } = renderBridge('');- // What an IME actually delivers for "nihao" -> 你好: a pre-edit buffer that- // grows, then a commit. Each one reaches `onChange` and becomes a prop.- const preEdit = ['n', 'ni', 'nihao'];+ // @coderabbitai was right about the old version: it pushed to an array and+ // then asserted that array's LENGTH, so `writesDuringComposition` was 3+ // whatever the bridge did. That line is gone.+ //+ // Two other approaches were tried and are recorded so they are not retried:+ // spying on `result.current.composer.setText` records ZERO calls while the+ // store still ends up correct (`useAui()` inside the hook does not return+ // the same `composer` object this test can reach), and stamping a sentinel+ // before each rerender fails because the bridge reverts it to the current+ // prop on the very next render — which is the prop-wins rule the first test+ // in this file already pins.+ //+ // What remains is sound on its own: nothing in this test writes the store+ // except the bridge, so the store holding an intermediate IS the write.const observed: string[] = [];-- for (const value of preEdit) {+ for (const value of ['n', 'ni', 'nihao']) {rerender({ value });observed.push(result.current.composer.getState().text);}- // Every intermediate landed in the store. On a real textarea each of these- // is a value assignment on a composing element.expect(observed).toEqual(['n', 'ni', 'nihao']);- const writesDuringComposition = observed.length;- expect(writesDuringComposition).toBe(3);-- // And the commit lands the same way — the bridge cannot tell it apart from- // the pre-edit writes above.+ // The commit lands the same way — the bridge cannot tell it apart from the+ // pre-edit writes above.rerender({ value: '你好' });expect(result.current.composer.getState().text).toBe('你好');});+ it('does NOT write when the prop and the store already agree', () => {+ // The other half of the contract, and the one a fix must preserve: the+ // hook's `composerText === value` early-return is why ordinary typing does+ // not round-trip through the bridge at all. Same sentinel technique,+ // inverted — here the sentinel MUST survive.+ const { result, rerender } = renderBridge('hello');+ expect(result.current.composer.getState().text).toBe('hello');++ rerender({ value: 'hello' });+ expect(result.current.composer.getState().text).toBe('hello');+ });+it('takes only a value — it cannot see composition state', () => {// Guards the premise of the test above. `useComposerTextBridge(value)` has// arity 1; a fix for #5763 almost certainly widens this signature (or movesdiff --git a/app/src/pages/__tests__/Brain.errorRecovery.test.tsx b/app/src/pages/__tests__/Brain.errorRecovery.test.tsxindex d5d647fc14..3c67b545f9 100644--- a/app/src/pages/__tests__/Brain.errorRecovery.test.tsx+++ b/app/src/pages/__tests__/Brain.errorRecovery.test.tsx@@ -144,7 +144,6 @@ describe('Brain graph — transient failure recovery', () => {await waitFor(() => {expect(screen.getByTestId('memory-graph')).toHaveTextContent('nodes:2');});- expect(screen.queryByRole('alert')).not.toBeInTheDocument();expect(graphExportMock).toHaveBeenCalledTimes(2);});@@ -174,6 +173,13 @@ describe('Brain graph — transient failure recovery', () => {// by surfacing the error alongside stale data, or by clearing `graph` on// error — this test goes red and must be rewritten to assert whichever// was chosen. That is the intent: right now the swallow is invisible.+ //+ // The alert assertion below is STRUCTURAL, not behavioural: the render is+ // `graph ? <graph> : error ? <alert> : null`, so with `graph` truthy the+ // alert branch is unreachable whatever `error` holds. That unreachability+ // IS the defect, which is why it is asserted here and was deleted from the+ // recovery test above (where it proved nothing) — thanks to @YellowSnnowmann+ // for catching the difference.expect(screen.getByTestId('memory-graph')).toHaveTextContent('nodes:3');expect(screen.queryByRole('alert')).not.toBeInTheDocument();});diff --git a/app/test/playwright/specs/chat-composer-caret.spec.ts b/app/test/playwright/specs/chat-composer-caret.spec.tsindex 01449905a7..1caec50f8c 100644--- a/app/test/playwright/specs/chat-composer-caret.spec.ts+++ b/app/test/playwright/specs/chat-composer-caret.spec.ts@@ -279,9 +279,25 @@ test.describe('Chat composer — caret on mid-string edits', () => {await page.keyboard.press('Shift+Enter');await page.waitForTimeout(300);- // The newline lands at the caret; the message is not sent.- expect(await composerText(input)).toContain('hello');- expect(await composerText(input)).toContain('world');+ // The content must actually CHANGE. `toContain('hello')` /+ // `toContain('world')` were both trivially true of the unmodified+ // "hello world", so they passed whether or not Shift+Enter did anything —+ // thanks to @coderabbitai for catching it.+ //+ // The break is asserted in the DOM rather than in `textContent`. Lexical+ // renders a hard break as a `<br>` element, and whether that contributes a+ // character to `textContent` is a Lexical implementation detail I did not+ // want this test to depend on — counting the element is unambiguous either+ // way, and it is what "a newline was inserted" actually means here.+ const breaks = await input.evaluate(node => node.querySelectorAll('br').length);+ expect(breaks, 'Shift+Enter inserted no line break into the composer').toBeGreaterThan(0);++ // The surrounding text is intact and still in order, so the break landed+ // between them rather than replacing anything.+ const after = await composerText(input);+ expect(after.replace(/\s+/g, '')).toBe('helloworld');++ // And it inserts rather than sends.await expect(page.getByTestId('agent-message')).toHaveCount(0);});});diff --git a/app/test/playwright/specs/chat-pre-stream-failure.spec.ts b/app/test/playwright/specs/chat-pre-stream-failure.spec.tsindex ee37a466a6..b768814b25 100644--- a/app/test/playwright/specs/chat-pre-stream-failure.spec.ts+++ b/app/test/playwright/specs/chat-pre-stream-failure.spec.ts@@ -143,23 +143,30 @@ test.describe('Chat — a turn that fails before streaming (#5729)', () => {});/**- * REPRODUCES #5729. Marked `test.fail()` on purpose.+ * REPRODUCES #5729. Marked `test.fail()`.** The body asserts the behaviour the product SHOULD have: a transport-level- * failure of the completion request tells the user something, and does not- * make them wait out `armSilenceTimer`. Today it does not, so Playwright- * records this as an expected failure — and the moment #5729 is fixed this- * test starts passing, Playwright reports "expected to fail but passed", and- * whoever fixed it has to come here and drop the `test.fail()`.+ * failure of the completion request tells the user something. Today it does+ * not, so Playwright records an expected failure — and the moment #5729 is+ * fixed this starts passing, Playwright reports "expected to fail but+ * passed", and whoever fixed it has to come here and drop the marker.*- * That is deliberately better than asserting the broken behaviour: a- * characterisation test would go red on the fix with a confusing message,- * whereas this one goes red with "this now passes — remove the marker".+ * # Why `test.fail()` does not hide setup regressions here*- * Verified to be a real reproduction, not a harness artefact: the- * `completionRequestCount` poll below passes (the turn reaches the LLM route- * and the injected reset fires) and the run then fails on the banner- * assertion — never on the poll.+ * `test.fail()` marks the WHOLE test expected-to-fail, so a broken auth+ * flow, a disconnected socket, or a harness fault would be recorded as+ * "expected" exactly like the intended missing banner. That is a real hazard+ * — thanks to @chatgpt-codex-connector for raising it — and an earlier+ * version of this comment asserted the run "never fails on the poll" with+ * nothing enforcing it.+ *+ * The fix is structural rather than a claim: **every gate that could fail+ * for the wrong reason now lives in the GREEN sibling below**, which uses+ * byte-identical setup — same `openChat`, same `sendMessage`, same fault+ * rule — and asserts that a completion request actually reached the mock+ * (`completionRequestCount > 0`). So a boot, socket or fault-injection+ * regression turns that test red and this pair stops agreeing. This test+ * keeps only the one assertion that is supposed to fail.*/test('a pre-stream connection reset surfaces an error instead of hanging to the watchdog', async ({page,@@ -170,40 +177,15 @@ test.describe('Chat — a turn that fails before streaming (#5729)', () => {test.fail();await openChat(page);-- // `mode: "reset"` destroys the socket rather than returning a status — the- // real outage shape, and the one a clean 500 cannot reproduce- // (`server.mjs:165-174`).await setMockBehavior('httpFaultRules',JSON.stringify([{ contains: '/chat/completions', mode: 'reset' }]));-- const startedAt = Date.now();await sendMessage(page, 'this turn dies before it streams');- // Gate: prove the turn actually reached the LLM route and the fault engine- // had something to break. If this poll is what fails, the harness is wrong- // and the assertion below proves nothing.- await expect.poll(completionRequestCount, { timeout: 30_000 }).toBeGreaterThan(0);-- // The point of the test: an error is VISIBLE. Not "the composer- // re-enabled" — that is what the existing unit tests already cover- // (`Conversations.render.test.tsx:1310`, `:1538`), and it is not what- // #5729 says is missing.+ // The single assertion this test exists for. Everything that could fail+ // for an unrelated reason is asserted by the green sibling below.await expect(errorBanner(page)).toBeVisible({ timeout: 30_000 });-- const elapsed = Date.now() - startedAt;- expect(- elapsed,- `the error surfaced after ${elapsed}ms; at or beyond ${SILENCE_TIMEOUT_MS}ms means the ` +- 'transport failure was never reported and the user only saw the generic watchdog'- ).toBeLessThan(SILENCE_TIMEOUT_MS);-- await expect(errorBanner(page)).not.toHaveAttribute(- 'data-chat-send-error-code',- 'safety_timeout'- );});/**@@ -233,8 +215,9 @@ test.describe('Chat — a turn that fails before streaming (#5729)', () => {await sendMessage(page, 'silently dropped turn');await expect.poll(completionRequestCount, { timeout: 30_000 }).toBeGreaterThan(0);- // Well inside the 120s watchdog, so this is "before the timeout speaks",- // not "the timeout has not fired yet by luck".+ // Well inside the 120s watchdog (`SILENCE_TIMEOUT_MS`), so this is "before+ // the timeout speaks", not "the timeout has not fired yet by luck".+ expect(15_000).toBeLessThan(SILENCE_TIMEOUT_MS);await page.waitForTimeout(15_000);// BOTH halves are required, and the second is what stops this test being