mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
* test: fix calendar integration test #2919 * chore: update frontend/appflowy_flutter/integration_test/database_calendar_test.dart Co-authored-by: Lucas.Xu <lucas.xu@appflowy.io> * test: fix date cell test --------- Co-authored-by: Lucas.Xu <lucas.xu@appflowy.io>
This commit is contained in:
parent
95d4fb6865
commit
3acd36e580
@ -206,12 +206,13 @@ void main() {
|
|||||||
await tester.tapCreateCalendarButton();
|
await tester.tapCreateCalendarButton();
|
||||||
|
|
||||||
// Create a new event in today's calendar cell
|
// Create a new event in today's calendar cell
|
||||||
|
final today = DateTime.now();
|
||||||
await tester.scrollToToday();
|
await tester.scrollToToday();
|
||||||
await tester.doubleClickCalendarCell(DateTime.now());
|
await tester.doubleClickCalendarCell(today);
|
||||||
await tester.dismissRowDetailPage();
|
await tester.dismissRowDetailPage();
|
||||||
|
|
||||||
// Make sure that the event is today
|
// Make sure that the event is today
|
||||||
tester.assertNumberofEventsOnSpecificDay(1, DateTime.now());
|
tester.assertNumberofEventsOnSpecificDay(1, today);
|
||||||
|
|
||||||
// Click on the event
|
// Click on the event
|
||||||
await tester.openCalendarEvent(index: 0);
|
await tester.openCalendarEvent(index: 0);
|
||||||
@ -220,9 +221,11 @@ void main() {
|
|||||||
await tester.tapDateCellInRowDetailPage();
|
await tester.tapDateCellInRowDetailPage();
|
||||||
await tester.findDateEditor(findsOneWidget);
|
await tester.findDateEditor(findsOneWidget);
|
||||||
|
|
||||||
// Edit the event's date
|
// Edit the event's date. To avoid selecting a day outside of the current month, the new date will be one day closer to the middle of the month.
|
||||||
final tomorrow = DateTime.now().add(const Duration(days: 1));
|
final newDate = today.day < 15
|
||||||
await tester.selectDay(content: tomorrow.day);
|
? today.add(const Duration(days: 1))
|
||||||
|
: today.subtract(const Duration(days: 1));
|
||||||
|
await tester.selectDay(content: newDate.day);
|
||||||
await tester.dismissCellEditor();
|
await tester.dismissCellEditor();
|
||||||
|
|
||||||
// Dismiss the row details page
|
// Dismiss the row details page
|
||||||
@ -230,7 +233,7 @@ void main() {
|
|||||||
|
|
||||||
// Make sure that the event is edited
|
// Make sure that the event is edited
|
||||||
tester.assertNumberOfEventsInCalendar(1);
|
tester.assertNumberOfEventsInCalendar(1);
|
||||||
tester.assertNumberofEventsOnSpecificDay(1, tomorrow);
|
tester.assertNumberofEventsOnSpecificDay(1, newDate);
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('reschedule an event by drag-and-drop', (tester) async {
|
testWidgets('reschedule an event by drag-and-drop', (tester) async {
|
||||||
|
@ -237,7 +237,7 @@ void main() {
|
|||||||
await tester.assertDateCellInGrid(
|
await tester.assertDateCellInGrid(
|
||||||
rowIndex: 0,
|
rowIndex: 0,
|
||||||
fieldType: fieldType,
|
fieldType: fieldType,
|
||||||
content: DateFormat('MMM d, y').format(today),
|
content: DateFormat('MMM dd, y').format(today),
|
||||||
);
|
);
|
||||||
|
|
||||||
await tester.tapCellInGrid(rowIndex: 0, fieldType: fieldType);
|
await tester.tapCellInGrid(rowIndex: 0, fieldType: fieldType);
|
||||||
@ -252,7 +252,7 @@ void main() {
|
|||||||
await tester.assertDateCellInGrid(
|
await tester.assertDateCellInGrid(
|
||||||
rowIndex: 0,
|
rowIndex: 0,
|
||||||
fieldType: fieldType,
|
fieldType: fieldType,
|
||||||
content: DateFormat('MMM d, y HH:mm').format(now),
|
content: DateFormat('MMM dd, y HH:mm').format(now),
|
||||||
);
|
);
|
||||||
|
|
||||||
await tester.tapCellInGrid(rowIndex: 0, fieldType: fieldType);
|
await tester.tapCellInGrid(rowIndex: 0, fieldType: fieldType);
|
||||||
|
@ -2,6 +2,7 @@ import 'dart:io';
|
|||||||
|
|
||||||
import 'package:appflowy/generated/locale_keys.g.dart';
|
import 'package:appflowy/generated/locale_keys.g.dart';
|
||||||
import 'package:appflowy/plugins/database_view/board/presentation/board_page.dart';
|
import 'package:appflowy/plugins/database_view/board/presentation/board_page.dart';
|
||||||
|
import 'package:appflowy/plugins/database_view/calendar/application/calendar_bloc.dart';
|
||||||
import 'package:appflowy/plugins/database_view/calendar/presentation/calendar_day.dart';
|
import 'package:appflowy/plugins/database_view/calendar/presentation/calendar_day.dart';
|
||||||
import 'package:appflowy/plugins/database_view/calendar/presentation/calendar_page.dart';
|
import 'package:appflowy/plugins/database_view/calendar/presentation/calendar_page.dart';
|
||||||
import 'package:appflowy/plugins/database_view/calendar/presentation/toolbar/calendar_layout_setting.dart';
|
import 'package:appflowy/plugins/database_view/calendar/presentation/toolbar/calendar_layout_setting.dart';
|
||||||
@ -40,6 +41,7 @@ import 'package:appflowy/workspace/presentation/widgets/pop_up_action.dart';
|
|||||||
import 'package:appflowy/workspace/presentation/widgets/toggle/toggle.dart';
|
import 'package:appflowy/workspace/presentation/widgets/toggle/toggle.dart';
|
||||||
import 'package:appflowy_backend/protobuf/flowy-database2/setting_entities.pbenum.dart';
|
import 'package:appflowy_backend/protobuf/flowy-database2/setting_entities.pbenum.dart';
|
||||||
import 'package:appflowy_backend/protobuf/flowy-folder2/view.pb.dart';
|
import 'package:appflowy_backend/protobuf/flowy-folder2/view.pb.dart';
|
||||||
|
import 'package:calendar_view/calendar_view.dart';
|
||||||
import 'package:easy_localization/easy_localization.dart';
|
import 'package:easy_localization/easy_localization.dart';
|
||||||
import 'package:flowy_infra_ui/flowy_infra_ui.dart';
|
import 'package:flowy_infra_ui/flowy_infra_ui.dart';
|
||||||
import 'package:flowy_infra_ui/style_widget/text_input.dart';
|
import 'package:flowy_infra_ui/style_widget/text_input.dart';
|
||||||
@ -977,9 +979,20 @@ extension AppFlowyDatabaseTest on WidgetTester {
|
|||||||
Future<void> scrollToToday() async {
|
Future<void> scrollToToday() async {
|
||||||
final todayCell = find.byWidgetPredicate(
|
final todayCell = find.byWidgetPredicate(
|
||||||
(widget) => widget is CalendarDayCard && widget.isToday,
|
(widget) => widget is CalendarDayCard && widget.isToday,
|
||||||
skipOffstage: false,
|
|
||||||
);
|
);
|
||||||
await ensureVisible(todayCell);
|
final scrollable = find
|
||||||
|
.descendant(
|
||||||
|
of: find.byType(MonthView<CalendarDayEvent>),
|
||||||
|
matching: find.byWidgetPredicate(
|
||||||
|
(widget) => widget is Scrollable && widget.axis == Axis.vertical,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.first;
|
||||||
|
await scrollUntilVisible(
|
||||||
|
todayCell,
|
||||||
|
300,
|
||||||
|
scrollable: scrollable,
|
||||||
|
);
|
||||||
await pumpAndSettle(const Duration(milliseconds: 300));
|
await pumpAndSettle(const Duration(milliseconds: 300));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user