Skip to content

Commit 35d09f0

Browse files
Copilothotlong
andcommitted
Add missing filterableFields and rowHeight short/extra_tall tests
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
1 parent 252d5ac commit 35d09f0

File tree

2 files changed

+59
-0
lines changed

2 files changed

+59
-0
lines changed

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

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1973,4 +1973,57 @@ describe('ListView', () => {
19731973
expect(shareButton).toHaveAttribute('title', 'Sharing: collaborative');
19741974
});
19751975
});
1976+
1977+
// ============================
1978+
// filterableFields whitelist
1979+
// ============================
1980+
describe('filterableFields', () => {
1981+
it('should restrict filter fields to the whitelist', () => {
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+
const { container } = renderWithProvider(<ListView schema={schema} />);
1995+
expect(container).toBeTruthy();
1996+
});
1997+
1998+
it('should allow all fields when filterableFields is not set', () => {
1999+
const schema: ListViewSchema = {
2000+
type: 'list-view',
2001+
objectName: 'contacts',
2002+
viewType: 'grid',
2003+
fields: [
2004+
{ name: 'name', label: 'Name', type: 'text' },
2005+
{ name: 'email', label: 'Email', type: 'text' },
2006+
] as any,
2007+
};
2008+
2009+
const { container } = renderWithProvider(<ListView schema={schema} />);
2010+
expect(container).toBeTruthy();
2011+
});
2012+
2013+
it('should allow all fields when filterableFields is empty array', () => {
2014+
const schema: ListViewSchema = {
2015+
type: 'list-view',
2016+
objectName: 'contacts',
2017+
viewType: 'grid',
2018+
fields: [
2019+
{ name: 'name', label: 'Name', type: 'text' },
2020+
{ name: 'email', label: 'Email', type: 'text' },
2021+
] as any,
2022+
filterableFields: [],
2023+
};
2024+
2025+
const { container } = renderWithProvider(<ListView schema={schema} />);
2026+
expect(container).toBeTruthy();
2027+
});
2028+
});
19762029
});

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)