Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

fix the two flakes that fail-fast the full CI matrix from an unrelated shard

[._.]/ Adam Eivy2ccfae73d903
diff --git a/client/src/components/messages/beeper/BeeperSettingsPanel.test.jsx b/client/src/components/messages/beeper/BeeperSettingsPanel.test.jsx
index 943981f721..930513387b 100644
--- a/client/src/components/messages/beeper/BeeperSettingsPanel.test.jsx
+++ b/client/src/components/messages/beeper/BeeperSettingsPanel.test.jsx
@@ -1,5 +1,5 @@
import { beforeEach, describe, expect, it, vi } from 'vitest';
-import { fireEvent, render, screen, waitFor } from '@testing-library/react';
+import { act, fireEvent, render, screen, waitFor } from '@testing-library/react';
const api = vi.hoisted(() => ({
getSettings: vi.fn(),
@@ -24,7 +24,16 @@ const BASE_SETTINGS = { beeper: { enabled: false, intervalMinutes: 5, baseUrl: '
// No router: the panel takes `realtime` as a prop and reads nothing off the
// URL — the OAuth outcome flag is the page shell's job, covered by the page's
// own suite.
-const renderPanel = (props = {}) => render(<BeeperSettingsPanel {...props} />);
+const renderPanel = async (props = {}) => {
+ const result = render(<BeeperSettingsPanel {...props} />);
+ // The panel and its AttachmentMirrorCard both fetch on mount. Settle those
+ // promises here, or a test that finishes before they resolve leaves a
+ // setState to land outside act(...) — and src/test/setup.js throws it in
+ // whichever test's afterEach happens to be running by then, blaming a case
+ // that never touched the component.
+ await act(async () => {});
+ return result;
+};
const BASE_ATTACHMENT_SUMMARY = {
budgetBytes: 5 * 1024 * 1024 * 1024,
@@ -53,7 +62,7 @@ describe('BeeperSettingsPanel — status card states', () => {
api.getBeeperStatus.mockResolvedValue({
tokenConfigured: false, reachable: null, lastProbeError: null, accounts: [],
});
- renderPanel();
+ await renderPanel();
expect(await screen.findByRole('heading', { name: 'Connect Beeper' })).toBeInTheDocument();
// Both paths are first-class (#11 decision 3), so both are on screen at once.
@@ -68,7 +77,7 @@ describe('BeeperSettingsPanel — status card states', () => {
api.getBeeperStatus.mockResolvedValue({
tokenConfigured: true, reachable: false, lastProbeError: 'Beeper request failed: connection refused', baseUrl: 'http://127.0.0.1:23373', accounts: [],
});
- renderPanel();
+ await renderPanel();
expect(await screen.findByText('Beeper Desktop unreachable')).toBeInTheDocument();
expect(screen.getByText('Beeper request failed: connection refused')).toBeInTheDocument();
@@ -79,7 +88,7 @@ describe('BeeperSettingsPanel — status card states', () => {
api.getBeeperStatus.mockResolvedValue({
tokenConfigured: true, reachable: true, lastProbeError: null, appVersion: '4.3.73', accounts: [],
});
- renderPanel();
+ await renderPanel();
expect(await screen.findByText('Beeper Desktop connected')).toBeInTheDocument();
expect(screen.getByTestId('beeper-roster-empty')).toBeInTheDocument();
@@ -92,7 +101,7 @@ describe('BeeperSettingsPanel — status card states', () => {
tokenConfigured: true, reachable: true, lastProbeError: null, accounts: [],
tokenScopes: ['read', 'write'],
});
- renderPanel();
+ await renderPanel();
expect(await screen.findByText('Beeper Desktop connected')).toBeInTheDocument();
expect(screen.getByText('Scopes: read, write')).toBeInTheDocument();
@@ -106,7 +115,7 @@ describe('BeeperSettingsPanel — status card states', () => {
tokenConfigured: true, reachable: true, lastProbeError: null, accounts: [],
tokenScopes: ['read'],
});
- renderPanel();
+ await renderPanel();
expect(await screen.findByText('Scopes: read')).toBeInTheDocument();
expect(screen.getByText('Read-only grant — sending will fail.')).toBeInTheDocument();
@@ -120,7 +129,7 @@ describe('BeeperSettingsPanel — status card states', () => {
tokenConfigured: true, tokenSource: 'pasted', reachable: true, lastProbeError: null, accounts: [],
tokenScopes: [],
});
- renderPanel();
+ await renderPanel();
expect(await screen.findByText('Beeper Desktop connected')).toBeInTheDocument();
expect(screen.getByText('Scopes unknown (pasted token).')).toBeInTheDocument();
@@ -133,7 +142,7 @@ describe('BeeperSettingsPanel — status card states', () => {
tokenConfigured: true, tokenSource: 'legacy-settings', reachable: true, lastProbeError: null, accounts: [],
tokenScopes: [],
});
- renderPanel();
+ await renderPanel();
expect(await screen.findByText('Beeper Desktop connected')).toBeInTheDocument();
expect(screen.queryByText(/Scopes/)).toBeNull();
@@ -149,7 +158,7 @@ describe('BeeperSettingsPanel — status card states', () => {
accountsDone: 3, accountsTotal: 9, chats: 40, messages: 812,
},
});
- renderPanel();
+ await renderPanel();
expect(await screen.findByText('Syncing… 3 of 9 accounts')).toBeInTheDocument();
});
@@ -162,7 +171,7 @@ describe('BeeperSettingsPanel — status card states', () => {
accountsDone: 9, accountsTotal: 9, chats: 210, messages: 4032,
},
});
- renderPanel();
+ await renderPanel();
expect(await screen.findByText(/Last synced \d{1,2}:\d{2}/)).toBeInTheDocument();
});
@@ -180,7 +189,7 @@ describe('BeeperSettingsPanel — status card states', () => {
baseUrl: 'http://127.0.0.1:23373',
accounts: [{ accountId: 'acc1', displayName: 'Example WhatsApp', network: 'whatsapp' }],
});
- renderPanel();
+ await renderPanel();
expect(await screen.findByText('Beeper Desktop unreachable')).toBeInTheDocument();
expect(screen.getByText('Example WhatsApp')).toBeInTheDocument();
@@ -194,7 +203,7 @@ describe('BeeperSettingsPanel — status card states', () => {
lastProbeError: null,
accounts: [{ accountId: 'acc1', displayName: 'Example WhatsApp', network: 'whatsapp' }],
});
- renderPanel();
+ await renderPanel();
expect(await screen.findByText('Checking Beeper Desktop…')).toBeInTheDocument();
expect(screen.getByText('Example WhatsApp')).toBeInTheDocument();
@@ -206,7 +215,7 @@ describe('BeeperSettingsPanel — status card states', () => {
{ accountId: 'acc1', displayName: 'Example WhatsApp', network: 'whatsapp' },
],
});
- renderPanel();
+ await renderPanel();
expect(await screen.findByText('Example WhatsApp')).toBeInTheDocument();
expect(screen.getByText('whatsapp')).toBeInTheDocument();
@@ -222,7 +231,7 @@ describe('BeeperSettingsPanel — status card states', () => {
state: 'reconnecting', lastEventAt: null, lastPingAt: null, appState: 'needs-login', appStateActionable: true,
},
});
- renderPanel();
+ await renderPanel();
await screen.findByText('Beeper Desktop connected');
expect(screen.getByTestId('connection-status-dot')).toHaveAttribute('data-status', 'reconnecting');
@@ -243,7 +252,7 @@ describe('BeeperSettingsPanel — status card states', () => {
state: 'connecting', lastEventAt: null, lastPingAt: null, appState: 'needs-login', appStateActionable: true,
},
});
- renderPanel();
+ await renderPanel();
await screen.findByText('Beeper Desktop unreachable');
expect(screen.getByTestId('connection-status-dot')).toHaveAttribute('data-status', 'connecting');
@@ -260,7 +269,7 @@ describe('BeeperSettingsPanel — status card states', () => {
state: 'down', lastEventAt: null, lastPingAt: null, appState: null, appStateActionable: false, authRejected: true,
},
});
- renderPanel();
+ await renderPanel();
await screen.findByText('Checking Beeper Desktop…');
expect(screen.getByTestId('connection-status-dot')).toHaveAttribute('data-status', 'down');
@@ -283,7 +292,7 @@ describe('BeeperSettingsPanel — status card states', () => {
state: 'down', lastEventAt: null, lastPingAt: null, appState: null, appStateActionable: false, authRejected: true,
},
});
- renderPanel();
+ await renderPanel();
await screen.findByText('Beeper token expired');
expect(screen.getByTestId('connection-status-dot')).toHaveAttribute('data-status', 'down');
@@ -297,7 +306,7 @@ describe('BeeperSettingsPanel — status card states', () => {
api.getBeeperStatus.mockResolvedValue({
tokenConfigured: true, reachable: true, lastProbeError: null, accounts: [],
});
- renderPanel();
+ await renderPanel();
await screen.findByText('Beeper Desktop connected');
expect(screen.queryByTestId('connection-status-dot')).toBeNull();
@@ -310,7 +319,7 @@ describe('BeeperSettingsPanel — status card states', () => {
api.getBeeperStatus.mockResolvedValue({
tokenConfigured: true, reachable: null, lastProbeError: null, accounts: [],
});
- renderPanel();
+ await renderPanel();
expect(await screen.findByText('Checking Beeper Desktop…')).toBeInTheDocument();
expect(screen.queryByText('Beeper Desktop unreachable')).toBeNull();
@@ -322,7 +331,7 @@ describe('BeeperSettingsPanel — status card states', () => {
// otherwise be silently told to connect.
it('never renders "Connect Beeper" when the status fetch itself rejects', async () => {
api.getBeeperStatus.mockRejectedValue(new Error('network down'));
- renderPanel();
+ await renderPanel();
expect(await screen.findByText('Could not read Beeper status')).toBeInTheDocument();
expect(screen.getByText('network down')).toBeInTheDocument();
@@ -338,7 +347,7 @@ describe('BeeperSettingsPanel — status card states', () => {
api.getBeeperStatus.mockResolvedValue({
tokenConfigured: true, reachable: true, probeState: 'slow', probeLatencyMs: 3000, lastProbeError: null, accounts: [],
});
- renderPanel();
+ await renderPanel();
expect(await screen.findByText('Beeper Desktop connected')).toBeInTheDocument();
expect(screen.getByText(/Slow to respond \(3000ms\)/)).toBeInTheDocument();
@@ -353,7 +362,7 @@ describe('BeeperSettingsPanel — status card states', () => {
api.getBeeperStatus.mockResolvedValue({
tokenConfigured: true, reachable: true, probeState: 'ok', probeLatencyMs: 8, lastProbeError: null, accounts: [],
});
- renderPanel();
+ await renderPanel();
expect(await screen.findByText('Beeper Desktop connected')).toBeInTheDocument();
expect(screen.queryByText(/Slow to respond/)).toBeNull();
@@ -366,7 +375,7 @@ describe('BeeperSettingsPanel — status card states', () => {
api.getBeeperStatus.mockResolvedValue({
tokenConfigured: true, reachable: true, lastProbeError: null, accounts: null, accountsError: 'Could not read the mirrored account roster',
});
- renderPanel();
+ await renderPanel();
expect(await screen.findByText('Beeper Desktop connected')).toBeInTheDocument();
expect(screen.getByTestId('beeper-roster-unknown')).toHaveTextContent('Could not read the mirrored account roster');
@@ -383,7 +392,7 @@ describe('BeeperSettingsPanel — status card states', () => {
describe('BeeperSettingsPanel — inline errors are announced', () => {
it('exposes the status-fetch failure with role="alert"', async () => {
api.getBeeperStatus.mockRejectedValue(new Error('network down'));
- renderPanel();
+ await renderPanel();
expect(await screen.findByText('network down')).toHaveAttribute('role', 'alert');
});
@@ -392,7 +401,7 @@ describe('BeeperSettingsPanel — inline errors are announced', () => {
api.getBeeperStatus.mockResolvedValue({
tokenConfigured: true, reachable: true, lastProbeError: null, accounts: null, accountsError: 'Could not read the mirrored account roster',
});
- renderPanel();
+ await renderPanel();
expect(await screen.findByTestId('beeper-roster-unknown')).toHaveAttribute('role', 'alert');
});
@@ -406,7 +415,7 @@ describe('BeeperSettingsPanel — settings', () => {
enabled: true, intervalMinutes: 5, baseUrl: 'http://127.0.0.1:23373', attachmentBudgetGb: 5, allowNonLoopbackBaseUrl: false,
},
});
- renderPanel();
+ await renderPanel();
// Exact, not /Save/: the connect card's "Save token" is on screen too.
const saveButton = await screen.findByRole('button', { name: 'Save' });
@@ -433,7 +442,7 @@ describe('BeeperSettingsPanel — settings', () => {
enabled: false, intervalMinutes: 5, baseUrl: 'http://127.0.0.1:23373', attachmentBudgetGb: 5, allowNonLoopbackBaseUrl: true,
},
});
- renderPanel();
+ await renderPanel();
const checkbox = await screen.findByLabelText(/Allow a non-loopback base URL/);
expect(checkbox).not.toBeChecked();
@@ -452,7 +461,7 @@ describe('BeeperSettingsPanel — settings', () => {
api.getBeeperStatus.mockResolvedValue({
tokenConfigured: true, reachable: false, lastProbeError: 'refused', baseUrl: 'http://127.0.0.1:23373', accounts: [],
});
- renderPanel();
+ await renderPanel();
await screen.findByText('Beeper Desktop unreachable');
const retryButton = screen.getByRole('button', { name: /Retry/ });
@@ -469,7 +478,7 @@ describe('BeeperSettingsPanel — settings', () => {
it('shows the load-failed card instead of the form when settings fail to load, and never offers Save', async () => {
api.getSettings.mockRejectedValue(new Error('network error'));
api.getBeeperStatus.mockResolvedValue({ tokenConfigured: false, reachable: null, accounts: [] });
- renderPanel();
+ await renderPanel();
expect(await screen.findByText('Could not load Beeper settings')).toBeInTheDocument();
expect(screen.queryByRole('button', { name: 'Save' })).toBeNull();
@@ -487,7 +496,7 @@ describe('BeeperSettingsPanel — the connect flow (#31)', () => {
it('opens the authorization URL the server minted, rather than building one client-side', async () => {
const open = vi.spyOn(window, 'open').mockImplementation(() => null);
api.startBeeperOAuth.mockResolvedValue({ authorizationUrl: 'http://127.0.0.1:23373/oauth/authorize?state=s' });
- renderPanel();
+ await renderPanel();
fireEvent.click(await screen.findByRole('button', { name: 'Connect Beeper' }));
await waitFor(() => expect(open).toHaveBeenCalledWith('http://127.0.0.1:23373/oauth/authorize?state=s', '_blank', 'noopener'));
@@ -499,7 +508,7 @@ describe('BeeperSettingsPanel — the connect flow (#31)', () => {
// code): one call, one toast, and no second attempt.
it('reports a failed connect once and does not retry', async () => {
api.startBeeperOAuth.mockRejectedValue(new Error('Beeper authorization-server metadata unavailable (404)'));
- renderPanel();
+ await renderPanel();
fireEvent.click(await screen.findByRole('button', { name: 'Connect Beeper' }));
await waitFor(() => expect(toast.error).toHaveBeenCalledWith('Beeper authorization-server metadata unavailable (404)'));
@@ -508,7 +517,7 @@ describe('BeeperSettingsPanel — the connect flow (#31)', () => {
it('posts a pasted token, clears the field, and refreshes status', async () => {
api.saveBeeperToken.mockResolvedValue({ tokenConfigured: true, tokenExpiresAt: null, tokenSource: 'pasted' });
- renderPanel();
+ await renderPanel();
const input = await screen.findByLabelText('Or paste an access token');
expect(input).toHaveAttribute('type', 'password');
@@ -521,7 +530,7 @@ describe('BeeperSettingsPanel — the connect flow (#31)', () => {
});
it('keeps Save token disabled until something is typed', async () => {
- renderPanel();
+ await renderPanel();
const save = await screen.findByRole('button', { name: /Save token/ });
expect(save).toBeDisabled();
fireEvent.change(screen.getByLabelText('Or paste an access token'), { target: { value: 'example-beeper-token' } });
@@ -539,7 +548,7 @@ describe('BeeperSettingsPanel — expired token', () => {
tokenExpiresAt: '2026-01-01T00:00:00.000Z', tokenExpiresInDays: -3,
reachable: false, lastProbeError: 'connection refused', accounts: [],
});
- renderPanel();
+ await renderPanel();
expect(await screen.findByText('Beeper token expired')).toBeInTheDocument();
expect(screen.getByRole('button', { name: 'Reconnect Beeper' })).toBeInTheDocument();
@@ -557,7 +566,7 @@ describe('BeeperSettingsPanel — disconnect', () => {
// No window.confirm anywhere in the client — the confirmation is inline.
it('confirms inline before disconnecting', async () => {
api.disconnectBeeper.mockResolvedValue({ deleted: true, tokenConfigured: false });
- renderPanel();
+ await renderPanel();
fireEvent.click(await screen.findByRole('button', { name: /Disconnect/ }));
expect(screen.getByText('Forget this Beeper credential?')).toBeInTheDocument();
@@ -569,7 +578,7 @@ describe('BeeperSettingsPanel — disconnect', () => {
});
it('cancels without calling the API', async () => {
- renderPanel();
+ await renderPanel();
fireEvent.click(await screen.findByRole('button', { name: /Disconnect/ }));
fireEvent.click(screen.getByRole('button', { name: 'Cancel' }));
expect(screen.queryByText('Forget this Beeper credential?')).toBeNull();
@@ -588,7 +597,7 @@ describe('BeeperSettingsPanel — attachment mirror', () => {
});
it('renders the disk picture without starting anything', async () => {
- renderPanel();
+ await renderPanel();
expect(await screen.findByText('Attachment mirror')).toBeInTheDocument();
expect(screen.getByText(/of 5 GB/)).toBeInTheDocument();
expect(api.backfillBeeperAttachments).not.toHaveBeenCalled();
@@ -599,7 +608,7 @@ describe('BeeperSettingsPanel — attachment mirror', () => {
...BASE_ATTACHMENT_SUMMARY, pendingCount: 12, pendingBytes: 4 * 1024 * 1024, pendingUnknownCount: 3,
});
api.backfillBeeperAttachments.mockResolvedValue({ fetched: 12, failed: 0, bytes: 4194304, stoppedForBudget: false });
- renderPanel();
+ await renderPanel();
fireEvent.click(await screen.findByRole('button', { name: /Mirror all attachments/i }));
// The modal states BOTH numbers, and the unknown-size tail separately
@@ -616,7 +625,7 @@ describe('BeeperSettingsPanel — attachment mirror', () => {
it('cancels the consent modal without transferring anything', async () => {
api.getBeeperAttachmentSummary.mockResolvedValue({ ...BASE_ATTACHMENT_SUMMARY, pendingCount: 4, pendingBytes: 2048 });
- renderPanel();
+ await renderPanel();
fireEvent.click(await screen.findByRole('button', { name: /Mirror all attachments/i }));
fireEvent.click(await screen.findByRole('button', { name: /^Cancel$/ }));
await waitFor(() => expect(screen.queryByText(/Mirror all attachments\?/)).not.toBeInTheDocument());
@@ -625,7 +634,7 @@ describe('BeeperSettingsPanel — attachment mirror', () => {
it('reports a failed summary read instead of rendering zeros as the truth', async () => {
api.getBeeperAttachmentSummary.mockRejectedValue(new Error('Database unavailable'));
- renderPanel();
+ await renderPanel();
expect(await screen.findByText('Database unavailable')).toBeInTheDocument();
expect(screen.queryByRole('button', { name: /Mirror all attachments/i })).not.toBeInTheDocument();
});
diff --git a/client/src/test/README.md b/client/src/test/README.md
index fba7066718..39ab810317 100644
--- a/client/src/test/README.md
+++ b/client/src/test/README.md
@@ -8,6 +8,7 @@ a new one.
| File | What it's for |
| --- | --- |
+| `actWarnings.js` | Attribution for React act(...) warnings — records the test a leaked setState escaped from, so the error names it instead of the later test that caught it. |
| `ariaRefAssertions.js` | Asserts a rendered tree's `aria-controls`/`aria-labelledby` IDREFs all resolve to a real element. |
| `classNameScan.js` | Shared string-literal scanner (comment-stripping + literal walk) for the class-string convention guards. |
| `dndKeyboardDrag.js` | Drives a real `@dnd-kit` keyboard drag under happy-dom, stubbing the layout happy-dom can't provide. |
diff --git a/client/src/test/actWarnings.js b/client/src/test/actWarnings.js
new file mode 100644
index 0000000000..65ae51fa05
--- /dev/null
+++ b/client/src/test/actWarnings.js
@@ -0,0 +1,44 @@
+/**
+ * Attribution for React's "not wrapped in act(...)" warnings (#7785).
+ *
+ * The warning fires when the setState lands, which for a leaked mount-effect
+ * promise is *after* its own test has ended. `afterEach` therefore throws it
+ * while some later, innocent test is the one vitest names — so a message that
+ * reports only the component sends the next reader bisecting the wrong file.
+ *
+ * Recording the test that was running at push time is what makes the class
+ * self-diagnosing: the error can then say "leaked from A, detected during B".
+ * Pure and separate from `setup.js` so it is testable without re-running that
+ * file's global installs (console patch, storage and form-validity polyfills).
+ */
+
+/** One captured warning: the component React named, and the test it escaped. */
+export const actWarningEntry = (component, test) => ({
+ component: String(component ?? 'unknown component'),
+ test: test ?? null,
+});
+
+/**
+ * The error message for a batch of warnings caught in one `afterEach`.
+ *
+ * @param {Array<{component: string, test: string|null}>} warnings
+ * @param {string|null} caughtBy - the test whose afterEach is throwing
+ * @returns {string}
+ */
+export function formatActWarningError(warnings, caughtBy) {
+ const detectedIn = caughtBy ?? 'an unnamed test';
+ const origins = [...new Set(warnings.map(({ component, test }) => (
+ test && test !== detectedIn ? `${component} (leaked from: ${test})` : component
+ )))].join(', ');
+ // Only claim misattribution when a warning really did escape another test —
+ // saying it on a same-test leak would send the reader looking elsewhere for a
+ // bug that is right where they are.
+ const misattributed = warnings.some(({ test }) => test && test !== detectedIn);
+
+ return `React state updated outside act(...) in: ${origins}. `
+ + (misattributed
+ ? `Detected while running "${detectedIn}", but the update escaped the test named above — fix it there, not here. `
+ : '')
+ + 'Settle pending mount/interaction promises inside the test — e.g. '
+ + '`await act(async () => {})` after render — see src/test/setup.js for the idiom.';
+}
diff --git a/client/src/test/actWarnings.test.js b/client/src/test/actWarnings.test.js
new file mode 100644
index 0000000000..ad1b4975f5
--- /dev/null
+++ b/client/src/test/actWarnings.test.js
@@ -0,0 +1,65 @@
+/**
+ * The act-warning message has one job beyond reporting the component: when a
+ * leaked setState is caught by a LATER test's afterEach, it must send the
+ * reader to the test that leaked — not to the one that happened to catch it.
+ * That misattribution cost a CI bisect on #7785, so it is pinned here.
+ */
+import { describe, it, expect } from 'vitest';
+import { actWarningEntry, formatActWarningError } from './actWarnings.js';
+
+describe('actWarningEntry', () => {
+ it('keeps the component and the test that was running', () => {
+ expect(actWarningEntry('AttachmentMirrorCard', 'renders the mirror')).toEqual({
+ component: 'AttachmentMirrorCard', test: 'renders the mirror',
+ });
+ });
+
+ it('survives React naming nothing, and a warning that fired between tests', () => {
+ expect(actWarningEntry(undefined, undefined)).toEqual({ component: 'unknown component', test: null });
+ });
+});
+
+describe('formatActWarningError', () => {
+ it('points at the leaking test when another test caught the warning', () => {
+ const message = formatActWarningError(
+ [actWarningEntry('AttachmentMirrorCard', 'mounts the panel')],
+ 'keeps Save token disabled until something is typed',
+ );
+ expect(message).toContain('AttachmentMirrorCard (leaked from: mounts the panel)');
+ expect(message).toContain('fix it there, not here');
+ expect(message).toContain('"keeps Save token disabled until something is typed"');
+ });
+
+ it('does not cry misattribution when the leak is in the catching test', () => {
+ const message = formatActWarningError(
+ [actWarningEntry('AttachmentMirrorCard', 'mounts the panel')],
+ 'mounts the panel',
+ );
+ expect(message).toContain('AttachmentMirrorCard');
+ expect(message).not.toContain('leaked from');
+ expect(message).not.toContain('fix it there, not here');
+ });
+
+ it('treats a warning that fired between tests as belonging to the catcher', () => {
+ // `currentTestName` is null outside a test body; with no origin to name,
+ // claiming it escaped somewhere else would be a guess.
+ const message = formatActWarningError([actWarningEntry('Card', null)], 'some test');
+ expect(message).not.toContain('leaked from');
+ });
+
+ it('dedupes repeats but keeps two origins of the same component apart', () => {
+ const message = formatActWarningError([
+ actWarningEntry('Card', 'test A'),
+ actWarningEntry('Card', 'test A'),
+ actWarningEntry('Card', 'test B'),
+ ], 'test C');
+ expect(message).toContain('Card (leaked from: test A)');
+ expect(message).toContain('Card (leaked from: test B)');
+ expect(message.match(/leaked from: test A/g)).toHaveLength(1);
+ });
+
+ it('always carries the remedy', () => {
+ const message = formatActWarningError([actWarningEntry('Card', 'test A')], 'test A');
+ expect(message).toContain('await act(async () => {})');
+ });
+});
diff --git a/client/src/test/setup.js b/client/src/test/setup.js
index 636faca45e..e3699e74d7 100644
--- a/client/src/test/setup.js
+++ b/client/src/test/setup.js
@@ -1,9 +1,10 @@
import '@testing-library/jest-dom/vitest';
-import { afterEach } from 'vitest';
+import { afterEach, expect } from 'vitest';
import { cleanup, configure } from '@testing-library/react';
import { installTestStorage } from './storagePolyfill.js';
import { installFormValidityFix } from './formValidityPolyfill.js';
import { ASYNC_UTIL_TIMEOUT_MS } from './timeouts.js';
+import { actWarningEntry, formatActWarningError } from './actWarnings.js';
// The suite-wide Testing Library async budget. The value, and why the per-test
// and hook budgets in vitest.config.js are derived from it rather than written
@@ -79,12 +80,17 @@ if (typeof HTMLCanvasElement !== 'undefined') {
// await act(async () => {});
// (see renderConfig in src/components/meatspace/post/PostDrillConfig.test.jsx).
// Tests that assert an in-flight pending state should settle at the END instead.
+// Each entry records BOTH the component React named and the test that was
+// running when the warning fired. A leaked setState lands after its own test
+// has ended, so the afterEach that throws is routinely a different — innocent —
+// test; naming only the component sends you bisecting the wrong file.
const actWarnings = [];
const originalConsoleError = console.error;
console.error = (...args) => {
originalConsoleError(...args);
if (typeof args[0] === 'string' && args[0].includes('not wrapped in act')) {
- actWarnings.push(String(args[1] ?? 'unknown component'));
+ // Null between tests; formatActWarningError renders that case too.
+ actWarnings.push(actWarningEntry(args[1], expect.getState().currentTestName));
}
};
@@ -95,12 +101,8 @@ afterEach(() => {
globalThis.localStorage?.clear();
globalThis.sessionStorage?.clear();
if (actWarnings.length > 0) {
- const components = [...new Set(actWarnings)].join(', ');
+ const message = formatActWarningError(actWarnings, expect.getState().currentTestName);
actWarnings.length = 0;
- throw new Error(
- `React state updated outside act(...) in: ${components}. ` +
- 'Settle pending mount/interaction promises inside the test — e.g. ' +
- '`await act(async () => {})` after render — see src/test/setup.js for the idiom.'
- );
+ throw new Error(message);
}
});
diff --git a/server/services/videoGen/reactor.test.js b/server/services/videoGen/reactor.test.js
index 4dfaf0dba3..9329c1e534 100644
--- a/server/services/videoGen/reactor.test.js
+++ b/server/services/videoGen/reactor.test.js
@@ -233,7 +233,12 @@ describe('Reactor SDK adapter', () => {
meta: expect.objectContaining({ aspect: '9:16', width: 768, height: 1344 }),
})));
// The fitted copy is scratch, not a render output left beside the clip.
- await expect(stat(input.sourceImagePath)).rejects.toBeTruthy();
+ // Polled, not asserted once: finalize is awaited inside the try, while the
+ // fitted frame is removed in the finally that runs after it — so the call
+ // above can land a tick before the cleanup does. On Linux the rm usually
+ // wins that tick and a bare assertion passes; on Windows it does not, and
+ // this failed the whole matrix from a shard that changed nothing (#7786).
+ await vi.waitFor(async () => { await expect(stat(input.sourceImagePath)).rejects.toBeTruthy(); });
});
it('opens the canvas the request named, over the one the frame implies', async () => {