diff --git a/frontend/appflowy_flutter/integration_test/database_calendar_test.dart b/frontend/appflowy_flutter/integration_test/database_calendar_test.dart index 25e3cc8ff5..cd096db6e8 100644 --- a/frontend/appflowy_flutter/integration_test/database_calendar_test.dart +++ b/frontend/appflowy_flutter/integration_test/database_calendar_test.dart @@ -9,7 +9,7 @@ import 'util/util.dart'; void main() { IntegrationTestWidgetsFlutterBinding.ensureInitialized(); - group('database', () { + group('calendar database view', () { testWidgets('update calendar layout', (tester) async { await tester.initializeAppFlowy(); await tester.tapGoButton(); @@ -60,7 +60,7 @@ void main() { await tester.pumpAndSettle(); }); - testWidgets('create new calendar event using new button', (tester) async { + testWidgets('creating and editing calendar events', (tester) async { await tester.initializeAppFlowy(); await tester.tapGoButton(); @@ -83,28 +83,8 @@ void main() { // Dismiss the row details page await tester.dismissRowDetailPage(); - // Make sure that the event is inserted in the cell tester.assertNumberOfEventsInCalendar(1); - // Create another event on the same day - await tester.hoverOnTodayCalendarCell(); - await tester.tapAddCalendarEventButton(); - await tester.dismissRowDetailPage(); - tester.assertNumberOfEventsInCalendar(2); - tester.assertNumberofEventsOnSpecificDay(2, DateTime.now()); - }); - - testWidgets('create new calendar event by double-clicking', (tester) async { - await tester.initializeAppFlowy(); - await tester.tapGoButton(); - - // Create the calendar view - await tester.tapAddButton(); - await tester.tapCreateCalendarButton(); - - // Scroll until today's date cell is visible - await tester.scrollToToday(); - // Double click on today's calendar cell to create a new event await tester.doubleClickCalendarCell(DateTime.now()); @@ -115,74 +95,42 @@ void main() { await tester.dismissRowDetailPage(); // Make sure that the event is inserted in the cell - tester.assertNumberOfEventsInCalendar(1); - - // Create another event on the same day - await tester.doubleClickCalendarCell(DateTime.now()); - await tester.dismissRowDetailPage(); tester.assertNumberOfEventsInCalendar(2); + + // Click on the event + await tester.openCalendarEvent(index: 0); + tester.assertRowDetailPageOpened(); + + // Change the title of the event + await tester.editTitleInRowDetailPage('hello world'); + await tester.dismissRowDetailPage(); + + // Make sure that the event is edited + tester.assertNumberOfEventsInCalendar(1, title: 'hello world'); tester.assertNumberofEventsOnSpecificDay(2, DateTime.now()); - }); - testWidgets('duplicate/delete a calendar event', (tester) async { - await tester.initializeAppFlowy(); - await tester.tapGoButton(); - - // Create the calendar view - await tester.tapAddButton(); - await tester.tapCreateCalendarButton(); - - // Create a new event in today's calendar cell - await tester.scrollToToday(); - await tester.doubleClickCalendarCell(DateTime.now()); + // Click on the event + await tester.openCalendarEvent(index: 1); + tester.assertRowDetailPageOpened(); // Duplicate the event await tester.tapRowDetailPageDuplicateRowButton(); await tester.dismissRowDetailPage(); // Check that there are 2 events - tester.assertNumberOfEventsInCalendar(2); + tester.assertNumberOfEventsInCalendar(2, title: 'hello world'); + tester.assertNumberofEventsOnSpecificDay(3, DateTime.now()); // Delete an event - await tester.openCalendarEvent(index: 0); + await tester.openCalendarEvent(index: 1); await tester.tapRowDetailPageDeleteRowButton(); // Check that there is 1 event - tester.assertNumberOfEventsInCalendar(1); - }); - - testWidgets('edit the title of a calendar date event', (tester) async { - await tester.initializeAppFlowy(); - await tester.tapGoButton(); - - // Create the calendar view - await tester.tapAddButton(); - await tester.tapCreateCalendarButton(); - - // Create a new event in today's calendar cell - await tester.scrollToToday(); - await tester.doubleClickCalendarCell(DateTime.now()); - await tester.dismissRowDetailPage(); - - // Click on the event - await tester.openCalendarEvent(index: 0); - - // Make sure that the row details page is opened - tester.assertRowDetailPageOpened(); - - // Change the title of the event - await tester.editTitleInRowDetailPage('hello world'); - - // Dismiss the row details page - await tester.dismissRowDetailPage(); - - // Make sure that the event is edited tester.assertNumberOfEventsInCalendar(1, title: 'hello world'); + tester.assertNumberofEventsOnSpecificDay(2, DateTime.now()); }); - testWidgets( - 'edit the date of the date field being used to layout the calendar', - (tester) async { + testWidgets('rescheduling events', (tester) async { await tester.initializeAppFlowy(); await tester.tapGoButton(); @@ -190,8 +138,25 @@ void main() { await tester.tapAddButton(); await tester.tapCreateCalendarButton(); - // Create a new event in today's calendar cell + // Create a new event on the first of this month final today = DateTime.now(); + final firstOfThisMonth = DateTime(today.year, today.month, 1); + await tester.doubleClickCalendarCell(firstOfThisMonth); + await tester.dismissRowDetailPage(); + + // Drag and drop the event onto the next week, same day + await tester.dragDropRescheduleCalendarEvent(firstOfThisMonth); + + // Make sure that the event has been rescheduled to the new date + final sameDayNextWeek = firstOfThisMonth.add(const Duration(days: 7)); + tester.assertNumberOfEventsInCalendar(1); + tester.assertNumberofEventsOnSpecificDay(1, sameDayNextWeek); + + // Delete the event + await tester.openCalendarEvent(index: 0, date: sameDayNextWeek); + await tester.tapRowDetailPageDeleteRowButton(); + + // Create a new event in today's calendar cell await tester.scrollToToday(); await tester.doubleClickCalendarCell(today); await tester.dismissRowDetailPage(); @@ -220,30 +185,5 @@ void main() { tester.assertNumberOfEventsInCalendar(1); tester.assertNumberofEventsOnSpecificDay(1, newDate); }); - - testWidgets('reschedule an event by drag-and-drop', (tester) async { - await tester.initializeAppFlowy(); - await tester.tapGoButton(); - - // Create the calendar view - await tester.tapAddButton(); - await tester.tapCreateCalendarButton(); - - // Create a new event on the first of this month - final today = DateTime.now(); - final firstOfThisMonth = DateTime(today.year, today.month, 1); - await tester.doubleClickCalendarCell(firstOfThisMonth); - await tester.dismissRowDetailPage(); - - // Drag and drop the event onto the next week, same day - await tester.dragDropRescheduleCalendarEvent(firstOfThisMonth); - - // Make sure that the event has been rescheduled to the new date - tester.assertNumberOfEventsInCalendar(1); - tester.assertNumberofEventsOnSpecificDay( - 1, - firstOfThisMonth.add(const Duration(days: 7)), - ); - }); }); }