Skip to content

Commit dc11eef

Browse files
Copilothotlong
andcommitted
fix: address code review - add error logging, improve test assertions, simplify condition
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
1 parent 4109f02 commit dc11eef

2 files changed

Lines changed: 12 additions & 2 deletions

File tree

packages/plugin-detail/src/RelatedList.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,10 @@ export const RelatedList: React.FC<RelatedListProps> = ({
8686

8787
// Auto-fetch object schema when api/dataSource available but columns missing
8888
React.useEffect(() => {
89-
if (api && dataSource?.getObjectSchema && (!columns || columns.length === 0)) {
90-
dataSource.getObjectSchema(api).then(setObjectSchema).catch(() => {});
89+
if (api && dataSource?.getObjectSchema && !columns?.length) {
90+
dataSource.getObjectSchema(api).then(setObjectSchema).catch((err: unknown) => {
91+
console.warn(`[RelatedList] Failed to fetch schema for ${api}:`, err);
92+
});
9193
}
9294
}, [api, dataSource, columns]);
9395

packages/plugin-detail/src/__tests__/RelatedList.test.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,14 @@ describe('RelatedList', () => {
9191
await waitFor(() => {
9292
expect(mockDataSource.getObjectSchema).toHaveBeenCalledWith('order_item');
9393
});
94+
95+
// Verify columns are generated from schema (excluding _id)
96+
await waitFor(() => {
97+
expect(screen.getByText('Product')).toBeInTheDocument();
98+
expect(screen.getByText('Quantity')).toBeInTheDocument();
99+
});
100+
// _id should be filtered out
101+
expect(screen.queryByText('ID')).not.toBeInTheDocument();
94102
});
95103

96104
it('should not fetch object schema when explicit columns are provided', () => {

0 commit comments

Comments
 (0)