From 4bc805d668225c400740fc3078af43435d11d35c Mon Sep 17 00:00:00 2001 From: "adam.nagy" Date: Wed, 12 Nov 2025 13:44:05 +0100 Subject: [PATCH 1/3] Implement E2E tests for Calendar event and To Do reminders. refs: MBL-18703 affects: Student, Teacher, Parent release note: --- .../ui/e2e/compose/CalendarE2ETest.kt | 509 +++++++++++++++++ .../parentapp/utils/ParentComposeTest.kt | 2 + .../student/ui/e2e/compose/CalendarE2ETest.kt | 521 ++++++++++++++++++ .../student/ui/utils/StudentComposeTest.kt | 2 + .../teacher/ui/e2e/compose/CalendarE2ETest.kt | 521 ++++++++++++++++++ .../teacher/ui/utils/TeacherComposeTest.kt | 2 + .../canvas/espresso/TestMetaData.kt | 3 +- .../common/pages/CalendarReminderPage.kt | 97 ++++ 8 files changed, 1656 insertions(+), 1 deletion(-) create mode 100644 automation/espresso/src/main/kotlin/com/instructure/canvas/espresso/common/pages/CalendarReminderPage.kt diff --git a/apps/parent/src/androidTest/java/com/instructure/parentapp/ui/e2e/compose/CalendarE2ETest.kt b/apps/parent/src/androidTest/java/com/instructure/parentapp/ui/e2e/compose/CalendarE2ETest.kt index 32f2c6da14..13313791f7 100644 --- a/apps/parent/src/androidTest/java/com/instructure/parentapp/ui/e2e/compose/CalendarE2ETest.kt +++ b/apps/parent/src/androidTest/java/com/instructure/parentapp/ui/e2e/compose/CalendarE2ETest.kt @@ -16,11 +16,14 @@ package com.instructure.parentapp.ui.e2e.compose import android.util.Log +import androidx.test.espresso.Espresso import com.instructure.canvas.espresso.FeatureCategory import com.instructure.canvas.espresso.Priority +import com.instructure.canvas.espresso.SecondaryFeatureCategory import com.instructure.canvas.espresso.TestCategory import com.instructure.canvas.espresso.TestMetaData import com.instructure.canvas.espresso.annotations.E2E +import com.instructure.canvas.espresso.checkToastText import com.instructure.canvasapi2.models.CanvasContext import com.instructure.canvasapi2.utils.toApiString import com.instructure.dataseeding.api.CalendarEventApi @@ -29,8 +32,12 @@ import com.instructure.dataseeding.api.EnrollmentsApi import com.instructure.dataseeding.model.EnrollmentTypes.STUDENT_ENROLLMENT import com.instructure.dataseeding.model.EnrollmentTypes.TEACHER_ENROLLMENT import com.instructure.dataseeding.util.CanvasNetworkAdapter +import com.instructure.dataseeding.util.days +import com.instructure.dataseeding.util.fromNow import com.instructure.espresso.getDateInCanvasCalendarFormat import com.instructure.pandautils.features.calendar.CalendarPrefs +import com.instructure.pandautils.utils.toFormattedString +import com.instructure.parentapp.R import com.instructure.parentapp.utils.ParentComposeTest import com.instructure.parentapp.utils.extensions.seedData import com.instructure.parentapp.utils.extensions.tokenLogin @@ -419,4 +426,506 @@ class CalendarE2ETest : ParentComposeTest() { calendarScreenPage.assertItemDisplayed(testEventSecondStudent.title.orEmpty()) calendarScreenPage.assertItemNotDisplayed(testEventFirstStudent.title.orEmpty()) } + + @E2E + @Test + @TestMetaData(Priority.MANDATORY, FeatureCategory.CALENDAR, TestCategory.E2E, SecondaryFeatureCategory.CALENDAR_EVENT_REMINDER) + fun testCalendarEventCustomReminderE2E() { + + Log.d(PREPARATION_TAG, "Seeding data.") + val data = seedData(students = 2, parents = 1, courses = 1) + val parent = data.parentsList[0] + val futureDate = 2.days.fromNow + + Log.d(STEP_TAG, "Login with user: '${parent.name}', login id: '${parent.loginId}'.") + tokenLogin(parent) + + Log.d(ASSERTION_TAG, "Assert that the Dashboard Page is the landing page and it is loaded successfully.") + dashboardPage.waitForRender() + dashboardPage.assertPageObjects() + + Log.d(STEP_TAG, "Click on the 'Calendar' bottom menu to navigate to the Calendar page.") + dashboardPage.clickCalendarBottomMenu() + + Log.d(STEP_TAG, "Click on the 'Add' (FAB) button and 'Add Event' to create a new event.") + calendarScreenPage.clickOnAddButton() + calendarScreenPage.clickAddEvent() + + Log.d(ASSERTION_TAG, "Assert that the Calendar Event Page is displayed and the title is 'New Event' as we are making a new one.") + calendarEventCreateEditPage.assertTitle("New Event") + + val newEventTitle = "Test Event With Reminder" + Log.d(STEP_TAG, "Type '$newEventTitle' to the title input field.") + calendarEventCreateEditPage.typeTitle(newEventTitle) + + val calendar = Calendar.getInstance().apply { timeInMillis = futureDate.timeInMillis } + Log.d(STEP_TAG, "Select a date which is 2 days in the future from today.") + calendarEventCreateEditPage.selectDate(calendar) + + Log.d(STEP_TAG, "Click on 'Save' to create the event.") + calendarEventCreateEditPage.clickSave() + + Log.d(STEP_TAG, "Swipe the calendar item 'body' to 2 days in the future from now.") + calendarScreenPage.swipeEventsLeft() + calendarScreenPage.swipeEventsLeft() + + Log.d(ASSERTION_TAG, "Assert that the event is displayed on the calendar.") + calendarScreenPage.assertItemDisplayed(newEventTitle) + + Log.d(STEP_TAG, "Click on the previously created '$newEventTitle' event.") + calendarScreenPage.clickOnItem(newEventTitle) + + Log.d(ASSERTION_TAG, "Assert that the Calendar Event Details Page is displayed and the title is 'Event'.") + calendarEventDetailsPage.assertEventDetailsPageTitle() + + Log.d(ASSERTION_TAG, "Assert that the reminder section is displayed.") + calendarReminderPage.assertReminderSectionDisplayed() + + Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to pick up a new reminder.") + calendarReminderPage.clickAddReminder() + + val reminderDateOneHour = futureDate.apply { add(Calendar.HOUR, -1) } + Log.d(STEP_TAG, "Select '1 Hour Before' using custom date/time picker.") + calendarReminderPage.clickCustomReminderOption() + calendarReminderPage.selectDate(reminderDateOneHour) + calendarReminderPage.selectTime(reminderDateOneHour) + + Log.d(ASSERTION_TAG, "Assert that the reminder has been picked up and displayed on the Event Details Page.") + calendarReminderPage.assertReminderDisplayedWithText(reminderDateOneHour.time.toFormattedString()) + + Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to pick up a new reminder.") + calendarReminderPage.clickAddReminder() + + Log.d(STEP_TAG, "Select '1 Hour Before' again.") + calendarReminderPage.clickCustomReminderOption() + calendarReminderPage.selectDate(reminderDateOneHour) + calendarReminderPage.selectTime(reminderDateOneHour) + + Log.d(ASSERTION_TAG, "Assert that a toast message is occurring which warns that we cannot pick up the same time reminder twice.") + checkToastText(R.string.reminderAlreadySet, activityRule.activity) + + Log.d(STEP_TAG, "Remove the '1 Hour Before' reminder and confirm the deletion dialog.") + calendarReminderPage.removeReminder() + + Log.d(ASSERTION_TAG, "Assert that the '1 Hour Before' reminder is not displayed any more.") + calendarReminderPage.assertReminderNotDisplayedWithText(reminderDateOneHour.time.toFormattedString()) + futureDate.apply { add(Calendar.HOUR, 1) } + + Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to pick up a new reminder.") + calendarReminderPage.clickAddReminder() + + val reminderDateOneWeek = futureDate.apply { add(Calendar.WEEK_OF_YEAR, -1) } + Log.d(STEP_TAG, "Select '1 Week Before'.") + calendarReminderPage.clickCustomReminderOption() + calendarReminderPage.selectDate(reminderDateOneWeek) + calendarReminderPage.selectTime(reminderDateOneWeek) + + Log.d(ASSERTION_TAG, "Assert that a toast message is occurring which warns that we cannot pick up a reminder which has already passed (for example cannot pick '1 Week Before' reminder for an event which ends in 2 days).") + calendarReminderPage.assertReminderNotDisplayedWithText(reminderDateOneWeek.time.toFormattedString()) + checkToastText(R.string.reminderInPast, activityRule.activity) + futureDate.apply { add(Calendar.WEEK_OF_YEAR, 1) } + + Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to pick up a new reminder.") + calendarReminderPage.clickAddReminder() + + val reminderDateOneDay = futureDate.apply { add(Calendar.DAY_OF_MONTH, -1) }.apply { add(Calendar.HOUR, -1) } + Log.d(STEP_TAG, "Select '1 Day Before and 1 hour before'.") + calendarReminderPage.clickCustomReminderOption() + calendarReminderPage.selectDate(reminderDateOneDay) + calendarReminderPage.selectTime(reminderDateOneDay) + + Log.d(ASSERTION_TAG, "Assert that the reminder has been picked up and displayed on the Event Details Page.") + calendarReminderPage.assertReminderDisplayedWithText(reminderDateOneDay.time.toFormattedString()) + + Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to pick up a new reminder.") + calendarReminderPage.clickAddReminder() + + Log.d(STEP_TAG, "Select '1 Day Before' again.") + calendarReminderPage.clickCustomReminderOption() + calendarReminderPage.selectDate(reminderDateOneDay) + calendarReminderPage.selectTime(reminderDateOneDay) + + Log.d(ASSERTION_TAG, "Assert that a toast message is occurring which warns that we cannot pick up the same time reminder twice. (Because 1 days and 24 hours is the same)") + checkToastText(R.string.reminderAlreadySet, activityRule.activity) + futureDate.apply { add(Calendar.DAY_OF_MONTH, 1) } + + Log.d(STEP_TAG, "Navigate back to Calendar Screen Page.") + Espresso.pressBack() + + Log.d(ASSERTION_TAG, "Assert that the event is displayed on the calendar.") + calendarScreenPage.assertItemDisplayed(newEventTitle) + } + + @E2E + @Test + @TestMetaData(Priority.MANDATORY, FeatureCategory.CALENDAR, TestCategory.E2E, SecondaryFeatureCategory.CALENDAR_EVENT_REMINDER) + fun testCalendarEventBeforeReminderE2E() { + + Log.d(PREPARATION_TAG, "Seeding data.") + val data = seedData(students = 2, parents = 1, courses = 1) + val parent = data.parentsList[0] + val futureDate = 2.days.fromNow + + Log.d(STEP_TAG, "Login with user: '${parent.name}', login id: '${parent.loginId}'.") + tokenLogin(parent) + + Log.d(ASSERTION_TAG, "Assert that the Dashboard Page is the landing page and it is loaded successfully.") + dashboardPage.waitForRender() + dashboardPage.assertPageObjects() + + Log.d(STEP_TAG, "Click on the 'Calendar' bottom menu to navigate to the Calendar page.") + dashboardPage.clickCalendarBottomMenu() + + Log.d(STEP_TAG, "Click on the 'Add' (FAB) button and 'Add Event' to create a new event.") + calendarScreenPage.clickOnAddButton() + calendarScreenPage.clickAddEvent() + + Log.d(ASSERTION_TAG, "Assert that the Calendar Event Page is displayed and the title is 'New Event' as we are making a new one.") + calendarEventCreateEditPage.assertTitle("New Event") + + val newEventTitle = "Test Event With Reminder" + Log.d(STEP_TAG, "Type '$newEventTitle' to the title input field.") + calendarEventCreateEditPage.typeTitle(newEventTitle) + + val calendar = Calendar.getInstance().apply { timeInMillis = futureDate.timeInMillis } + Log.d(STEP_TAG, "Select a date which is 2 days in the future from today.") + calendarEventCreateEditPage.selectDate(calendar) + + Log.d(STEP_TAG, "Click on 'Save' to create the event.") + calendarEventCreateEditPage.clickSave() + + Log.d(STEP_TAG, "Swipe the calendar item 'body' to 2 days in the future from now.") + calendarScreenPage.swipeEventsLeft() + calendarScreenPage.swipeEventsLeft() + + Log.d(ASSERTION_TAG, "Assert that the event is displayed on the calendar.") + calendarScreenPage.assertItemDisplayed(newEventTitle) + + Log.d(STEP_TAG, "Click on the previously created '$newEventTitle' event.") + calendarScreenPage.clickOnItem(newEventTitle) + + Log.d(ASSERTION_TAG, "Assert that the Calendar Event Details Page is displayed and the title is 'Event'.") + calendarEventDetailsPage.assertEventDetailsPageTitle() + + Log.d(ASSERTION_TAG, "Assert that the reminder section is displayed.") + calendarReminderPage.assertReminderSectionDisplayed() + + Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to pick up a new reminder.") + calendarReminderPage.clickAddReminder() + + val reminderDateOneHour = futureDate.apply { add(Calendar.HOUR, -1) } + Log.d(STEP_TAG, "Select '1 Hour Before'.") + calendarReminderPage.clickBeforeReminderOption("1 Hour Before") + + Log.d(ASSERTION_TAG, "Assert that the reminder has been picked up and displayed on the Event Details Page.") + calendarReminderPage.assertReminderDisplayedWithText(reminderDateOneHour.time.toFormattedString()) + + Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to pick up a new reminder.") + calendarReminderPage.clickAddReminder() + + Log.d(STEP_TAG, "Select '1 Hour Before' again.") + calendarReminderPage.clickBeforeReminderOption("1 Hour Before") + + Log.d(ASSERTION_TAG, "Assert that a toast message is occurring which warns that we cannot pick up the same time reminder twice.") + checkToastText(R.string.reminderAlreadySet, activityRule.activity) + + Log.d(STEP_TAG, "Remove the '1 Hour Before' reminder and confirm the deletion dialog.") + calendarReminderPage.removeReminder() + + Log.d(ASSERTION_TAG, "Assert that the '1 Hour Before' reminder is not displayed any more.") + calendarReminderPage.assertReminderNotDisplayedWithText(reminderDateOneHour.time.toFormattedString()) + futureDate.apply { add(Calendar.HOUR, 1) } + + Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to add a new reminder.") + calendarReminderPage.clickAddReminder() + + val reminderDateOneWeek = futureDate.apply { add(Calendar.WEEK_OF_YEAR, -1) } + Log.d(STEP_TAG, "Select '1 Week Before'.") + calendarReminderPage.clickBeforeReminderOption("1 Week Before") + + Log.d(ASSERTION_TAG, "Assert that a toast message is occurring which warns that we cannot pick up a reminder which has already passed (for example cannot pick '1 Week Before' reminder for an event which ends in 2 days).") + calendarReminderPage.assertReminderNotDisplayedWithText(reminderDateOneWeek.time.toFormattedString()) + checkToastText(R.string.reminderInPast, activityRule.activity) + futureDate.apply { add(Calendar.WEEK_OF_YEAR, 1) } + + Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to add a new reminder.") + calendarReminderPage.clickAddReminder() + + val reminderDateOneDay = futureDate.apply { add(Calendar.DAY_OF_MONTH, -1) } + Log.d(STEP_TAG, "Select '1 Day Before'.") + calendarReminderPage.clickBeforeReminderOption("1 Day Before") + + Log.d(ASSERTION_TAG, "Assert that the reminder has been picked up and displayed on the Event Details Page.") + calendarReminderPage.assertReminderDisplayedWithText(reminderDateOneDay.time.toFormattedString()) + + Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to pick up a new reminder.") + calendarReminderPage.clickAddReminder() + + Log.d(STEP_TAG, "Select '1 Day Before' again.") + calendarReminderPage.clickBeforeReminderOption("1 Day Before") + + Log.d(ASSERTION_TAG, "Assert that a toast message is occurring which warns that we cannot pick up the same time reminder twice. (Because 1 days and 24 hours is the same)") + checkToastText(R.string.reminderAlreadySet, activityRule.activity) + futureDate.apply { add(Calendar.DAY_OF_MONTH, 1) } + + Log.d(STEP_TAG, "Navigate back to Calendar Screen Page.") + Espresso.pressBack() + + Log.d(ASSERTION_TAG, "Assert that the event is displayed on the calendar.") + calendarScreenPage.assertItemDisplayed(newEventTitle) + } + + @E2E + @Test + @TestMetaData(Priority.MANDATORY, FeatureCategory.CALENDAR, TestCategory.E2E, SecondaryFeatureCategory.CALENDAR_TODO_REMINDER) + fun testCalendarToDoCustomReminderE2E() { + + Log.d(PREPARATION_TAG, "Seeding data.") + val data = seedData(students = 2, parents = 1, courses = 1) + val parent = data.parentsList[0] + val futureDate = 2.days.fromNow + + Log.d(STEP_TAG, "Login with user: '${parent.name}', login id: '${parent.loginId}'.") + tokenLogin(parent) + + Log.d(ASSERTION_TAG, "Assert that the Dashboard Page is the landing page and it is loaded successfully.") + dashboardPage.waitForRender() + dashboardPage.assertPageObjects() + + Log.d(STEP_TAG, "Click on the 'Calendar' bottom menu to navigate to the Calendar page.") + dashboardPage.clickCalendarBottomMenu() + + Log.d(STEP_TAG, "Click on the 'Add' (FAB) button and 'Add To Do' to create a new To Do.") + calendarScreenPage.clickOnAddButton() + calendarScreenPage.clickAddTodo() + + Log.d(ASSERTION_TAG, "Assert that the page title is 'New To Do' as we are clicked on the 'Add To Do' button to create a new one.") + calendarToDoCreateUpdatePage.assertPageTitle("New To Do") + + val testTodoTitle = "Test ToDo With Reminder" + val testTodoDescription = "Details of ToDo" + Log.d(STEP_TAG, "Fill the title with '$testTodoTitle' and the description with '$testTodoDescription'.") + calendarToDoCreateUpdatePage.typeTodoTitle(testTodoTitle) + calendarToDoCreateUpdatePage.typeDetails(testTodoDescription) + + val calendar = Calendar.getInstance().apply { timeInMillis = futureDate.timeInMillis } + Log.d(STEP_TAG, "Select a date which is 2 days in the future from today.") + calendarToDoCreateUpdatePage.selectDate(calendar) + + Log.d(STEP_TAG, "Click on the 'Save' button.") + calendarToDoCreateUpdatePage.clickSave() + + Log.d(STEP_TAG, "Swipe the calendar item 'body' to 2 days in the future from now.") + calendarScreenPage.swipeEventsLeft() + calendarScreenPage.swipeEventsLeft() + + Log.d(ASSERTION_TAG, "Assert that the To Do item is displayed on the calendar.") + calendarScreenPage.assertItemDisplayed(testTodoTitle) + + Log.d(STEP_TAG, "Click on the previously created '$testTodoTitle' To Do item.") + calendarScreenPage.clickOnItem(testTodoTitle) + + Log.d(ASSERTION_TAG, "Assert that the title is '$testTodoTitle' and the context is 'To Do'.") + calendarToDoDetailsPage.assertTitle(testTodoTitle) + calendarToDoDetailsPage.assertPageTitle("To Do") + + Log.d(ASSERTION_TAG, "Assert that the reminder section is displayed.") + calendarReminderPage.assertReminderSectionDisplayed() + + Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to pick up a new reminder.") + calendarReminderPage.clickAddReminder() + + val reminderDateOneHour = futureDate.apply { add(Calendar.HOUR, -1) } + Log.d(STEP_TAG, "Select '1 Hour Before' using custom date/time picker.") + calendarReminderPage.clickCustomReminderOption() + calendarReminderPage.selectDate(reminderDateOneHour) + calendarReminderPage.selectTime(reminderDateOneHour) + + Log.d(ASSERTION_TAG, "Assert that the reminder has been picked up and displayed on the To Do Details Page.") + calendarReminderPage.assertReminderDisplayedWithText(reminderDateOneHour.time.toFormattedString()) + + Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to pick up a new reminder.") + calendarReminderPage.clickAddReminder() + + Log.d(STEP_TAG, "Select '1 Hour Before' again.") + calendarReminderPage.clickCustomReminderOption() + calendarReminderPage.selectDate(reminderDateOneHour) + calendarReminderPage.selectTime(reminderDateOneHour) + + Log.d(ASSERTION_TAG, "Assert that a toast message is occurring which warns that we cannot pick up the same time reminder twice.") + checkToastText(R.string.reminderAlreadySet, activityRule.activity) + + Log.d(STEP_TAG, "Remove the '1 Hour Before' reminder and confirm the deletion dialog.") + calendarReminderPage.removeReminder() + + Log.d(ASSERTION_TAG, "Assert that the '1 Hour Before' reminder is not displayed any more.") + calendarReminderPage.assertReminderNotDisplayedWithText(reminderDateOneHour.time.toFormattedString()) + futureDate.apply { add(Calendar.HOUR, 1) } + + Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to pick up a new reminder.") + calendarReminderPage.clickAddReminder() + + val reminderDateOneWeek = futureDate.apply { add(Calendar.WEEK_OF_YEAR, -1) } + Log.d(STEP_TAG, "Select '1 Week Before'.") + calendarReminderPage.clickCustomReminderOption() + calendarReminderPage.selectDate(reminderDateOneWeek) + calendarReminderPage.selectTime(reminderDateOneWeek) + + Log.d(ASSERTION_TAG, "Assert that a toast message is occurring which warns that we cannot pick up a reminder which has already passed (for example cannot pick '1 Week Before' reminder for a To Do which is due in 2 days).") + calendarReminderPage.assertReminderNotDisplayedWithText(reminderDateOneWeek.time.toFormattedString()) + checkToastText(R.string.reminderInPast, activityRule.activity) + futureDate.apply { add(Calendar.WEEK_OF_YEAR, 1) } + + Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to pick up a new reminder.") + calendarReminderPage.clickAddReminder() + + val reminderDateOneDay = futureDate.apply { add(Calendar.DAY_OF_MONTH, -1) }.apply { add(Calendar.HOUR, -1) } + Log.d(STEP_TAG, "Select '1 Day Before and 1 hour before'.") + calendarReminderPage.clickCustomReminderOption() + calendarReminderPage.selectDate(reminderDateOneDay) + calendarReminderPage.selectTime(reminderDateOneDay) + + Log.d(ASSERTION_TAG, "Assert that the reminder has been picked up and displayed on the To Do Details Page.") + calendarReminderPage.assertReminderDisplayedWithText(reminderDateOneDay.time.toFormattedString()) + + Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to pick up a new reminder.") + calendarReminderPage.clickAddReminder() + + Log.d(STEP_TAG, "Select '1 Day Before' again.") + calendarReminderPage.clickCustomReminderOption() + calendarReminderPage.selectDate(reminderDateOneDay) + calendarReminderPage.selectTime(reminderDateOneDay) + + Log.d(ASSERTION_TAG, "Assert that a toast message is occurring which warns that we cannot pick up the same time reminder twice. (Because 1 days and 24 hours is the same)") + checkToastText(R.string.reminderAlreadySet, activityRule.activity) + futureDate.apply { add(Calendar.DAY_OF_MONTH, 1) } + + Log.d(STEP_TAG, "Navigate back to Calendar Screen Page.") + Espresso.pressBack() + + Log.d(ASSERTION_TAG, "Assert that the To Do item is displayed on the calendar.") + calendarScreenPage.assertItemDisplayed(testTodoTitle) + } + + @E2E + @Test + @TestMetaData(Priority.MANDATORY, FeatureCategory.CALENDAR, TestCategory.E2E, SecondaryFeatureCategory.CALENDAR_TODO_REMINDER) + fun testCalendarToDoBeforeReminderE2E() { + + Log.d(PREPARATION_TAG, "Seeding data.") + val data = seedData(students = 2, parents = 1, courses = 1) + val parent = data.parentsList[0] + val futureDate = 2.days.fromNow + + Log.d(STEP_TAG, "Login with user: '${parent.name}', login id: '${parent.loginId}'.") + tokenLogin(parent) + + Log.d(ASSERTION_TAG, "Assert that the Dashboard Page is the landing page and it is loaded successfully.") + dashboardPage.waitForRender() + dashboardPage.assertPageObjects() + + Log.d(STEP_TAG, "Click on the 'Calendar' bottom menu to navigate to the Calendar page.") + dashboardPage.clickCalendarBottomMenu() + + Log.d(STEP_TAG, "Click on the 'Add' (FAB) button and 'Add To Do' to create a new To Do.") + calendarScreenPage.clickOnAddButton() + calendarScreenPage.clickAddTodo() + + Log.d(ASSERTION_TAG, "Assert that the page title is 'New To Do' as we are clicked on the 'Add To Do' button to create a new one.") + calendarToDoCreateUpdatePage.assertPageTitle("New To Do") + + val testTodoTitle = "Test ToDo With Reminder" + val testTodoDescription = "Details of ToDo" + Log.d(STEP_TAG, "Fill the title with '$testTodoTitle' and the description with '$testTodoDescription'.") + calendarToDoCreateUpdatePage.typeTodoTitle(testTodoTitle) + calendarToDoCreateUpdatePage.typeDetails(testTodoDescription) + + val calendar = Calendar.getInstance().apply { timeInMillis = futureDate.timeInMillis } + Log.d(STEP_TAG, "Select a date which is 2 days in the future from today.") + calendarToDoCreateUpdatePage.selectDate(calendar) + + Log.d(STEP_TAG, "Click on the 'Save' button.") + calendarToDoCreateUpdatePage.clickSave() + + Log.d(STEP_TAG, "Swipe the calendar item 'body' to 2 days in the future from now.") + calendarScreenPage.swipeEventsLeft() + calendarScreenPage.swipeEventsLeft() + + Log.d(ASSERTION_TAG, "Assert that the To Do item is displayed on the calendar.") + calendarScreenPage.assertItemDisplayed(testTodoTitle) + + Log.d(STEP_TAG, "Click on the previously created '$testTodoTitle' To Do item.") + calendarScreenPage.clickOnItem(testTodoTitle) + + Log.d(ASSERTION_TAG, "Assert that the title is '$testTodoTitle' and the context is 'To Do'.") + calendarToDoDetailsPage.assertTitle(testTodoTitle) + calendarToDoDetailsPage.assertPageTitle("To Do") + + Log.d(ASSERTION_TAG, "Assert that the reminder section is displayed.") + calendarReminderPage.assertReminderSectionDisplayed() + + Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to pick up a new reminder.") + calendarReminderPage.clickAddReminder() + + val reminderDateOneHour = futureDate.apply { add(Calendar.HOUR, -1) } + Log.d(STEP_TAG, "Select '1 Hour Before'.") + calendarReminderPage.clickBeforeReminderOption("1 Hour Before") + + Log.d(ASSERTION_TAG, "Assert that the reminder has been picked up and displayed on the To Do Details Page.") + calendarReminderPage.assertReminderDisplayedWithText(reminderDateOneHour.time.toFormattedString()) + + Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to pick up a new reminder.") + calendarReminderPage.clickAddReminder() + + Log.d(STEP_TAG, "Select '1 Hour Before' again.") + calendarReminderPage.clickBeforeReminderOption("1 Hour Before") + + Log.d(ASSERTION_TAG, "Assert that a toast message is occurring which warns that we cannot pick up the same time reminder twice.") + checkToastText(R.string.reminderAlreadySet, activityRule.activity) + + Log.d(STEP_TAG, "Remove the '1 Hour Before' reminder and confirm the deletion dialog.") + calendarReminderPage.removeReminder() + + Log.d(ASSERTION_TAG, "Assert that the '1 Hour Before' reminder is not displayed any more.") + calendarReminderPage.assertReminderNotDisplayedWithText(reminderDateOneHour.time.toFormattedString()) + futureDate.apply { add(Calendar.HOUR, 1) } + + Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to add a new reminder.") + calendarReminderPage.clickAddReminder() + + val reminderDateOneWeek = futureDate.apply { add(Calendar.WEEK_OF_YEAR, -1) } + Log.d(STEP_TAG, "Select '1 Week Before'.") + calendarReminderPage.clickBeforeReminderOption("1 Week Before") + + Log.d(ASSERTION_TAG, "Assert that a toast message is occurring which warns that we cannot pick up a reminder which has already passed (for example cannot pick '1 Week Before' reminder for a To Do which is due in 2 days).") + calendarReminderPage.assertReminderNotDisplayedWithText(reminderDateOneWeek.time.toFormattedString()) + checkToastText(R.string.reminderInPast, activityRule.activity) + futureDate.apply { add(Calendar.WEEK_OF_YEAR, 1) } + + Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to add a new reminder.") + calendarReminderPage.clickAddReminder() + + val reminderDateOneDay = futureDate.apply { add(Calendar.DAY_OF_MONTH, -1) } + Log.d(STEP_TAG, "Select '1 Day Before'.") + calendarReminderPage.clickBeforeReminderOption("1 Day Before") + + Log.d(ASSERTION_TAG, "Assert that the reminder has been picked up and displayed on the To Do Details Page.") + calendarReminderPage.assertReminderDisplayedWithText(reminderDateOneDay.time.toFormattedString()) + + Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to pick up a new reminder.") + calendarReminderPage.clickAddReminder() + + Log.d(STEP_TAG, "Select '1 Day Before' again.") + calendarReminderPage.clickBeforeReminderOption("1 Day Before") + + Log.d(ASSERTION_TAG, "Assert that a toast message is occurring which warns that we cannot pick up the same time reminder twice. (Because 1 days and 24 hours is the same)") + checkToastText(R.string.reminderAlreadySet, activityRule.activity) + futureDate.apply { add(Calendar.DAY_OF_MONTH, 1) } + + Log.d(STEP_TAG, "Navigate back to Calendar Screen Page.") + Espresso.pressBack() + + Log.d(ASSERTION_TAG, "Assert that the To Do item is displayed on the calendar.") + calendarScreenPage.assertItemDisplayed(testTodoTitle) + } } \ No newline at end of file diff --git a/apps/parent/src/androidTest/java/com/instructure/parentapp/utils/ParentComposeTest.kt b/apps/parent/src/androidTest/java/com/instructure/parentapp/utils/ParentComposeTest.kt index 81beeda7f9..2b986e6fd8 100644 --- a/apps/parent/src/androidTest/java/com/instructure/parentapp/utils/ParentComposeTest.kt +++ b/apps/parent/src/androidTest/java/com/instructure/parentapp/utils/ParentComposeTest.kt @@ -20,6 +20,7 @@ package com.instructure.parentapp.utils import androidx.compose.ui.test.junit4.createAndroidComposeRule import com.instructure.canvas.espresso.common.pages.AssignmentDetailsPage import com.instructure.canvas.espresso.common.pages.AssignmentReminderPage +import com.instructure.canvas.espresso.common.pages.CalendarReminderPage import com.instructure.canvas.espresso.common.pages.compose.CalendarEventCreateEditPage import com.instructure.canvas.espresso.common.pages.compose.CalendarEventDetailsPage import com.instructure.canvas.espresso.common.pages.compose.CalendarFilterPage @@ -82,6 +83,7 @@ abstract class ParentComposeTest : ParentTest() { protected val calendarToDoDetailsPage = CalendarToDoDetailsPage(composeTestRule) protected val calendarFilterPage = CalendarFilterPage(composeTestRule) protected val assignmentReminderPage = AssignmentReminderPage(composeTestRule) + protected val calendarReminderPage = CalendarReminderPage(composeTestRule) protected val inboxSignatureSettingsPage = InboxSignatureSettingsPage(composeTestRule) protected val assignmentDetailsPage = AssignmentDetailsPage(ModuleItemInteractions(), composeTestRule) diff --git a/apps/student/src/androidTest/java/com/instructure/student/ui/e2e/compose/CalendarE2ETest.kt b/apps/student/src/androidTest/java/com/instructure/student/ui/e2e/compose/CalendarE2ETest.kt index 661fd12c56..f91bbcbfc1 100644 --- a/apps/student/src/androidTest/java/com/instructure/student/ui/e2e/compose/CalendarE2ETest.kt +++ b/apps/student/src/androidTest/java/com/instructure/student/ui/e2e/compose/CalendarE2ETest.kt @@ -16,13 +16,20 @@ package com.instructure.student.ui.e2e.compose import android.util.Log +import androidx.test.espresso.Espresso import com.instructure.canvas.espresso.FeatureCategory import com.instructure.canvas.espresso.Priority +import com.instructure.canvas.espresso.SecondaryFeatureCategory import com.instructure.canvas.espresso.TestCategory import com.instructure.canvas.espresso.TestMetaData import com.instructure.canvas.espresso.annotations.E2E +import com.instructure.canvas.espresso.checkToastText +import com.instructure.dataseeding.util.days +import com.instructure.dataseeding.util.fromNow import com.instructure.espresso.getDateInCanvasCalendarFormat import com.instructure.pandautils.features.calendar.CalendarPrefs +import com.instructure.pandautils.utils.toFormattedString +import com.instructure.student.R import com.instructure.student.ui.utils.StudentComposeTest import com.instructure.student.ui.utils.extensions.seedData import com.instructure.student.ui.utils.extensions.tokenLogin @@ -313,4 +320,518 @@ class CalendarE2ETest : StudentComposeTest() { calendarScreenPage.assertItemDetails(newEventTitle, student.name, currentDate) } + @E2E + @Test + @TestMetaData(Priority.MANDATORY, FeatureCategory.CALENDAR, TestCategory.E2E, SecondaryFeatureCategory.CALENDAR_EVENT_REMINDER) + fun testCalendarEventCustomReminderE2E() { + + Log.d(PREPARATION_TAG, "Seeding data.") + val data = seedData(students = 1, courses = 1) + val student = data.studentsList[0] + val futureDate = 2.days.fromNow + + Log.d(STEP_TAG, "Login with user: '${student.name}', login id: '${student.loginId}'.") + tokenLogin(student) + + Log.d(ASSERTION_TAG, "Assert that the Dashboard Page is the landing page and it is loaded successfully.") + dashboardPage.waitForRender() + dashboardPage.assertPageObjects() + + Log.d(STEP_TAG, "Click on the 'Calendar' bottom menu to navigate to the Calendar page.") + dashboardPage.clickCalendarTab() + + Log.d(ASSERTION_TAG, "Assert that the page title is 'Calendar'.") + calendarScreenPage.assertCalendarPageTitle() + + Log.d(STEP_TAG, "Click on the 'Add' (FAB) button and 'Add Event' to create a new event.") + calendarScreenPage.clickOnAddButton() + calendarScreenPage.clickAddEvent() + + Log.d(ASSERTION_TAG, "Assert that the Calendar Event Page is displayed and the title is 'New Event' as we are making a new one.") + calendarEventCreateEditPage.assertTitle("New Event") + + val newEventTitle = "Test Event With Reminder" + Log.d(STEP_TAG, "Type '$newEventTitle' to the title input field.") + calendarEventCreateEditPage.typeTitle(newEventTitle) + + val calendar = Calendar.getInstance().apply { timeInMillis = futureDate.timeInMillis } + Log.d(STEP_TAG, "Select a date which is 2 days in the future from today.") + calendarEventCreateEditPage.selectDate(calendar) + + Log.d(STEP_TAG, "Click on 'Save' to create the event.") + calendarEventCreateEditPage.clickSave() + + Log.d(STEP_TAG, "Swipe the calendar item 'body' to 2 days in the future from now.") + calendarScreenPage.swipeEventsLeft() + calendarScreenPage.swipeEventsLeft() + + Log.d(ASSERTION_TAG, "Assert that the event is displayed on the calendar.") + calendarScreenPage.assertItemDisplayed(newEventTitle) + + Log.d(STEP_TAG, "Click on the previously created '$newEventTitle' event.") + calendarScreenPage.clickOnItem(newEventTitle) + + Log.d(ASSERTION_TAG, "Assert that the Calendar Event Details Page is displayed and the title is 'Event'.") + calendarEventDetailsPage.assertEventDetailsPageTitle() + + Log.d(ASSERTION_TAG, "Assert that the reminder section is displayed.") + calendarReminderPage.assertReminderSectionDisplayed() + + Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to pick up a new reminder.") + calendarReminderPage.clickAddReminder() + + val reminderDateOneHour = futureDate.apply { add(Calendar.HOUR, -1) } + Log.d(STEP_TAG, "Select '1 Hour Before' using custom date/time picker.") + calendarReminderPage.clickCustomReminderOption() + calendarReminderPage.selectDate(reminderDateOneHour) + calendarReminderPage.selectTime(reminderDateOneHour) + + Log.d(ASSERTION_TAG, "Assert that the reminder has been picked up and displayed on the Event Details Page.") + calendarReminderPage.assertReminderDisplayedWithText(reminderDateOneHour.time.toFormattedString()) + + Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to pick up a new reminder.") + calendarReminderPage.clickAddReminder() + + Log.d(STEP_TAG, "Select '1 Hour Before' again.") + calendarReminderPage.clickCustomReminderOption() + calendarReminderPage.selectDate(reminderDateOneHour) + calendarReminderPage.selectTime(reminderDateOneHour) + + Log.d(ASSERTION_TAG, "Assert that a toast message is occurring which warns that we cannot pick up the same time reminder twice.") + checkToastText(R.string.reminderAlreadySet, activityRule.activity) + + Log.d(STEP_TAG, "Remove the '1 Hour Before' reminder and confirm the deletion dialog.") + calendarReminderPage.removeReminder() + + Log.d(ASSERTION_TAG, "Assert that the '1 Hour Before' reminder is not displayed any more.") + calendarReminderPage.assertReminderNotDisplayedWithText(reminderDateOneHour.time.toFormattedString()) + futureDate.apply { add(Calendar.HOUR, 1) } + + Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to pick up a new reminder.") + calendarReminderPage.clickAddReminder() + + val reminderDateOneWeek = futureDate.apply { add(Calendar.WEEK_OF_YEAR, -1) } + Log.d(STEP_TAG, "Select '1 Week Before'.") + calendarReminderPage.clickCustomReminderOption() + calendarReminderPage.selectDate(reminderDateOneWeek) + calendarReminderPage.selectTime(reminderDateOneWeek) + + Log.d(ASSERTION_TAG, "Assert that a toast message is occurring which warns that we cannot pick up a reminder which has already passed (for example cannot pick '1 Week Before' reminder for an event which ends in 2 days).") + calendarReminderPage.assertReminderNotDisplayedWithText(reminderDateOneWeek.time.toFormattedString()) + checkToastText(R.string.reminderInPast, activityRule.activity) + futureDate.apply { add(Calendar.WEEK_OF_YEAR, 1) } + + Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to pick up a new reminder.") + calendarReminderPage.clickAddReminder() + + val reminderDateOneDay = futureDate.apply { add(Calendar.DAY_OF_MONTH, -1) }.apply { add(Calendar.HOUR, -1) } + Log.d(STEP_TAG, "Select '1 Day Before and 1 hour before'.") + calendarReminderPage.clickCustomReminderOption() + calendarReminderPage.selectDate(reminderDateOneDay) + calendarReminderPage.selectTime(reminderDateOneDay) + + Log.d(ASSERTION_TAG, "Assert that the reminder has been picked up and displayed on the Event Details Page.") + calendarReminderPage.assertReminderDisplayedWithText(reminderDateOneDay.time.toFormattedString()) + + Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to pick up a new reminder.") + calendarReminderPage.clickAddReminder() + + Log.d(STEP_TAG, "Select '1 Day Before' again.") + calendarReminderPage.clickCustomReminderOption() + calendarReminderPage.selectDate(reminderDateOneDay) + calendarReminderPage.selectTime(reminderDateOneDay) + + Log.d(ASSERTION_TAG, "Assert that a toast message is occurring which warns that we cannot pick up the same time reminder twice. (Because 1 days and 24 hours is the same)") + checkToastText(R.string.reminderAlreadySet, activityRule.activity) + futureDate.apply { add(Calendar.DAY_OF_MONTH, 1) } + + Log.d(STEP_TAG, "Navigate back to Calendar Screen Page.") + Espresso.pressBack() + + Log.d(ASSERTION_TAG, "Assert that the event is displayed on the calendar.") + calendarScreenPage.assertItemDisplayed(newEventTitle) + } + + @E2E + @Test + @TestMetaData(Priority.MANDATORY, FeatureCategory.CALENDAR, TestCategory.E2E, SecondaryFeatureCategory.CALENDAR_EVENT_REMINDER) + fun testCalendarEventBeforeReminderE2E() { + + Log.d(PREPARATION_TAG, "Seeding data.") + val data = seedData(students = 1, courses = 1) + val student = data.studentsList[0] + val futureDate = 2.days.fromNow + + Log.d(STEP_TAG, "Login with user: '${student.name}', login id: '${student.loginId}'.") + tokenLogin(student) + + Log.d(ASSERTION_TAG, "Assert that the Dashboard Page is the landing page and it is loaded successfully.") + dashboardPage.waitForRender() + dashboardPage.assertPageObjects() + + Log.d(STEP_TAG, "Click on the 'Calendar' bottom menu to navigate to the Calendar page.") + dashboardPage.clickCalendarTab() + + Log.d(ASSERTION_TAG, "Assert that the page title is 'Calendar'.") + calendarScreenPage.assertCalendarPageTitle() + + Log.d(STEP_TAG, "Click on the 'Add' (FAB) button and 'Add Event' to create a new event.") + calendarScreenPage.clickOnAddButton() + calendarScreenPage.clickAddEvent() + + Log.d(ASSERTION_TAG, "Assert that the Calendar Event Page is displayed and the title is 'New Event' as we are making a new one.") + calendarEventCreateEditPage.assertTitle("New Event") + + val newEventTitle = "Test Event With Reminder" + Log.d(STEP_TAG, "Type '$newEventTitle' to the title input field.") + calendarEventCreateEditPage.typeTitle(newEventTitle) + + val calendar = Calendar.getInstance().apply { timeInMillis = futureDate.timeInMillis } + Log.d(STEP_TAG, "Select a date which is 2 days in the future from today.") + calendarEventCreateEditPage.selectDate(calendar) + + Log.d(STEP_TAG, "Click on 'Save' to create the event.") + calendarEventCreateEditPage.clickSave() + + Log.d(STEP_TAG, "Swipe the calendar item 'body' to 2 days in the future from now.") + calendarScreenPage.swipeEventsLeft() + calendarScreenPage.swipeEventsLeft() + + Log.d(ASSERTION_TAG, "Assert that the event is displayed on the calendar.") + calendarScreenPage.assertItemDisplayed(newEventTitle) + + Log.d(STEP_TAG, "Click on the previously created '$newEventTitle' event.") + calendarScreenPage.clickOnItem(newEventTitle) + + Log.d(ASSERTION_TAG, "Assert that the Calendar Event Details Page is displayed and the title is 'Event'.") + calendarEventDetailsPage.assertEventDetailsPageTitle() + + Log.d(ASSERTION_TAG, "Assert that the reminder section is displayed.") + calendarReminderPage.assertReminderSectionDisplayed() + + Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to pick up a new reminder.") + calendarReminderPage.clickAddReminder() + + val reminderDateOneHour = futureDate.apply { add(Calendar.HOUR, -1) } + Log.d(STEP_TAG, "Select '1 Hour Before'.") + calendarReminderPage.clickBeforeReminderOption("1 Hour Before") + + Log.d(ASSERTION_TAG, "Assert that the reminder has been picked up and displayed on the Event Details Page.") + calendarReminderPage.assertReminderDisplayedWithText(reminderDateOneHour.time.toFormattedString()) + + Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to pick up a new reminder.") + calendarReminderPage.clickAddReminder() + + Log.d(STEP_TAG, "Select '1 Hour Before' again.") + calendarReminderPage.clickBeforeReminderOption("1 Hour Before") + + Log.d(ASSERTION_TAG, "Assert that a toast message is occurring which warns that we cannot pick up the same time reminder twice.") + checkToastText(R.string.reminderAlreadySet, activityRule.activity) + + Log.d(STEP_TAG, "Remove the '1 Hour Before' reminder and confirm the deletion dialog.") + calendarReminderPage.removeReminder() + + Log.d(ASSERTION_TAG, "Assert that the '1 Hour Before' reminder is not displayed any more.") + calendarReminderPage.assertReminderNotDisplayedWithText(reminderDateOneHour.time.toFormattedString()) + futureDate.apply { add(Calendar.HOUR, 1) } + + Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to add a new reminder.") + calendarReminderPage.clickAddReminder() + + val reminderDateOneWeek = futureDate.apply { add(Calendar.WEEK_OF_YEAR, -1) } + Log.d(STEP_TAG, "Select '1 Week Before'.") + calendarReminderPage.clickBeforeReminderOption("1 Week Before") + + Log.d(ASSERTION_TAG, "Assert that a toast message is occurring which warns that we cannot pick up a reminder which has already passed (for example cannot pick '1 Week Before' reminder for an event which ends in 2 days).") + calendarReminderPage.assertReminderNotDisplayedWithText(reminderDateOneWeek.time.toFormattedString()) + checkToastText(R.string.reminderInPast, activityRule.activity) + futureDate.apply { add(Calendar.WEEK_OF_YEAR, 1) } + + Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to add a new reminder.") + calendarReminderPage.clickAddReminder() + + val reminderDateOneDay = futureDate.apply { add(Calendar.DAY_OF_MONTH, -1) } + Log.d(STEP_TAG, "Select '1 Day Before'.") + calendarReminderPage.clickBeforeReminderOption("1 Day Before") + + Log.d(ASSERTION_TAG, "Assert that the reminder has been picked up and displayed on the Event Details Page.") + calendarReminderPage.assertReminderDisplayedWithText(reminderDateOneDay.time.toFormattedString()) + + Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to pick up a new reminder.") + calendarReminderPage.clickAddReminder() + + Log.d(STEP_TAG, "Select '1 Day Before' again.") + calendarReminderPage.clickBeforeReminderOption("1 Day Before") + + Log.d(ASSERTION_TAG, "Assert that a toast message is occurring which warns that we cannot pick up the same time reminder twice. (Because 1 days and 24 hours is the same)") + checkToastText(R.string.reminderAlreadySet, activityRule.activity) + futureDate.apply { add(Calendar.DAY_OF_MONTH, 1) } + + Log.d(STEP_TAG, "Navigate back to Calendar Screen Page.") + Espresso.pressBack() + + Log.d(ASSERTION_TAG, "Assert that the event is displayed on the calendar.") + calendarScreenPage.assertItemDisplayed(newEventTitle) + } + + @E2E + @Test + @TestMetaData(Priority.MANDATORY, FeatureCategory.CALENDAR, TestCategory.E2E, SecondaryFeatureCategory.CALENDAR_TODO_REMINDER) + fun testCalendarToDoCustomReminderE2E() { + + Log.d(PREPARATION_TAG, "Seeding data.") + val data = seedData(students = 1, courses = 1) + val student = data.studentsList[0] + val futureDate = 2.days.fromNow + + Log.d(STEP_TAG, "Login with user: '${student.name}', login id: '${student.loginId}'.") + tokenLogin(student) + + Log.d(ASSERTION_TAG, "Assert that the Dashboard Page is the landing page and it is loaded successfully.") + dashboardPage.waitForRender() + dashboardPage.assertPageObjects() + + Log.d(STEP_TAG, "Click on the 'Calendar' bottom menu to navigate to the Calendar page.") + dashboardPage.clickCalendarTab() + + Log.d(ASSERTION_TAG, "Assert that the page title is 'Calendar'.") + calendarScreenPage.assertCalendarPageTitle() + + Log.d(STEP_TAG, "Click on the 'Add' (FAB) button and 'Add To Do' to create a new To Do.") + calendarScreenPage.clickOnAddButton() + calendarScreenPage.clickAddTodo() + + Log.d(ASSERTION_TAG, "Assert that the page title is 'New To Do' as we are clicked on the 'Add To Do' button to create a new one.") + calendarToDoCreateUpdatePage.assertPageTitle("New To Do") + + val testTodoTitle = "Test ToDo With Reminder" + val testTodoDescription = "Details of ToDo" + Log.d(STEP_TAG, "Fill the title with '$testTodoTitle' and the description with '$testTodoDescription'.") + calendarToDoCreateUpdatePage.typeTodoTitle(testTodoTitle) + calendarToDoCreateUpdatePage.typeDetails(testTodoDescription) + + val calendar = Calendar.getInstance().apply { timeInMillis = futureDate.timeInMillis } + Log.d(STEP_TAG, "Select a date which is 2 days in the future from today.") + calendarToDoCreateUpdatePage.selectDate(calendar) + + Log.d(STEP_TAG, "Click on the 'Save' button.") + calendarToDoCreateUpdatePage.clickSave() + + Log.d(STEP_TAG, "Swipe the calendar item 'body' to 2 days in the future from now.") + calendarScreenPage.swipeEventsLeft() + calendarScreenPage.swipeEventsLeft() + + Log.d(ASSERTION_TAG, "Assert that the To Do item is displayed on the calendar.") + calendarScreenPage.assertItemDisplayed(testTodoTitle) + + Log.d(STEP_TAG, "Click on the previously created '$testTodoTitle' To Do item.") + calendarScreenPage.clickOnItem(testTodoTitle) + + Log.d(ASSERTION_TAG, "Assert that the title is '$testTodoTitle' and the context is 'To Do'.") + calendarToDoDetailsPage.assertTitle(testTodoTitle) + calendarToDoDetailsPage.assertPageTitle("To Do") + + Log.d(ASSERTION_TAG, "Assert that the reminder section is displayed.") + calendarReminderPage.assertReminderSectionDisplayed() + + Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to pick up a new reminder.") + calendarReminderPage.clickAddReminder() + + val reminderDateOneHour = futureDate.apply { add(Calendar.HOUR, -1) } + Log.d(STEP_TAG, "Select '1 Hour Before' using custom date/time picker.") + calendarReminderPage.clickCustomReminderOption() + calendarReminderPage.selectDate(reminderDateOneHour) + calendarReminderPage.selectTime(reminderDateOneHour) + + Log.d(ASSERTION_TAG, "Assert that the reminder has been picked up and displayed on the To Do Details Page.") + calendarReminderPage.assertReminderDisplayedWithText(reminderDateOneHour.time.toFormattedString()) + + Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to pick up a new reminder.") + calendarReminderPage.clickAddReminder() + + Log.d(STEP_TAG, "Select '1 Hour Before' again.") + calendarReminderPage.clickCustomReminderOption() + calendarReminderPage.selectDate(reminderDateOneHour) + calendarReminderPage.selectTime(reminderDateOneHour) + + Log.d(ASSERTION_TAG, "Assert that a toast message is occurring which warns that we cannot pick up the same time reminder twice.") + checkToastText(R.string.reminderAlreadySet, activityRule.activity) + + Log.d(STEP_TAG, "Remove the '1 Hour Before' reminder and confirm the deletion dialog.") + calendarReminderPage.removeReminder() + + Log.d(ASSERTION_TAG, "Assert that the '1 Hour Before' reminder is not displayed any more.") + calendarReminderPage.assertReminderNotDisplayedWithText(reminderDateOneHour.time.toFormattedString()) + futureDate.apply { add(Calendar.HOUR, 1) } + + Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to pick up a new reminder.") + calendarReminderPage.clickAddReminder() + + val reminderDateOneWeek = futureDate.apply { add(Calendar.WEEK_OF_YEAR, -1) } + Log.d(STEP_TAG, "Select '1 Week Before'.") + calendarReminderPage.clickCustomReminderOption() + calendarReminderPage.selectDate(reminderDateOneWeek) + calendarReminderPage.selectTime(reminderDateOneWeek) + + Log.d(ASSERTION_TAG, "Assert that a toast message is occurring which warns that we cannot pick up a reminder which has already passed (for example cannot pick '1 Week Before' reminder for a To Do which is due in 2 days).") + calendarReminderPage.assertReminderNotDisplayedWithText(reminderDateOneWeek.time.toFormattedString()) + checkToastText(R.string.reminderInPast, activityRule.activity) + futureDate.apply { add(Calendar.WEEK_OF_YEAR, 1) } + + Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to pick up a new reminder.") + calendarReminderPage.clickAddReminder() + + val reminderDateOneDay = futureDate.apply { add(Calendar.DAY_OF_MONTH, -1) }.apply { add(Calendar.HOUR, -1) } + Log.d(STEP_TAG, "Select '1 Day Before and 1 hour before'.") + calendarReminderPage.clickCustomReminderOption() + calendarReminderPage.selectDate(reminderDateOneDay) + calendarReminderPage.selectTime(reminderDateOneDay) + + Log.d(ASSERTION_TAG, "Assert that the reminder has been picked up and displayed on the To Do Details Page.") + calendarReminderPage.assertReminderDisplayedWithText(reminderDateOneDay.time.toFormattedString()) + + Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to pick up a new reminder.") + calendarReminderPage.clickAddReminder() + + Log.d(STEP_TAG, "Select '1 Day Before' again.") + calendarReminderPage.clickCustomReminderOption() + calendarReminderPage.selectDate(reminderDateOneDay) + calendarReminderPage.selectTime(reminderDateOneDay) + + Log.d(ASSERTION_TAG, "Assert that a toast message is occurring which warns that we cannot pick up the same time reminder twice. (Because 1 days and 24 hours is the same)") + checkToastText(R.string.reminderAlreadySet, activityRule.activity) + futureDate.apply { add(Calendar.DAY_OF_MONTH, 1) } + + Log.d(STEP_TAG, "Navigate back to Calendar Screen Page.") + Espresso.pressBack() + + Log.d(ASSERTION_TAG, "Assert that the To Do item is displayed on the calendar.") + calendarScreenPage.assertItemDisplayed(testTodoTitle) + } + + @E2E + @Test + @TestMetaData(Priority.MANDATORY, FeatureCategory.CALENDAR, TestCategory.E2E, SecondaryFeatureCategory.CALENDAR_TODO_REMINDER) + fun testCalendarToDoBeforeReminderE2E() { + + Log.d(PREPARATION_TAG, "Seeding data.") + val data = seedData(students = 1, courses = 1) + val student = data.studentsList[0] + val futureDate = 2.days.fromNow + + Log.d(STEP_TAG, "Login with user: '${student.name}', login id: '${student.loginId}'.") + tokenLogin(student) + + Log.d(ASSERTION_TAG, "Assert that the Dashboard Page is the landing page and it is loaded successfully.") + dashboardPage.waitForRender() + dashboardPage.assertPageObjects() + + Log.d(STEP_TAG, "Click on the 'Calendar' bottom menu to navigate to the Calendar page.") + dashboardPage.clickCalendarTab() + + Log.d(ASSERTION_TAG, "Assert that the page title is 'Calendar'.") + calendarScreenPage.assertCalendarPageTitle() + + Log.d(STEP_TAG, "Click on the 'Add' (FAB) button and 'Add To Do' to create a new To Do.") + calendarScreenPage.clickOnAddButton() + calendarScreenPage.clickAddTodo() + + Log.d(ASSERTION_TAG, "Assert that the page title is 'New To Do' as we are clicked on the 'Add To Do' button to create a new one.") + calendarToDoCreateUpdatePage.assertPageTitle("New To Do") + + val testTodoTitle = "Test ToDo With Reminder" + val testTodoDescription = "Details of ToDo" + Log.d(STEP_TAG, "Fill the title with '$testTodoTitle' and the description with '$testTodoDescription'.") + calendarToDoCreateUpdatePage.typeTodoTitle(testTodoTitle) + calendarToDoCreateUpdatePage.typeDetails(testTodoDescription) + + val calendar = Calendar.getInstance().apply { timeInMillis = futureDate.timeInMillis } + Log.d(STEP_TAG, "Select a date which is 2 days in the future from today.") + calendarToDoCreateUpdatePage.selectDate(calendar) + + Log.d(STEP_TAG, "Click on the 'Save' button.") + calendarToDoCreateUpdatePage.clickSave() + + Log.d(STEP_TAG, "Swipe the calendar item 'body' to 2 days in the future from now.") + calendarScreenPage.swipeEventsLeft() + calendarScreenPage.swipeEventsLeft() + + Log.d(ASSERTION_TAG, "Assert that the To Do item is displayed on the calendar.") + calendarScreenPage.assertItemDisplayed(testTodoTitle) + + Log.d(STEP_TAG, "Click on the previously created '$testTodoTitle' To Do item.") + calendarScreenPage.clickOnItem(testTodoTitle) + + Log.d(ASSERTION_TAG, "Assert that the title is '$testTodoTitle' and the context is 'To Do'.") + calendarToDoDetailsPage.assertTitle(testTodoTitle) + calendarToDoDetailsPage.assertPageTitle("To Do") + + Log.d(ASSERTION_TAG, "Assert that the reminder section is displayed.") + calendarReminderPage.assertReminderSectionDisplayed() + + Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to pick up a new reminder.") + calendarReminderPage.clickAddReminder() + + val reminderDateOneHour = futureDate.apply { add(Calendar.HOUR, -1) } + Log.d(STEP_TAG, "Select '1 Hour Before'.") + calendarReminderPage.clickBeforeReminderOption("1 Hour Before") + + Log.d(ASSERTION_TAG, "Assert that the reminder has been picked up and displayed on the To Do Details Page.") + calendarReminderPage.assertReminderDisplayedWithText(reminderDateOneHour.time.toFormattedString()) + + Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to pick up a new reminder.") + calendarReminderPage.clickAddReminder() + + Log.d(STEP_TAG, "Select '1 Hour Before' again.") + calendarReminderPage.clickBeforeReminderOption("1 Hour Before") + + Log.d(ASSERTION_TAG, "Assert that a toast message is occurring which warns that we cannot pick up the same time reminder twice.") + checkToastText(R.string.reminderAlreadySet, activityRule.activity) + + Log.d(STEP_TAG, "Remove the '1 Hour Before' reminder and confirm the deletion dialog.") + calendarReminderPage.removeReminder() + + Log.d(ASSERTION_TAG, "Assert that the '1 Hour Before' reminder is not displayed any more.") + calendarReminderPage.assertReminderNotDisplayedWithText(reminderDateOneHour.time.toFormattedString()) + futureDate.apply { add(Calendar.HOUR, 1) } + + Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to add a new reminder.") + calendarReminderPage.clickAddReminder() + + val reminderDateOneWeek = futureDate.apply { add(Calendar.WEEK_OF_YEAR, -1) } + Log.d(STEP_TAG, "Select '1 Week Before'.") + calendarReminderPage.clickBeforeReminderOption("1 Week Before") + + Log.d(ASSERTION_TAG, "Assert that a toast message is occurring which warns that we cannot pick up a reminder which has already passed (for example cannot pick '1 Week Before' reminder for a To Do which is due in 2 days).") + calendarReminderPage.assertReminderNotDisplayedWithText(reminderDateOneWeek.time.toFormattedString()) + checkToastText(R.string.reminderInPast, activityRule.activity) + futureDate.apply { add(Calendar.WEEK_OF_YEAR, 1) } + + Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to add a new reminder.") + calendarReminderPage.clickAddReminder() + + val reminderDateOneDay = futureDate.apply { add(Calendar.DAY_OF_MONTH, -1) } + Log.d(STEP_TAG, "Select '1 Day Before'.") + calendarReminderPage.clickBeforeReminderOption("1 Day Before") + + Log.d(ASSERTION_TAG, "Assert that the reminder has been picked up and displayed on the To Do Details Page.") + calendarReminderPage.assertReminderDisplayedWithText(reminderDateOneDay.time.toFormattedString()) + + Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to pick up a new reminder.") + calendarReminderPage.clickAddReminder() + + Log.d(STEP_TAG, "Select '1 Day Before' again.") + calendarReminderPage.clickBeforeReminderOption("1 Day Before") + + Log.d(ASSERTION_TAG, "Assert that a toast message is occurring which warns that we cannot pick up the same time reminder twice. (Because 1 days and 24 hours is the same)") + checkToastText(R.string.reminderAlreadySet, activityRule.activity) + futureDate.apply { add(Calendar.DAY_OF_MONTH, 1) } + + Log.d(STEP_TAG, "Navigate back to Calendar Screen Page.") + Espresso.pressBack() + + Log.d(ASSERTION_TAG, "Assert that the To Do item is displayed on the calendar.") + calendarScreenPage.assertItemDisplayed(testTodoTitle) + } + } \ No newline at end of file diff --git a/apps/student/src/androidTest/java/com/instructure/student/ui/utils/StudentComposeTest.kt b/apps/student/src/androidTest/java/com/instructure/student/ui/utils/StudentComposeTest.kt index 5ccf520462..63b658dc24 100644 --- a/apps/student/src/androidTest/java/com/instructure/student/ui/utils/StudentComposeTest.kt +++ b/apps/student/src/androidTest/java/com/instructure/student/ui/utils/StudentComposeTest.kt @@ -20,6 +20,7 @@ package com.instructure.student.ui.utils import androidx.compose.ui.test.junit4.createAndroidComposeRule import com.instructure.canvas.espresso.common.pages.AssignmentReminderPage +import com.instructure.canvas.espresso.common.pages.CalendarReminderPage import com.instructure.canvas.espresso.common.pages.compose.AssignmentListPage import com.instructure.canvas.espresso.common.pages.compose.CalendarEventCreateEditPage import com.instructure.canvas.espresso.common.pages.compose.CalendarEventDetailsPage @@ -55,6 +56,7 @@ abstract class StudentComposeTest : StudentTest() { val calendarFilterPage = CalendarFilterPage(composeTestRule) val settingsPage = SettingsPage(composeTestRule) val assignmentReminderPage = AssignmentReminderPage(composeTestRule) + val calendarReminderPage = CalendarReminderPage(composeTestRule) val inboxDetailsPage = InboxDetailsPage(composeTestRule) val inboxComposePage = InboxComposePage(composeTestRule) val recipientPickerPage = RecipientPickerPage(composeTestRule) diff --git a/apps/teacher/src/androidTest/java/com/instructure/teacher/ui/e2e/compose/CalendarE2ETest.kt b/apps/teacher/src/androidTest/java/com/instructure/teacher/ui/e2e/compose/CalendarE2ETest.kt index dd77cfa54a..9e235cb4f8 100644 --- a/apps/teacher/src/androidTest/java/com/instructure/teacher/ui/e2e/compose/CalendarE2ETest.kt +++ b/apps/teacher/src/androidTest/java/com/instructure/teacher/ui/e2e/compose/CalendarE2ETest.kt @@ -16,13 +16,20 @@ package com.instructure.teacher.ui.e2e.compose import android.util.Log +import androidx.test.espresso.Espresso import com.instructure.canvas.espresso.FeatureCategory import com.instructure.canvas.espresso.Priority +import com.instructure.canvas.espresso.SecondaryFeatureCategory import com.instructure.canvas.espresso.TestCategory import com.instructure.canvas.espresso.TestMetaData import com.instructure.canvas.espresso.annotations.E2E +import com.instructure.canvas.espresso.checkToastText +import com.instructure.dataseeding.util.days +import com.instructure.dataseeding.util.fromNow import com.instructure.espresso.getDateInCanvasCalendarFormat import com.instructure.pandautils.features.calendar.CalendarPrefs +import com.instructure.pandautils.utils.toFormattedString +import com.instructure.teacher.R import com.instructure.teacher.ui.utils.TeacherComposeTest import com.instructure.teacher.ui.utils.extensions.clickCalendarTab import com.instructure.teacher.ui.utils.extensions.seedData @@ -317,4 +324,518 @@ class CalendarE2ETest: TeacherComposeTest() { Log.d(ASSERTION_TAG, "Assert that the event is displayed with the corresponding details (title, context name, date, status) on the page.") calendarScreenPage.assertItemDetails(newEventTitle, teacher.name, currentDate) } + + @E2E + @Test + @TestMetaData(Priority.MANDATORY, FeatureCategory.CALENDAR, TestCategory.E2E, SecondaryFeatureCategory.CALENDAR_EVENT_REMINDER) + fun testCalendarEventCustomReminderE2E() { + + Log.d(PREPARATION_TAG, "Seeding data.") + val data = seedData(teachers = 1, courses = 1) + val teacher = data.teachersList[0] + val futureDate = 2.days.fromNow + + Log.d(STEP_TAG, "Login with user: '${teacher.name}', login id: '${teacher.loginId}'.") + tokenLogin(teacher) + + Log.d(ASSERTION_TAG, "Assert that the Dashboard Page is the landing page and it is loaded successfully.") + dashboardPage.waitForRender() + dashboardPage.assertPageObjects() + + Log.d(STEP_TAG, "Click on the 'Calendar' bottom menu to navigate to the Calendar page.") + dashboardPage.clickCalendarTab() + + Log.d(ASSERTION_TAG, "Assert that the page title is 'Calendar'.") + calendarScreenPage.assertCalendarPageTitle() + + Log.d(STEP_TAG, "Click on the 'Add' (FAB) button and 'Add Event' to create a new event.") + calendarScreenPage.clickOnAddButton() + calendarScreenPage.clickAddEvent() + + Log.d(ASSERTION_TAG, "Assert that the Calendar Event Page is displayed and the title is 'New Event' as we are making a new one.") + calendarEventCreateEditPage.assertTitle("New Event") + + val newEventTitle = "Test Event With Reminder" + Log.d(STEP_TAG, "Type '$newEventTitle' to the title input field.") + calendarEventCreateEditPage.typeTitle(newEventTitle) + + val calendar = Calendar.getInstance().apply { timeInMillis = futureDate.timeInMillis } + Log.d(STEP_TAG, "Select a date which is 2 days in the future from today.") + calendarEventCreateEditPage.selectDate(calendar) + + Log.d(STEP_TAG, "Click on 'Save' to create the event.") + calendarEventCreateEditPage.clickSave() + + Log.d(STEP_TAG, "Swipe the calendar item 'body' to 2 days in the future from now.") + calendarScreenPage.swipeEventsLeft() + calendarScreenPage.swipeEventsLeft() + + Log.d(ASSERTION_TAG, "Assert that the event is displayed on the calendar.") + calendarScreenPage.assertItemDisplayed(newEventTitle) + + Log.d(STEP_TAG, "Click on the previously created '$newEventTitle' event.") + calendarScreenPage.clickOnItem(newEventTitle) + + Log.d(ASSERTION_TAG, "Assert that the Calendar Event Details Page is displayed and the title is 'Event'.") + calendarEventDetailsPage.assertEventDetailsPageTitle() + + Log.d(ASSERTION_TAG, "Assert that the reminder section is displayed.") + calendarReminderPage.assertReminderSectionDisplayed() + + Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to pick up a new reminder.") + calendarReminderPage.clickAddReminder() + + val reminderDateOneHour = futureDate.apply { add(Calendar.HOUR, -1) } + Log.d(STEP_TAG, "Select '1 Hour Before' using custom date/time picker.") + calendarReminderPage.clickCustomReminderOption() + calendarReminderPage.selectDate(reminderDateOneHour) + calendarReminderPage.selectTime(reminderDateOneHour) + + Log.d(ASSERTION_TAG, "Assert that the reminder has been picked up and displayed on the Event Details Page.") + calendarReminderPage.assertReminderDisplayedWithText(reminderDateOneHour.time.toFormattedString()) + + Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to pick up a new reminder.") + calendarReminderPage.clickAddReminder() + + Log.d(STEP_TAG, "Select '1 Hour Before' again.") + calendarReminderPage.clickCustomReminderOption() + calendarReminderPage.selectDate(reminderDateOneHour) + calendarReminderPage.selectTime(reminderDateOneHour) + + Log.d(ASSERTION_TAG, "Assert that a toast message is occurring which warns that we cannot pick up the same time reminder twice.") + checkToastText(R.string.reminderAlreadySet, activityRule.activity) + + Log.d(STEP_TAG, "Remove the '1 Hour Before' reminder and confirm the deletion dialog.") + calendarReminderPage.removeReminder() + + Log.d(ASSERTION_TAG, "Assert that the '1 Hour Before' reminder is not displayed any more.") + calendarReminderPage.assertReminderNotDisplayedWithText(reminderDateOneHour.time.toFormattedString()) + futureDate.apply { add(Calendar.HOUR, 1) } + + Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to pick up a new reminder.") + calendarReminderPage.clickAddReminder() + + val reminderDateOneWeek = futureDate.apply { add(Calendar.WEEK_OF_YEAR, -1) } + Log.d(STEP_TAG, "Select '1 Week Before'.") + calendarReminderPage.clickCustomReminderOption() + calendarReminderPage.selectDate(reminderDateOneWeek) + calendarReminderPage.selectTime(reminderDateOneWeek) + + Log.d(ASSERTION_TAG, "Assert that a toast message is occurring which warns that we cannot pick up a reminder which has already passed (for example cannot pick '1 Week Before' reminder for an event which ends in 2 days).") + calendarReminderPage.assertReminderNotDisplayedWithText(reminderDateOneWeek.time.toFormattedString()) + checkToastText(R.string.reminderInPast, activityRule.activity) + futureDate.apply { add(Calendar.WEEK_OF_YEAR, 1) } + + Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to pick up a new reminder.") + calendarReminderPage.clickAddReminder() + + val reminderDateOneDay = futureDate.apply { add(Calendar.DAY_OF_MONTH, -1) }.apply { add(Calendar.HOUR, -1) } + Log.d(STEP_TAG, "Select '1 Day Before and 1 hour before'.") + calendarReminderPage.clickCustomReminderOption() + calendarReminderPage.selectDate(reminderDateOneDay) + calendarReminderPage.selectTime(reminderDateOneDay) + + Log.d(ASSERTION_TAG, "Assert that the reminder has been picked up and displayed on the Event Details Page.") + calendarReminderPage.assertReminderDisplayedWithText(reminderDateOneDay.time.toFormattedString()) + + Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to pick up a new reminder.") + calendarReminderPage.clickAddReminder() + + Log.d(STEP_TAG, "Select '1 Day Before' again.") + calendarReminderPage.clickCustomReminderOption() + calendarReminderPage.selectDate(reminderDateOneDay) + calendarReminderPage.selectTime(reminderDateOneDay) + + Log.d(ASSERTION_TAG, "Assert that a toast message is occurring which warns that we cannot pick up the same time reminder twice. (Because 1 days and 24 hours is the same)") + checkToastText(R.string.reminderAlreadySet, activityRule.activity) + futureDate.apply { add(Calendar.DAY_OF_MONTH, 1) } + + Log.d(STEP_TAG, "Navigate back to Calendar Screen Page.") + Espresso.pressBack() + + Log.d(ASSERTION_TAG, "Assert that the event is displayed on the calendar.") + calendarScreenPage.assertItemDisplayed(newEventTitle) + } + + @E2E + @Test + @TestMetaData(Priority.MANDATORY, FeatureCategory.CALENDAR, TestCategory.E2E, SecondaryFeatureCategory.CALENDAR_EVENT_REMINDER) + fun testCalendarEventBeforeReminderE2E() { + + Log.d(PREPARATION_TAG, "Seeding data.") + val data = seedData(teachers = 1, courses = 1) + val teacher = data.teachersList[0] + val futureDate = 2.days.fromNow + + Log.d(STEP_TAG, "Login with user: '${teacher.name}', login id: '${teacher.loginId}'.") + tokenLogin(teacher) + + Log.d(ASSERTION_TAG, "Assert that the Dashboard Page is the landing page and it is loaded successfully.") + dashboardPage.waitForRender() + dashboardPage.assertPageObjects() + + Log.d(STEP_TAG, "Click on the 'Calendar' bottom menu to navigate to the Calendar page.") + dashboardPage.clickCalendarTab() + + Log.d(ASSERTION_TAG, "Assert that the page title is 'Calendar'.") + calendarScreenPage.assertCalendarPageTitle() + + Log.d(STEP_TAG, "Click on the 'Add' (FAB) button and 'Add Event' to create a new event.") + calendarScreenPage.clickOnAddButton() + calendarScreenPage.clickAddEvent() + + Log.d(ASSERTION_TAG, "Assert that the Calendar Event Page is displayed and the title is 'New Event' as we are making a new one.") + calendarEventCreateEditPage.assertTitle("New Event") + + val newEventTitle = "Test Event With Reminder" + Log.d(STEP_TAG, "Type '$newEventTitle' to the title input field.") + calendarEventCreateEditPage.typeTitle(newEventTitle) + + val calendar = Calendar.getInstance().apply { timeInMillis = futureDate.timeInMillis } + Log.d(STEP_TAG, "Select a date which is 2 days in the future from today.") + calendarEventCreateEditPage.selectDate(calendar) + + Log.d(STEP_TAG, "Click on 'Save' to create the event.") + calendarEventCreateEditPage.clickSave() + + Log.d(STEP_TAG, "Swipe the calendar item 'body' to 2 days in the future from now.") + calendarScreenPage.swipeEventsLeft() + calendarScreenPage.swipeEventsLeft() + + Log.d(ASSERTION_TAG, "Assert that the event is displayed on the calendar.") + calendarScreenPage.assertItemDisplayed(newEventTitle) + + Log.d(STEP_TAG, "Click on the previously created '$newEventTitle' event.") + calendarScreenPage.clickOnItem(newEventTitle) + + Log.d(ASSERTION_TAG, "Assert that the Calendar Event Details Page is displayed and the title is 'Event'.") + calendarEventDetailsPage.assertEventDetailsPageTitle() + + Log.d(ASSERTION_TAG, "Assert that the reminder section is displayed.") + calendarReminderPage.assertReminderSectionDisplayed() + + Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to pick up a new reminder.") + calendarReminderPage.clickAddReminder() + + val reminderDateOneHour = futureDate.apply { add(Calendar.HOUR, -1) } + Log.d(STEP_TAG, "Select '1 Hour Before'.") + calendarReminderPage.clickBeforeReminderOption("1 Hour Before") + + Log.d(ASSERTION_TAG, "Assert that the reminder has been picked up and displayed on the Event Details Page.") + calendarReminderPage.assertReminderDisplayedWithText(reminderDateOneHour.time.toFormattedString()) + + Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to pick up a new reminder.") + calendarReminderPage.clickAddReminder() + + Log.d(STEP_TAG, "Select '1 Hour Before' again.") + calendarReminderPage.clickBeforeReminderOption("1 Hour Before") + + Log.d(ASSERTION_TAG, "Assert that a toast message is occurring which warns that we cannot pick up the same time reminder twice.") + checkToastText(R.string.reminderAlreadySet, activityRule.activity) + + Log.d(STEP_TAG, "Remove the '1 Hour Before' reminder and confirm the deletion dialog.") + calendarReminderPage.removeReminder() + + Log.d(ASSERTION_TAG, "Assert that the '1 Hour Before' reminder is not displayed any more.") + calendarReminderPage.assertReminderNotDisplayedWithText(reminderDateOneHour.time.toFormattedString()) + futureDate.apply { add(Calendar.HOUR, 1) } + + Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to add a new reminder.") + calendarReminderPage.clickAddReminder() + + val reminderDateOneWeek = futureDate.apply { add(Calendar.WEEK_OF_YEAR, -1) } + Log.d(STEP_TAG, "Select '1 Week Before'.") + calendarReminderPage.clickBeforeReminderOption("1 Week Before") + + Log.d(ASSERTION_TAG, "Assert that a toast message is occurring which warns that we cannot pick up a reminder which has already passed (for example cannot pick '1 Week Before' reminder for an event which ends in 2 days).") + calendarReminderPage.assertReminderNotDisplayedWithText(reminderDateOneWeek.time.toFormattedString()) + checkToastText(R.string.reminderInPast, activityRule.activity) + futureDate.apply { add(Calendar.WEEK_OF_YEAR, 1) } + + Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to add a new reminder.") + calendarReminderPage.clickAddReminder() + + val reminderDateOneDay = futureDate.apply { add(Calendar.DAY_OF_MONTH, -1) } + Log.d(STEP_TAG, "Select '1 Day Before'.") + calendarReminderPage.clickBeforeReminderOption("1 Day Before") + + Log.d(ASSERTION_TAG, "Assert that the reminder has been picked up and displayed on the Event Details Page.") + calendarReminderPage.assertReminderDisplayedWithText(reminderDateOneDay.time.toFormattedString()) + + Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to pick up a new reminder.") + calendarReminderPage.clickAddReminder() + + Log.d(STEP_TAG, "Select '1 Day Before' again.") + calendarReminderPage.clickBeforeReminderOption("1 Day Before") + + Log.d(ASSERTION_TAG, "Assert that a toast message is occurring which warns that we cannot pick up the same time reminder twice. (Because 1 days and 24 hours is the same)") + checkToastText(R.string.reminderAlreadySet, activityRule.activity) + futureDate.apply { add(Calendar.DAY_OF_MONTH, 1) } + + Log.d(STEP_TAG, "Navigate back to Calendar Screen Page.") + Espresso.pressBack() + + Log.d(ASSERTION_TAG, "Assert that the event is displayed on the calendar.") + calendarScreenPage.assertItemDisplayed(newEventTitle) + } + + @E2E + @Test + @TestMetaData(Priority.MANDATORY, FeatureCategory.CALENDAR, TestCategory.E2E, SecondaryFeatureCategory.CALENDAR_TODO_REMINDER) + fun testCalendarToDoCustomReminderE2E() { + + Log.d(PREPARATION_TAG, "Seeding data.") + val data = seedData(teachers = 1, courses = 1) + val teacher = data.teachersList[0] + val futureDate = 2.days.fromNow + + Log.d(STEP_TAG, "Login with user: '${teacher.name}', login id: '${teacher.loginId}'.") + tokenLogin(teacher) + + Log.d(ASSERTION_TAG, "Assert that the Dashboard Page is the landing page and it is loaded successfully.") + dashboardPage.waitForRender() + dashboardPage.assertPageObjects() + + Log.d(STEP_TAG, "Click on the 'Calendar' bottom menu to navigate to the Calendar page.") + dashboardPage.clickCalendarTab() + + Log.d(ASSERTION_TAG, "Assert that the page title is 'Calendar'.") + calendarScreenPage.assertCalendarPageTitle() + + Log.d(STEP_TAG, "Click on the 'Add' (FAB) button and 'Add To Do' to create a new To Do.") + calendarScreenPage.clickOnAddButton() + calendarScreenPage.clickAddTodo() + + Log.d(ASSERTION_TAG, "Assert that the page title is 'New To Do' as we are clicked on the 'Add To Do' button to create a new one.") + calendarToDoCreateUpdatePage.assertPageTitle("New To Do") + + val testTodoTitle = "Test ToDo With Reminder" + val testTodoDescription = "Details of ToDo" + Log.d(STEP_TAG, "Fill the title with '$testTodoTitle' and the description with '$testTodoDescription'.") + calendarToDoCreateUpdatePage.typeTodoTitle(testTodoTitle) + calendarToDoCreateUpdatePage.typeDetails(testTodoDescription) + + val calendar = Calendar.getInstance().apply { timeInMillis = futureDate.timeInMillis } + Log.d(STEP_TAG, "Select a date which is 2 days in the future from today.") + calendarToDoCreateUpdatePage.selectDate(calendar) + + Log.d(STEP_TAG, "Click on the 'Save' button.") + calendarToDoCreateUpdatePage.clickSave() + + Log.d(STEP_TAG, "Swipe the calendar item 'body' to 2 days in the future from now.") + calendarScreenPage.swipeEventsLeft() + calendarScreenPage.swipeEventsLeft() + + Log.d(ASSERTION_TAG, "Assert that the To Do item is displayed on the calendar.") + calendarScreenPage.assertItemDisplayed(testTodoTitle) + + Log.d(STEP_TAG, "Click on the previously created '$testTodoTitle' To Do item.") + calendarScreenPage.clickOnItem(testTodoTitle) + + Log.d(ASSERTION_TAG, "Assert that the title is '$testTodoTitle' and the context is 'To Do'.") + calendarToDoDetailsPage.assertTitle(testTodoTitle) + calendarToDoDetailsPage.assertPageTitle("To Do") + + Log.d(ASSERTION_TAG, "Assert that the reminder section is displayed.") + calendarReminderPage.assertReminderSectionDisplayed() + + Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to pick up a new reminder.") + calendarReminderPage.clickAddReminder() + + val reminderDateOneHour = futureDate.apply { add(Calendar.HOUR, -1) } + Log.d(STEP_TAG, "Select '1 Hour Before' using custom date/time picker.") + calendarReminderPage.clickCustomReminderOption() + calendarReminderPage.selectDate(reminderDateOneHour) + calendarReminderPage.selectTime(reminderDateOneHour) + + Log.d(ASSERTION_TAG, "Assert that the reminder has been picked up and displayed on the To Do Details Page.") + calendarReminderPage.assertReminderDisplayedWithText(reminderDateOneHour.time.toFormattedString()) + + Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to pick up a new reminder.") + calendarReminderPage.clickAddReminder() + + Log.d(STEP_TAG, "Select '1 Hour Before' again.") + calendarReminderPage.clickCustomReminderOption() + calendarReminderPage.selectDate(reminderDateOneHour) + calendarReminderPage.selectTime(reminderDateOneHour) + + Log.d(ASSERTION_TAG, "Assert that a toast message is occurring which warns that we cannot pick up the same time reminder twice.") + checkToastText(R.string.reminderAlreadySet, activityRule.activity) + + Log.d(STEP_TAG, "Remove the '1 Hour Before' reminder and confirm the deletion dialog.") + calendarReminderPage.removeReminder() + + Log.d(ASSERTION_TAG, "Assert that the '1 Hour Before' reminder is not displayed any more.") + calendarReminderPage.assertReminderNotDisplayedWithText(reminderDateOneHour.time.toFormattedString()) + futureDate.apply { add(Calendar.HOUR, 1) } + + Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to pick up a new reminder.") + calendarReminderPage.clickAddReminder() + + val reminderDateOneWeek = futureDate.apply { add(Calendar.WEEK_OF_YEAR, -1) } + Log.d(STEP_TAG, "Select '1 Week Before'.") + calendarReminderPage.clickCustomReminderOption() + calendarReminderPage.selectDate(reminderDateOneWeek) + calendarReminderPage.selectTime(reminderDateOneWeek) + + Log.d(ASSERTION_TAG, "Assert that a toast message is occurring which warns that we cannot pick up a reminder which has already passed (for example cannot pick '1 Week Before' reminder for a To Do which is due in 2 days).") + calendarReminderPage.assertReminderNotDisplayedWithText(reminderDateOneWeek.time.toFormattedString()) + checkToastText(R.string.reminderInPast, activityRule.activity) + futureDate.apply { add(Calendar.WEEK_OF_YEAR, 1) } + + Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to pick up a new reminder.") + calendarReminderPage.clickAddReminder() + + val reminderDateOneDay = futureDate.apply { add(Calendar.DAY_OF_MONTH, -1) }.apply { add(Calendar.HOUR, -1) } + Log.d(STEP_TAG, "Select '1 Day Before and 1 hour before'.") + calendarReminderPage.clickCustomReminderOption() + calendarReminderPage.selectDate(reminderDateOneDay) + calendarReminderPage.selectTime(reminderDateOneDay) + + Log.d(ASSERTION_TAG, "Assert that the reminder has been picked up and displayed on the To Do Details Page.") + calendarReminderPage.assertReminderDisplayedWithText(reminderDateOneDay.time.toFormattedString()) + + Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to pick up a new reminder.") + calendarReminderPage.clickAddReminder() + + Log.d(STEP_TAG, "Select '1 Day Before' again.") + calendarReminderPage.clickCustomReminderOption() + calendarReminderPage.selectDate(reminderDateOneDay) + calendarReminderPage.selectTime(reminderDateOneDay) + + Log.d(ASSERTION_TAG, "Assert that a toast message is occurring which warns that we cannot pick up the same time reminder twice. (Because 1 days and 24 hours is the same)") + checkToastText(R.string.reminderAlreadySet, activityRule.activity) + futureDate.apply { add(Calendar.DAY_OF_MONTH, 1) } + + Log.d(STEP_TAG, "Navigate back to Calendar Screen Page.") + Espresso.pressBack() + + Log.d(ASSERTION_TAG, "Assert that the To Do item is displayed on the calendar.") + calendarScreenPage.assertItemDisplayed(testTodoTitle) + } + + @E2E + @Test + @TestMetaData(Priority.MANDATORY, FeatureCategory.CALENDAR, TestCategory.E2E, SecondaryFeatureCategory.CALENDAR_TODO_REMINDER) + fun testCalendarToDoBeforeReminderE2E() { + + Log.d(PREPARATION_TAG, "Seeding data.") + val data = seedData(teachers = 1, courses = 1) + val teacher = data.teachersList[0] + val futureDate = 2.days.fromNow + + Log.d(STEP_TAG, "Login with user: '${teacher.name}', login id: '${teacher.loginId}'.") + tokenLogin(teacher) + + Log.d(ASSERTION_TAG, "Assert that the Dashboard Page is the landing page and it is loaded successfully.") + dashboardPage.waitForRender() + dashboardPage.assertPageObjects() + + Log.d(STEP_TAG, "Click on the 'Calendar' bottom menu to navigate to the Calendar page.") + dashboardPage.clickCalendarTab() + + Log.d(ASSERTION_TAG, "Assert that the page title is 'Calendar'.") + calendarScreenPage.assertCalendarPageTitle() + + Log.d(STEP_TAG, "Click on the 'Add' (FAB) button and 'Add To Do' to create a new To Do.") + calendarScreenPage.clickOnAddButton() + calendarScreenPage.clickAddTodo() + + Log.d(ASSERTION_TAG, "Assert that the page title is 'New To Do' as we are clicked on the 'Add To Do' button to create a new one.") + calendarToDoCreateUpdatePage.assertPageTitle("New To Do") + + val testTodoTitle = "Test ToDo With Reminder" + val testTodoDescription = "Details of ToDo" + Log.d(STEP_TAG, "Fill the title with '$testTodoTitle' and the description with '$testTodoDescription'.") + calendarToDoCreateUpdatePage.typeTodoTitle(testTodoTitle) + calendarToDoCreateUpdatePage.typeDetails(testTodoDescription) + + val calendar = Calendar.getInstance().apply { timeInMillis = futureDate.timeInMillis } + Log.d(STEP_TAG, "Select a date which is 2 days in the future from today.") + calendarToDoCreateUpdatePage.selectDate(calendar) + + Log.d(STEP_TAG, "Click on the 'Save' button.") + calendarToDoCreateUpdatePage.clickSave() + + Log.d(STEP_TAG, "Swipe the calendar item 'body' to 2 days in the future from now.") + calendarScreenPage.swipeEventsLeft() + calendarScreenPage.swipeEventsLeft() + + Log.d(ASSERTION_TAG, "Assert that the To Do item is displayed on the calendar.") + calendarScreenPage.assertItemDisplayed(testTodoTitle) + + Log.d(STEP_TAG, "Click on the previously created '$testTodoTitle' To Do item.") + calendarScreenPage.clickOnItem(testTodoTitle) + + Log.d(ASSERTION_TAG, "Assert that the title is '$testTodoTitle' and the context is 'To Do'.") + calendarToDoDetailsPage.assertTitle(testTodoTitle) + calendarToDoDetailsPage.assertPageTitle("To Do") + + Log.d(ASSERTION_TAG, "Assert that the reminder section is displayed.") + calendarReminderPage.assertReminderSectionDisplayed() + + Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to pick up a new reminder.") + calendarReminderPage.clickAddReminder() + + val reminderDateOneHour = futureDate.apply { add(Calendar.HOUR, -1) } + Log.d(STEP_TAG, "Select '1 Hour Before'.") + calendarReminderPage.clickBeforeReminderOption("1 Hour Before") + + Log.d(ASSERTION_TAG, "Assert that the reminder has been picked up and displayed on the To Do Details Page.") + calendarReminderPage.assertReminderDisplayedWithText(reminderDateOneHour.time.toFormattedString()) + + Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to pick up a new reminder.") + calendarReminderPage.clickAddReminder() + + Log.d(STEP_TAG, "Select '1 Hour Before' again.") + calendarReminderPage.clickBeforeReminderOption("1 Hour Before") + + Log.d(ASSERTION_TAG, "Assert that a toast message is occurring which warns that we cannot pick up the same time reminder twice.") + checkToastText(R.string.reminderAlreadySet, activityRule.activity) + + Log.d(STEP_TAG, "Remove the '1 Hour Before' reminder and confirm the deletion dialog.") + calendarReminderPage.removeReminder() + + Log.d(ASSERTION_TAG, "Assert that the '1 Hour Before' reminder is not displayed any more.") + calendarReminderPage.assertReminderNotDisplayedWithText(reminderDateOneHour.time.toFormattedString()) + futureDate.apply { add(Calendar.HOUR, 1) } + + Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to add a new reminder.") + calendarReminderPage.clickAddReminder() + + val reminderDateOneWeek = futureDate.apply { add(Calendar.WEEK_OF_YEAR, -1) } + Log.d(STEP_TAG, "Select '1 Week Before'.") + calendarReminderPage.clickBeforeReminderOption("1 Week Before") + + Log.d(ASSERTION_TAG, "Assert that a toast message is occurring which warns that we cannot pick up a reminder which has already passed (for example cannot pick '1 Week Before' reminder for a To Do which is due in 2 days).") + calendarReminderPage.assertReminderNotDisplayedWithText(reminderDateOneWeek.time.toFormattedString()) + checkToastText(R.string.reminderInPast, activityRule.activity) + futureDate.apply { add(Calendar.WEEK_OF_YEAR, 1) } + + Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to add a new reminder.") + calendarReminderPage.clickAddReminder() + + val reminderDateOneDay = futureDate.apply { add(Calendar.DAY_OF_MONTH, -1) } + Log.d(STEP_TAG, "Select '1 Day Before'.") + calendarReminderPage.clickBeforeReminderOption("1 Day Before") + + Log.d(ASSERTION_TAG, "Assert that the reminder has been picked up and displayed on the To Do Details Page.") + calendarReminderPage.assertReminderDisplayedWithText(reminderDateOneDay.time.toFormattedString()) + + Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to pick up a new reminder.") + calendarReminderPage.clickAddReminder() + + Log.d(STEP_TAG, "Select '1 Day Before' again.") + calendarReminderPage.clickBeforeReminderOption("1 Day Before") + + Log.d(ASSERTION_TAG, "Assert that a toast message is occurring which warns that we cannot pick up the same time reminder twice. (Because 1 days and 24 hours is the same)") + checkToastText(R.string.reminderAlreadySet, activityRule.activity) + futureDate.apply { add(Calendar.DAY_OF_MONTH, 1) } + + Log.d(STEP_TAG, "Navigate back to Calendar Screen Page.") + Espresso.pressBack() + + Log.d(ASSERTION_TAG, "Assert that the To Do item is displayed on the calendar.") + calendarScreenPage.assertItemDisplayed(testTodoTitle) + } } \ No newline at end of file diff --git a/apps/teacher/src/androidTest/java/com/instructure/teacher/ui/utils/TeacherComposeTest.kt b/apps/teacher/src/androidTest/java/com/instructure/teacher/ui/utils/TeacherComposeTest.kt index ffa88fdb1e..d962240c3e 100644 --- a/apps/teacher/src/androidTest/java/com/instructure/teacher/ui/utils/TeacherComposeTest.kt +++ b/apps/teacher/src/androidTest/java/com/instructure/teacher/ui/utils/TeacherComposeTest.kt @@ -19,6 +19,7 @@ package com.instructure.teacher.ui.utils import androidx.compose.ui.test.junit4.createAndroidComposeRule +import com.instructure.canvas.espresso.common.pages.CalendarReminderPage import com.instructure.canvas.espresso.common.pages.compose.AssignmentListPage import com.instructure.canvas.espresso.common.pages.compose.CalendarEventCreateEditPage import com.instructure.canvas.espresso.common.pages.compose.CalendarEventDetailsPage @@ -52,6 +53,7 @@ abstract class TeacherComposeTest : TeacherTest() { val calendarToDoCreateUpdatePage = CalendarToDoCreateUpdatePage(composeTestRule) val calendarToDoDetailsPage = CalendarToDoDetailsPage(composeTestRule) val calendarFilterPage = CalendarFilterPage(composeTestRule) + val calendarReminderPage = CalendarReminderPage(composeTestRule) val progressPage = ProgressPage(composeTestRule) val settingsPage = SettingsPage(composeTestRule) val inboxDetailsPage = InboxDetailsPage(composeTestRule) diff --git a/automation/espresso/src/main/kotlin/com/instructure/canvas/espresso/TestMetaData.kt b/automation/espresso/src/main/kotlin/com/instructure/canvas/espresso/TestMetaData.kt index 106fb425bc..4102b4e1c3 100644 --- a/automation/espresso/src/main/kotlin/com/instructure/canvas/espresso/TestMetaData.kt +++ b/automation/espresso/src/main/kotlin/com/instructure/canvas/espresso/TestMetaData.kt @@ -44,7 +44,8 @@ enum class SecondaryFeatureCategory { GROUPS_DASHBOARD, GROUPS_FILES, GROUPS_ANNOUNCEMENTS, GROUPS_DISCUSSIONS, GROUPS_PAGES, GROUPS_PEOPLE, EVENTS_DISCUSSIONS, EVENTS_QUIZZES, EVENTS_ASSIGNMENTS, EVENTS_NOTIFICATIONS, SETTINGS_EMAIL_NOTIFICATIONS, MODULES_ASSIGNMENTS, MODULES_DISCUSSIONS, MODULES_FILES, MODULES_PAGES, MODULES_QUIZZES, OFFLINE_MODE, ALL_COURSES, CHANGE_USER, ASSIGNMENT_REMINDER, ASSIGNMENT_DETAILS, SMART_SEARCH, ADD_STUDENT, - SYLLABUS, SUMMARY, FRONT_PAGE, CANVAS_NETWORK, INBOX_SIGNATURE, ACCESS_TOKEN_EXPIRATION, SECTIONS, HELP_MENU, DISCUSSION_CHECKPOINTS + SYLLABUS, SUMMARY, FRONT_PAGE, CANVAS_NETWORK, INBOX_SIGNATURE, ACCESS_TOKEN_EXPIRATION, SECTIONS, HELP_MENU, DISCUSSION_CHECKPOINTS, + CALENDAR_EVENT_REMINDER, CALENDAR_TODO_REMINDER } enum class TestCategory { diff --git a/automation/espresso/src/main/kotlin/com/instructure/canvas/espresso/common/pages/CalendarReminderPage.kt b/automation/espresso/src/main/kotlin/com/instructure/canvas/espresso/common/pages/CalendarReminderPage.kt new file mode 100644 index 0000000000..f8fc2739de --- /dev/null +++ b/automation/espresso/src/main/kotlin/com/instructure/canvas/espresso/common/pages/CalendarReminderPage.kt @@ -0,0 +1,97 @@ +/* + * Copyright (C) 2024 - present Instructure, Inc. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +package com.instructure.canvas.espresso.common.pages + +import android.widget.DatePicker +import android.widget.TimePicker +import androidx.compose.ui.test.hasContentDescription +import androidx.compose.ui.test.isDisplayed +import androidx.compose.ui.test.junit4.ComposeTestRule +import androidx.compose.ui.test.onNodeWithContentDescription +import androidx.compose.ui.test.onNodeWithText +import androidx.compose.ui.test.performClick +import androidx.test.espresso.Espresso.onData +import androidx.test.espresso.Espresso.onView +import androidx.test.espresso.action.ViewActions.click +import androidx.test.espresso.assertion.ViewAssertions.doesNotExist +import androidx.test.espresso.contrib.PickerActions +import androidx.test.espresso.matcher.RootMatchers.isDialog +import androidx.test.espresso.matcher.ViewMatchers.withClassName +import androidx.test.espresso.matcher.ViewMatchers.withId +import androidx.test.espresso.matcher.ViewMatchers.withText +import com.instructure.espresso.click +import com.instructure.espresso.matchers.WaitForViewMatcher.waitForView +import com.instructure.espresso.scrollTo +import com.instructure.pandautils.R +import org.hamcrest.Matchers +import org.hamcrest.Matchers.anything +import java.util.Calendar + +class CalendarReminderPage(private val composeTestRule: ComposeTestRule) { + private val reminderTitle = "Reminder" + private val reminderDescription = "Add due date reminder notifications about this assignment on this device." + private val reminderAdd = "Add reminder" + + fun assertReminderSectionDisplayed() { + composeTestRule.onNodeWithText(reminderTitle).isDisplayed() + composeTestRule.onNodeWithText(reminderDescription).isDisplayed() + composeTestRule.onNodeWithContentDescription(reminderAdd).isDisplayed() + } + + fun clickBeforeReminderOption(text: String) { + waitForView(withText(text)).scrollTo().click() + composeTestRule.waitForIdle() + } + + fun clickCustomReminderOption() { + onData(anything()).inRoot(isDialog()).atPosition(6).perform(click()) + } + + fun clickAddReminder() { + composeTestRule.onNodeWithContentDescription(reminderAdd).performClick() + } + + fun assertReminderDisplayedWithText(text: String) { + composeTestRule.onNodeWithText(text).isDisplayed() + } + + fun removeReminder() { + composeTestRule.onNode( + hasContentDescription("Remove") + ).performClick() + Thread.sleep(1000) + onView(withText(R.string.yes)).scrollTo().click() + } + + fun assertReminderNotDisplayedWithText(text: String) { + onView(withText(text)).check(doesNotExist()) + } + + fun selectDate(calendar: Calendar) { + onView(withClassName(Matchers.equalTo(DatePicker::class.java.name))) + .perform(PickerActions.setDate(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH) + 1, calendar.get(Calendar.DAY_OF_MONTH))) + + onView(withId(android.R.id.button1)).perform(click()) + } + + fun selectTime(calendar: Calendar) { + onView(withClassName(Matchers.equalTo(TimePicker::class.java.name))) + .perform(PickerActions.setTime(calendar.get(Calendar.HOUR_OF_DAY), calendar.get(Calendar.MINUTE))) + + onView(withId(android.R.id.button1)).perform(click()) + } +} \ No newline at end of file From d88bcc8ca07374c1c0474fa51b3c195e77031583 Mon Sep 17 00:00:00 2001 From: "adam.nagy" Date: Mon, 17 Nov 2025 13:14:43 +0100 Subject: [PATCH 2/3] PR findings fix refs: MBL-18703 affects: Student, Teacher, Parent release note: --- .../ui/e2e/compose/CalendarE2ETest.kt | 185 +++++++++--------- .../parentapp/utils/ParentComposeTest.kt | 2 - .../student/ui/e2e/compose/CalendarE2ETest.kt | 185 +++++++++--------- .../student/ui/utils/StudentComposeTest.kt | 2 - .../teacher/ui/e2e/compose/CalendarE2ETest.kt | 185 +++++++++--------- .../teacher/ui/utils/TeacherComposeTest.kt | 2 - .../common/pages/CalendarReminderPage.kt | 97 --------- .../pages/compose/CalendarEventDetailsPage.kt | 64 ++++++ .../pages/compose/CalendarScreenPage.kt | 20 +- .../pages/compose/CalendarToDoDetailsPage.kt | 67 +++++++ 10 files changed, 413 insertions(+), 396 deletions(-) delete mode 100644 automation/espresso/src/main/kotlin/com/instructure/canvas/espresso/common/pages/CalendarReminderPage.kt diff --git a/apps/parent/src/androidTest/java/com/instructure/parentapp/ui/e2e/compose/CalendarE2ETest.kt b/apps/parent/src/androidTest/java/com/instructure/parentapp/ui/e2e/compose/CalendarE2ETest.kt index 13313791f7..569548eb1d 100644 --- a/apps/parent/src/androidTest/java/com/instructure/parentapp/ui/e2e/compose/CalendarE2ETest.kt +++ b/apps/parent/src/androidTest/java/com/instructure/parentapp/ui/e2e/compose/CalendarE2ETest.kt @@ -319,8 +319,7 @@ class CalendarE2ETest : ParentComposeTest() { calendarScreenPage.assertItemNotExist(testTodoTitle) //It's created for 2 days from today so it shouldn't displayed for today. Log.d(STEP_TAG, "Swipe the calendar item 'body' to 2 days in the future from now.") - calendarScreenPage.swipeEventsLeft() - calendarScreenPage.swipeEventsLeft() + calendarScreenPage.swipeEventsLeft(2) Log.d(ASSERTION_TAG, "Assert that the '$testTodoTitle' To Do item is displayed because we created it to this particular day. " + "Assert that '$newEventTitle' calendar event is NOT displayed because it's created for today.") @@ -466,8 +465,7 @@ class CalendarE2ETest : ParentComposeTest() { calendarEventCreateEditPage.clickSave() Log.d(STEP_TAG, "Swipe the calendar item 'body' to 2 days in the future from now.") - calendarScreenPage.swipeEventsLeft() - calendarScreenPage.swipeEventsLeft() + calendarScreenPage.swipeEventsLeft(2) Log.d(ASSERTION_TAG, "Assert that the event is displayed on the calendar.") calendarScreenPage.assertItemDisplayed(newEventTitle) @@ -479,71 +477,71 @@ class CalendarE2ETest : ParentComposeTest() { calendarEventDetailsPage.assertEventDetailsPageTitle() Log.d(ASSERTION_TAG, "Assert that the reminder section is displayed.") - calendarReminderPage.assertReminderSectionDisplayed() + calendarEventDetailsPage.assertReminderSectionDisplayed() Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to pick up a new reminder.") - calendarReminderPage.clickAddReminder() + calendarEventDetailsPage.clickAddReminder() val reminderDateOneHour = futureDate.apply { add(Calendar.HOUR, -1) } Log.d(STEP_TAG, "Select '1 Hour Before' using custom date/time picker.") - calendarReminderPage.clickCustomReminderOption() - calendarReminderPage.selectDate(reminderDateOneHour) - calendarReminderPage.selectTime(reminderDateOneHour) + calendarEventDetailsPage.clickCustomReminderOption() + calendarEventDetailsPage.selectDate(reminderDateOneHour) + calendarEventDetailsPage.selectTime(reminderDateOneHour) Log.d(ASSERTION_TAG, "Assert that the reminder has been picked up and displayed on the Event Details Page.") - calendarReminderPage.assertReminderDisplayedWithText(reminderDateOneHour.time.toFormattedString()) + calendarEventDetailsPage.assertReminderDisplayedWithText(reminderDateOneHour.time.toFormattedString()) Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to pick up a new reminder.") - calendarReminderPage.clickAddReminder() + calendarEventDetailsPage.clickAddReminder() Log.d(STEP_TAG, "Select '1 Hour Before' again.") - calendarReminderPage.clickCustomReminderOption() - calendarReminderPage.selectDate(reminderDateOneHour) - calendarReminderPage.selectTime(reminderDateOneHour) + calendarEventDetailsPage.clickCustomReminderOption() + calendarEventDetailsPage.selectDate(reminderDateOneHour) + calendarEventDetailsPage.selectTime(reminderDateOneHour) Log.d(ASSERTION_TAG, "Assert that a toast message is occurring which warns that we cannot pick up the same time reminder twice.") checkToastText(R.string.reminderAlreadySet, activityRule.activity) Log.d(STEP_TAG, "Remove the '1 Hour Before' reminder and confirm the deletion dialog.") - calendarReminderPage.removeReminder() + calendarEventDetailsPage.removeReminder() Log.d(ASSERTION_TAG, "Assert that the '1 Hour Before' reminder is not displayed any more.") - calendarReminderPage.assertReminderNotDisplayedWithText(reminderDateOneHour.time.toFormattedString()) + calendarEventDetailsPage.assertReminderNotDisplayedWithText(reminderDateOneHour.time.toFormattedString()) futureDate.apply { add(Calendar.HOUR, 1) } Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to pick up a new reminder.") - calendarReminderPage.clickAddReminder() + calendarEventDetailsPage.clickAddReminder() val reminderDateOneWeek = futureDate.apply { add(Calendar.WEEK_OF_YEAR, -1) } Log.d(STEP_TAG, "Select '1 Week Before'.") - calendarReminderPage.clickCustomReminderOption() - calendarReminderPage.selectDate(reminderDateOneWeek) - calendarReminderPage.selectTime(reminderDateOneWeek) + calendarEventDetailsPage.clickCustomReminderOption() + calendarEventDetailsPage.selectDate(reminderDateOneWeek) + calendarEventDetailsPage.selectTime(reminderDateOneWeek) Log.d(ASSERTION_TAG, "Assert that a toast message is occurring which warns that we cannot pick up a reminder which has already passed (for example cannot pick '1 Week Before' reminder for an event which ends in 2 days).") - calendarReminderPage.assertReminderNotDisplayedWithText(reminderDateOneWeek.time.toFormattedString()) + calendarEventDetailsPage.assertReminderNotDisplayedWithText(reminderDateOneWeek.time.toFormattedString()) checkToastText(R.string.reminderInPast, activityRule.activity) futureDate.apply { add(Calendar.WEEK_OF_YEAR, 1) } Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to pick up a new reminder.") - calendarReminderPage.clickAddReminder() + calendarEventDetailsPage.clickAddReminder() val reminderDateOneDay = futureDate.apply { add(Calendar.DAY_OF_MONTH, -1) }.apply { add(Calendar.HOUR, -1) } Log.d(STEP_TAG, "Select '1 Day Before and 1 hour before'.") - calendarReminderPage.clickCustomReminderOption() - calendarReminderPage.selectDate(reminderDateOneDay) - calendarReminderPage.selectTime(reminderDateOneDay) + calendarEventDetailsPage.clickCustomReminderOption() + calendarEventDetailsPage.selectDate(reminderDateOneDay) + calendarEventDetailsPage.selectTime(reminderDateOneDay) Log.d(ASSERTION_TAG, "Assert that the reminder has been picked up and displayed on the Event Details Page.") - calendarReminderPage.assertReminderDisplayedWithText(reminderDateOneDay.time.toFormattedString()) + calendarEventDetailsPage.assertReminderDisplayedWithText(reminderDateOneDay.time.toFormattedString()) Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to pick up a new reminder.") - calendarReminderPage.clickAddReminder() + calendarEventDetailsPage.clickAddReminder() Log.d(STEP_TAG, "Select '1 Day Before' again.") - calendarReminderPage.clickCustomReminderOption() - calendarReminderPage.selectDate(reminderDateOneDay) - calendarReminderPage.selectTime(reminderDateOneDay) + calendarEventDetailsPage.clickCustomReminderOption() + calendarEventDetailsPage.selectDate(reminderDateOneDay) + calendarEventDetailsPage.selectTime(reminderDateOneDay) Log.d(ASSERTION_TAG, "Assert that a toast message is occurring which warns that we cannot pick up the same time reminder twice. (Because 1 days and 24 hours is the same)") checkToastText(R.string.reminderAlreadySet, activityRule.activity) @@ -595,8 +593,7 @@ class CalendarE2ETest : ParentComposeTest() { calendarEventCreateEditPage.clickSave() Log.d(STEP_TAG, "Swipe the calendar item 'body' to 2 days in the future from now.") - calendarScreenPage.swipeEventsLeft() - calendarScreenPage.swipeEventsLeft() + calendarScreenPage.swipeEventsLeft(2) Log.d(ASSERTION_TAG, "Assert that the event is displayed on the calendar.") calendarScreenPage.assertItemDisplayed(newEventTitle) @@ -608,61 +605,61 @@ class CalendarE2ETest : ParentComposeTest() { calendarEventDetailsPage.assertEventDetailsPageTitle() Log.d(ASSERTION_TAG, "Assert that the reminder section is displayed.") - calendarReminderPage.assertReminderSectionDisplayed() + calendarToDoDetailsPage.assertReminderSectionDisplayed() Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to pick up a new reminder.") - calendarReminderPage.clickAddReminder() + calendarToDoDetailsPage.clickAddReminder() val reminderDateOneHour = futureDate.apply { add(Calendar.HOUR, -1) } Log.d(STEP_TAG, "Select '1 Hour Before'.") - calendarReminderPage.clickBeforeReminderOption("1 Hour Before") + calendarToDoDetailsPage.clickBeforeReminderOption("1 Hour Before") Log.d(ASSERTION_TAG, "Assert that the reminder has been picked up and displayed on the Event Details Page.") - calendarReminderPage.assertReminderDisplayedWithText(reminderDateOneHour.time.toFormattedString()) + calendarToDoDetailsPage.assertReminderDisplayedWithText(reminderDateOneHour.time.toFormattedString()) Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to pick up a new reminder.") - calendarReminderPage.clickAddReminder() + calendarToDoDetailsPage.clickAddReminder() Log.d(STEP_TAG, "Select '1 Hour Before' again.") - calendarReminderPage.clickBeforeReminderOption("1 Hour Before") + calendarToDoDetailsPage.clickBeforeReminderOption("1 Hour Before") Log.d(ASSERTION_TAG, "Assert that a toast message is occurring which warns that we cannot pick up the same time reminder twice.") checkToastText(R.string.reminderAlreadySet, activityRule.activity) Log.d(STEP_TAG, "Remove the '1 Hour Before' reminder and confirm the deletion dialog.") - calendarReminderPage.removeReminder() + calendarToDoDetailsPage.removeReminder() Log.d(ASSERTION_TAG, "Assert that the '1 Hour Before' reminder is not displayed any more.") - calendarReminderPage.assertReminderNotDisplayedWithText(reminderDateOneHour.time.toFormattedString()) + calendarToDoDetailsPage.assertReminderNotDisplayedWithText(reminderDateOneHour.time.toFormattedString()) futureDate.apply { add(Calendar.HOUR, 1) } Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to add a new reminder.") - calendarReminderPage.clickAddReminder() + calendarToDoDetailsPage.clickAddReminder() val reminderDateOneWeek = futureDate.apply { add(Calendar.WEEK_OF_YEAR, -1) } Log.d(STEP_TAG, "Select '1 Week Before'.") - calendarReminderPage.clickBeforeReminderOption("1 Week Before") + calendarToDoDetailsPage.clickBeforeReminderOption("1 Week Before") Log.d(ASSERTION_TAG, "Assert that a toast message is occurring which warns that we cannot pick up a reminder which has already passed (for example cannot pick '1 Week Before' reminder for an event which ends in 2 days).") - calendarReminderPage.assertReminderNotDisplayedWithText(reminderDateOneWeek.time.toFormattedString()) + calendarToDoDetailsPage.assertReminderNotDisplayedWithText(reminderDateOneWeek.time.toFormattedString()) checkToastText(R.string.reminderInPast, activityRule.activity) futureDate.apply { add(Calendar.WEEK_OF_YEAR, 1) } Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to add a new reminder.") - calendarReminderPage.clickAddReminder() + calendarToDoDetailsPage.clickAddReminder() val reminderDateOneDay = futureDate.apply { add(Calendar.DAY_OF_MONTH, -1) } Log.d(STEP_TAG, "Select '1 Day Before'.") - calendarReminderPage.clickBeforeReminderOption("1 Day Before") + calendarToDoDetailsPage.clickBeforeReminderOption("1 Day Before") Log.d(ASSERTION_TAG, "Assert that the reminder has been picked up and displayed on the Event Details Page.") - calendarReminderPage.assertReminderDisplayedWithText(reminderDateOneDay.time.toFormattedString()) + calendarToDoDetailsPage.assertReminderDisplayedWithText(reminderDateOneDay.time.toFormattedString()) Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to pick up a new reminder.") - calendarReminderPage.clickAddReminder() + calendarToDoDetailsPage.clickAddReminder() Log.d(STEP_TAG, "Select '1 Day Before' again.") - calendarReminderPage.clickBeforeReminderOption("1 Day Before") + calendarToDoDetailsPage.clickBeforeReminderOption("1 Day Before") Log.d(ASSERTION_TAG, "Assert that a toast message is occurring which warns that we cannot pick up the same time reminder twice. (Because 1 days and 24 hours is the same)") checkToastText(R.string.reminderAlreadySet, activityRule.activity) @@ -716,8 +713,7 @@ class CalendarE2ETest : ParentComposeTest() { calendarToDoCreateUpdatePage.clickSave() Log.d(STEP_TAG, "Swipe the calendar item 'body' to 2 days in the future from now.") - calendarScreenPage.swipeEventsLeft() - calendarScreenPage.swipeEventsLeft() + calendarScreenPage.swipeEventsLeft(2) Log.d(ASSERTION_TAG, "Assert that the To Do item is displayed on the calendar.") calendarScreenPage.assertItemDisplayed(testTodoTitle) @@ -730,71 +726,71 @@ class CalendarE2ETest : ParentComposeTest() { calendarToDoDetailsPage.assertPageTitle("To Do") Log.d(ASSERTION_TAG, "Assert that the reminder section is displayed.") - calendarReminderPage.assertReminderSectionDisplayed() + calendarToDoDetailsPage.assertReminderSectionDisplayed() Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to pick up a new reminder.") - calendarReminderPage.clickAddReminder() + calendarToDoDetailsPage.clickAddReminder() val reminderDateOneHour = futureDate.apply { add(Calendar.HOUR, -1) } Log.d(STEP_TAG, "Select '1 Hour Before' using custom date/time picker.") - calendarReminderPage.clickCustomReminderOption() - calendarReminderPage.selectDate(reminderDateOneHour) - calendarReminderPage.selectTime(reminderDateOneHour) + calendarToDoDetailsPage.clickCustomReminderOption() + calendarToDoDetailsPage.selectDate(reminderDateOneHour) + calendarToDoDetailsPage.selectTime(reminderDateOneHour) Log.d(ASSERTION_TAG, "Assert that the reminder has been picked up and displayed on the To Do Details Page.") - calendarReminderPage.assertReminderDisplayedWithText(reminderDateOneHour.time.toFormattedString()) + calendarToDoDetailsPage.assertReminderDisplayedWithText(reminderDateOneHour.time.toFormattedString()) Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to pick up a new reminder.") - calendarReminderPage.clickAddReminder() + calendarToDoDetailsPage.clickAddReminder() Log.d(STEP_TAG, "Select '1 Hour Before' again.") - calendarReminderPage.clickCustomReminderOption() - calendarReminderPage.selectDate(reminderDateOneHour) - calendarReminderPage.selectTime(reminderDateOneHour) + calendarToDoDetailsPage.clickCustomReminderOption() + calendarToDoDetailsPage.selectDate(reminderDateOneHour) + calendarToDoDetailsPage.selectTime(reminderDateOneHour) Log.d(ASSERTION_TAG, "Assert that a toast message is occurring which warns that we cannot pick up the same time reminder twice.") checkToastText(R.string.reminderAlreadySet, activityRule.activity) Log.d(STEP_TAG, "Remove the '1 Hour Before' reminder and confirm the deletion dialog.") - calendarReminderPage.removeReminder() + calendarToDoDetailsPage.removeReminder() Log.d(ASSERTION_TAG, "Assert that the '1 Hour Before' reminder is not displayed any more.") - calendarReminderPage.assertReminderNotDisplayedWithText(reminderDateOneHour.time.toFormattedString()) + calendarToDoDetailsPage.assertReminderNotDisplayedWithText(reminderDateOneHour.time.toFormattedString()) futureDate.apply { add(Calendar.HOUR, 1) } Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to pick up a new reminder.") - calendarReminderPage.clickAddReminder() + calendarToDoDetailsPage.clickAddReminder() val reminderDateOneWeek = futureDate.apply { add(Calendar.WEEK_OF_YEAR, -1) } Log.d(STEP_TAG, "Select '1 Week Before'.") - calendarReminderPage.clickCustomReminderOption() - calendarReminderPage.selectDate(reminderDateOneWeek) - calendarReminderPage.selectTime(reminderDateOneWeek) + calendarToDoDetailsPage.clickCustomReminderOption() + calendarToDoDetailsPage.selectDate(reminderDateOneWeek) + calendarToDoDetailsPage.selectTime(reminderDateOneWeek) Log.d(ASSERTION_TAG, "Assert that a toast message is occurring which warns that we cannot pick up a reminder which has already passed (for example cannot pick '1 Week Before' reminder for a To Do which is due in 2 days).") - calendarReminderPage.assertReminderNotDisplayedWithText(reminderDateOneWeek.time.toFormattedString()) + calendarToDoDetailsPage.assertReminderNotDisplayedWithText(reminderDateOneWeek.time.toFormattedString()) checkToastText(R.string.reminderInPast, activityRule.activity) futureDate.apply { add(Calendar.WEEK_OF_YEAR, 1) } Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to pick up a new reminder.") - calendarReminderPage.clickAddReminder() + calendarToDoDetailsPage.clickAddReminder() val reminderDateOneDay = futureDate.apply { add(Calendar.DAY_OF_MONTH, -1) }.apply { add(Calendar.HOUR, -1) } Log.d(STEP_TAG, "Select '1 Day Before and 1 hour before'.") - calendarReminderPage.clickCustomReminderOption() - calendarReminderPage.selectDate(reminderDateOneDay) - calendarReminderPage.selectTime(reminderDateOneDay) + calendarToDoDetailsPage.clickCustomReminderOption() + calendarToDoDetailsPage.selectDate(reminderDateOneDay) + calendarToDoDetailsPage.selectTime(reminderDateOneDay) Log.d(ASSERTION_TAG, "Assert that the reminder has been picked up and displayed on the To Do Details Page.") - calendarReminderPage.assertReminderDisplayedWithText(reminderDateOneDay.time.toFormattedString()) + calendarToDoDetailsPage.assertReminderDisplayedWithText(reminderDateOneDay.time.toFormattedString()) Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to pick up a new reminder.") - calendarReminderPage.clickAddReminder() + calendarToDoDetailsPage.clickAddReminder() Log.d(STEP_TAG, "Select '1 Day Before' again.") - calendarReminderPage.clickCustomReminderOption() - calendarReminderPage.selectDate(reminderDateOneDay) - calendarReminderPage.selectTime(reminderDateOneDay) + calendarToDoDetailsPage.clickCustomReminderOption() + calendarToDoDetailsPage.selectDate(reminderDateOneDay) + calendarToDoDetailsPage.selectTime(reminderDateOneDay) Log.d(ASSERTION_TAG, "Assert that a toast message is occurring which warns that we cannot pick up the same time reminder twice. (Because 1 days and 24 hours is the same)") checkToastText(R.string.reminderAlreadySet, activityRule.activity) @@ -848,8 +844,7 @@ class CalendarE2ETest : ParentComposeTest() { calendarToDoCreateUpdatePage.clickSave() Log.d(STEP_TAG, "Swipe the calendar item 'body' to 2 days in the future from now.") - calendarScreenPage.swipeEventsLeft() - calendarScreenPage.swipeEventsLeft() + calendarScreenPage.swipeEventsLeft(2) Log.d(ASSERTION_TAG, "Assert that the To Do item is displayed on the calendar.") calendarScreenPage.assertItemDisplayed(testTodoTitle) @@ -862,61 +857,61 @@ class CalendarE2ETest : ParentComposeTest() { calendarToDoDetailsPage.assertPageTitle("To Do") Log.d(ASSERTION_TAG, "Assert that the reminder section is displayed.") - calendarReminderPage.assertReminderSectionDisplayed() + calendarToDoDetailsPage.assertReminderSectionDisplayed() Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to pick up a new reminder.") - calendarReminderPage.clickAddReminder() + calendarToDoDetailsPage.clickAddReminder() val reminderDateOneHour = futureDate.apply { add(Calendar.HOUR, -1) } Log.d(STEP_TAG, "Select '1 Hour Before'.") - calendarReminderPage.clickBeforeReminderOption("1 Hour Before") + calendarToDoDetailsPage.clickBeforeReminderOption("1 Hour Before") Log.d(ASSERTION_TAG, "Assert that the reminder has been picked up and displayed on the To Do Details Page.") - calendarReminderPage.assertReminderDisplayedWithText(reminderDateOneHour.time.toFormattedString()) + calendarToDoDetailsPage.assertReminderDisplayedWithText(reminderDateOneHour.time.toFormattedString()) Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to pick up a new reminder.") - calendarReminderPage.clickAddReminder() + calendarToDoDetailsPage.clickAddReminder() Log.d(STEP_TAG, "Select '1 Hour Before' again.") - calendarReminderPage.clickBeforeReminderOption("1 Hour Before") + calendarToDoDetailsPage.clickBeforeReminderOption("1 Hour Before") Log.d(ASSERTION_TAG, "Assert that a toast message is occurring which warns that we cannot pick up the same time reminder twice.") checkToastText(R.string.reminderAlreadySet, activityRule.activity) Log.d(STEP_TAG, "Remove the '1 Hour Before' reminder and confirm the deletion dialog.") - calendarReminderPage.removeReminder() + calendarToDoDetailsPage.removeReminder() Log.d(ASSERTION_TAG, "Assert that the '1 Hour Before' reminder is not displayed any more.") - calendarReminderPage.assertReminderNotDisplayedWithText(reminderDateOneHour.time.toFormattedString()) + calendarToDoDetailsPage.assertReminderNotDisplayedWithText(reminderDateOneHour.time.toFormattedString()) futureDate.apply { add(Calendar.HOUR, 1) } Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to add a new reminder.") - calendarReminderPage.clickAddReminder() + calendarToDoDetailsPage.clickAddReminder() val reminderDateOneWeek = futureDate.apply { add(Calendar.WEEK_OF_YEAR, -1) } Log.d(STEP_TAG, "Select '1 Week Before'.") - calendarReminderPage.clickBeforeReminderOption("1 Week Before") + calendarToDoDetailsPage.clickBeforeReminderOption("1 Week Before") Log.d(ASSERTION_TAG, "Assert that a toast message is occurring which warns that we cannot pick up a reminder which has already passed (for example cannot pick '1 Week Before' reminder for a To Do which is due in 2 days).") - calendarReminderPage.assertReminderNotDisplayedWithText(reminderDateOneWeek.time.toFormattedString()) + calendarToDoDetailsPage.assertReminderNotDisplayedWithText(reminderDateOneWeek.time.toFormattedString()) checkToastText(R.string.reminderInPast, activityRule.activity) futureDate.apply { add(Calendar.WEEK_OF_YEAR, 1) } Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to add a new reminder.") - calendarReminderPage.clickAddReminder() + calendarToDoDetailsPage.clickAddReminder() val reminderDateOneDay = futureDate.apply { add(Calendar.DAY_OF_MONTH, -1) } Log.d(STEP_TAG, "Select '1 Day Before'.") - calendarReminderPage.clickBeforeReminderOption("1 Day Before") + calendarToDoDetailsPage.clickBeforeReminderOption("1 Day Before") Log.d(ASSERTION_TAG, "Assert that the reminder has been picked up and displayed on the To Do Details Page.") - calendarReminderPage.assertReminderDisplayedWithText(reminderDateOneDay.time.toFormattedString()) + calendarToDoDetailsPage.assertReminderDisplayedWithText(reminderDateOneDay.time.toFormattedString()) Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to pick up a new reminder.") - calendarReminderPage.clickAddReminder() + calendarToDoDetailsPage.clickAddReminder() Log.d(STEP_TAG, "Select '1 Day Before' again.") - calendarReminderPage.clickBeforeReminderOption("1 Day Before") + calendarToDoDetailsPage.clickBeforeReminderOption("1 Day Before") Log.d(ASSERTION_TAG, "Assert that a toast message is occurring which warns that we cannot pick up the same time reminder twice. (Because 1 days and 24 hours is the same)") checkToastText(R.string.reminderAlreadySet, activityRule.activity) @@ -928,4 +923,4 @@ class CalendarE2ETest : ParentComposeTest() { Log.d(ASSERTION_TAG, "Assert that the To Do item is displayed on the calendar.") calendarScreenPage.assertItemDisplayed(testTodoTitle) } -} \ No newline at end of file +} diff --git a/apps/parent/src/androidTest/java/com/instructure/parentapp/utils/ParentComposeTest.kt b/apps/parent/src/androidTest/java/com/instructure/parentapp/utils/ParentComposeTest.kt index 2b986e6fd8..81beeda7f9 100644 --- a/apps/parent/src/androidTest/java/com/instructure/parentapp/utils/ParentComposeTest.kt +++ b/apps/parent/src/androidTest/java/com/instructure/parentapp/utils/ParentComposeTest.kt @@ -20,7 +20,6 @@ package com.instructure.parentapp.utils import androidx.compose.ui.test.junit4.createAndroidComposeRule import com.instructure.canvas.espresso.common.pages.AssignmentDetailsPage import com.instructure.canvas.espresso.common.pages.AssignmentReminderPage -import com.instructure.canvas.espresso.common.pages.CalendarReminderPage import com.instructure.canvas.espresso.common.pages.compose.CalendarEventCreateEditPage import com.instructure.canvas.espresso.common.pages.compose.CalendarEventDetailsPage import com.instructure.canvas.espresso.common.pages.compose.CalendarFilterPage @@ -83,7 +82,6 @@ abstract class ParentComposeTest : ParentTest() { protected val calendarToDoDetailsPage = CalendarToDoDetailsPage(composeTestRule) protected val calendarFilterPage = CalendarFilterPage(composeTestRule) protected val assignmentReminderPage = AssignmentReminderPage(composeTestRule) - protected val calendarReminderPage = CalendarReminderPage(composeTestRule) protected val inboxSignatureSettingsPage = InboxSignatureSettingsPage(composeTestRule) protected val assignmentDetailsPage = AssignmentDetailsPage(ModuleItemInteractions(), composeTestRule) diff --git a/apps/student/src/androidTest/java/com/instructure/student/ui/e2e/compose/CalendarE2ETest.kt b/apps/student/src/androidTest/java/com/instructure/student/ui/e2e/compose/CalendarE2ETest.kt index f91bbcbfc1..6747da19cf 100644 --- a/apps/student/src/androidTest/java/com/instructure/student/ui/e2e/compose/CalendarE2ETest.kt +++ b/apps/student/src/androidTest/java/com/instructure/student/ui/e2e/compose/CalendarE2ETest.kt @@ -294,8 +294,7 @@ class CalendarE2ETest : StudentComposeTest() { calendarScreenPage.assertItemNotExist(testTodoTitle) //It's created for 2 days from today so it shouldn't displayed for today. Log.d(STEP_TAG, "Swipe the calendar item 'body' to 2 days in the future from now.") - calendarScreenPage.swipeEventsLeft() - calendarScreenPage.swipeEventsLeft() + calendarScreenPage.swipeEventsLeft(2) Log.d(ASSERTION_TAG, "Assert that the '$testTodoTitle' To Do item is displayed because we created it to this particular day. Assert that '$newEventTitle' calendar event is not displayed because it's created for today.") calendarScreenPage.assertItemDisplayed(testTodoTitle) @@ -362,8 +361,7 @@ class CalendarE2ETest : StudentComposeTest() { calendarEventCreateEditPage.clickSave() Log.d(STEP_TAG, "Swipe the calendar item 'body' to 2 days in the future from now.") - calendarScreenPage.swipeEventsLeft() - calendarScreenPage.swipeEventsLeft() + calendarScreenPage.swipeEventsLeft(2) Log.d(ASSERTION_TAG, "Assert that the event is displayed on the calendar.") calendarScreenPage.assertItemDisplayed(newEventTitle) @@ -375,71 +373,71 @@ class CalendarE2ETest : StudentComposeTest() { calendarEventDetailsPage.assertEventDetailsPageTitle() Log.d(ASSERTION_TAG, "Assert that the reminder section is displayed.") - calendarReminderPage.assertReminderSectionDisplayed() + calendarEventDetailsPage.assertReminderSectionDisplayed() Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to pick up a new reminder.") - calendarReminderPage.clickAddReminder() + calendarEventDetailsPage.clickAddReminder() val reminderDateOneHour = futureDate.apply { add(Calendar.HOUR, -1) } Log.d(STEP_TAG, "Select '1 Hour Before' using custom date/time picker.") - calendarReminderPage.clickCustomReminderOption() - calendarReminderPage.selectDate(reminderDateOneHour) - calendarReminderPage.selectTime(reminderDateOneHour) + calendarEventDetailsPage.clickCustomReminderOption() + calendarEventDetailsPage.selectDate(reminderDateOneHour) + calendarEventDetailsPage.selectTime(reminderDateOneHour) Log.d(ASSERTION_TAG, "Assert that the reminder has been picked up and displayed on the Event Details Page.") - calendarReminderPage.assertReminderDisplayedWithText(reminderDateOneHour.time.toFormattedString()) + calendarEventDetailsPage.assertReminderDisplayedWithText(reminderDateOneHour.time.toFormattedString()) Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to pick up a new reminder.") - calendarReminderPage.clickAddReminder() + calendarEventDetailsPage.clickAddReminder() Log.d(STEP_TAG, "Select '1 Hour Before' again.") - calendarReminderPage.clickCustomReminderOption() - calendarReminderPage.selectDate(reminderDateOneHour) - calendarReminderPage.selectTime(reminderDateOneHour) + calendarEventDetailsPage.clickCustomReminderOption() + calendarEventDetailsPage.selectDate(reminderDateOneHour) + calendarEventDetailsPage.selectTime(reminderDateOneHour) Log.d(ASSERTION_TAG, "Assert that a toast message is occurring which warns that we cannot pick up the same time reminder twice.") checkToastText(R.string.reminderAlreadySet, activityRule.activity) Log.d(STEP_TAG, "Remove the '1 Hour Before' reminder and confirm the deletion dialog.") - calendarReminderPage.removeReminder() + calendarEventDetailsPage.removeReminder() Log.d(ASSERTION_TAG, "Assert that the '1 Hour Before' reminder is not displayed any more.") - calendarReminderPage.assertReminderNotDisplayedWithText(reminderDateOneHour.time.toFormattedString()) + calendarEventDetailsPage.assertReminderNotDisplayedWithText(reminderDateOneHour.time.toFormattedString()) futureDate.apply { add(Calendar.HOUR, 1) } Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to pick up a new reminder.") - calendarReminderPage.clickAddReminder() + calendarEventDetailsPage.clickAddReminder() val reminderDateOneWeek = futureDate.apply { add(Calendar.WEEK_OF_YEAR, -1) } Log.d(STEP_TAG, "Select '1 Week Before'.") - calendarReminderPage.clickCustomReminderOption() - calendarReminderPage.selectDate(reminderDateOneWeek) - calendarReminderPage.selectTime(reminderDateOneWeek) + calendarEventDetailsPage.clickCustomReminderOption() + calendarEventDetailsPage.selectDate(reminderDateOneWeek) + calendarEventDetailsPage.selectTime(reminderDateOneWeek) Log.d(ASSERTION_TAG, "Assert that a toast message is occurring which warns that we cannot pick up a reminder which has already passed (for example cannot pick '1 Week Before' reminder for an event which ends in 2 days).") - calendarReminderPage.assertReminderNotDisplayedWithText(reminderDateOneWeek.time.toFormattedString()) + calendarEventDetailsPage.assertReminderNotDisplayedWithText(reminderDateOneWeek.time.toFormattedString()) checkToastText(R.string.reminderInPast, activityRule.activity) futureDate.apply { add(Calendar.WEEK_OF_YEAR, 1) } Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to pick up a new reminder.") - calendarReminderPage.clickAddReminder() + calendarEventDetailsPage.clickAddReminder() val reminderDateOneDay = futureDate.apply { add(Calendar.DAY_OF_MONTH, -1) }.apply { add(Calendar.HOUR, -1) } Log.d(STEP_TAG, "Select '1 Day Before and 1 hour before'.") - calendarReminderPage.clickCustomReminderOption() - calendarReminderPage.selectDate(reminderDateOneDay) - calendarReminderPage.selectTime(reminderDateOneDay) + calendarEventDetailsPage.clickCustomReminderOption() + calendarEventDetailsPage.selectDate(reminderDateOneDay) + calendarEventDetailsPage.selectTime(reminderDateOneDay) Log.d(ASSERTION_TAG, "Assert that the reminder has been picked up and displayed on the Event Details Page.") - calendarReminderPage.assertReminderDisplayedWithText(reminderDateOneDay.time.toFormattedString()) + calendarEventDetailsPage.assertReminderDisplayedWithText(reminderDateOneDay.time.toFormattedString()) Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to pick up a new reminder.") - calendarReminderPage.clickAddReminder() + calendarEventDetailsPage.clickAddReminder() Log.d(STEP_TAG, "Select '1 Day Before' again.") - calendarReminderPage.clickCustomReminderOption() - calendarReminderPage.selectDate(reminderDateOneDay) - calendarReminderPage.selectTime(reminderDateOneDay) + calendarEventDetailsPage.clickCustomReminderOption() + calendarEventDetailsPage.selectDate(reminderDateOneDay) + calendarEventDetailsPage.selectTime(reminderDateOneDay) Log.d(ASSERTION_TAG, "Assert that a toast message is occurring which warns that we cannot pick up the same time reminder twice. (Because 1 days and 24 hours is the same)") checkToastText(R.string.reminderAlreadySet, activityRule.activity) @@ -494,8 +492,7 @@ class CalendarE2ETest : StudentComposeTest() { calendarEventCreateEditPage.clickSave() Log.d(STEP_TAG, "Swipe the calendar item 'body' to 2 days in the future from now.") - calendarScreenPage.swipeEventsLeft() - calendarScreenPage.swipeEventsLeft() + calendarScreenPage.swipeEventsLeft(2) Log.d(ASSERTION_TAG, "Assert that the event is displayed on the calendar.") calendarScreenPage.assertItemDisplayed(newEventTitle) @@ -507,61 +504,61 @@ class CalendarE2ETest : StudentComposeTest() { calendarEventDetailsPage.assertEventDetailsPageTitle() Log.d(ASSERTION_TAG, "Assert that the reminder section is displayed.") - calendarReminderPage.assertReminderSectionDisplayed() + calendarEventDetailsPage.assertReminderSectionDisplayed() Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to pick up a new reminder.") - calendarReminderPage.clickAddReminder() + calendarEventDetailsPage.clickAddReminder() val reminderDateOneHour = futureDate.apply { add(Calendar.HOUR, -1) } Log.d(STEP_TAG, "Select '1 Hour Before'.") - calendarReminderPage.clickBeforeReminderOption("1 Hour Before") + calendarEventDetailsPage.clickBeforeReminderOption("1 Hour Before") Log.d(ASSERTION_TAG, "Assert that the reminder has been picked up and displayed on the Event Details Page.") - calendarReminderPage.assertReminderDisplayedWithText(reminderDateOneHour.time.toFormattedString()) + calendarEventDetailsPage.assertReminderDisplayedWithText(reminderDateOneHour.time.toFormattedString()) Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to pick up a new reminder.") - calendarReminderPage.clickAddReminder() + calendarEventDetailsPage.clickAddReminder() Log.d(STEP_TAG, "Select '1 Hour Before' again.") - calendarReminderPage.clickBeforeReminderOption("1 Hour Before") + calendarEventDetailsPage.clickBeforeReminderOption("1 Hour Before") Log.d(ASSERTION_TAG, "Assert that a toast message is occurring which warns that we cannot pick up the same time reminder twice.") checkToastText(R.string.reminderAlreadySet, activityRule.activity) Log.d(STEP_TAG, "Remove the '1 Hour Before' reminder and confirm the deletion dialog.") - calendarReminderPage.removeReminder() + calendarEventDetailsPage.removeReminder() Log.d(ASSERTION_TAG, "Assert that the '1 Hour Before' reminder is not displayed any more.") - calendarReminderPage.assertReminderNotDisplayedWithText(reminderDateOneHour.time.toFormattedString()) + calendarEventDetailsPage.assertReminderNotDisplayedWithText(reminderDateOneHour.time.toFormattedString()) futureDate.apply { add(Calendar.HOUR, 1) } Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to add a new reminder.") - calendarReminderPage.clickAddReminder() + calendarEventDetailsPage.clickAddReminder() val reminderDateOneWeek = futureDate.apply { add(Calendar.WEEK_OF_YEAR, -1) } Log.d(STEP_TAG, "Select '1 Week Before'.") - calendarReminderPage.clickBeforeReminderOption("1 Week Before") + calendarEventDetailsPage.clickBeforeReminderOption("1 Week Before") Log.d(ASSERTION_TAG, "Assert that a toast message is occurring which warns that we cannot pick up a reminder which has already passed (for example cannot pick '1 Week Before' reminder for an event which ends in 2 days).") - calendarReminderPage.assertReminderNotDisplayedWithText(reminderDateOneWeek.time.toFormattedString()) + calendarEventDetailsPage.assertReminderNotDisplayedWithText(reminderDateOneWeek.time.toFormattedString()) checkToastText(R.string.reminderInPast, activityRule.activity) futureDate.apply { add(Calendar.WEEK_OF_YEAR, 1) } Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to add a new reminder.") - calendarReminderPage.clickAddReminder() + calendarEventDetailsPage.clickAddReminder() val reminderDateOneDay = futureDate.apply { add(Calendar.DAY_OF_MONTH, -1) } Log.d(STEP_TAG, "Select '1 Day Before'.") - calendarReminderPage.clickBeforeReminderOption("1 Day Before") + calendarEventDetailsPage.clickBeforeReminderOption("1 Day Before") Log.d(ASSERTION_TAG, "Assert that the reminder has been picked up and displayed on the Event Details Page.") - calendarReminderPage.assertReminderDisplayedWithText(reminderDateOneDay.time.toFormattedString()) + calendarEventDetailsPage.assertReminderDisplayedWithText(reminderDateOneDay.time.toFormattedString()) Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to pick up a new reminder.") - calendarReminderPage.clickAddReminder() + calendarEventDetailsPage.clickAddReminder() Log.d(STEP_TAG, "Select '1 Day Before' again.") - calendarReminderPage.clickBeforeReminderOption("1 Day Before") + calendarEventDetailsPage.clickBeforeReminderOption("1 Day Before") Log.d(ASSERTION_TAG, "Assert that a toast message is occurring which warns that we cannot pick up the same time reminder twice. (Because 1 days and 24 hours is the same)") checkToastText(R.string.reminderAlreadySet, activityRule.activity) @@ -618,8 +615,7 @@ class CalendarE2ETest : StudentComposeTest() { calendarToDoCreateUpdatePage.clickSave() Log.d(STEP_TAG, "Swipe the calendar item 'body' to 2 days in the future from now.") - calendarScreenPage.swipeEventsLeft() - calendarScreenPage.swipeEventsLeft() + calendarScreenPage.swipeEventsLeft(2) Log.d(ASSERTION_TAG, "Assert that the To Do item is displayed on the calendar.") calendarScreenPage.assertItemDisplayed(testTodoTitle) @@ -632,71 +628,71 @@ class CalendarE2ETest : StudentComposeTest() { calendarToDoDetailsPage.assertPageTitle("To Do") Log.d(ASSERTION_TAG, "Assert that the reminder section is displayed.") - calendarReminderPage.assertReminderSectionDisplayed() + calendarToDoDetailsPage.assertReminderSectionDisplayed() Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to pick up a new reminder.") - calendarReminderPage.clickAddReminder() + calendarToDoDetailsPage.clickAddReminder() val reminderDateOneHour = futureDate.apply { add(Calendar.HOUR, -1) } Log.d(STEP_TAG, "Select '1 Hour Before' using custom date/time picker.") - calendarReminderPage.clickCustomReminderOption() - calendarReminderPage.selectDate(reminderDateOneHour) - calendarReminderPage.selectTime(reminderDateOneHour) + calendarToDoDetailsPage.clickCustomReminderOption() + calendarToDoDetailsPage.selectDate(reminderDateOneHour) + calendarToDoDetailsPage.selectTime(reminderDateOneHour) Log.d(ASSERTION_TAG, "Assert that the reminder has been picked up and displayed on the To Do Details Page.") - calendarReminderPage.assertReminderDisplayedWithText(reminderDateOneHour.time.toFormattedString()) + calendarToDoDetailsPage.assertReminderDisplayedWithText(reminderDateOneHour.time.toFormattedString()) Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to pick up a new reminder.") - calendarReminderPage.clickAddReminder() + calendarToDoDetailsPage.clickAddReminder() Log.d(STEP_TAG, "Select '1 Hour Before' again.") - calendarReminderPage.clickCustomReminderOption() - calendarReminderPage.selectDate(reminderDateOneHour) - calendarReminderPage.selectTime(reminderDateOneHour) + calendarToDoDetailsPage.clickCustomReminderOption() + calendarToDoDetailsPage.selectDate(reminderDateOneHour) + calendarToDoDetailsPage.selectTime(reminderDateOneHour) Log.d(ASSERTION_TAG, "Assert that a toast message is occurring which warns that we cannot pick up the same time reminder twice.") checkToastText(R.string.reminderAlreadySet, activityRule.activity) Log.d(STEP_TAG, "Remove the '1 Hour Before' reminder and confirm the deletion dialog.") - calendarReminderPage.removeReminder() + calendarToDoDetailsPage.removeReminder() Log.d(ASSERTION_TAG, "Assert that the '1 Hour Before' reminder is not displayed any more.") - calendarReminderPage.assertReminderNotDisplayedWithText(reminderDateOneHour.time.toFormattedString()) + calendarToDoDetailsPage.assertReminderNotDisplayedWithText(reminderDateOneHour.time.toFormattedString()) futureDate.apply { add(Calendar.HOUR, 1) } Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to pick up a new reminder.") - calendarReminderPage.clickAddReminder() + calendarToDoDetailsPage.clickAddReminder() val reminderDateOneWeek = futureDate.apply { add(Calendar.WEEK_OF_YEAR, -1) } Log.d(STEP_TAG, "Select '1 Week Before'.") - calendarReminderPage.clickCustomReminderOption() - calendarReminderPage.selectDate(reminderDateOneWeek) - calendarReminderPage.selectTime(reminderDateOneWeek) + calendarToDoDetailsPage.clickCustomReminderOption() + calendarToDoDetailsPage.selectDate(reminderDateOneWeek) + calendarToDoDetailsPage.selectTime(reminderDateOneWeek) Log.d(ASSERTION_TAG, "Assert that a toast message is occurring which warns that we cannot pick up a reminder which has already passed (for example cannot pick '1 Week Before' reminder for a To Do which is due in 2 days).") - calendarReminderPage.assertReminderNotDisplayedWithText(reminderDateOneWeek.time.toFormattedString()) + calendarToDoDetailsPage.assertReminderNotDisplayedWithText(reminderDateOneWeek.time.toFormattedString()) checkToastText(R.string.reminderInPast, activityRule.activity) futureDate.apply { add(Calendar.WEEK_OF_YEAR, 1) } Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to pick up a new reminder.") - calendarReminderPage.clickAddReminder() + calendarToDoDetailsPage.clickAddReminder() val reminderDateOneDay = futureDate.apply { add(Calendar.DAY_OF_MONTH, -1) }.apply { add(Calendar.HOUR, -1) } Log.d(STEP_TAG, "Select '1 Day Before and 1 hour before'.") - calendarReminderPage.clickCustomReminderOption() - calendarReminderPage.selectDate(reminderDateOneDay) - calendarReminderPage.selectTime(reminderDateOneDay) + calendarToDoDetailsPage.clickCustomReminderOption() + calendarToDoDetailsPage.selectDate(reminderDateOneDay) + calendarToDoDetailsPage.selectTime(reminderDateOneDay) Log.d(ASSERTION_TAG, "Assert that the reminder has been picked up and displayed on the To Do Details Page.") - calendarReminderPage.assertReminderDisplayedWithText(reminderDateOneDay.time.toFormattedString()) + calendarToDoDetailsPage.assertReminderDisplayedWithText(reminderDateOneDay.time.toFormattedString()) Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to pick up a new reminder.") - calendarReminderPage.clickAddReminder() + calendarToDoDetailsPage.clickAddReminder() Log.d(STEP_TAG, "Select '1 Day Before' again.") - calendarReminderPage.clickCustomReminderOption() - calendarReminderPage.selectDate(reminderDateOneDay) - calendarReminderPage.selectTime(reminderDateOneDay) + calendarToDoDetailsPage.clickCustomReminderOption() + calendarToDoDetailsPage.selectDate(reminderDateOneDay) + calendarToDoDetailsPage.selectTime(reminderDateOneDay) Log.d(ASSERTION_TAG, "Assert that a toast message is occurring which warns that we cannot pick up the same time reminder twice. (Because 1 days and 24 hours is the same)") checkToastText(R.string.reminderAlreadySet, activityRule.activity) @@ -753,8 +749,7 @@ class CalendarE2ETest : StudentComposeTest() { calendarToDoCreateUpdatePage.clickSave() Log.d(STEP_TAG, "Swipe the calendar item 'body' to 2 days in the future from now.") - calendarScreenPage.swipeEventsLeft() - calendarScreenPage.swipeEventsLeft() + calendarScreenPage.swipeEventsLeft(2) Log.d(ASSERTION_TAG, "Assert that the To Do item is displayed on the calendar.") calendarScreenPage.assertItemDisplayed(testTodoTitle) @@ -767,61 +762,61 @@ class CalendarE2ETest : StudentComposeTest() { calendarToDoDetailsPage.assertPageTitle("To Do") Log.d(ASSERTION_TAG, "Assert that the reminder section is displayed.") - calendarReminderPage.assertReminderSectionDisplayed() + calendarToDoDetailsPage.assertReminderSectionDisplayed() Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to pick up a new reminder.") - calendarReminderPage.clickAddReminder() + calendarToDoDetailsPage.clickAddReminder() val reminderDateOneHour = futureDate.apply { add(Calendar.HOUR, -1) } Log.d(STEP_TAG, "Select '1 Hour Before'.") - calendarReminderPage.clickBeforeReminderOption("1 Hour Before") + calendarToDoDetailsPage.clickBeforeReminderOption("1 Hour Before") Log.d(ASSERTION_TAG, "Assert that the reminder has been picked up and displayed on the To Do Details Page.") - calendarReminderPage.assertReminderDisplayedWithText(reminderDateOneHour.time.toFormattedString()) + calendarToDoDetailsPage.assertReminderDisplayedWithText(reminderDateOneHour.time.toFormattedString()) Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to pick up a new reminder.") - calendarReminderPage.clickAddReminder() + calendarToDoDetailsPage.clickAddReminder() Log.d(STEP_TAG, "Select '1 Hour Before' again.") - calendarReminderPage.clickBeforeReminderOption("1 Hour Before") + calendarToDoDetailsPage.clickBeforeReminderOption("1 Hour Before") Log.d(ASSERTION_TAG, "Assert that a toast message is occurring which warns that we cannot pick up the same time reminder twice.") checkToastText(R.string.reminderAlreadySet, activityRule.activity) Log.d(STEP_TAG, "Remove the '1 Hour Before' reminder and confirm the deletion dialog.") - calendarReminderPage.removeReminder() + calendarToDoDetailsPage.removeReminder() Log.d(ASSERTION_TAG, "Assert that the '1 Hour Before' reminder is not displayed any more.") - calendarReminderPage.assertReminderNotDisplayedWithText(reminderDateOneHour.time.toFormattedString()) + calendarToDoDetailsPage.assertReminderNotDisplayedWithText(reminderDateOneHour.time.toFormattedString()) futureDate.apply { add(Calendar.HOUR, 1) } Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to add a new reminder.") - calendarReminderPage.clickAddReminder() + calendarToDoDetailsPage.clickAddReminder() val reminderDateOneWeek = futureDate.apply { add(Calendar.WEEK_OF_YEAR, -1) } Log.d(STEP_TAG, "Select '1 Week Before'.") - calendarReminderPage.clickBeforeReminderOption("1 Week Before") + calendarToDoDetailsPage.clickBeforeReminderOption("1 Week Before") Log.d(ASSERTION_TAG, "Assert that a toast message is occurring which warns that we cannot pick up a reminder which has already passed (for example cannot pick '1 Week Before' reminder for a To Do which is due in 2 days).") - calendarReminderPage.assertReminderNotDisplayedWithText(reminderDateOneWeek.time.toFormattedString()) + calendarToDoDetailsPage.assertReminderNotDisplayedWithText(reminderDateOneWeek.time.toFormattedString()) checkToastText(R.string.reminderInPast, activityRule.activity) futureDate.apply { add(Calendar.WEEK_OF_YEAR, 1) } Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to add a new reminder.") - calendarReminderPage.clickAddReminder() + calendarToDoDetailsPage.clickAddReminder() val reminderDateOneDay = futureDate.apply { add(Calendar.DAY_OF_MONTH, -1) } Log.d(STEP_TAG, "Select '1 Day Before'.") - calendarReminderPage.clickBeforeReminderOption("1 Day Before") + calendarToDoDetailsPage.clickBeforeReminderOption("1 Day Before") Log.d(ASSERTION_TAG, "Assert that the reminder has been picked up and displayed on the To Do Details Page.") - calendarReminderPage.assertReminderDisplayedWithText(reminderDateOneDay.time.toFormattedString()) + calendarToDoDetailsPage.assertReminderDisplayedWithText(reminderDateOneDay.time.toFormattedString()) Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to pick up a new reminder.") - calendarReminderPage.clickAddReminder() + calendarToDoDetailsPage.clickAddReminder() Log.d(STEP_TAG, "Select '1 Day Before' again.") - calendarReminderPage.clickBeforeReminderOption("1 Day Before") + calendarToDoDetailsPage.clickBeforeReminderOption("1 Day Before") Log.d(ASSERTION_TAG, "Assert that a toast message is occurring which warns that we cannot pick up the same time reminder twice. (Because 1 days and 24 hours is the same)") checkToastText(R.string.reminderAlreadySet, activityRule.activity) @@ -834,4 +829,4 @@ class CalendarE2ETest : StudentComposeTest() { calendarScreenPage.assertItemDisplayed(testTodoTitle) } -} \ No newline at end of file +} diff --git a/apps/student/src/androidTest/java/com/instructure/student/ui/utils/StudentComposeTest.kt b/apps/student/src/androidTest/java/com/instructure/student/ui/utils/StudentComposeTest.kt index 63b658dc24..5ccf520462 100644 --- a/apps/student/src/androidTest/java/com/instructure/student/ui/utils/StudentComposeTest.kt +++ b/apps/student/src/androidTest/java/com/instructure/student/ui/utils/StudentComposeTest.kt @@ -20,7 +20,6 @@ package com.instructure.student.ui.utils import androidx.compose.ui.test.junit4.createAndroidComposeRule import com.instructure.canvas.espresso.common.pages.AssignmentReminderPage -import com.instructure.canvas.espresso.common.pages.CalendarReminderPage import com.instructure.canvas.espresso.common.pages.compose.AssignmentListPage import com.instructure.canvas.espresso.common.pages.compose.CalendarEventCreateEditPage import com.instructure.canvas.espresso.common.pages.compose.CalendarEventDetailsPage @@ -56,7 +55,6 @@ abstract class StudentComposeTest : StudentTest() { val calendarFilterPage = CalendarFilterPage(composeTestRule) val settingsPage = SettingsPage(composeTestRule) val assignmentReminderPage = AssignmentReminderPage(composeTestRule) - val calendarReminderPage = CalendarReminderPage(composeTestRule) val inboxDetailsPage = InboxDetailsPage(composeTestRule) val inboxComposePage = InboxComposePage(composeTestRule) val recipientPickerPage = RecipientPickerPage(composeTestRule) diff --git a/apps/teacher/src/androidTest/java/com/instructure/teacher/ui/e2e/compose/CalendarE2ETest.kt b/apps/teacher/src/androidTest/java/com/instructure/teacher/ui/e2e/compose/CalendarE2ETest.kt index 9e235cb4f8..80ef83394e 100644 --- a/apps/teacher/src/androidTest/java/com/instructure/teacher/ui/e2e/compose/CalendarE2ETest.kt +++ b/apps/teacher/src/androidTest/java/com/instructure/teacher/ui/e2e/compose/CalendarE2ETest.kt @@ -298,8 +298,7 @@ class CalendarE2ETest: TeacherComposeTest() { calendarScreenPage.assertItemNotExist(testTodoTitle) //It's created for 2 days from today so it shouldn't displayed for today. Log.d(STEP_TAG, "Swipe the calendar item 'body' to 2 days in the future from now.") - calendarScreenPage.swipeEventsLeft() - calendarScreenPage.swipeEventsLeft() + calendarScreenPage.swipeEventsLeft(2) Log.d(ASSERTION_TAG, "Assert that the '$testTodoTitle' To Do item is displayed because we created it to this particular day." + "Assert that '$newEventTitle' calendar event is not displayed because it's created for today.") @@ -367,8 +366,7 @@ class CalendarE2ETest: TeacherComposeTest() { calendarEventCreateEditPage.clickSave() Log.d(STEP_TAG, "Swipe the calendar item 'body' to 2 days in the future from now.") - calendarScreenPage.swipeEventsLeft() - calendarScreenPage.swipeEventsLeft() + calendarScreenPage.swipeEventsLeft(2) Log.d(ASSERTION_TAG, "Assert that the event is displayed on the calendar.") calendarScreenPage.assertItemDisplayed(newEventTitle) @@ -380,71 +378,71 @@ class CalendarE2ETest: TeacherComposeTest() { calendarEventDetailsPage.assertEventDetailsPageTitle() Log.d(ASSERTION_TAG, "Assert that the reminder section is displayed.") - calendarReminderPage.assertReminderSectionDisplayed() + calendarEventDetailsPage.assertReminderSectionDisplayed() Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to pick up a new reminder.") - calendarReminderPage.clickAddReminder() + calendarEventDetailsPage.clickAddReminder() val reminderDateOneHour = futureDate.apply { add(Calendar.HOUR, -1) } Log.d(STEP_TAG, "Select '1 Hour Before' using custom date/time picker.") - calendarReminderPage.clickCustomReminderOption() - calendarReminderPage.selectDate(reminderDateOneHour) - calendarReminderPage.selectTime(reminderDateOneHour) + calendarEventDetailsPage.clickCustomReminderOption() + calendarEventDetailsPage.selectDate(reminderDateOneHour) + calendarEventDetailsPage.selectTime(reminderDateOneHour) Log.d(ASSERTION_TAG, "Assert that the reminder has been picked up and displayed on the Event Details Page.") - calendarReminderPage.assertReminderDisplayedWithText(reminderDateOneHour.time.toFormattedString()) + calendarEventDetailsPage.assertReminderDisplayedWithText(reminderDateOneHour.time.toFormattedString()) Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to pick up a new reminder.") - calendarReminderPage.clickAddReminder() + calendarEventDetailsPage.clickAddReminder() Log.d(STEP_TAG, "Select '1 Hour Before' again.") - calendarReminderPage.clickCustomReminderOption() - calendarReminderPage.selectDate(reminderDateOneHour) - calendarReminderPage.selectTime(reminderDateOneHour) + calendarEventDetailsPage.clickCustomReminderOption() + calendarEventDetailsPage.selectDate(reminderDateOneHour) + calendarEventDetailsPage.selectTime(reminderDateOneHour) Log.d(ASSERTION_TAG, "Assert that a toast message is occurring which warns that we cannot pick up the same time reminder twice.") checkToastText(R.string.reminderAlreadySet, activityRule.activity) Log.d(STEP_TAG, "Remove the '1 Hour Before' reminder and confirm the deletion dialog.") - calendarReminderPage.removeReminder() + calendarEventDetailsPage.removeReminder() Log.d(ASSERTION_TAG, "Assert that the '1 Hour Before' reminder is not displayed any more.") - calendarReminderPage.assertReminderNotDisplayedWithText(reminderDateOneHour.time.toFormattedString()) + calendarEventDetailsPage.assertReminderNotDisplayedWithText(reminderDateOneHour.time.toFormattedString()) futureDate.apply { add(Calendar.HOUR, 1) } Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to pick up a new reminder.") - calendarReminderPage.clickAddReminder() + calendarEventDetailsPage.clickAddReminder() val reminderDateOneWeek = futureDate.apply { add(Calendar.WEEK_OF_YEAR, -1) } Log.d(STEP_TAG, "Select '1 Week Before'.") - calendarReminderPage.clickCustomReminderOption() - calendarReminderPage.selectDate(reminderDateOneWeek) - calendarReminderPage.selectTime(reminderDateOneWeek) + calendarEventDetailsPage.clickCustomReminderOption() + calendarEventDetailsPage.selectDate(reminderDateOneWeek) + calendarEventDetailsPage.selectTime(reminderDateOneWeek) Log.d(ASSERTION_TAG, "Assert that a toast message is occurring which warns that we cannot pick up a reminder which has already passed (for example cannot pick '1 Week Before' reminder for an event which ends in 2 days).") - calendarReminderPage.assertReminderNotDisplayedWithText(reminderDateOneWeek.time.toFormattedString()) + calendarEventDetailsPage.assertReminderNotDisplayedWithText(reminderDateOneWeek.time.toFormattedString()) checkToastText(R.string.reminderInPast, activityRule.activity) futureDate.apply { add(Calendar.WEEK_OF_YEAR, 1) } Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to pick up a new reminder.") - calendarReminderPage.clickAddReminder() + calendarEventDetailsPage.clickAddReminder() val reminderDateOneDay = futureDate.apply { add(Calendar.DAY_OF_MONTH, -1) }.apply { add(Calendar.HOUR, -1) } Log.d(STEP_TAG, "Select '1 Day Before and 1 hour before'.") - calendarReminderPage.clickCustomReminderOption() - calendarReminderPage.selectDate(reminderDateOneDay) - calendarReminderPage.selectTime(reminderDateOneDay) + calendarEventDetailsPage.clickCustomReminderOption() + calendarEventDetailsPage.selectDate(reminderDateOneDay) + calendarEventDetailsPage.selectTime(reminderDateOneDay) Log.d(ASSERTION_TAG, "Assert that the reminder has been picked up and displayed on the Event Details Page.") - calendarReminderPage.assertReminderDisplayedWithText(reminderDateOneDay.time.toFormattedString()) + calendarEventDetailsPage.assertReminderDisplayedWithText(reminderDateOneDay.time.toFormattedString()) Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to pick up a new reminder.") - calendarReminderPage.clickAddReminder() + calendarEventDetailsPage.clickAddReminder() Log.d(STEP_TAG, "Select '1 Day Before' again.") - calendarReminderPage.clickCustomReminderOption() - calendarReminderPage.selectDate(reminderDateOneDay) - calendarReminderPage.selectTime(reminderDateOneDay) + calendarEventDetailsPage.clickCustomReminderOption() + calendarEventDetailsPage.selectDate(reminderDateOneDay) + calendarEventDetailsPage.selectTime(reminderDateOneDay) Log.d(ASSERTION_TAG, "Assert that a toast message is occurring which warns that we cannot pick up the same time reminder twice. (Because 1 days and 24 hours is the same)") checkToastText(R.string.reminderAlreadySet, activityRule.activity) @@ -499,8 +497,7 @@ class CalendarE2ETest: TeacherComposeTest() { calendarEventCreateEditPage.clickSave() Log.d(STEP_TAG, "Swipe the calendar item 'body' to 2 days in the future from now.") - calendarScreenPage.swipeEventsLeft() - calendarScreenPage.swipeEventsLeft() + calendarScreenPage.swipeEventsLeft(2) Log.d(ASSERTION_TAG, "Assert that the event is displayed on the calendar.") calendarScreenPage.assertItemDisplayed(newEventTitle) @@ -512,61 +509,61 @@ class CalendarE2ETest: TeacherComposeTest() { calendarEventDetailsPage.assertEventDetailsPageTitle() Log.d(ASSERTION_TAG, "Assert that the reminder section is displayed.") - calendarReminderPage.assertReminderSectionDisplayed() + calendarEventDetailsPage.assertReminderSectionDisplayed() Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to pick up a new reminder.") - calendarReminderPage.clickAddReminder() + calendarEventDetailsPage.clickAddReminder() val reminderDateOneHour = futureDate.apply { add(Calendar.HOUR, -1) } Log.d(STEP_TAG, "Select '1 Hour Before'.") - calendarReminderPage.clickBeforeReminderOption("1 Hour Before") + calendarEventDetailsPage.clickBeforeReminderOption("1 Hour Before") Log.d(ASSERTION_TAG, "Assert that the reminder has been picked up and displayed on the Event Details Page.") - calendarReminderPage.assertReminderDisplayedWithText(reminderDateOneHour.time.toFormattedString()) + calendarEventDetailsPage.assertReminderDisplayedWithText(reminderDateOneHour.time.toFormattedString()) Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to pick up a new reminder.") - calendarReminderPage.clickAddReminder() + calendarEventDetailsPage.clickAddReminder() Log.d(STEP_TAG, "Select '1 Hour Before' again.") - calendarReminderPage.clickBeforeReminderOption("1 Hour Before") + calendarEventDetailsPage.clickBeforeReminderOption("1 Hour Before") Log.d(ASSERTION_TAG, "Assert that a toast message is occurring which warns that we cannot pick up the same time reminder twice.") checkToastText(R.string.reminderAlreadySet, activityRule.activity) Log.d(STEP_TAG, "Remove the '1 Hour Before' reminder and confirm the deletion dialog.") - calendarReminderPage.removeReminder() + calendarEventDetailsPage.removeReminder() Log.d(ASSERTION_TAG, "Assert that the '1 Hour Before' reminder is not displayed any more.") - calendarReminderPage.assertReminderNotDisplayedWithText(reminderDateOneHour.time.toFormattedString()) + calendarEventDetailsPage.assertReminderNotDisplayedWithText(reminderDateOneHour.time.toFormattedString()) futureDate.apply { add(Calendar.HOUR, 1) } Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to add a new reminder.") - calendarReminderPage.clickAddReminder() + calendarEventDetailsPage.clickAddReminder() val reminderDateOneWeek = futureDate.apply { add(Calendar.WEEK_OF_YEAR, -1) } Log.d(STEP_TAG, "Select '1 Week Before'.") - calendarReminderPage.clickBeforeReminderOption("1 Week Before") + calendarEventDetailsPage.clickBeforeReminderOption("1 Week Before") Log.d(ASSERTION_TAG, "Assert that a toast message is occurring which warns that we cannot pick up a reminder which has already passed (for example cannot pick '1 Week Before' reminder for an event which ends in 2 days).") - calendarReminderPage.assertReminderNotDisplayedWithText(reminderDateOneWeek.time.toFormattedString()) + calendarEventDetailsPage.assertReminderNotDisplayedWithText(reminderDateOneWeek.time.toFormattedString()) checkToastText(R.string.reminderInPast, activityRule.activity) futureDate.apply { add(Calendar.WEEK_OF_YEAR, 1) } Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to add a new reminder.") - calendarReminderPage.clickAddReminder() + calendarEventDetailsPage.clickAddReminder() val reminderDateOneDay = futureDate.apply { add(Calendar.DAY_OF_MONTH, -1) } Log.d(STEP_TAG, "Select '1 Day Before'.") - calendarReminderPage.clickBeforeReminderOption("1 Day Before") + calendarEventDetailsPage.clickBeforeReminderOption("1 Day Before") Log.d(ASSERTION_TAG, "Assert that the reminder has been picked up and displayed on the Event Details Page.") - calendarReminderPage.assertReminderDisplayedWithText(reminderDateOneDay.time.toFormattedString()) + calendarEventDetailsPage.assertReminderDisplayedWithText(reminderDateOneDay.time.toFormattedString()) Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to pick up a new reminder.") - calendarReminderPage.clickAddReminder() + calendarEventDetailsPage.clickAddReminder() Log.d(STEP_TAG, "Select '1 Day Before' again.") - calendarReminderPage.clickBeforeReminderOption("1 Day Before") + calendarEventDetailsPage.clickBeforeReminderOption("1 Day Before") Log.d(ASSERTION_TAG, "Assert that a toast message is occurring which warns that we cannot pick up the same time reminder twice. (Because 1 days and 24 hours is the same)") checkToastText(R.string.reminderAlreadySet, activityRule.activity) @@ -623,8 +620,7 @@ class CalendarE2ETest: TeacherComposeTest() { calendarToDoCreateUpdatePage.clickSave() Log.d(STEP_TAG, "Swipe the calendar item 'body' to 2 days in the future from now.") - calendarScreenPage.swipeEventsLeft() - calendarScreenPage.swipeEventsLeft() + calendarScreenPage.swipeEventsLeft(2) Log.d(ASSERTION_TAG, "Assert that the To Do item is displayed on the calendar.") calendarScreenPage.assertItemDisplayed(testTodoTitle) @@ -637,71 +633,71 @@ class CalendarE2ETest: TeacherComposeTest() { calendarToDoDetailsPage.assertPageTitle("To Do") Log.d(ASSERTION_TAG, "Assert that the reminder section is displayed.") - calendarReminderPage.assertReminderSectionDisplayed() + calendarToDoDetailsPage.assertReminderSectionDisplayed() Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to pick up a new reminder.") - calendarReminderPage.clickAddReminder() + calendarToDoDetailsPage.clickAddReminder() val reminderDateOneHour = futureDate.apply { add(Calendar.HOUR, -1) } Log.d(STEP_TAG, "Select '1 Hour Before' using custom date/time picker.") - calendarReminderPage.clickCustomReminderOption() - calendarReminderPage.selectDate(reminderDateOneHour) - calendarReminderPage.selectTime(reminderDateOneHour) + calendarToDoDetailsPage.clickCustomReminderOption() + calendarToDoDetailsPage.selectDate(reminderDateOneHour) + calendarToDoDetailsPage.selectTime(reminderDateOneHour) Log.d(ASSERTION_TAG, "Assert that the reminder has been picked up and displayed on the To Do Details Page.") - calendarReminderPage.assertReminderDisplayedWithText(reminderDateOneHour.time.toFormattedString()) + calendarToDoDetailsPage.assertReminderDisplayedWithText(reminderDateOneHour.time.toFormattedString()) Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to pick up a new reminder.") - calendarReminderPage.clickAddReminder() + calendarToDoDetailsPage.clickAddReminder() Log.d(STEP_TAG, "Select '1 Hour Before' again.") - calendarReminderPage.clickCustomReminderOption() - calendarReminderPage.selectDate(reminderDateOneHour) - calendarReminderPage.selectTime(reminderDateOneHour) + calendarToDoDetailsPage.clickCustomReminderOption() + calendarToDoDetailsPage.selectDate(reminderDateOneHour) + calendarToDoDetailsPage.selectTime(reminderDateOneHour) Log.d(ASSERTION_TAG, "Assert that a toast message is occurring which warns that we cannot pick up the same time reminder twice.") checkToastText(R.string.reminderAlreadySet, activityRule.activity) Log.d(STEP_TAG, "Remove the '1 Hour Before' reminder and confirm the deletion dialog.") - calendarReminderPage.removeReminder() + calendarToDoDetailsPage.removeReminder() Log.d(ASSERTION_TAG, "Assert that the '1 Hour Before' reminder is not displayed any more.") - calendarReminderPage.assertReminderNotDisplayedWithText(reminderDateOneHour.time.toFormattedString()) + calendarToDoDetailsPage.assertReminderNotDisplayedWithText(reminderDateOneHour.time.toFormattedString()) futureDate.apply { add(Calendar.HOUR, 1) } Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to pick up a new reminder.") - calendarReminderPage.clickAddReminder() + calendarToDoDetailsPage.clickAddReminder() val reminderDateOneWeek = futureDate.apply { add(Calendar.WEEK_OF_YEAR, -1) } Log.d(STEP_TAG, "Select '1 Week Before'.") - calendarReminderPage.clickCustomReminderOption() - calendarReminderPage.selectDate(reminderDateOneWeek) - calendarReminderPage.selectTime(reminderDateOneWeek) + calendarToDoDetailsPage.clickCustomReminderOption() + calendarToDoDetailsPage.selectDate(reminderDateOneWeek) + calendarToDoDetailsPage.selectTime(reminderDateOneWeek) Log.d(ASSERTION_TAG, "Assert that a toast message is occurring which warns that we cannot pick up a reminder which has already passed (for example cannot pick '1 Week Before' reminder for a To Do which is due in 2 days).") - calendarReminderPage.assertReminderNotDisplayedWithText(reminderDateOneWeek.time.toFormattedString()) + calendarToDoDetailsPage.assertReminderNotDisplayedWithText(reminderDateOneWeek.time.toFormattedString()) checkToastText(R.string.reminderInPast, activityRule.activity) futureDate.apply { add(Calendar.WEEK_OF_YEAR, 1) } Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to pick up a new reminder.") - calendarReminderPage.clickAddReminder() + calendarToDoDetailsPage.clickAddReminder() val reminderDateOneDay = futureDate.apply { add(Calendar.DAY_OF_MONTH, -1) }.apply { add(Calendar.HOUR, -1) } Log.d(STEP_TAG, "Select '1 Day Before and 1 hour before'.") - calendarReminderPage.clickCustomReminderOption() - calendarReminderPage.selectDate(reminderDateOneDay) - calendarReminderPage.selectTime(reminderDateOneDay) + calendarToDoDetailsPage.clickCustomReminderOption() + calendarToDoDetailsPage.selectDate(reminderDateOneDay) + calendarToDoDetailsPage.selectTime(reminderDateOneDay) Log.d(ASSERTION_TAG, "Assert that the reminder has been picked up and displayed on the To Do Details Page.") - calendarReminderPage.assertReminderDisplayedWithText(reminderDateOneDay.time.toFormattedString()) + calendarToDoDetailsPage.assertReminderDisplayedWithText(reminderDateOneDay.time.toFormattedString()) Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to pick up a new reminder.") - calendarReminderPage.clickAddReminder() + calendarToDoDetailsPage.clickAddReminder() Log.d(STEP_TAG, "Select '1 Day Before' again.") - calendarReminderPage.clickCustomReminderOption() - calendarReminderPage.selectDate(reminderDateOneDay) - calendarReminderPage.selectTime(reminderDateOneDay) + calendarToDoDetailsPage.clickCustomReminderOption() + calendarToDoDetailsPage.selectDate(reminderDateOneDay) + calendarToDoDetailsPage.selectTime(reminderDateOneDay) Log.d(ASSERTION_TAG, "Assert that a toast message is occurring which warns that we cannot pick up the same time reminder twice. (Because 1 days and 24 hours is the same)") checkToastText(R.string.reminderAlreadySet, activityRule.activity) @@ -758,8 +754,7 @@ class CalendarE2ETest: TeacherComposeTest() { calendarToDoCreateUpdatePage.clickSave() Log.d(STEP_TAG, "Swipe the calendar item 'body' to 2 days in the future from now.") - calendarScreenPage.swipeEventsLeft() - calendarScreenPage.swipeEventsLeft() + calendarScreenPage.swipeEventsLeft(2) Log.d(ASSERTION_TAG, "Assert that the To Do item is displayed on the calendar.") calendarScreenPage.assertItemDisplayed(testTodoTitle) @@ -772,61 +767,61 @@ class CalendarE2ETest: TeacherComposeTest() { calendarToDoDetailsPage.assertPageTitle("To Do") Log.d(ASSERTION_TAG, "Assert that the reminder section is displayed.") - calendarReminderPage.assertReminderSectionDisplayed() + calendarToDoDetailsPage.assertReminderSectionDisplayed() Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to pick up a new reminder.") - calendarReminderPage.clickAddReminder() + calendarToDoDetailsPage.clickAddReminder() val reminderDateOneHour = futureDate.apply { add(Calendar.HOUR, -1) } Log.d(STEP_TAG, "Select '1 Hour Before'.") - calendarReminderPage.clickBeforeReminderOption("1 Hour Before") + calendarToDoDetailsPage.clickBeforeReminderOption("1 Hour Before") Log.d(ASSERTION_TAG, "Assert that the reminder has been picked up and displayed on the To Do Details Page.") - calendarReminderPage.assertReminderDisplayedWithText(reminderDateOneHour.time.toFormattedString()) + calendarToDoDetailsPage.assertReminderDisplayedWithText(reminderDateOneHour.time.toFormattedString()) Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to pick up a new reminder.") - calendarReminderPage.clickAddReminder() + calendarToDoDetailsPage.clickAddReminder() Log.d(STEP_TAG, "Select '1 Hour Before' again.") - calendarReminderPage.clickBeforeReminderOption("1 Hour Before") + calendarToDoDetailsPage.clickBeforeReminderOption("1 Hour Before") Log.d(ASSERTION_TAG, "Assert that a toast message is occurring which warns that we cannot pick up the same time reminder twice.") checkToastText(R.string.reminderAlreadySet, activityRule.activity) Log.d(STEP_TAG, "Remove the '1 Hour Before' reminder and confirm the deletion dialog.") - calendarReminderPage.removeReminder() + calendarToDoDetailsPage.removeReminder() Log.d(ASSERTION_TAG, "Assert that the '1 Hour Before' reminder is not displayed any more.") - calendarReminderPage.assertReminderNotDisplayedWithText(reminderDateOneHour.time.toFormattedString()) + calendarToDoDetailsPage.assertReminderNotDisplayedWithText(reminderDateOneHour.time.toFormattedString()) futureDate.apply { add(Calendar.HOUR, 1) } Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to add a new reminder.") - calendarReminderPage.clickAddReminder() + calendarToDoDetailsPage.clickAddReminder() val reminderDateOneWeek = futureDate.apply { add(Calendar.WEEK_OF_YEAR, -1) } Log.d(STEP_TAG, "Select '1 Week Before'.") - calendarReminderPage.clickBeforeReminderOption("1 Week Before") + calendarToDoDetailsPage.clickBeforeReminderOption("1 Week Before") Log.d(ASSERTION_TAG, "Assert that a toast message is occurring which warns that we cannot pick up a reminder which has already passed (for example cannot pick '1 Week Before' reminder for a To Do which is due in 2 days).") - calendarReminderPage.assertReminderNotDisplayedWithText(reminderDateOneWeek.time.toFormattedString()) + calendarToDoDetailsPage.assertReminderNotDisplayedWithText(reminderDateOneWeek.time.toFormattedString()) checkToastText(R.string.reminderInPast, activityRule.activity) futureDate.apply { add(Calendar.WEEK_OF_YEAR, 1) } Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to add a new reminder.") - calendarReminderPage.clickAddReminder() + calendarToDoDetailsPage.clickAddReminder() val reminderDateOneDay = futureDate.apply { add(Calendar.DAY_OF_MONTH, -1) } Log.d(STEP_TAG, "Select '1 Day Before'.") - calendarReminderPage.clickBeforeReminderOption("1 Day Before") + calendarToDoDetailsPage.clickBeforeReminderOption("1 Day Before") Log.d(ASSERTION_TAG, "Assert that the reminder has been picked up and displayed on the To Do Details Page.") - calendarReminderPage.assertReminderDisplayedWithText(reminderDateOneDay.time.toFormattedString()) + calendarToDoDetailsPage.assertReminderDisplayedWithText(reminderDateOneDay.time.toFormattedString()) Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to pick up a new reminder.") - calendarReminderPage.clickAddReminder() + calendarToDoDetailsPage.clickAddReminder() Log.d(STEP_TAG, "Select '1 Day Before' again.") - calendarReminderPage.clickBeforeReminderOption("1 Day Before") + calendarToDoDetailsPage.clickBeforeReminderOption("1 Day Before") Log.d(ASSERTION_TAG, "Assert that a toast message is occurring which warns that we cannot pick up the same time reminder twice. (Because 1 days and 24 hours is the same)") checkToastText(R.string.reminderAlreadySet, activityRule.activity) @@ -838,4 +833,4 @@ class CalendarE2ETest: TeacherComposeTest() { Log.d(ASSERTION_TAG, "Assert that the To Do item is displayed on the calendar.") calendarScreenPage.assertItemDisplayed(testTodoTitle) } -} \ No newline at end of file +} diff --git a/apps/teacher/src/androidTest/java/com/instructure/teacher/ui/utils/TeacherComposeTest.kt b/apps/teacher/src/androidTest/java/com/instructure/teacher/ui/utils/TeacherComposeTest.kt index d962240c3e..ffa88fdb1e 100644 --- a/apps/teacher/src/androidTest/java/com/instructure/teacher/ui/utils/TeacherComposeTest.kt +++ b/apps/teacher/src/androidTest/java/com/instructure/teacher/ui/utils/TeacherComposeTest.kt @@ -19,7 +19,6 @@ package com.instructure.teacher.ui.utils import androidx.compose.ui.test.junit4.createAndroidComposeRule -import com.instructure.canvas.espresso.common.pages.CalendarReminderPage import com.instructure.canvas.espresso.common.pages.compose.AssignmentListPage import com.instructure.canvas.espresso.common.pages.compose.CalendarEventCreateEditPage import com.instructure.canvas.espresso.common.pages.compose.CalendarEventDetailsPage @@ -53,7 +52,6 @@ abstract class TeacherComposeTest : TeacherTest() { val calendarToDoCreateUpdatePage = CalendarToDoCreateUpdatePage(composeTestRule) val calendarToDoDetailsPage = CalendarToDoDetailsPage(composeTestRule) val calendarFilterPage = CalendarFilterPage(composeTestRule) - val calendarReminderPage = CalendarReminderPage(composeTestRule) val progressPage = ProgressPage(composeTestRule) val settingsPage = SettingsPage(composeTestRule) val inboxDetailsPage = InboxDetailsPage(composeTestRule) diff --git a/automation/espresso/src/main/kotlin/com/instructure/canvas/espresso/common/pages/CalendarReminderPage.kt b/automation/espresso/src/main/kotlin/com/instructure/canvas/espresso/common/pages/CalendarReminderPage.kt deleted file mode 100644 index f8fc2739de..0000000000 --- a/automation/espresso/src/main/kotlin/com/instructure/canvas/espresso/common/pages/CalendarReminderPage.kt +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright (C) 2024 - present Instructure, Inc. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, version 3 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - */ -package com.instructure.canvas.espresso.common.pages - -import android.widget.DatePicker -import android.widget.TimePicker -import androidx.compose.ui.test.hasContentDescription -import androidx.compose.ui.test.isDisplayed -import androidx.compose.ui.test.junit4.ComposeTestRule -import androidx.compose.ui.test.onNodeWithContentDescription -import androidx.compose.ui.test.onNodeWithText -import androidx.compose.ui.test.performClick -import androidx.test.espresso.Espresso.onData -import androidx.test.espresso.Espresso.onView -import androidx.test.espresso.action.ViewActions.click -import androidx.test.espresso.assertion.ViewAssertions.doesNotExist -import androidx.test.espresso.contrib.PickerActions -import androidx.test.espresso.matcher.RootMatchers.isDialog -import androidx.test.espresso.matcher.ViewMatchers.withClassName -import androidx.test.espresso.matcher.ViewMatchers.withId -import androidx.test.espresso.matcher.ViewMatchers.withText -import com.instructure.espresso.click -import com.instructure.espresso.matchers.WaitForViewMatcher.waitForView -import com.instructure.espresso.scrollTo -import com.instructure.pandautils.R -import org.hamcrest.Matchers -import org.hamcrest.Matchers.anything -import java.util.Calendar - -class CalendarReminderPage(private val composeTestRule: ComposeTestRule) { - private val reminderTitle = "Reminder" - private val reminderDescription = "Add due date reminder notifications about this assignment on this device." - private val reminderAdd = "Add reminder" - - fun assertReminderSectionDisplayed() { - composeTestRule.onNodeWithText(reminderTitle).isDisplayed() - composeTestRule.onNodeWithText(reminderDescription).isDisplayed() - composeTestRule.onNodeWithContentDescription(reminderAdd).isDisplayed() - } - - fun clickBeforeReminderOption(text: String) { - waitForView(withText(text)).scrollTo().click() - composeTestRule.waitForIdle() - } - - fun clickCustomReminderOption() { - onData(anything()).inRoot(isDialog()).atPosition(6).perform(click()) - } - - fun clickAddReminder() { - composeTestRule.onNodeWithContentDescription(reminderAdd).performClick() - } - - fun assertReminderDisplayedWithText(text: String) { - composeTestRule.onNodeWithText(text).isDisplayed() - } - - fun removeReminder() { - composeTestRule.onNode( - hasContentDescription("Remove") - ).performClick() - Thread.sleep(1000) - onView(withText(R.string.yes)).scrollTo().click() - } - - fun assertReminderNotDisplayedWithText(text: String) { - onView(withText(text)).check(doesNotExist()) - } - - fun selectDate(calendar: Calendar) { - onView(withClassName(Matchers.equalTo(DatePicker::class.java.name))) - .perform(PickerActions.setDate(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH) + 1, calendar.get(Calendar.DAY_OF_MONTH))) - - onView(withId(android.R.id.button1)).perform(click()) - } - - fun selectTime(calendar: Calendar) { - onView(withClassName(Matchers.equalTo(TimePicker::class.java.name))) - .perform(PickerActions.setTime(calendar.get(Calendar.HOUR_OF_DAY), calendar.get(Calendar.MINUTE))) - - onView(withId(android.R.id.button1)).perform(click()) - } -} \ No newline at end of file diff --git a/automation/espresso/src/main/kotlin/com/instructure/canvas/espresso/common/pages/compose/CalendarEventDetailsPage.kt b/automation/espresso/src/main/kotlin/com/instructure/canvas/espresso/common/pages/compose/CalendarEventDetailsPage.kt index dbe5f25419..6c51d259b3 100644 --- a/automation/espresso/src/main/kotlin/com/instructure/canvas/espresso/common/pages/compose/CalendarEventDetailsPage.kt +++ b/automation/espresso/src/main/kotlin/com/instructure/canvas/espresso/common/pages/compose/CalendarEventDetailsPage.kt @@ -15,6 +15,8 @@ */ package com.instructure.canvas.espresso.common.pages.compose +import android.widget.DatePicker +import android.widget.TimePicker import androidx.compose.ui.test.assertIsDisplayed import androidx.compose.ui.test.assertIsNotDisplayed import androidx.compose.ui.test.assertTextContains @@ -23,21 +25,35 @@ import androidx.compose.ui.test.hasContentDescription import androidx.compose.ui.test.hasParent import androidx.compose.ui.test.hasTestTag import androidx.compose.ui.test.hasText +import androidx.compose.ui.test.isDisplayed import androidx.compose.ui.test.junit4.ComposeTestRule import androidx.compose.ui.test.onNodeWithContentDescription import androidx.compose.ui.test.onNodeWithText import androidx.compose.ui.test.performClick +import androidx.test.espresso.Espresso.onData +import androidx.test.espresso.Espresso.onView +import androidx.test.espresso.action.ViewActions.click +import androidx.test.espresso.assertion.ViewAssertions.doesNotExist +import androidx.test.espresso.contrib.PickerActions +import androidx.test.espresso.matcher.RootMatchers.isDialog +import androidx.test.espresso.matcher.ViewMatchers.withClassName +import androidx.test.espresso.matcher.ViewMatchers.withText import androidx.test.espresso.web.assertion.WebViewAssertions.webMatches import androidx.test.espresso.web.sugar.Web.onWebView import androidx.test.espresso.web.webdriver.DriverAtoms.findElement import androidx.test.espresso.web.webdriver.DriverAtoms.getText import androidx.test.espresso.web.webdriver.Locator +import com.instructure.espresso.click +import com.instructure.espresso.matchers.WaitForViewMatcher.waitForView import com.instructure.espresso.page.BasePage import com.instructure.espresso.page.plus import com.instructure.espresso.page.withAncestor import com.instructure.espresso.page.withId +import com.instructure.espresso.scrollTo import com.instructure.pandautils.R import org.hamcrest.Matchers +import org.hamcrest.Matchers.anything +import java.util.Calendar class CalendarEventDetailsPage(private val composeTestRule: ComposeTestRule) : BasePage() { @@ -124,4 +140,52 @@ class CalendarEventDetailsPage(private val composeTestRule: ComposeTestRule) : B fun clickComposeMessageFAB() { composeTestRule.onNodeWithContentDescription("Send a message about this event").performClick() } + + fun assertReminderSectionDisplayed() { + composeTestRule.onNodeWithText(R.string.reminderTitle.toString()).isDisplayed() + composeTestRule.onNodeWithText(R.string.reminderDescription.toString()).isDisplayed() + composeTestRule.onNodeWithContentDescription(R.string.a11y_addReminder.toString()).isDisplayed() + } + + fun clickBeforeReminderOption(reminderText: String) { + waitForView(withText(reminderText)).scrollTo().click() + composeTestRule.waitForIdle() + } + + fun clickCustomReminderOption() { + onData(anything()).inRoot(isDialog()).atPosition(6).perform(click()) + } + + fun clickAddReminder() { + composeTestRule.onNodeWithContentDescription("Add reminder").performClick() + } + + fun assertReminderDisplayedWithText(reminderText: String) { + composeTestRule.onNodeWithText(reminderText).isDisplayed() + } + + fun removeReminder() { + composeTestRule.onNode( + hasContentDescription("Remove") + ).performClick() + waitForView(withText(R.string.yes)).scrollTo().click() + } + + fun assertReminderNotDisplayedWithText(reminderText: String) { + onView(withText(reminderText)).check(doesNotExist()) + } + + fun selectDate(calendar: Calendar) { + onView(withClassName(Matchers.equalTo(DatePicker::class.java.name))) + .perform(PickerActions.setDate(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH) + 1, calendar.get(Calendar.DAY_OF_MONTH))) + + onView(withId(android.R.id.button1)).perform(click()) + } + + fun selectTime(calendar: Calendar) { + onView(withClassName(Matchers.equalTo(TimePicker::class.java.name))) + .perform(PickerActions.setTime(calendar.get(Calendar.HOUR_OF_DAY), calendar.get(Calendar.MINUTE))) + + onView(withId(android.R.id.button1)).perform(click()) + } } diff --git a/automation/espresso/src/main/kotlin/com/instructure/canvas/espresso/common/pages/compose/CalendarScreenPage.kt b/automation/espresso/src/main/kotlin/com/instructure/canvas/espresso/common/pages/compose/CalendarScreenPage.kt index 5d4c765e86..73461307ed 100644 --- a/automation/espresso/src/main/kotlin/com/instructure/canvas/espresso/common/pages/compose/CalendarScreenPage.kt +++ b/automation/espresso/src/main/kotlin/com/instructure/canvas/espresso/common/pages/compose/CalendarScreenPage.kt @@ -99,18 +99,22 @@ class CalendarScreenPage(private val composeTestRule: ComposeTestRule) : BasePag composeTestRule.waitForIdle() } - fun swipeEventsLeft() { - composeTestRule.onNodeWithTag("calendarEventsPage0").performTouchInput { - swipeLeft() + fun swipeEventsLeft(times: Int = 1) { + repeat(times) { + composeTestRule.onNodeWithTag("calendarEventsPage0").performTouchInput { + swipeLeft() + } + composeTestRule.waitForIdle() } - composeTestRule.waitForIdle() } - fun swipeEventsRight() { - composeTestRule.onNodeWithTag("calendarEventsPage0").performTouchInput { - swipeRight() + fun swipeEventsRight(times: Int = 1) { + repeat(times) { + composeTestRule.onNodeWithTag("calendarEventsPage0").performTouchInput { + swipeRight() + } + composeTestRule.waitForIdle() } - composeTestRule.waitForIdle() } fun clickCalendarHeader() { diff --git a/automation/espresso/src/main/kotlin/com/instructure/canvas/espresso/common/pages/compose/CalendarToDoDetailsPage.kt b/automation/espresso/src/main/kotlin/com/instructure/canvas/espresso/common/pages/compose/CalendarToDoDetailsPage.kt index 8a02b1a74c..bc2891c152 100644 --- a/automation/espresso/src/main/kotlin/com/instructure/canvas/espresso/common/pages/compose/CalendarToDoDetailsPage.kt +++ b/automation/espresso/src/main/kotlin/com/instructure/canvas/espresso/common/pages/compose/CalendarToDoDetailsPage.kt @@ -16,6 +16,8 @@ package com.instructure.canvas.espresso.common.pages.compose import android.content.Context +import android.widget.DatePicker +import android.widget.TimePicker import androidx.compose.ui.test.assertIsDisplayed import androidx.compose.ui.test.assertTextEquals import androidx.compose.ui.test.hasContentDescription @@ -24,10 +26,27 @@ import androidx.compose.ui.test.hasTestTag import androidx.compose.ui.test.hasText import androidx.compose.ui.test.isDisplayed import androidx.compose.ui.test.junit4.ComposeTestRule +import androidx.compose.ui.test.onNodeWithContentDescription import androidx.compose.ui.test.onNodeWithTag import androidx.compose.ui.test.onNodeWithText import androidx.compose.ui.test.performClick +import androidx.test.espresso.Espresso.onData +import androidx.test.espresso.Espresso.onView +import androidx.test.espresso.action.ViewActions.click +import androidx.test.espresso.assertion.ViewAssertions.doesNotExist +import androidx.test.espresso.contrib.PickerActions +import androidx.test.espresso.matcher.RootMatchers.isDialog +import androidx.test.espresso.matcher.ViewMatchers.withClassName +import androidx.test.espresso.matcher.ViewMatchers.withId +import androidx.test.espresso.matcher.ViewMatchers.withText import com.instructure.canvasapi2.utils.DateHelper +import com.instructure.espresso.click +import com.instructure.espresso.matchers.WaitForViewMatcher.waitForView +import com.instructure.espresso.scrollTo +import com.instructure.pandautils.R +import org.hamcrest.Matchers +import org.hamcrest.Matchers.anything +import java.util.Calendar import java.util.Date class CalendarToDoDetailsPage(private val composeTestRule: ComposeTestRule) { @@ -92,4 +111,52 @@ class CalendarToDoDetailsPage(private val composeTestRule: ComposeTestRule) { composeTestRule.onNodeWithText("Delete To Do?").assertIsDisplayed() composeTestRule.onNodeWithText("Delete").performClick() } + + fun assertReminderSectionDisplayed() { + composeTestRule.onNodeWithText(R.string.reminderTitle.toString()).isDisplayed() + composeTestRule.onNodeWithText(R.string.reminderDescription.toString()).isDisplayed() + composeTestRule.onNodeWithContentDescription(R.string.a11y_addReminder.toString()).isDisplayed() + } + + fun clickBeforeReminderOption(reminderText: String) { + waitForView(withText(reminderText)).scrollTo().click() + composeTestRule.waitForIdle() + } + + fun clickCustomReminderOption() { + onData(anything()).inRoot(isDialog()).atPosition(6).perform(click()) + } + + fun clickAddReminder() { + composeTestRule.onNodeWithContentDescription("Add reminder").performClick() + } + + fun assertReminderDisplayedWithText(reminderText: String) { + composeTestRule.onNodeWithText(reminderText).isDisplayed() + } + + fun removeReminder() { + composeTestRule.onNode( + hasContentDescription("Remove") + ).performClick() + waitForView(withText(com.instructure.pandautils.R.string.yes)).scrollTo().click() + } + + fun assertReminderNotDisplayedWithText(reminderText: String) { + onView(withText(reminderText)).check(doesNotExist()) + } + + fun selectDate(calendar: Calendar) { + onView(withClassName(Matchers.equalTo(DatePicker::class.java.name))) + .perform(PickerActions.setDate(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH) + 1, calendar.get(Calendar.DAY_OF_MONTH))) + + onView(withId(android.R.id.button1)).perform(click()) + } + + fun selectTime(calendar: Calendar) { + onView(withClassName(Matchers.equalTo(TimePicker::class.java.name))) + .perform(PickerActions.setTime(calendar.get(Calendar.HOUR_OF_DAY), calendar.get(Calendar.MINUTE))) + + onView(withId(android.R.id.button1)).perform(click()) + } } \ No newline at end of file From a041c3bfdcdf78c0554cd0495ae4e83016094c8f Mon Sep 17 00:00:00 2001 From: "adam.nagy" Date: Mon, 17 Nov 2025 21:20:52 +0100 Subject: [PATCH 3/3] PR fix refs: MBL-18703 affects: Student, Teacher, Parent release note: --- .../espresso/common/pages/compose/CalendarEventDetailsPage.kt | 1 + .../espresso/common/pages/compose/CalendarToDoDetailsPage.kt | 1 + 2 files changed, 2 insertions(+) diff --git a/automation/espresso/src/main/kotlin/com/instructure/canvas/espresso/common/pages/compose/CalendarEventDetailsPage.kt b/automation/espresso/src/main/kotlin/com/instructure/canvas/espresso/common/pages/compose/CalendarEventDetailsPage.kt index 6c51d259b3..f89c5e001b 100644 --- a/automation/espresso/src/main/kotlin/com/instructure/canvas/espresso/common/pages/compose/CalendarEventDetailsPage.kt +++ b/automation/espresso/src/main/kotlin/com/instructure/canvas/espresso/common/pages/compose/CalendarEventDetailsPage.kt @@ -168,6 +168,7 @@ class CalendarEventDetailsPage(private val composeTestRule: ComposeTestRule) : B composeTestRule.onNode( hasContentDescription("Remove") ).performClick() + Thread.sleep(1000) waitForView(withText(R.string.yes)).scrollTo().click() } diff --git a/automation/espresso/src/main/kotlin/com/instructure/canvas/espresso/common/pages/compose/CalendarToDoDetailsPage.kt b/automation/espresso/src/main/kotlin/com/instructure/canvas/espresso/common/pages/compose/CalendarToDoDetailsPage.kt index bc2891c152..2681506ac8 100644 --- a/automation/espresso/src/main/kotlin/com/instructure/canvas/espresso/common/pages/compose/CalendarToDoDetailsPage.kt +++ b/automation/espresso/src/main/kotlin/com/instructure/canvas/espresso/common/pages/compose/CalendarToDoDetailsPage.kt @@ -139,6 +139,7 @@ class CalendarToDoDetailsPage(private val composeTestRule: ComposeTestRule) { composeTestRule.onNode( hasContentDescription("Remove") ).performClick() + Thread.sleep(1000) waitForView(withText(com.instructure.pandautils.R.string.yes)).scrollTo().click() }