Skip to content

Commit

Permalink
test: added date filter test
Browse files Browse the repository at this point in the history
  • Loading branch information
zoli committed Sep 12, 2024
1 parent c6352b2 commit 9e715ed
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -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';

Expand Down Expand Up @@ -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();
});
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -1057,6 +1058,10 @@ extension AppFlowyDatabaseTest on WidgetTester {
await tapButton(find.byType(ChecklistFilterConditionList));
}

Future<void> tapDateFilterButtonInGrid() async {
await tapButton(find.byType(DateFilterConditionPBList));
}

/// The [SelectOptionFilterList] must show up first.
Future<void> tapOptionFilterWithName(String name) async {
final findCell = find.descendant(
Expand Down Expand Up @@ -1090,6 +1095,15 @@ extension AppFlowyDatabaseTest on WidgetTester {
await tapButton(button);
}

Future<void> 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<void> tapViewPropertiesButton() async {
final findSettingItem = find.byType(DatabaseSettingsList);
Expand Down

0 comments on commit 9e715ed

Please sign in to comment.