Skip to content

Commit 1c69eaa

Browse files
Copilothotlong
andcommitted
chore: report initial plan for fixing object list click-to-detail navigation
Agent-Logs-Url: https://github.com/objectstack-ai/objectui/sessions/2766f2c6-b5ea-42f9-8327-dd8201c1afb7 Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
1 parent ff47289 commit 1c69eaa

File tree

1 file changed

+67
-0
lines changed

1 file changed

+67
-0
lines changed
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
/**
2+
* Quick diagnostic test: verify clicking primary-field-link navigates to detail
3+
*/
4+
import { describe, it, expect, vi } from 'vitest';
5+
import { render, screen, waitFor, fireEvent, act } from '@testing-library/react';
6+
import { MemoryRouter, Routes, Route, useLocation } from 'react-router-dom';
7+
import { ObjectManagerPage } from '../pages/system/ObjectManagerPage';
8+
9+
vi.mock('../context/MetadataProvider', () => ({
10+
useMetadata: () => ({
11+
objects: [
12+
{
13+
name: 'account',
14+
label: 'Accounts',
15+
fields: [
16+
{ name: 'id', type: 'text', label: 'ID', readonly: true },
17+
{ name: 'name', type: 'text', label: 'Account Name' },
18+
],
19+
},
20+
],
21+
refresh: vi.fn(),
22+
}),
23+
}));
24+
25+
vi.mock('sonner', () => ({ toast: { success: vi.fn(), error: vi.fn() } }));
26+
27+
function LocationDisplay() {
28+
const location = useLocation();
29+
return <div data-testid="location-display">{location.pathname}</div>;
30+
}
31+
32+
describe('click-to-navigate diagnostic', () => {
33+
it('should show primary-field-link buttons after data loads', async () => {
34+
render(
35+
<MemoryRouter initialEntries={['/system/objects']}>
36+
<Routes>
37+
<Route path="/system/objects" element={<><ObjectManagerPage /><LocationDisplay /></>} />
38+
<Route path="/system/objects/:objectName" element={<><ObjectManagerPage /><LocationDisplay /></>} />
39+
</Routes>
40+
</MemoryRouter>
41+
);
42+
43+
// Wait for ObjectGrid async data to load
44+
let links: HTMLElement[] = [];
45+
await waitFor(() => {
46+
links = screen.queryAllByTestId('primary-field-link');
47+
expect(links.length).toBeGreaterThan(0);
48+
}, { timeout: 5000 });
49+
50+
console.log('Found primary-field-link buttons:', links.length);
51+
console.log('Current location:', screen.getByTestId('location-display').textContent);
52+
53+
// Click the first primary field link
54+
await act(async () => {
55+
fireEvent.click(links[0]);
56+
});
57+
58+
console.log('After click location:', screen.getByTestId('location-display').textContent);
59+
60+
// Should navigate to detail view
61+
await waitFor(() => {
62+
const loc = screen.getByTestId('location-display').textContent;
63+
console.log('Final location:', loc);
64+
expect(loc).toBe('/system/objects/account');
65+
}, { timeout: 5000 });
66+
});
67+
});

0 commit comments

Comments
 (0)