-
Notifications
You must be signed in to change notification settings - Fork 0
feat(search-list): optional trailing widget beside the search field [REQ-177] #209
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
be64add
feat(search-list): optional trailing widget beside the search field […
rgulati-f2k 947538f
chore: ignore agent runtime notes [REQ-177]
rgulati-f2k 2b40c46
fix(search-list): fix vacuous trailing tests + add SearchList coverag…
rgulati-f2k ff4a6d7
style(search-list): address review nits on test comments [REQ-177]
rgulati-f2k 3dc1488
fix(search-list): drop unnecessary source comments [REQ-177]
rgulati-f2k File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -83,3 +83,8 @@ build/ | |
|
|
||
| # FVM Version Cache | ||
| .fvm/ | ||
|
|
||
| # Agent runtime notes (never committed) | ||
| AI_AGENT_CHANGES/ | ||
| AGENT.md | ||
| AGENTS.md | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| // [REQ-177] IntegratedSearchTextField.trailing: an optional widget rendered beside the | ||
| // search field. Null by default, so an existing consumer's widget tree is unchanged. | ||
| import 'package:fa_flutter_ui_kit/src/modules/common/search_list/integrated_search_textfield.dart'; | ||
| import 'package:flutter/material.dart'; | ||
| import 'package:flutter_test/flutter_test.dart'; | ||
|
|
||
| void main() { | ||
| Widget wrap(Widget child) => MaterialApp(home: Scaffold(body: child)); | ||
|
|
||
| testWidgets( | ||
| 'renders the Card directly (no wrapping Row) when trailing is null', | ||
| (tester) async { | ||
| await tester.pumpWidget( | ||
| wrap( | ||
| IntegratedSearchTextField( | ||
| searchFieldLabel: 'Search', | ||
| queryTextController: TextEditingController(), | ||
| ), | ||
| ), | ||
| ); | ||
|
|
||
| // find.byKey('search-trailing') can never fail here since that | ||
| // key is only ever attached by a caller-supplied trailing widget — assert the actual | ||
| // structural invariant instead: the outer Padding's child is the Card itself, not a Row. | ||
| final padding = tester.widget<Padding>( | ||
| find.byKey(const Key('integrated-search-textfield-padding'))); | ||
| expect(padding.child, isA<Card>()); | ||
| expect(find.byType(TextField), findsOneWidget); | ||
| }); | ||
|
|
||
| testWidgets( | ||
| 'renders the trailing widget beside the search field, inside a Row, when supplied', | ||
| (tester) async { | ||
| await tester.pumpWidget( | ||
| wrap( | ||
| IntegratedSearchTextField( | ||
| searchFieldLabel: 'Search', | ||
| queryTextController: TextEditingController(), | ||
| trailing: const Icon(Icons.filter_list, key: Key('search-trailing')), | ||
| ), | ||
| ), | ||
| ); | ||
|
|
||
| expect(find.byKey(const Key('search-trailing')), findsOneWidget); | ||
| expect(find.byType(TextField), findsOneWidget); | ||
|
|
||
| // find.byType(Row) alone also matches the suffixIcon Row inside | ||
| // the TextField's decoration, so it passes even if `trailing` were placed elsewhere. | ||
| // Assert the actual wiring: the outer Padding's child is a Row whose children are | ||
| // Expanded(searchCard) followed by the trailing widget itself. | ||
| final padding = tester.widget<Padding>( | ||
| find.byKey(const Key('integrated-search-textfield-padding'))); | ||
| expect(padding.child, isA<Row>()); | ||
| final row = padding.child! as Row; | ||
| expect(row.children.first, isA<Expanded>()); | ||
| expect((row.children.first as Expanded).child, isA<Card>()); | ||
| expect(row.children.last.key, const Key('search-trailing')); | ||
| }); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| // SearchList.searchBarTrailing is plumbed to IntegratedSearchTextField | ||
| // on both the SearchBarInBody and SearchWithAppBar code paths, but neither was pumped by a | ||
| // widget test. Covers both here. | ||
| import 'package:fa_flutter_ui_kit/src/modules/common/search_list/search_list.dart'; | ||
| import 'package:flutter/material.dart'; | ||
| import 'package:flutter_test/flutter_test.dart'; | ||
|
|
||
| void main() { | ||
| Widget buildSearchList(SearchListType type) { | ||
| return MaterialApp( | ||
| home: SearchList<String>( | ||
| data: const ['Alpha', 'Beta'], | ||
| selectedItem: (_) {}, | ||
| itemBuilder: (item, isSelected) => Text(item), | ||
| type: type, | ||
| searchBarTrailing: | ||
| const Icon(Icons.filter_list, key: Key('search-trailing')), | ||
| ), | ||
| ); | ||
| } | ||
|
|
||
| testWidgets( | ||
| 'SearchBarInBody renders searchBarTrailing beside the search field', | ||
| (tester) async { | ||
| await tester.pumpWidget(buildSearchList(SearchListType.SearchBarInBody)); | ||
| await tester.pump(); | ||
|
|
||
| expect(find.byKey(const Key('search-trailing')), findsOneWidget); | ||
| }); | ||
|
|
||
| testWidgets( | ||
| 'SearchWithAppBar renders searchBarTrailing beside the search field', | ||
| (tester) async { | ||
| await tester.pumpWidget(buildSearchList(SearchListType.SearchWithAppBar)); | ||
| await tester.pump(); | ||
|
|
||
| expect(find.byKey(const Key('search-trailing')), findsOneWidget); | ||
| }); | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.