Skip to content

Commit 64eb668

Browse files
Copilothotlong
andcommitted
fix: update console ObjectManagerPage tests for new ObjectGrid-based DOM structure
Agent-Logs-Url: https://github.com/objectstack-ai/objectui/sessions/1fc56880-e6fe-4a79-b357-ecc715973306 Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
1 parent 1409008 commit 64eb668

1 file changed

Lines changed: 14 additions & 25 deletions

File tree

apps/console/src/__tests__/ObjectManagerPage.test.tsx

Lines changed: 14 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -109,26 +109,17 @@ describe('ObjectManagerPage', () => {
109109
it('should show FieldDesigner when an object row is clicked', async () => {
110110
renderPage();
111111

112-
// The ObjectGrid renders asynchronously - wait for it and find a clickable row
112+
// ObjectGrid renders data asynchronously via ValueDataSource.
113+
// Once loaded, primary field values become clickable links (data-testid="primary-field-link").
113114
await waitFor(() => {
114-
// Look for a row-click button rendered by ObjectGrid
115-
const selectBtn = screen.queryByTestId('grid-row-click-account');
116-
if (selectBtn) {
117-
fireEvent.click(selectBtn);
118-
} else {
119-
// ObjectGrid renders table rows - clicking "Accounts" text triggers onRowClick
120-
const accountText = screen.getAllByText('Accounts');
121-
const clickable = accountText.find(
122-
(el) => el.tagName === 'BUTTON' || el.closest('button') || el.closest('tr')
123-
);
124-
if (clickable) {
125-
fireEvent.click(clickable.closest('button') || clickable.closest('tr') || clickable);
126-
}
115+
const links = screen.queryAllByTestId('primary-field-link');
116+
if (links.length > 0) {
117+
// Click the first object's primary field link
118+
fireEvent.click(links[0]);
127119
}
128120
});
129121

130-
// Either FieldDesigner shows or we're still on the object list
131-
// The integration depends on the actual ObjectGrid rendering
122+
// Either FieldDesigner shows (if primary-field-link was found) or ObjectManager remains
132123
const fieldDesigner = screen.queryByTestId('field-designer');
133124
const objectManager = screen.queryByTestId('object-manager');
134125
expect(fieldDesigner || objectManager).toBeDefined();
@@ -137,15 +128,14 @@ describe('ObjectManagerPage', () => {
137128
it('should show back button when a field designer is active', async () => {
138129
renderPage();
139130

140-
// Try to select an object via ObjectGrid's row click
141131
await waitFor(() => {
142-
const selectBtn = screen.queryByTestId('grid-row-click-account');
143-
if (selectBtn) {
144-
fireEvent.click(selectBtn);
132+
const links = screen.queryAllByTestId('primary-field-link');
133+
if (links.length > 0) {
134+
fireEvent.click(links[0]);
145135
}
146136
});
147137

148-
// If the field designer is shown, back button should be present
138+
// If field designer is active, back button should be present
149139
const backBtn = screen.queryByTestId('back-to-objects');
150140
const fieldDesigner = screen.queryByTestId('field-designer');
151141
if (fieldDesigner) {
@@ -156,11 +146,10 @@ describe('ObjectManagerPage', () => {
156146
it('should return to object list when back button is clicked', async () => {
157147
renderPage();
158148

159-
// Try to select an object
160149
await waitFor(() => {
161-
const selectBtn = screen.queryByTestId('grid-row-click-account');
162-
if (selectBtn) {
163-
fireEvent.click(selectBtn);
150+
const links = screen.queryAllByTestId('primary-field-link');
151+
if (links.length > 0) {
152+
fireEvent.click(links[0]);
164153
}
165154
});
166155

0 commit comments

Comments
 (0)