diff --git a/frontend/appflowy_flutter/integration_test/desktop/database/database_filter_test.dart b/frontend/appflowy_flutter/integration_test/desktop/database/database_filter_test.dart index b6db3e1a62f5..1da2e625a52f 100644 --- a/frontend/appflowy_flutter/integration_test/desktop/database/database_filter_test.dart +++ b/frontend/appflowy_flutter/integration_test/desktop/database/database_filter_test.dart @@ -1,6 +1,6 @@ import 'package:appflowy/plugins/database/grid/presentation/widgets/filter/choicechip/checkbox.dart'; import 'package:appflowy/plugins/database/grid/presentation/widgets/filter/choicechip/text.dart'; -import 'package:appflowy_backend/protobuf/flowy-database2/field_entities.pbenum.dart'; +import 'package:appflowy_backend/protobuf/flowy-database2/protobuf.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:integration_test/integration_test.dart'; @@ -138,5 +138,27 @@ void main() { await tester.pumpAndSettle(); }); + + testWidgets('add date filter', (tester) async { + await tester.openV020database(); + + // create a filter + await tester.tapDatabaseFilterButton(); + await tester.tapCreateFilterByFieldType(FieldType.DateTime, 'date'); + + // By default, the condition of date filter is current day and time + await tester.assertNumberOfRowsInGridPage(0); + + await tester.tapFilterButtonInGrid('date'); + await tester.tapDateFilterButtonInGrid(); + await tester.tapDateFilterCondition(DateFilterConditionPB.DateBefore); + await tester.assertNumberOfRowsInGridPage(7); + + await tester.tapDateFilterButtonInGrid(); + await tester.tapDateFilterCondition(DateFilterConditionPB.DateIsEmpty); + await tester.assertNumberOfRowsInGridPage(3); + + await tester.pumpAndSettle(); + }); }); } diff --git a/frontend/appflowy_flutter/integration_test/shared/database_test_op.dart b/frontend/appflowy_flutter/integration_test/shared/database_test_op.dart index b25fb056a586..a8fc3a25b678 100644 --- a/frontend/appflowy_flutter/integration_test/shared/database_test_op.dart +++ b/frontend/appflowy_flutter/integration_test/shared/database_test_op.dart @@ -24,6 +24,7 @@ import 'package:appflowy/plugins/database/grid/presentation/widgets/filter/choic import 'package:appflowy/plugins/database/grid/presentation/widgets/filter/choicechip/select_option/option_list.dart'; import 'package:appflowy/plugins/database/grid/presentation/widgets/filter/choicechip/select_option/select_option.dart'; import 'package:appflowy/plugins/database/grid/presentation/widgets/filter/choicechip/text.dart'; +import 'package:appflowy/plugins/database/grid/presentation/widgets/filter/choicechip/date.dart'; import 'package:appflowy/plugins/database/grid/presentation/widgets/filter/create_filter_list.dart'; import 'package:appflowy/plugins/database/grid/presentation/widgets/filter/disclosure_button.dart'; import 'package:appflowy/plugins/database/grid/presentation/widgets/filter/filter_menu_item.dart'; @@ -1057,6 +1058,10 @@ extension AppFlowyDatabaseTest on WidgetTester { await tapButton(find.byType(ChecklistFilterConditionList)); } + Future tapDateFilterButtonInGrid() async { + await tapButton(find.byType(DateFilterConditionPBList)); + } + /// The [SelectOptionFilterList] must show up first. Future tapOptionFilterWithName(String name) async { final findCell = find.descendant( @@ -1090,6 +1095,15 @@ extension AppFlowyDatabaseTest on WidgetTester { await tapButton(button); } + Future tapDateFilterCondition(DateFilterConditionPB condition) async { + final button = find.descendant( + of: find.byType(HoverButton), + matching: find.text(condition.filterName), + ); + + await tapButton(button); + } + /// Should call [tapDatabaseSettingButton] first. Future tapViewPropertiesButton() async { final findSettingItem = find.byType(DatabaseSettingsList);