Skip to content

Commit 60ee942

Browse files
Copilothotlong
andcommitted
fix: update ListView tests to match inline search input behavior, remove unused searchExpanded state
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
1 parent 3b014cb commit 60ee942

2 files changed

Lines changed: 17 additions & 30 deletions

File tree

packages/plugin-list/src/ListView.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -888,8 +888,6 @@ export const ListView: React.FC<ListViewProps> = ({
888888
return fields;
889889
}, [objectDef, schema.fields, schema.filterableFields]);
890890

891-
const [searchExpanded, setSearchExpanded] = React.useState(false);
892-
893891
// Quick filter toggle handler
894892
const toggleQuickFilter = React.useCallback((id: string) => {
895893
setActiveQuickFilters(prev => {

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

Lines changed: 17 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ describe('ListView', () => {
6666
expect(container).toBeTruthy();
6767
});
6868

69-
it('should render search button', () => {
69+
it('should render search input', () => {
7070
const schema: ListViewSchema = {
7171
type: 'list-view',
7272
objectName: 'contacts',
@@ -75,8 +75,8 @@ describe('ListView', () => {
7575
};
7676

7777
renderWithProvider(<ListView schema={schema} />);
78-
const searchButton = screen.getByRole('button', { name: /search/i });
79-
expect(searchButton).toBeInTheDocument();
78+
const searchInput = screen.getByPlaceholderText(/search/i);
79+
expect(searchInput).toBeInTheDocument();
8080
});
8181

8282
it('should expand search and call onSearchChange when search input changes', () => {
@@ -90,11 +90,7 @@ describe('ListView', () => {
9090

9191
renderWithProvider(<ListView schema={schema} onSearchChange={onSearchChange} />);
9292

93-
// Click search button to expand
94-
const searchButton = screen.getByRole('button', { name: /search/i });
95-
fireEvent.click(searchButton);
96-
97-
const searchInput = screen.getByPlaceholderText(/find/i);
93+
const searchInput = screen.getByPlaceholderText(/search/i);
9894
fireEvent.change(searchInput, { target: { value: 'test' } });
9995
expect(onSearchChange).toHaveBeenCalledWith('test');
10096
});
@@ -201,17 +197,13 @@ describe('ListView', () => {
201197

202198
renderWithProvider(<ListView schema={schema} />);
203199

204-
// Click search button to expand search input
205-
const searchButton = screen.getByRole('button', { name: /search/i });
206-
fireEvent.click(searchButton);
207-
208-
const searchInput = screen.getByPlaceholderText(/find/i) as HTMLInputElement;
200+
const searchInput = screen.getByPlaceholderText(/search/i) as HTMLInputElement;
209201

210202
// Type in search
211203
fireEvent.change(searchInput, { target: { value: 'test' } });
212204
expect(searchInput.value).toBe('test');
213205

214-
// Find and click clear button (the X button inside the expanded search)
206+
// Find and click clear button (the X button inside the search area)
215207
const buttons = screen.getAllByRole('button');
216208
const clearButton = buttons.find(btn =>
217209
btn.querySelector('svg') !== null && searchInput.value !== ''
@@ -603,7 +595,7 @@ describe('ListView', () => {
603595
// Toolbar Toggle Visibility
604596
// ============================
605597
describe('Toolbar Toggle Visibility', () => {
606-
it('should hide Search button when showSearch is false', () => {
598+
it('should hide Search input when showSearch is false', () => {
607599
const schema: ListViewSchema = {
608600
type: 'list-view',
609601
objectName: 'contacts',
@@ -613,10 +605,10 @@ describe('ListView', () => {
613605
};
614606

615607
renderWithProvider(<ListView schema={schema} />);
616-
expect(screen.queryByRole('button', { name: /search/i })).not.toBeInTheDocument();
608+
expect(screen.queryByPlaceholderText(/search/i)).not.toBeInTheDocument();
617609
});
618610

619-
it('should show Search button when showSearch is true', () => {
611+
it('should show Search input when showSearch is true', () => {
620612
const schema: ListViewSchema = {
621613
type: 'list-view',
622614
objectName: 'contacts',
@@ -626,10 +618,10 @@ describe('ListView', () => {
626618
};
627619

628620
renderWithProvider(<ListView schema={schema} />);
629-
expect(screen.getByRole('button', { name: /search/i })).toBeInTheDocument();
621+
expect(screen.getByPlaceholderText(/search/i)).toBeInTheDocument();
630622
});
631623

632-
it('should show Search button when showSearch is undefined (default)', () => {
624+
it('should show Search input when showSearch is undefined (default)', () => {
633625
const schema: ListViewSchema = {
634626
type: 'list-view',
635627
objectName: 'contacts',
@@ -638,7 +630,7 @@ describe('ListView', () => {
638630
};
639631

640632
renderWithProvider(<ListView schema={schema} />);
641-
expect(screen.getByRole('button', { name: /search/i })).toBeInTheDocument();
633+
expect(screen.getByPlaceholderText(/search/i)).toBeInTheDocument();
642634
});
643635

644636
it('should hide Filter button when showFilters is false', () => {
@@ -1222,7 +1214,7 @@ describe('ListView', () => {
12221214
};
12231215

12241216
renderWithProvider(<ListView schema={schema} />);
1225-
expect(screen.queryByRole('button', { name: /search/i })).not.toBeInTheDocument();
1217+
expect(screen.queryByPlaceholderText(/search/i)).not.toBeInTheDocument();
12261218
});
12271219

12281220
it('should hide Sort when userActions.sort is false', () => {
@@ -1274,7 +1266,7 @@ describe('ListView', () => {
12741266
};
12751267

12761268
renderWithProvider(<ListView schema={schema} />);
1277-
expect(screen.getByRole('button', { name: /search/i })).toBeInTheDocument();
1269+
expect(screen.getByPlaceholderText(/search/i)).toBeInTheDocument();
12781270
expect(screen.getByRole('button', { name: /^sort$/i })).toBeInTheDocument();
12791271
expect(screen.getByRole('button', { name: /filter/i })).toBeInTheDocument();
12801272
expect(screen.getByTitle(/density/i)).toBeInTheDocument();
@@ -1291,7 +1283,7 @@ describe('ListView', () => {
12911283
};
12921284

12931285
renderWithProvider(<ListView schema={schema} />);
1294-
expect(screen.queryByRole('button', { name: /search/i })).not.toBeInTheDocument();
1286+
expect(screen.queryByPlaceholderText(/search/i)).not.toBeInTheDocument();
12951287
});
12961288
});
12971289

@@ -1456,11 +1448,8 @@ describe('ListView', () => {
14561448

14571449
renderWithProvider(<ListView schema={schema} dataSource={mockDataSource} />);
14581450

1459-
// Click search button to expand
1460-
const searchButton = screen.getByRole('button', { name: /search/i });
1461-
fireEvent.click(searchButton);
1462-
1463-
const searchInput = screen.getByPlaceholderText(/find/i);
1451+
// Search input is always visible inline
1452+
const searchInput = screen.getByPlaceholderText(/search/i);
14641453
fireEvent.change(searchInput, { target: { value: 'alice' } });
14651454

14661455
// Wait for debounced fetch

0 commit comments

Comments
 (0)