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

test: wait for the detail fetch before resolving it in the On This Day reader test (#10000)

Adam Eivy96d0ce8b5452
diff --git a/client/src/components/dashboard/builtins/OnThisDayWidget.navigation.test.jsx b/client/src/components/dashboard/builtins/OnThisDayWidget.navigation.test.jsx
index 03810911a7..061a6820d0 100644
--- a/client/src/components/dashboard/builtins/OnThisDayWidget.navigation.test.jsx
+++ b/client/src/components/dashboard/builtins/OnThisDayWidget.navigation.test.jsx
@@ -1,5 +1,5 @@
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
-import { act, cleanup, fireEvent, render, screen, within } from '@testing-library/react';
+import { act, cleanup, fireEvent, render, screen, waitFor, within } from '@testing-library/react';
import { MemoryRouter, Route, Routes, useLocation, useNavigate } from 'react-router';
import Brain from '../../../pages/Brain';
import OnThisDayWidget from './OnThisDayWidget';
@@ -76,6 +76,8 @@ describe('On This Day record destinations', () => {
expect(screen.queryByText('Entry not found')).toBeNull();
expect(screen.queryByRole('complementary', { name: 'Preview: Example first' })).toBeNull();
+ // findBy can resolve on the DOM mutation, before MemoryTab's passive effect has issued the fetch.
+ await waitFor(() => expect(resolveDetail).toBeTypeOf('function'));
await act(async () => resolveDetail(second));
const reader = await screen.findByRole('complementary', { name: 'Preview: Example second' });
expect(within(reader).getByText('Second full text').tagName).toBe('STRONG');
@@ -179,6 +181,7 @@ describe('On This Day record destinations', () => {
api.getBrainMemory.mockImplementation(() => new Promise(resolve => { resolveDetail = resolve; }));
mount('memory', '/brain/memory/memories/example-second');
await screen.findByRole('complementary', { name: 'Loading entry' });
+ await waitFor(() => expect(resolveDetail).toBeTypeOf('function'));
fireEvent.click(screen.getByRole('button', { name: 'Select first memory' }));
await screen.findByRole('complementary', { name: 'Preview: Example first' });
await act(async () => resolveDetail(second));