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

review: update CatalogIngredient test to batched details mock; setLoading(false) on load error

[._.]/ Adam Eivy9d369475b1ae
diff --git a/client/src/pages/CatalogIngredient.jsx b/client/src/pages/CatalogIngredient.jsx
index 80c79b8f1e..4d17b9de5f 100644
--- a/client/src/pages/CatalogIngredient.jsx
+++ b/client/src/pages/CatalogIngredient.jsx
@@ -95,6 +95,7 @@ export default function CatalogIngredient() {
.then((d) => {
if (cancelled) return;
if (!d?.ingredient) {
+ setLoading(false);
toast.error('Ingredient not found');
navigate('/catalog');
return;
@@ -115,6 +116,7 @@ export default function CatalogIngredient() {
})
.catch((err) => {
if (cancelled) return;
+ setLoading(false);
toast.error(err?.message || 'Failed to load ingredient');
navigate('/catalog');
});
diff --git a/client/src/pages/CatalogIngredient.test.jsx b/client/src/pages/CatalogIngredient.test.jsx
index fdc73b2e48..1282b335eb 100644
--- a/client/src/pages/CatalogIngredient.test.jsx
+++ b/client/src/pages/CatalogIngredient.test.jsx
@@ -40,8 +40,22 @@ const { CHAR_FIXTURE } = vi.hoisted(() => ({
},
}));
+// The detail page now hydrates via the batched getCatalogIngredientDetails
+// ({ ingredient, refs, sources, relations, revisions, media, missingMedia }).
+const { detailsOf } = vi.hoisted(() => ({
+ detailsOf: (ing) => ({
+ ingredient: ing,
+ refs: ing.refs || [],
+ sources: ing.sources || [],
+ relations: { outbound: [], inbound: [] },
+ revisions: [],
+ media: [],
+ missingMedia: [],
+ }),
+}));
+
vi.mock('../services/apiCatalog', () => ({
- getCatalogIngredient: vi.fn(async () => CHAR_FIXTURE),
+ getCatalogIngredientDetails: vi.fn(async () => detailsOf(CHAR_FIXTURE)),
updateCatalogIngredient: vi.fn(),
deleteCatalogIngredient: vi.fn(),
listCatalogIngredientRelations: vi.fn(async () => ({ outbound: [], inbound: [] })),
@@ -63,12 +77,12 @@ vi.mock('../components/TagPicker', () => ({ default: () => <div data-testid="tag
vi.mock('../components/ui/Toast', () => ({ default: { success: vi.fn(), error: vi.fn(), info: vi.fn() } }));
import CatalogIngredient from './CatalogIngredient';
-import { getCatalogIngredient } from '../services/apiCatalog';
+import { getCatalogIngredientDetails } from '../services/apiCatalog';
const renderPage = () => render(<MemoryRouter><CatalogIngredient /></MemoryRouter>);
beforeEach(() => {
- getCatalogIngredient.mockImplementation(async () => CHAR_FIXTURE);
+ getCatalogIngredientDetails.mockImplementation(async () => detailsOf(CHAR_FIXTURE));
});
describe('CatalogIngredient — character sheet', () => {
@@ -99,7 +113,7 @@ describe('CatalogIngredient — character sheet', () => {
});
it('shows an existing reference sheet image when payload carries one', async () => {
- getCatalogIngredient.mockImplementation(async () => ({
+ getCatalogIngredientDetails.mockImplementation(async () => detailsOf({
...CHAR_FIXTURE,
payload: { ...CHAR_FIXTURE.payload, referenceSheetImageRef: 'sheet-123.png' },
}));