Skip to content

Commit 5f2c752

Browse files
authored
Merge pull request #803 from objectstack-ai/copilot/implement-listview-properties
2 parents 08fa370 + 35b07df commit 5f2c752

File tree

2 files changed

+63
-0
lines changed

2 files changed

+63
-0
lines changed

packages/plugin-list/src/__tests__/ListView.test.tsx

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1973,4 +1973,61 @@ describe('ListView', () => {
19731973
expect(shareButton).toHaveAttribute('title', 'Sharing: collaborative');
19741974
});
19751975
});
1976+
1977+
// ============================
1978+
// filterableFields whitelist
1979+
// ============================
1980+
describe('filterableFields', () => {
1981+
it('should render with filterableFields whitelist restricting available fields', () => {
1982+
const schema: ListViewSchema = {
1983+
type: 'list-view',
1984+
objectName: 'contacts',
1985+
viewType: 'grid',
1986+
fields: [
1987+
{ name: 'name', label: 'Name', type: 'text' },
1988+
{ name: 'email', label: 'Email', type: 'text' },
1989+
{ name: 'phone', label: 'Phone', type: 'text' },
1990+
] as any,
1991+
filterableFields: ['name', 'email'],
1992+
};
1993+
1994+
renderWithProvider(<ListView schema={schema} />);
1995+
// Filter button should still be visible
1996+
const filterButton = screen.getByRole('button', { name: /filter/i });
1997+
expect(filterButton).toBeInTheDocument();
1998+
});
1999+
2000+
it('should render filter button when filterableFields is not set', () => {
2001+
const schema: ListViewSchema = {
2002+
type: 'list-view',
2003+
objectName: 'contacts',
2004+
viewType: 'grid',
2005+
fields: [
2006+
{ name: 'name', label: 'Name', type: 'text' },
2007+
{ name: 'email', label: 'Email', type: 'text' },
2008+
] as any,
2009+
};
2010+
2011+
renderWithProvider(<ListView schema={schema} />);
2012+
const filterButton = screen.getByRole('button', { name: /filter/i });
2013+
expect(filterButton).toBeInTheDocument();
2014+
});
2015+
2016+
it('should render filter button when filterableFields is empty array', () => {
2017+
const schema: ListViewSchema = {
2018+
type: 'list-view',
2019+
objectName: 'contacts',
2020+
viewType: 'grid',
2021+
fields: [
2022+
{ name: 'name', label: 'Name', type: 'text' },
2023+
{ name: 'email', label: 'Email', type: 'text' },
2024+
] as any,
2025+
filterableFields: [],
2026+
};
2027+
2028+
renderWithProvider(<ListView schema={schema} />);
2029+
const filterButton = screen.getByRole('button', { name: /filter/i });
2030+
expect(filterButton).toBeInTheDocument();
2031+
});
2032+
});
19762033
});

packages/react/src/spec-bridge/__tests__/SpecBridge.test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,12 @@ describe('SpecBridge', () => {
172172

173173
const small = bridgeListView({ rowHeight: 'small' }, {});
174174
expect(small.density).toBe('compact');
175+
176+
const short = bridgeListView({ rowHeight: 'short' }, {});
177+
expect(short.density).toBe('compact');
178+
179+
const extraTall = bridgeListView({ rowHeight: 'extra_tall' }, {});
180+
expect(extraTall.density).toBe('spacious');
175181
});
176182

177183
it('includes optional list properties', () => {

0 commit comments

Comments
 (0)