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([client-tests-for-deep-routing-drag-smoke-tests-for]): address codex review iter-1

[._.]/ Adam Eivy6f081c1d6d92
diff --git a/client/src/components/universeBuilder/InfluenceChipsInput.test.jsx b/client/src/components/universeBuilder/InfluenceChipsInput.test.jsx
index 874040835b..9c1eaaa37d 100644
--- a/client/src/components/universeBuilder/InfluenceChipsInput.test.jsx
+++ b/client/src/components/universeBuilder/InfluenceChipsInput.test.jsx
@@ -57,9 +57,15 @@ const fireDragEnd = (activeId, overId) => act(() => {
describe('InfluenceChipsInput — chip-reorder smoke tests', () => {
it('renders the token chips in order', () => {
render(<InfluenceChipsInput tokens={['alpha', 'bravo', 'charlie']} onChange={() => {}} />);
- expect(screen.getByText('alpha')).toBeInTheDocument();
- expect(screen.getByText('bravo')).toBeInTheDocument();
- expect(screen.getByText('charlie')).toBeInTheDocument();
+ // Assert DOM order via the per-chip drag-handle aria-labels — they share
+ // a parent ordering with the visible chip text and are uniquely scoped
+ // to each chip, so we don't pick up the label-via-token side text.
+ const handles = screen.getAllByLabelText(/Drag (alpha|bravo|charlie) to reorder/);
+ expect(handles.map((h) => h.getAttribute('aria-label'))).toEqual([
+ 'Drag alpha to reorder',
+ 'Drag bravo to reorder',
+ 'Drag charlie to reorder',
+ ]);
});
it('calls onChange with the reordered tokens when a chip moves forward', () => {
@@ -110,6 +116,15 @@ describe('InfluenceChipsInput — chip-reorder smoke tests', () => {
expect(onChange).not.toHaveBeenCalled();
});
+ it('does not call onChange when over id is not in the list (stale target)', () => {
+ const onChange = vi.fn();
+ render(<InfluenceChipsInput tokens={['alpha', 'bravo', 'charlie']} onChange={onChange} />);
+
+ fireDragEnd('alpha', 'ghost');
+
+ expect(onChange).not.toHaveBeenCalled();
+ });
+
it('removes a chip via the X button', async () => {
const onChange = vi.fn();
const user = userEvent.setup();
diff --git a/client/src/hooks/useUniverseNav.js b/client/src/hooks/useUniverseNav.js
index 01f0aea9aa..e96e90d999 100644
--- a/client/src/hooks/useUniverseNav.js
+++ b/client/src/hooks/useUniverseNav.js
@@ -1,3 +1,4 @@
+import { useCallback } from 'react';
import { useLocation, useNavigate } from 'react-router-dom';
// Strips any trailing `/:universeId` (or deeper path) so the result is always
@@ -17,8 +18,8 @@ export function useUniverseNav() {
const navigate = useNavigate();
const location = useLocation();
const basePath = universeBuilderBasePath(location.pathname);
- return (id) => navigate({
+ return useCallback((id) => navigate({
pathname: id ? `${basePath}/${encodeURIComponent(id)}` : basePath,
search: location.search,
- });
+ }), [navigate, basePath, location.search]);
}