Skip to content

Commit e2c3cb0

Browse files
Copilothotlong
andcommitted
test: add ListColumn[] inline data + objectSchema enrichment test
Covers the case where ListColumn[] columns have no explicit type and rely on objectSchema for type resolution with inline data + dataSource. Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
1 parent d09929c commit e2c3cb0

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

packages/plugin-grid/src/__tests__/objectdef-enrichment.test.tsx

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -522,4 +522,45 @@ describe('Inline data with DataSource schema fetch', () => {
522522
// find() should NOT be called
523523
expect(mockDataSource.find).not.toHaveBeenCalled();
524524
});
525+
526+
it('should enrich ListColumn[] with objectSchema types when inline data + dataSource', async () => {
527+
const mockDataSource = createMockDataSource(opportunitySchema, []);
528+
529+
const schema: any = {
530+
type: 'object-grid' as const,
531+
objectName: 'opportunity',
532+
data: { provider: 'value', items: opportunityData },
533+
// ListColumn[] without explicit type — objectSchema should provide types
534+
columns: [
535+
{ field: 'name', label: 'Name' },
536+
{ field: 'stage', label: 'Stage' },
537+
{ field: 'amount', label: 'Amount' },
538+
],
539+
};
540+
541+
render(
542+
<ActionProvider>
543+
<ObjectGrid schema={schema} dataSource={mockDataSource} />
544+
</ActionProvider>
545+
);
546+
547+
// Schema should be fetched
548+
await waitFor(() => {
549+
expect(mockDataSource.getObjectSchema).toHaveBeenCalledWith('opportunity');
550+
});
551+
552+
// Stage should render with colored badge from objectSchema select options
553+
await waitFor(() => {
554+
const closedWonBadge = screen.getByText('Closed Won');
555+
expect(closedWonBadge).toHaveClass('bg-green-100');
556+
});
557+
558+
// Amount should be formatted as currency from objectSchema type
559+
await waitFor(() => {
560+
expect(screen.getByText('$150,000.00')).toBeInTheDocument();
561+
});
562+
563+
// find() should NOT be called
564+
expect(mockDataSource.find).not.toHaveBeenCalled();
565+
});
525566
});

0 commit comments

Comments
 (0)