Skip to content

Commit 00cb5cd

Browse files
Copilothotlong
andcommitted
test: strengthen Console ObjectView navigation mode tests with click-through verification
- ListView mock now exposes onRowClick via clickable button for end-to-end flow testing - Page mode: verify mockNavigate called with record/rec-1 after row click - New_window mode: verify window.open called with /record/rec-1 in new tab after row click - Split mode: verify split detail panel renders with Close panel button after row click - Popover mode: verify fallback dialog renders after row click - Full test suite: 6,736 passed, 0 failed (366 files) Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
1 parent 97cd6c5 commit 00cb5cd

File tree

1 file changed

+25
-8
lines changed

1 file changed

+25
-8
lines changed

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

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ vi.mock('@object-ui/plugin-list', () => ({
3333
{props.schema?.selection?.type && <div data-testid="schema-selection-type">{props.schema.selection.type}</div>}
3434
{props.schema?.addRecord?.enabled && <div data-testid="schema-addRecord-enabled">addRecord</div>}
3535
{props.schema?.addRecordViaForm && <div data-testid="schema-addRecordViaForm">addRecordViaForm</div>}
36+
<button data-testid="list-row-click" onClick={() => props.onRowClick?.({ _id: 'rec-1', id: 'rec-1', name: 'Test Record' })}>Click Row</button>
3637
</div>
3738
);
3839
},
@@ -773,8 +774,11 @@ describe('ObjectView Component', () => {
773774

774775
render(<ObjectView dataSource={mockDataSource} objects={objectsWithPage} onEdit={vi.fn()} />);
775776

776-
// The grid should render, and no overlay should be visible
777-
expect(screen.getByTestId('object-grid')).toBeInTheDocument();
777+
// Click a list row — should trigger page navigation
778+
fireEvent.click(screen.getByTestId('list-row-click'));
779+
780+
// Verify React Router navigate was called with the record detail path
781+
expect(mockNavigate).toHaveBeenCalledWith('record/rec-1');
778782
});
779783

780784
it('opens new window with correct URL for new_window navigation mode', () => {
@@ -792,14 +796,18 @@ describe('ObjectView Component', () => {
792796

793797
render(<ObjectView dataSource={mockDataSource} objects={objectsWithNewWindow} onEdit={vi.fn()} />);
794798

795-
// The grid should render, no overlay visible
796-
expect(screen.getByTestId('object-grid')).toBeInTheDocument();
799+
// Click a list row — should open new window
800+
fireEvent.click(screen.getByTestId('list-row-click'));
801+
802+
// Verify window.open was called with a URL containing /record/rec-1
803+
expect(mockOpen).toHaveBeenCalledTimes(1);
804+
expect(mockOpen.mock.calls[0][0]).toContain('/record/rec-1');
805+
expect(mockOpen.mock.calls[0][1]).toBe('_blank');
797806

798807
window.open = originalOpen;
799808
});
800809

801810
it('renders split layout with mainContent when split mode is active', async () => {
802-
mockSearchParams = new URLSearchParams('recordId=rec-1');
803811
const objectsWithSplit = [
804812
{
805813
...mockObjects[0],
@@ -815,14 +823,18 @@ describe('ObjectView Component', () => {
815823

816824
render(<ObjectView dataSource={dataSourceWithFindOne} objects={objectsWithSplit} onEdit={vi.fn()} />);
817825

826+
// Click a list row — should open the split detail panel
827+
fireEvent.click(screen.getByTestId('list-row-click'));
828+
818829
// The grid should still render inside the split layout
819830
await vi.waitFor(() => {
820831
expect(screen.getByTestId('object-grid')).toBeInTheDocument();
832+
// Split mode should render the close button for the detail panel
833+
expect(screen.getByLabelText('Close panel')).toBeInTheDocument();
821834
});
822835
});
823836

824837
it('renders popover overlay without popoverTrigger using fallback dialog', async () => {
825-
mockSearchParams = new URLSearchParams('recordId=rec-1');
826838
const objectsWithPopover = [
827839
{
828840
...mockObjects[0],
@@ -838,8 +850,13 @@ describe('ObjectView Component', () => {
838850

839851
render(<ObjectView dataSource={dataSourceWithFindOne} objects={objectsWithPopover} onEdit={vi.fn()} />);
840852

841-
// The grid should render
842-
expect(screen.getByTestId('object-grid')).toBeInTheDocument();
853+
// Click a list row — should open the popover fallback dialog
854+
fireEvent.click(screen.getByTestId('list-row-click'));
855+
856+
// The popover fallback dialog should render (dialog role from Radix)
857+
await vi.waitFor(() => {
858+
expect(screen.getByRole('dialog')).toBeInTheDocument();
859+
});
843860
});
844861

845862
it('renders RecordChatterPanel inside drawer overlay when navigation mode is drawer', async () => {

0 commit comments

Comments
 (0)