-
Notifications
You must be signed in to change notification settings - Fork 2
Add missing unit tests for ListView miscellaneous properties #803
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1973,4 +1973,61 @@ describe('ListView', () => { | |
| expect(shareButton).toHaveAttribute('title', 'Sharing: collaborative'); | ||
| }); | ||
| }); | ||
|
|
||
| // ============================ | ||
| // filterableFields whitelist | ||
| // ============================ | ||
| describe('filterableFields', () => { | ||
| it('should render with filterableFields whitelist restricting available fields', () => { | ||
| const schema: ListViewSchema = { | ||
| type: 'list-view', | ||
| objectName: 'contacts', | ||
| viewType: 'grid', | ||
| fields: [ | ||
| { name: 'name', label: 'Name', type: 'text' }, | ||
| { name: 'email', label: 'Email', type: 'text' }, | ||
| { name: 'phone', label: 'Phone', type: 'text' }, | ||
| ] as any, | ||
| filterableFields: ['name', 'email'], | ||
| }; | ||
|
|
||
| renderWithProvider(<ListView schema={schema} />); | ||
| // Filter button should still be visible | ||
| const filterButton = screen.getByRole('button', { name: /filter/i }); | ||
| expect(filterButton).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| it('should render filter button when filterableFields is not set', () => { | ||
| const schema: ListViewSchema = { | ||
| type: 'list-view', | ||
| objectName: 'contacts', | ||
| viewType: 'grid', | ||
| fields: [ | ||
| { name: 'name', label: 'Name', type: 'text' }, | ||
| { name: 'email', label: 'Email', type: 'text' }, | ||
| ] as any, | ||
| }; | ||
|
|
||
| renderWithProvider(<ListView schema={schema} />); | ||
| const filterButton = screen.getByRole('button', { name: /filter/i }); | ||
| expect(filterButton).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| it('should render filter button when filterableFields is empty array', () => { | ||
| const schema: ListViewSchema = { | ||
| type: 'list-view', | ||
| objectName: 'contacts', | ||
| viewType: 'grid', | ||
| fields: [ | ||
| { name: 'name', label: 'Name', type: 'text' }, | ||
| { name: 'email', label: 'Email', type: 'text' }, | ||
| ] as any, | ||
| filterableFields: [], | ||
| }; | ||
|
|
||
| renderWithProvider(<ListView schema={schema} />); | ||
| const filterButton = screen.getByRole('button', { name: /filter/i }); | ||
| expect(filterButton).toBeInTheDocument(); | ||
| }); | ||
|
Comment on lines
+2000
to
+2031
|
||
| }); | ||
| }); | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test for filterableFields whitelist only verifies that the filter button renders, but doesn't actually verify that the whitelist is being applied. According to the implementation at ListView.tsx L883-887, filterableFields restricts which fields are available in the FilterBuilder.
To properly test this functionality, the test should:
Similar to how other tests in this file verify behavior after interactions (e.g., lines 148-168 for filter panel toggle, lines 536-543 for auto-derived userFilters), this test should verify the actual filtering behavior, not just button presence.