Skip to content

Commit

Permalink
Merge pull request #2276 from instructure/release-conflicts
Browse files Browse the repository at this point in the history
Release conflicts
  • Loading branch information
hermannakos authored Dec 7, 2023
2 parents b194d38 + 624c6af commit 042514c
Show file tree
Hide file tree
Showing 11 changed files with 272 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,11 @@ class DashboardE2ETest : StudentTest() {
dashboardPage.assertDisplaysGroup(group2, course1)

Log.d(STEP_TAG,"Click on 'All Courses' button. Assert that the All Courses Page is loaded.")
dashboardPage.clickEditDashboard()
editDashboardPage.assertPageObjects()
dashboardPage.openAllCoursesPage()
allCoursesPage.assertPageObjects()

Log.d(STEP_TAG, "Favorite '${course1.name}' course and navigate back to Dashboard Page.")
editDashboardPage.favoriteCourse(course1.name)
allCoursesPage.favoriteCourse(course1.name)
Espresso.pressBack()

Log.d(STEP_TAG,"Assert that only the favoured course, '${course1.name}' is displayed." +
Expand All @@ -124,16 +124,16 @@ class DashboardE2ETest : StudentTest() {

Log.d(STEP_TAG,"Click on 'All Courses' button. Assert that the All Courses Page is loaded.")
dashboardPage.assertPageObjects()
dashboardPage.clickEditDashboard()
editDashboardPage.assertPageObjects()
dashboardPage.openAllCoursesPage()
allCoursesPage.assertPageObjects()

Log.d(STEP_TAG, "Assert that the mass select button's text is 'Unselect All', since one of the courses is selected.")
editDashboardPage.assertCourseMassSelectButtonIsDisplayed(true)
allCoursesPage.assertCourseMassSelectButtonIsDisplayed(true)

Log.d(STEP_TAG, "Toggle off favourite star icon of '${course1.name}' course." +
"Assert that the 'mass' select button's label is 'Select All'.")
editDashboardPage.unfavoriteCourse(course1.name)
editDashboardPage.assertCourseMassSelectButtonIsDisplayed(false)
allCoursesPage.unfavoriteCourse(course1.name)
allCoursesPage.assertCourseMassSelectButtonIsDisplayed(false)

Log.d(STEP_TAG, "Navigate back to Dashboard Page.")
Espresso.pressBack()
Expand Down Expand Up @@ -186,15 +186,15 @@ class DashboardE2ETest : StudentTest() {
dashboardPage.assertCourseGrade(course2.name, "N/A")

Log.d(STEP_TAG,"Click on 'All Courses' button.")
dashboardPage.clickEditDashboard()
editDashboardPage.assertPageObjects()
dashboardPage.openAllCoursesPage()
allCoursesPage.assertPageObjects()

Log.d(STEP_TAG, "Assert that the group 'mass' select button's label is 'Select All'.")
editDashboardPage.swipeUp()
editDashboardPage.assertGroupMassSelectButtonIsDisplayed(false)
allCoursesPage.swipeUp()
allCoursesPage.assertGroupMassSelectButtonIsDisplayed(false)

Log.d(STEP_TAG, "Favorite '${group.name}' course and navigate back to Dashboard Page.")
editDashboardPage.favoriteGroup(group.name)
allCoursesPage.favoriteGroup(group.name)
Espresso.pressBack()

Log.d(STEP_TAG,"Assert that only the favoured group, '${group.name}' is displayed." +
Expand All @@ -203,18 +203,18 @@ class DashboardE2ETest : StudentTest() {
dashboardPage.assertGroupNotDisplayed(group2)

Log.d(STEP_TAG,"Click on 'All Courses' button.")
dashboardPage.clickEditDashboard()
editDashboardPage.assertPageObjects()
dashboardPage.openAllCoursesPage()
allCoursesPage.assertPageObjects()
Thread.sleep(2000) //It can be flaky without this 2 seconds
editDashboardPage.swipeUp()
allCoursesPage.swipeUp()

Log.d(STEP_TAG, "Assert that the group 'mass' select button's label is 'Unselect All'.")
editDashboardPage.assertGroupMassSelectButtonIsDisplayed(true)
allCoursesPage.assertGroupMassSelectButtonIsDisplayed(true)

Log.d(STEP_TAG, "Toggle off favourite star icon of '${group.name}' group." +
"Assert that the 'mass' select button's label is 'Select All'.")
editDashboardPage.unfavoriteGroup(group.name)
editDashboardPage.assertGroupMassSelectButtonIsDisplayed(false)
allCoursesPage.unfavoriteGroup(group.name)
allCoursesPage.assertGroupMassSelectButtonIsDisplayed(false)

Log.d(STEP_TAG, "Navigate back to Dashboard Page.")
Espresso.pressBack()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ class TodoE2ETest: StudentTest() {

Log.d(STEP_TAG, "Navigate back to the Dashboard Page. Open ${favoriteCourse.name} course. Mark it as favorite.")
Espresso.pressBack()
dashboardPage.clickEditDashboard()
editDashboardPage.favoriteCourse(favoriteCourse.name)
dashboardPage.openAllCoursesPage()
allCoursesPage.favoriteCourse(favoriteCourse.name)

Log.d(STEP_TAG, "Navigate back to the Dashboard Page and open the To Do Page again.")
Espresso.pressBack()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
/*
* Copyright (C) 2023 - present Instructure, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package com.instructure.student.ui.e2e.offline

import android.util.Log
import androidx.test.espresso.Espresso
import androidx.test.espresso.matcher.ViewMatchers
import com.google.android.material.checkbox.MaterialCheckBox
import com.instructure.canvas.espresso.OfflineE2E
import com.instructure.panda_annotations.FeatureCategory
import com.instructure.panda_annotations.Priority
import com.instructure.panda_annotations.SecondaryFeatureCategory
import com.instructure.panda_annotations.TestCategory
import com.instructure.panda_annotations.TestMetaData
import com.instructure.student.ui.utils.StudentTest
import com.instructure.student.ui.utils.seedData
import com.instructure.student.ui.utils.tokenLogin
import dagger.hilt.android.testing.HiltAndroidTest
import org.junit.After
import org.junit.Test
import java.lang.Thread.sleep

@HiltAndroidTest
class OfflineAllCoursesE2ETest : StudentTest() {
override fun displaysPageObjects() = Unit

override fun enableAndConfigureAccessibilityChecks() = Unit

@OfflineE2E
@Test
@TestMetaData(Priority.MANDATORY, FeatureCategory.DASHBOARD, TestCategory.E2E, false, SecondaryFeatureCategory.ALL_COURSES)
fun testOfflineAllCoursesE2E() {

Log.d(PREPARATION_TAG, "Seeding data.")
val data = seedData(students = 1, teachers = 1, courses = 3, announcements = 1)
val student = data.studentsList[0]
val course1 = data.coursesList[0]
val course2 = data.coursesList[1]
val course3 = data.coursesList[2]

Log.d(STEP_TAG, "Login with user: ${student.name}, login id: ${student.loginId}.")
tokenLogin(student)
dashboardPage.waitForRender()

Log.d(STEP_TAG, "Open the 'All Courses' page and wait for it to be rendered.")
dashboardPage.openAllCoursesPage()
allCoursesPage.assertPageObjects()

Log.d(STEP_TAG, "Favourite '${course1.name}' course and assert if it became favourited. Then navigate back to Dashboard page.")
allCoursesPage.favoriteCourse(course1.name)
allCoursesPage.assertCourseFavorited(course1)
Espresso.pressBack()

Log.d(STEP_TAG, "Open global 'Manage Offline Content' page via the more menu of the Dashboard Page.")
dashboardPage.openGlobalManageOfflineContentPage()
manageOfflineContentPage.assertPageObjects()

Log.d(STEP_TAG, "Assert that the '${course1.name}' course's checkbox state is 'Unchecked'.")
manageOfflineContentPage.assertCheckedStateOfItem(course1.name, MaterialCheckBox.STATE_UNCHECKED)
manageOfflineContentPage.assertCheckedStateOfItem(course2.name, MaterialCheckBox.STATE_UNCHECKED)

Log.d(STEP_TAG, "Select '${course1.name}' and '${course2.name}' courses' checkboxes and Sync them.")
manageOfflineContentPage.changeItemSelectionState(course1.name)
manageOfflineContentPage.changeItemSelectionState(course2.name)
manageOfflineContentPage.clickOnSyncButtonAndConfirm()

Log.d(STEP_TAG, "Wait for the 'Download Started' dashboard notification to be displayed, and the to disappear.")
dashboardPage.waitForRender()
dashboardPage.waitForSyncProgressDownloadStartedNotification()
dashboardPage.waitForSyncProgressDownloadStartedNotificationToDisappear()

Log.d(STEP_TAG, "Wait for the 'Syncing Offline Content' dashboard notification to be displayed, and the to disappear. (It should be displayed after the 'Download Started' notification immediately.)")
dashboardPage.waitForSyncProgressStartingNotification()
dashboardPage.waitForSyncProgressStartingNotificationToDisappear()

Log.d(PREPARATION_TAG, "Turn off the Wi-Fi and Mobile Data on the device, so it will go offline.")
turnOffConnectionViaADB()

Log.d(STEP_TAG, "Wait for the Dashboard Page to be rendered, and assert that '${course1.name}' is the only course which is displayed on the offline mode Dashboard Page.")
dashboardPage.waitForRender()
sleep(10000)
dashboardPage.assertDisplaysCourse(course1)
dashboardPage.assertCourseNotDisplayed(course2)
dashboardPage.assertCourseNotDisplayed(course3)

Log.d(STEP_TAG, "Open the 'All Courses' page and wait for it to be rendered.")
dashboardPage.openAllCoursesPage()
allCoursesPage.assertPageObjects()

Log.d(STEP_TAG, "Assert that the plus 'Note' box is displayed in which warns the user that favouring courses can only be done in online mode.")
allCoursesPage.assertOfflineNoteDisplayed()

Log.d(STEP_TAG, "Dismiss the offline 'Note' box and assert if it's disappear.")
allCoursesPage.dismissOfflineNoteBox()
allCoursesPage.assertOfflineNoteNotDisplayed()

Log.d(STEP_TAG, "Assert that the select/unselect all button is not clickable because offline mode does not supports it.")
allCoursesPage.assertSelectUnselectAllButtonNotClickable()

Log.d(STEP_TAG, "Try to unfavorite '${course1.name}' course and assert it does not happened because favoring does not allowed in offline state.")
allCoursesPage.unfavoriteCourse(course1.name)
allCoursesPage.assertCourseFavorited(course1)

Log.d(STEP_TAG, "Assert that '${course3.name}' course's details are faded (and they having 0.4 alpha value) and it's offline sync icon is not displayed since it's not synced.")
allCoursesPage.assertCourseDetailsAlpha(course3.name, 0.4f)
allCoursesPage.assertCourseOfflineSyncButton(course3.name, ViewMatchers.Visibility.GONE)

Log.d(STEP_TAG, "Assert that '${course1.name}' course's favourite star is faded (and it's having 0.4 alpha value) because favoring is not possible in offline mode," +
"the course title and open button are not faded (1.0 alpha value) and the offline sync icon is displayed since the course is synced.")
allCoursesPage.assertCourseFavouriteStarAlpha(course1.name, 0.4f)
allCoursesPage.assertCourseTitleAlpha(course1.name, 1.0f)
allCoursesPage.assertCourseOpenButtonAlpha(course1.name, 1.0f)
allCoursesPage.assertCourseOfflineSyncButton(course1.name, ViewMatchers.Visibility.VISIBLE)

Log.d(STEP_TAG, "Click on '${course1.name}' course and assert if it will navigate the user to the CourseBrowser Page.")
allCoursesPage.openCourse(course1.name)
courseBrowserPage.assertTitleCorrect(course1)

}

@After
fun tearDown() {
Log.d(PREPARATION_TAG, "Turn back on the Wi-Fi and Mobile Data on the device, so it will come back online.")
turnOnConnectionViaADB()
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class OfflineCourseBrowserE2ETest : StudentTest() {

@OfflineE2E
@Test
@TestMetaData(Priority.MANDATORY, FeatureCategory.DASHBOARD, TestCategory.E2E)
@TestMetaData(Priority.MANDATORY, FeatureCategory.COURSE, TestCategory.E2E)
fun testOfflineCourseBrowserPageUnavailableE2E() {

Log.d(PREPARATION_TAG,"Seeding data.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,10 @@ class DashboardInteractionTest : StudentTest() {
dashboardPage.assertCourseNotShown(nonFavorite)

dashboardPage.editFavorites()
editDashboardPage.assertCourseDisplayed(nonFavorite)
editDashboardPage.assertCourseNotFavorited(nonFavorite)
editDashboardPage.favoriteCourse(nonFavorite)
editDashboardPage.assertCourseFavorited(nonFavorite)
allCoursesPage.assertCourseDisplayed(nonFavorite)
allCoursesPage.assertCourseNotFavorited(nonFavorite)
allCoursesPage.favoriteCourse(nonFavorite)
allCoursesPage.assertCourseFavorited(nonFavorite)

Espresso.pressBack()

Expand All @@ -115,10 +115,10 @@ class DashboardInteractionTest : StudentTest() {
dashboardPage.assertDisplaysCourse(favorite)

dashboardPage.editFavorites()
editDashboardPage.assertCourseDisplayed(favorite)
editDashboardPage.assertCourseFavorited(favorite)
editDashboardPage.unfavoriteCourse(favorite)
editDashboardPage.assertCourseNotFavorited(favorite)
allCoursesPage.assertCourseDisplayed(favorite)
allCoursesPage.assertCourseFavorited(favorite)
allCoursesPage.unfavoriteCourse(favorite)
allCoursesPage.assertCourseNotFavorited(favorite)

Espresso.pressBack()

Expand All @@ -137,9 +137,9 @@ class DashboardInteractionTest : StudentTest() {
data.courses.values.forEach { dashboardPage.assertDisplaysCourse(it) }

dashboardPage.editFavorites()
toFavorite.forEach { editDashboardPage.assertCourseNotFavorited(it) }
editDashboardPage.selectAllCourses()
toFavorite.forEach { editDashboardPage.assertCourseFavorited(it) }
toFavorite.forEach { allCoursesPage.assertCourseNotFavorited(it) }
allCoursesPage.selectAllCourses()
toFavorite.forEach { allCoursesPage.assertCourseFavorited(it) }

Espresso.pressBack()

Expand All @@ -156,9 +156,9 @@ class DashboardInteractionTest : StudentTest() {
toRemove.forEach { dashboardPage.assertDisplaysCourse(it) }

dashboardPage.editFavorites()
toRemove.forEach { editDashboardPage.assertCourseFavorited(it) }
editDashboardPage.unselectAllCourses()
toRemove.forEach { editDashboardPage.assertCourseNotFavorited(it) }
toRemove.forEach { allCoursesPage.assertCourseFavorited(it) }
allCoursesPage.unselectAllCourses()
toRemove.forEach { allCoursesPage.assertCourseNotFavorited(it) }

Espresso.pressBack()

Expand Down
Loading

0 comments on commit 042514c

Please sign in to comment.