Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

test(settings): address review — two vacuous assertions and formatting\n\nReview fixes for #5886.\n\n**Prettier (YellowSnnowmann, 5 threads).** All six Playwright specs violated\nimport-sort and line width. Fixed with the repo-local binary\n(`app/node_modules/.bin/prettier`) — my earlier `npx --prefix app prettier`\nruns had reported clean, so the local binary is the one to trust.\n\n**Two of my assertions were genuinely vacuous. Both reviewers were right.**\n\nCodeRabbit, SandboxSettingsPanel.validation: the refusal tests awaited\n`waitFor(() => expect(mockGet).toHaveBeenCalled())` before asserting\n`mockUpdate` was NOT called. `mockGet` fires on mount, so that condition is\nalready true and `waitFor` resolves on its first tick — before a blur handler's\npromise chain can reach `mockUpdate`. The negative assertion would have passed\nwith the guard removed. Replaced with a real two-macrotask flush. Same file: the\nempty-limit-fields test waited on the ABSENCE of '512', which is also true while\nnothing has loaded; it now waits for a positive signal (the populated image\nfield) first.\n\nCodeRabbit, PrivacyModeSection.status: `toHaveTextContent('')` is a documented\nfalse positive — jest-dom treats an empty expected string as matching anything\n(it now throws rather than assert). Replaced with `toBeEmptyDOMElement()`, which\nactually checks emptiness.\n\n**One ask I am pushing back on, with evidence** (tinysweeper, "missing-async" on\nthe disabled-while-loading test): the claim is that the assertion could pass\neven if the component never disabled the options. It cannot. `status` is\ninitialised to 'loading' and the options are rendered disabled from the first\nrender, and `getByTestId` throws if they are absent rather than passing\nvacuously. Directly verified by setting `disabled={false}` in the component:\nBOTH disabled tests fail. Reply posted on the thread.\n\n**Walkthrough dismiss (CodeRabbit):** added to the navigation spec. It was\nalready handled — `seedBrowserCoreMode` sets `openhuman:walkthrough_completed`,\nwhich is why the suite passed without it — but the dismiss is free and keeps\nthe spec robust if that seed changes. Noted as defence-in-depth in the comment.\n\nVerification note: the four behavioural checks above were executed and their\nfault-injection proofs observed BEFORE the no-local-builds rule took effect.\nNothing here has been run since; the formatting and typecheck results quoted in\nthe threads are from that same window. CI is the check from here.\n

M3gA-Mind31316cf03206
diff --git a/app/src/components/settings/panels/__tests__/PrivacyModeSection.status.test.tsx b/app/src/components/settings/panels/__tests__/PrivacyModeSection.status.test.tsx
index 1cb207f4da..59a699aa35 100644
--- a/app/src/components/settings/panels/__tests__/PrivacyModeSection.status.test.tsx
+++ b/app/src/components/settings/panels/__tests__/PrivacyModeSection.status.test.tsx
@@ -152,7 +152,11 @@ describe('PrivacyModeSection — save', () => {
await act(async () => {
vi.advanceTimersByTime(2000);
});
- await waitFor(() => expect(statusLine()).toHaveTextContent(''));
+ // `toHaveTextContent('')` is a false positive: jest-dom treats an empty
+ // expected string as matching anything (it now throws rather than assert),
+ // so it would pass whether or not the note cleared. `toBeEmptyDOMElement`
+ // is the matcher that actually checks emptiness.
+ await waitFor(() => expect(statusLine()).toBeEmptyDOMElement());
});
it('does not call the setter when the already-selected mode is re-chosen', async () => {
diff --git a/app/src/components/settings/panels/__tests__/SandboxSettingsPanel.validation.test.tsx b/app/src/components/settings/panels/__tests__/SandboxSettingsPanel.validation.test.tsx
index 673193b8bd..165c5e4cad 100644
--- a/app/src/components/settings/panels/__tests__/SandboxSettingsPanel.validation.test.tsx
+++ b/app/src/components/settings/panels/__tests__/SandboxSettingsPanel.validation.test.tsx
@@ -15,7 +15,7 @@
* Separate file rather than an edit to the sibling: three of us are in this
* directory.
*/
-import { fireEvent, screen, waitFor } from '@testing-library/react';
+import { act, fireEvent, screen, waitFor } from '@testing-library/react';
import { beforeEach, describe, expect, it, vi } from 'vitest';
import { renderWithProviders } from '../../../../test/test-utils';
@@ -69,6 +69,23 @@ async function renderLoaded(overrides: Partial<SandboxSettings> = {}) {
await waitFor(() => expect(mockGet).toHaveBeenCalled());
}
+/**
+ * Let any queued persist actually run before asserting it did NOT happen.
+ *
+ * `await waitFor(() => expect(mockGet).toHaveBeenCalled())` is NOT a readiness
+ * signal here: `mockGet` fires on mount, so the condition is already true and
+ * `waitFor` resolves on its first tick — before a blur handler's promise chain
+ * has had a chance to reach `mockUpdate`. The negative assertion that follows
+ * would then pass whether or not the guard exists. Two macrotasks is what a
+ * `void persist(...)` needs to get from the handler to the mock.
+ */
+async function flushPersist() {
+ await act(async () => {
+ await new Promise(resolve => setTimeout(resolve, 0));
+ await new Promise(resolve => setTimeout(resolve, 0));
+ });
+}
+
/** Blur a field after typing `value`, then report what (if anything) persisted. */
function blurWith(input: HTMLElement, value: string) {
fireEvent.change(input, { target: { value } });
@@ -95,8 +112,7 @@ describe('SandboxSettingsPanel — memory limit validation', () => {
await renderLoaded();
blurWith(memoryInput(), value);
- // A moment for any stray async persist to land.
- await waitFor(() => expect(mockGet).toHaveBeenCalled());
+ await flushPersist();
expect(mockUpdate).not.toHaveBeenCalled();
});
@@ -120,7 +136,7 @@ describe('SandboxSettingsPanel — CPU limit validation', () => {
await renderLoaded();
blurWith(cpuInput(), value);
- await waitFor(() => expect(mockGet).toHaveBeenCalled());
+ await flushPersist();
expect(mockUpdate).not.toHaveBeenCalled();
});
@@ -144,7 +160,7 @@ describe('SandboxSettingsPanel — docker image validation', () => {
await renderLoaded();
blurWith(imageInput(), ' ');
- await waitFor(() => expect(mockGet).toHaveBeenCalled());
+ await flushPersist();
expect(mockUpdate).not.toHaveBeenCalled();
});
@@ -160,7 +176,11 @@ describe('SandboxSettingsPanel — load shape', () => {
it('renders empty limit fields when the core reports no limits', async () => {
await renderLoaded({ docker_memory_limit_mb: null, docker_cpu_limit: null });
- await waitFor(() => expect(screen.queryByDisplayValue('512')).not.toBeInTheDocument());
+ // Wait for a POSITIVE loaded signal first — the image field is populated
+ // from the same response. Waiting on the absence of '512' would pass while
+ // the panel was still empty because nothing had loaded at all.
+ expect(await screen.findByDisplayValue('alpine:3.20')).toBeInTheDocument();
+ expect(screen.queryByDisplayValue('512')).not.toBeInTheDocument();
expect(screen.queryByDisplayValue('1')).not.toBeInTheDocument();
});
diff --git a/app/test/playwright/specs/settings-navigation-panels.spec.ts b/app/test/playwright/specs/settings-navigation-panels.spec.ts
index e4716dec5b..5a931994cc 100644
--- a/app/test/playwright/specs/settings-navigation-panels.spec.ts
+++ b/app/test/playwright/specs/settings-navigation-panels.spec.ts
@@ -1,6 +1,10 @@
import { expect, type Page, test } from '@playwright/test';
-import { bootAuthenticatedPage, waitForAppReady } from '../helpers/core-rpc';
+import {
+ bootAuthenticatedPage,
+ dismissWalkthroughIfPresent,
+ waitForAppReady,
+} from '../helpers/core-rpc';
/**
* Settings navigation, driven in a real browser.
@@ -107,6 +111,11 @@ const panelHeading = (page: Page) => page.getByRole('heading', { level: 1 });
async function gotoSettings(page: Page, route: string) {
await page.goto(`/#/settings/${route}`);
await waitForAppReady(page);
+ // Defence in depth: `seedBrowserCoreMode` already sets
+ // `openhuman:walkthrough_completed`, which is why this suite passed without
+ // it — but if that seed ever changes, an open walkthrough would intercept
+ // the sidebar clicks below rather than failing loudly.
+ await dismissWalkthroughIfPresent(page);
// `waitForAppReady` only proves the shell painted; the routed panel mounts a
// beat later. Wait for the panel's own heading before asserting on it.
await expect(panelHeading(page)).toBeVisible({ timeout: 30_000 });