From a57ca5c0cb76806a9864014a9b01d7b70c165eeb Mon Sep 17 00:00:00 2001 From: Richard Shiue <71320345+richardshiue@users.noreply.github.com> Date: Mon, 23 Oct 2023 11:44:04 +0800 Subject: [PATCH] fix: integration tests failing on Sundays (#3753) --- .../database_calendar_test.dart | 18 ++++++++---------- .../util/database_test_op.dart | 2 +- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/frontend/appflowy_flutter/integration_test/database_calendar_test.dart b/frontend/appflowy_flutter/integration_test/database_calendar_test.dart index 59987a0984..af17cf15c1 100644 --- a/frontend/appflowy_flutter/integration_test/database_calendar_test.dart +++ b/frontend/appflowy_flutter/integration_test/database_calendar_test.dart @@ -174,25 +174,23 @@ void main() { await tester.openCalendarEvent(index: 0, date: sameDayNextWeek); await tester.deleteEventFromEventEditor(); - // Create a new event in today's calendar cell - await tester.scrollToToday(); - await tester.doubleClickCalendarCell(today); + // Create another event on the 5th of this month + final fifthOfThisMonth = DateTime(today.year, today.month, 5); + await tester.doubleClickCalendarCell(fifthOfThisMonth); await tester.dismissEventEditor(); - // Make sure that the event is today - tester.assertNumberOfEventsOnSpecificDay(1, today); + // Make sure that the event is on the 4t + tester.assertNumberOfEventsOnSpecificDay(1, fifthOfThisMonth); // Click on the event - await tester.openCalendarEvent(index: 0); + await tester.openCalendarEvent(index: 0, date: fifthOfThisMonth); // Open the date editor of the event await tester.tapDateCellInRowDetailPage(); await tester.findDateEditor(findsOneWidget); - // 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 newDate = today.day < 15 - ? today.add(const Duration(days: 1)) - : today.subtract(const Duration(days: 1)); + // Edit the event's date + final newDate = fifthOfThisMonth.add(const Duration(days: 1)); await tester.selectDay(content: newDate.day); await tester.dismissCellEditor(); diff --git a/frontend/appflowy_flutter/integration_test/util/database_test_op.dart b/frontend/appflowy_flutter/integration_test/util/database_test_op.dart index 4458b3adad..5b909f4723 100644 --- a/frontend/appflowy_flutter/integration_test/util/database_test_op.dart +++ b/frontend/appflowy_flutter/integration_test/util/database_test_op.dart @@ -1302,7 +1302,7 @@ extension AppFlowyDatabaseTest on WidgetTester { await doubleTapAt(location); } - Future openCalendarEvent({required index, DateTime? date}) async { + Future openCalendarEvent({required int index, DateTime? date}) async { final findDayCell = find.byWidgetPredicate( (widget) => widget is CalendarDayCard &&