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..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 @@ -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 @@ -312,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.") @@ -419,4 +425,502 @@ class CalendarE2ETest : ParentComposeTest() { calendarScreenPage.assertItemDisplayed(testEventSecondStudent.title.orEmpty()) calendarScreenPage.assertItemNotDisplayed(testEventFirstStudent.title.orEmpty()) } -} \ No newline at end of file + + @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(2) + + 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.") + calendarEventDetailsPage.assertReminderSectionDisplayed() + + Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to pick up a new reminder.") + calendarEventDetailsPage.clickAddReminder() + + val reminderDateOneHour = futureDate.apply { add(Calendar.HOUR, -1) } + Log.d(STEP_TAG, "Select '1 Hour Before' using custom date/time picker.") + 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.") + calendarEventDetailsPage.assertReminderDisplayedWithText(reminderDateOneHour.time.toFormattedString()) + + Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to pick up a new reminder.") + calendarEventDetailsPage.clickAddReminder() + + Log.d(STEP_TAG, "Select '1 Hour Before' again.") + 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.") + calendarEventDetailsPage.removeReminder() + + Log.d(ASSERTION_TAG, "Assert that the '1 Hour Before' reminder is not displayed any more.") + 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.") + calendarEventDetailsPage.clickAddReminder() + + val reminderDateOneWeek = futureDate.apply { add(Calendar.WEEK_OF_YEAR, -1) } + Log.d(STEP_TAG, "Select '1 Week Before'.") + 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).") + 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.") + 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'.") + 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.") + calendarEventDetailsPage.assertReminderDisplayedWithText(reminderDateOneDay.time.toFormattedString()) + + Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to pick up a new reminder.") + calendarEventDetailsPage.clickAddReminder() + + Log.d(STEP_TAG, "Select '1 Day Before' again.") + 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) + 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(2) + + 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.") + calendarToDoDetailsPage.assertReminderSectionDisplayed() + + Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to pick up a new reminder.") + calendarToDoDetailsPage.clickAddReminder() + + val reminderDateOneHour = futureDate.apply { add(Calendar.HOUR, -1) } + Log.d(STEP_TAG, "Select '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.") + calendarToDoDetailsPage.assertReminderDisplayedWithText(reminderDateOneHour.time.toFormattedString()) + + Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to pick up a new reminder.") + calendarToDoDetailsPage.clickAddReminder() + + Log.d(STEP_TAG, "Select '1 Hour Before' again.") + 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.") + calendarToDoDetailsPage.removeReminder() + + Log.d(ASSERTION_TAG, "Assert that the '1 Hour Before' reminder is not displayed any more.") + 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.") + calendarToDoDetailsPage.clickAddReminder() + + val reminderDateOneWeek = futureDate.apply { add(Calendar.WEEK_OF_YEAR, -1) } + Log.d(STEP_TAG, "Select '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).") + 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.") + calendarToDoDetailsPage.clickAddReminder() + + val reminderDateOneDay = futureDate.apply { add(Calendar.DAY_OF_MONTH, -1) } + Log.d(STEP_TAG, "Select '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.") + calendarToDoDetailsPage.assertReminderDisplayedWithText(reminderDateOneDay.time.toFormattedString()) + + Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to pick up a new reminder.") + calendarToDoDetailsPage.clickAddReminder() + + Log.d(STEP_TAG, "Select '1 Day Before' again.") + 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) + 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(2) + + 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.") + calendarToDoDetailsPage.assertReminderSectionDisplayed() + + Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to pick up a new reminder.") + calendarToDoDetailsPage.clickAddReminder() + + val reminderDateOneHour = futureDate.apply { add(Calendar.HOUR, -1) } + Log.d(STEP_TAG, "Select '1 Hour Before' using custom date/time picker.") + 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.") + calendarToDoDetailsPage.assertReminderDisplayedWithText(reminderDateOneHour.time.toFormattedString()) + + Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to pick up a new reminder.") + calendarToDoDetailsPage.clickAddReminder() + + Log.d(STEP_TAG, "Select '1 Hour Before' again.") + 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.") + calendarToDoDetailsPage.removeReminder() + + Log.d(ASSERTION_TAG, "Assert that the '1 Hour Before' reminder is not displayed any more.") + 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.") + calendarToDoDetailsPage.clickAddReminder() + + val reminderDateOneWeek = futureDate.apply { add(Calendar.WEEK_OF_YEAR, -1) } + Log.d(STEP_TAG, "Select '1 Week Before'.") + 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).") + 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.") + 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'.") + 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.") + calendarToDoDetailsPage.assertReminderDisplayedWithText(reminderDateOneDay.time.toFormattedString()) + + Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to pick up a new reminder.") + calendarToDoDetailsPage.clickAddReminder() + + Log.d(STEP_TAG, "Select '1 Day Before' again.") + 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) + 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(2) + + 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.") + calendarToDoDetailsPage.assertReminderSectionDisplayed() + + Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to pick up a new reminder.") + calendarToDoDetailsPage.clickAddReminder() + + val reminderDateOneHour = futureDate.apply { add(Calendar.HOUR, -1) } + Log.d(STEP_TAG, "Select '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.") + calendarToDoDetailsPage.assertReminderDisplayedWithText(reminderDateOneHour.time.toFormattedString()) + + Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to pick up a new reminder.") + calendarToDoDetailsPage.clickAddReminder() + + Log.d(STEP_TAG, "Select '1 Hour Before' again.") + 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.") + calendarToDoDetailsPage.removeReminder() + + Log.d(ASSERTION_TAG, "Assert that the '1 Hour Before' reminder is not displayed any more.") + 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.") + calendarToDoDetailsPage.clickAddReminder() + + val reminderDateOneWeek = futureDate.apply { add(Calendar.WEEK_OF_YEAR, -1) } + Log.d(STEP_TAG, "Select '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).") + 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.") + calendarToDoDetailsPage.clickAddReminder() + + val reminderDateOneDay = futureDate.apply { add(Calendar.DAY_OF_MONTH, -1) } + Log.d(STEP_TAG, "Select '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.") + calendarToDoDetailsPage.assertReminderDisplayedWithText(reminderDateOneDay.time.toFormattedString()) + + Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to pick up a new reminder.") + calendarToDoDetailsPage.clickAddReminder() + + Log.d(STEP_TAG, "Select '1 Day Before' again.") + 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) + 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) + } +} 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..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 @@ -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 @@ -287,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) @@ -313,4 +319,514 @@ class CalendarE2ETest : StudentComposeTest() { calendarScreenPage.assertItemDetails(newEventTitle, student.name, currentDate) } -} \ No newline at end of file + @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(2) + + 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.") + calendarEventDetailsPage.assertReminderSectionDisplayed() + + Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to pick up a new reminder.") + calendarEventDetailsPage.clickAddReminder() + + val reminderDateOneHour = futureDate.apply { add(Calendar.HOUR, -1) } + Log.d(STEP_TAG, "Select '1 Hour Before' using custom date/time picker.") + 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.") + calendarEventDetailsPage.assertReminderDisplayedWithText(reminderDateOneHour.time.toFormattedString()) + + Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to pick up a new reminder.") + calendarEventDetailsPage.clickAddReminder() + + Log.d(STEP_TAG, "Select '1 Hour Before' again.") + 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.") + calendarEventDetailsPage.removeReminder() + + Log.d(ASSERTION_TAG, "Assert that the '1 Hour Before' reminder is not displayed any more.") + 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.") + calendarEventDetailsPage.clickAddReminder() + + val reminderDateOneWeek = futureDate.apply { add(Calendar.WEEK_OF_YEAR, -1) } + Log.d(STEP_TAG, "Select '1 Week Before'.") + 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).") + 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.") + 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'.") + 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.") + calendarEventDetailsPage.assertReminderDisplayedWithText(reminderDateOneDay.time.toFormattedString()) + + Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to pick up a new reminder.") + calendarEventDetailsPage.clickAddReminder() + + Log.d(STEP_TAG, "Select '1 Day Before' again.") + 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) + 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(2) + + 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.") + calendarEventDetailsPage.assertReminderSectionDisplayed() + + Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to pick up a new reminder.") + calendarEventDetailsPage.clickAddReminder() + + val reminderDateOneHour = futureDate.apply { add(Calendar.HOUR, -1) } + Log.d(STEP_TAG, "Select '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.") + calendarEventDetailsPage.assertReminderDisplayedWithText(reminderDateOneHour.time.toFormattedString()) + + Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to pick up a new reminder.") + calendarEventDetailsPage.clickAddReminder() + + Log.d(STEP_TAG, "Select '1 Hour Before' again.") + 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.") + calendarEventDetailsPage.removeReminder() + + Log.d(ASSERTION_TAG, "Assert that the '1 Hour Before' reminder is not displayed any more.") + 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.") + calendarEventDetailsPage.clickAddReminder() + + val reminderDateOneWeek = futureDate.apply { add(Calendar.WEEK_OF_YEAR, -1) } + Log.d(STEP_TAG, "Select '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).") + 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.") + calendarEventDetailsPage.clickAddReminder() + + val reminderDateOneDay = futureDate.apply { add(Calendar.DAY_OF_MONTH, -1) } + Log.d(STEP_TAG, "Select '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.") + calendarEventDetailsPage.assertReminderDisplayedWithText(reminderDateOneDay.time.toFormattedString()) + + Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to pick up a new reminder.") + calendarEventDetailsPage.clickAddReminder() + + Log.d(STEP_TAG, "Select '1 Day Before' again.") + 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) + 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(2) + + 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.") + calendarToDoDetailsPage.assertReminderSectionDisplayed() + + Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to pick up a new reminder.") + calendarToDoDetailsPage.clickAddReminder() + + val reminderDateOneHour = futureDate.apply { add(Calendar.HOUR, -1) } + Log.d(STEP_TAG, "Select '1 Hour Before' using custom date/time picker.") + 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.") + calendarToDoDetailsPage.assertReminderDisplayedWithText(reminderDateOneHour.time.toFormattedString()) + + Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to pick up a new reminder.") + calendarToDoDetailsPage.clickAddReminder() + + Log.d(STEP_TAG, "Select '1 Hour Before' again.") + 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.") + calendarToDoDetailsPage.removeReminder() + + Log.d(ASSERTION_TAG, "Assert that the '1 Hour Before' reminder is not displayed any more.") + 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.") + calendarToDoDetailsPage.clickAddReminder() + + val reminderDateOneWeek = futureDate.apply { add(Calendar.WEEK_OF_YEAR, -1) } + Log.d(STEP_TAG, "Select '1 Week Before'.") + 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).") + 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.") + 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'.") + 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.") + calendarToDoDetailsPage.assertReminderDisplayedWithText(reminderDateOneDay.time.toFormattedString()) + + Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to pick up a new reminder.") + calendarToDoDetailsPage.clickAddReminder() + + Log.d(STEP_TAG, "Select '1 Day Before' again.") + 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) + 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(2) + + 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.") + calendarToDoDetailsPage.assertReminderSectionDisplayed() + + Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to pick up a new reminder.") + calendarToDoDetailsPage.clickAddReminder() + + val reminderDateOneHour = futureDate.apply { add(Calendar.HOUR, -1) } + Log.d(STEP_TAG, "Select '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.") + calendarToDoDetailsPage.assertReminderDisplayedWithText(reminderDateOneHour.time.toFormattedString()) + + Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to pick up a new reminder.") + calendarToDoDetailsPage.clickAddReminder() + + Log.d(STEP_TAG, "Select '1 Hour Before' again.") + 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.") + calendarToDoDetailsPage.removeReminder() + + Log.d(ASSERTION_TAG, "Assert that the '1 Hour Before' reminder is not displayed any more.") + 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.") + calendarToDoDetailsPage.clickAddReminder() + + val reminderDateOneWeek = futureDate.apply { add(Calendar.WEEK_OF_YEAR, -1) } + Log.d(STEP_TAG, "Select '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).") + 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.") + calendarToDoDetailsPage.clickAddReminder() + + val reminderDateOneDay = futureDate.apply { add(Calendar.DAY_OF_MONTH, -1) } + Log.d(STEP_TAG, "Select '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.") + calendarToDoDetailsPage.assertReminderDisplayedWithText(reminderDateOneDay.time.toFormattedString()) + + Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to pick up a new reminder.") + calendarToDoDetailsPage.clickAddReminder() + + Log.d(STEP_TAG, "Select '1 Day Before' again.") + 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) + 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) + } + +} 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..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 @@ -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 @@ -291,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.") @@ -317,4 +323,514 @@ 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) } -} \ No newline at end of file + + @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(2) + + 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.") + calendarEventDetailsPage.assertReminderSectionDisplayed() + + Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to pick up a new reminder.") + calendarEventDetailsPage.clickAddReminder() + + val reminderDateOneHour = futureDate.apply { add(Calendar.HOUR, -1) } + Log.d(STEP_TAG, "Select '1 Hour Before' using custom date/time picker.") + 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.") + calendarEventDetailsPage.assertReminderDisplayedWithText(reminderDateOneHour.time.toFormattedString()) + + Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to pick up a new reminder.") + calendarEventDetailsPage.clickAddReminder() + + Log.d(STEP_TAG, "Select '1 Hour Before' again.") + 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.") + calendarEventDetailsPage.removeReminder() + + Log.d(ASSERTION_TAG, "Assert that the '1 Hour Before' reminder is not displayed any more.") + 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.") + calendarEventDetailsPage.clickAddReminder() + + val reminderDateOneWeek = futureDate.apply { add(Calendar.WEEK_OF_YEAR, -1) } + Log.d(STEP_TAG, "Select '1 Week Before'.") + 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).") + 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.") + 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'.") + 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.") + calendarEventDetailsPage.assertReminderDisplayedWithText(reminderDateOneDay.time.toFormattedString()) + + Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to pick up a new reminder.") + calendarEventDetailsPage.clickAddReminder() + + Log.d(STEP_TAG, "Select '1 Day Before' again.") + 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) + 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(2) + + 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.") + calendarEventDetailsPage.assertReminderSectionDisplayed() + + Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to pick up a new reminder.") + calendarEventDetailsPage.clickAddReminder() + + val reminderDateOneHour = futureDate.apply { add(Calendar.HOUR, -1) } + Log.d(STEP_TAG, "Select '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.") + calendarEventDetailsPage.assertReminderDisplayedWithText(reminderDateOneHour.time.toFormattedString()) + + Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to pick up a new reminder.") + calendarEventDetailsPage.clickAddReminder() + + Log.d(STEP_TAG, "Select '1 Hour Before' again.") + 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.") + calendarEventDetailsPage.removeReminder() + + Log.d(ASSERTION_TAG, "Assert that the '1 Hour Before' reminder is not displayed any more.") + 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.") + calendarEventDetailsPage.clickAddReminder() + + val reminderDateOneWeek = futureDate.apply { add(Calendar.WEEK_OF_YEAR, -1) } + Log.d(STEP_TAG, "Select '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).") + 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.") + calendarEventDetailsPage.clickAddReminder() + + val reminderDateOneDay = futureDate.apply { add(Calendar.DAY_OF_MONTH, -1) } + Log.d(STEP_TAG, "Select '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.") + calendarEventDetailsPage.assertReminderDisplayedWithText(reminderDateOneDay.time.toFormattedString()) + + Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to pick up a new reminder.") + calendarEventDetailsPage.clickAddReminder() + + Log.d(STEP_TAG, "Select '1 Day Before' again.") + 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) + 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(2) + + 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.") + calendarToDoDetailsPage.assertReminderSectionDisplayed() + + Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to pick up a new reminder.") + calendarToDoDetailsPage.clickAddReminder() + + val reminderDateOneHour = futureDate.apply { add(Calendar.HOUR, -1) } + Log.d(STEP_TAG, "Select '1 Hour Before' using custom date/time picker.") + 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.") + calendarToDoDetailsPage.assertReminderDisplayedWithText(reminderDateOneHour.time.toFormattedString()) + + Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to pick up a new reminder.") + calendarToDoDetailsPage.clickAddReminder() + + Log.d(STEP_TAG, "Select '1 Hour Before' again.") + 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.") + calendarToDoDetailsPage.removeReminder() + + Log.d(ASSERTION_TAG, "Assert that the '1 Hour Before' reminder is not displayed any more.") + 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.") + calendarToDoDetailsPage.clickAddReminder() + + val reminderDateOneWeek = futureDate.apply { add(Calendar.WEEK_OF_YEAR, -1) } + Log.d(STEP_TAG, "Select '1 Week Before'.") + 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).") + 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.") + 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'.") + 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.") + calendarToDoDetailsPage.assertReminderDisplayedWithText(reminderDateOneDay.time.toFormattedString()) + + Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to pick up a new reminder.") + calendarToDoDetailsPage.clickAddReminder() + + Log.d(STEP_TAG, "Select '1 Day Before' again.") + 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) + 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(2) + + 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.") + calendarToDoDetailsPage.assertReminderSectionDisplayed() + + Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to pick up a new reminder.") + calendarToDoDetailsPage.clickAddReminder() + + val reminderDateOneHour = futureDate.apply { add(Calendar.HOUR, -1) } + Log.d(STEP_TAG, "Select '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.") + calendarToDoDetailsPage.assertReminderDisplayedWithText(reminderDateOneHour.time.toFormattedString()) + + Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to pick up a new reminder.") + calendarToDoDetailsPage.clickAddReminder() + + Log.d(STEP_TAG, "Select '1 Hour Before' again.") + 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.") + calendarToDoDetailsPage.removeReminder() + + Log.d(ASSERTION_TAG, "Assert that the '1 Hour Before' reminder is not displayed any more.") + 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.") + calendarToDoDetailsPage.clickAddReminder() + + val reminderDateOneWeek = futureDate.apply { add(Calendar.WEEK_OF_YEAR, -1) } + Log.d(STEP_TAG, "Select '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).") + 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.") + calendarToDoDetailsPage.clickAddReminder() + + val reminderDateOneDay = futureDate.apply { add(Calendar.DAY_OF_MONTH, -1) } + Log.d(STEP_TAG, "Select '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.") + calendarToDoDetailsPage.assertReminderDisplayedWithText(reminderDateOneDay.time.toFormattedString()) + + Log.d(STEP_TAG, "Click on the '+' button (Add reminder) to pick up a new reminder.") + calendarToDoDetailsPage.clickAddReminder() + + Log.d(STEP_TAG, "Select '1 Day Before' again.") + 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) + 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) + } +} 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 6508504a3c..da6fb3124c 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/compose/CalendarEventDetailsPage.kt b/automation/espresso/src/main/kotlin/com/instructure/canvas/espresso/common/pages/compose/CalendarEventDetailsPage.kt index dbe5f25419..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 @@ -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,53 @@ 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() + Thread.sleep(1000) + 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..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 @@ -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,53 @@ 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() + Thread.sleep(1000) + 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