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

M3gA-Mind5e15656f96a6
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 });