From da7330c22839cda78411d065943b26a3deddfba2 Mon Sep 17 00:00:00 2001 From: "kristof.deak" Date: Fri, 5 Dec 2025 15:44:02 +0100 Subject: [PATCH 1/2] [MBL-19509][Teacher] - Add test for disabled front page course home selection MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add E2E test to verify that the "Pages Front Page" option in course settings is disabled when no front page exists, and enabled when a front page is present. Changes: - Added assertRadioButtonClickable() and assertRadioButtonNotClickable() methods to CourseSettingsPage for checking radio button enabled state - Added selectNewHomePageOption() method to select specific home page option by text - Added cancelNewHomePageSelectionDialog() method to cancel the dialog - Renamed assertHomePageChanged() to assertHomePageText() for clarity - Added comprehensive E2E test testCannotSelectCourseSettingsFrontPageIfNoFrontPageE2E() that: * Verifies "Pages Front Page" is disabled when no front page exists * Creates a front page and verifies the option becomes enabled * Removes the front page and verifies the option is disabled again * Checks that course home falls back to "Course Activity Stream" when front page is removed Technical details: - Radio buttons are found by their text content using onViewWithText() - Uses assertEnabled() and assertDisabled() extension functions for clickability checks - Test covers the full lifecycle of front page creation and removal refs: MBL-19509 affects: Teacher release note: none 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- .../ui/e2e/classic/CourseSettingsE2ETest.kt | 129 +++++++++++++++++- .../CourseSettingsInteractionTest.kt | 2 +- .../ui/pages/classic/CourseSettingsPage.kt | 51 ++++++- 3 files changed, 174 insertions(+), 8 deletions(-) diff --git a/apps/teacher/src/androidTest/java/com/instructure/teacher/ui/e2e/classic/CourseSettingsE2ETest.kt b/apps/teacher/src/androidTest/java/com/instructure/teacher/ui/e2e/classic/CourseSettingsE2ETest.kt index 74152321e0..fe05774052 100644 --- a/apps/teacher/src/androidTest/java/com/instructure/teacher/ui/e2e/classic/CourseSettingsE2ETest.kt +++ b/apps/teacher/src/androidTest/java/com/instructure/teacher/ui/e2e/classic/CourseSettingsE2ETest.kt @@ -24,6 +24,7 @@ import com.instructure.canvas.espresso.TestCategory import com.instructure.canvas.espresso.TestMetaData import com.instructure.canvas.espresso.annotations.E2E import com.instructure.canvas.espresso.refresh +import com.instructure.dataseeding.api.PagesApi import com.instructure.teacher.ui.utils.TeacherTest import com.instructure.teacher.ui.utils.extensions.seedData import com.instructure.teacher.ui.utils.extensions.tokenLogin @@ -64,7 +65,7 @@ class CourseSettingsE2ETest : TeacherTest() { val newCourseHomePage: String = courseSettingsPage.selectNewHomePage() Log.d(ASSERTION_TAG, "Assert if home page has been changed.") - courseSettingsPage.assertHomePageChanged(newCourseHomePage) + courseSettingsPage.assertHomePageText(newCourseHomePage) val newCourseName = "New Course Name" Log.d(STEP_TAG, "Click on 'Course Name' menu and edit course's name to be '$newCourseName'.") @@ -101,7 +102,7 @@ class CourseSettingsE2ETest : TeacherTest() { val secondCourseNewHomePage: String = courseSettingsPage.selectNewHomePage() Log.d(ASSERTION_TAG, "Assert if home page has been changed.") - courseSettingsPage.assertHomePageChanged(secondCourseNewHomePage) + courseSettingsPage.assertHomePageText(secondCourseNewHomePage) Log.d(STEP_TAG, "Go back to course browser page.") Espresso.pressBack() @@ -125,4 +126,128 @@ class CourseSettingsE2ETest : TeacherTest() { dashboardPage.assertDisplaysCourse(newCourseName) dashboardPage.assertDisplaysCourse(secondCourse.name) } + + @E2E + @Test + @TestMetaData(Priority.BUG_CASE, FeatureCategory.COURSE, TestCategory.E2E) // MBL-19486 + fun testCannotSelectCourseSettingsFrontPageIfNoFrontPageE2E() { + + Log.d(PREPARATION_TAG, "Seeding data.") + val data = seedData(teachers = 1, courses = 1) + val course = data.coursesList[0] + val teacher = data.teachersList[0] + val firstCourse = data.coursesList[0] + + Log.d(PREPARATION_TAG, "Create a published page for course: '${course.name}'.") + val publishedPage = PagesApi.createCoursePage(course.id, teacher.token, published = true, frontPage = false, body = "

Regular Page Text

") + + Log.d(STEP_TAG, "Login with user: '${teacher.name}', login id: '${teacher.loginId}'.") + tokenLogin(teacher) + + Log.d(STEP_TAG, "Open '${firstCourse.name}' course and click on Course Settings button.") + dashboardPage.waitForRender() + dashboardPage.openCourse(firstCourse) + courseBrowserPage.clickSettingsButton() + + Log.d(ASSERTION_TAG, "Assert if Course Settings page is displayed correctly.") + courseSettingsPage.assertPageObjects() + + Log.d(STEP_TAG, "Click on 'Set Home Page' menu and select another page as home page.") + courseSettingsPage.clickSetHomePage() + + Log.d(ASSERTION_TAG, "Assert that the 'Pages Front Page' radio button is not clickable since there is no front page in the course yet.") + courseSettingsPage.assertRadioButtonNotClickable("Pages Front Page") + + Log.d(ASSERTION_TAG, "Assert that the other radio buttons are clickable.") + courseSettingsPage.assertRadioButtonClickable("Course Activity Stream") + courseSettingsPage.assertRadioButtonClickable("Course Modules") + courseSettingsPage.assertRadioButtonClickable("Assignments List") + courseSettingsPage.assertRadioButtonClickable("Syllabus") + + Log.d(STEP_TAG, "Cancel the new home page selection dialog and navigate back to Course Browser Page.") + courseSettingsPage.cancelNewHomePageSelectionDialog() + Espresso.pressBack() + + Log.d(STEP_TAG, "Open Pages tab.") + courseBrowserPage.openPagesTab() + + Log.d(STEP_TAG, "Open '${publishedPage.title}' page and Edit it. Set it as a front page and click on 'Save'.") + pageListPage.openPage(publishedPage.title) + editPageDetailsPage.openEdit() + editPageDetailsPage.toggleFrontPage() + editPageDetailsPage.savePage() + + Log.d(STEP_TAG, "Navigate back to Pages List Page.") + Espresso.pressBack() + + Log.d(ASSERTION_TAG, "Assert that '${publishedPage.title}' is displayed as a FRONT page.") + pageListPage.assertFrontPageDisplayed(publishedPage.title) + + Log.d(STEP_TAG, " Navigate back to Course Browser Page.") + Espresso.pressBack() + + Log.d(STEP_TAG, "Click on Course Settings button.") + courseBrowserPage.clickSettingsButton() + + Log.d(ASSERTION_TAG, "Assert if Course Settings page is displayed correctly.") + courseSettingsPage.assertPageObjects() + + Log.d(STEP_TAG, "Click on 'Set Home Page' menu.") + courseSettingsPage.clickSetHomePage() + + Log.d(ASSERTION_TAG, "Assert that ALL the radio buttons are clickable, so the 'Course Front Page' as well, because there is a front page yet in the course.") + courseSettingsPage.assertRadioButtonClickable("Pages Front Page") + courseSettingsPage.assertRadioButtonClickable("Course Activity Stream") + courseSettingsPage.assertRadioButtonClickable("Course Modules") + courseSettingsPage.assertRadioButtonClickable("Assignments List") + courseSettingsPage.assertRadioButtonClickable("Syllabus") + + Log.d(STEP_TAG, "Select 'Course Front Page' as new home page.") + courseSettingsPage.selectNewHomePageOption("Pages Front Page") + + Log.d(ASSERTION_TAG, "Assert if home page has been changed to 'Course Front Page'.") + courseSettingsPage.assertHomePageText("Pages Front Page") + + Log.d(STEP_TAG, "Navigate back to the Course Browser Page.") + Espresso.pressBack() + + Log.d(STEP_TAG, "Open Pages tab.") + courseBrowserPage.openPagesTab() + + Log.d(STEP_TAG, "Open '${publishedPage.title}' page and Edit it. TURN OFF front page toggle and click on 'Save'.") + pageListPage.openPage(publishedPage.title) + editPageDetailsPage.openEdit() + editPageDetailsPage.toggleFrontPage() + editPageDetailsPage.savePage() + + Log.d(STEP_TAG, "Navigate back to Pages List Page.") + Espresso.pressBack() + + Log.d(ASSERTION_TAG, "Assert that '${publishedPage.title}' is displayed as a COMMON page.") + pageListPage.assertPageDisplayed(publishedPage.title) + + Log.d(STEP_TAG, " Navigate back to Course Browser Page.") + Espresso.pressBack() + + Log.d(STEP_TAG, "Click on Course Settings button.") + courseBrowserPage.clickSettingsButton() + + Log.d(ASSERTION_TAG, "Assert if Course Settings page is displayed correctly.") + courseSettingsPage.assertPageObjects() + + Log.d(ASSERTION_TAG, "Assert that the course home page fell back to 'Course Activity Stream' as we removed the front page so there is no front page yet.") + courseSettingsPage.assertHomePageText("Course Activity Stream") + + Log.d(STEP_TAG, "Click on 'Set Home Page' menu.") + courseSettingsPage.clickSetHomePage() + + Log.d(ASSERTION_TAG, "Assert that the 'Pages Front Page' radio button is not clickable since there is no front page in the course yet.") + courseSettingsPage.assertRadioButtonNotClickable("Pages Front Page") + + Log.d(ASSERTION_TAG, "Assert that the other radio buttons are clickable.") + courseSettingsPage.assertRadioButtonClickable("Course Activity Stream") + courseSettingsPage.assertRadioButtonClickable("Course Modules") + courseSettingsPage.assertRadioButtonClickable("Assignments List") + courseSettingsPage.assertRadioButtonClickable("Syllabus") + } } \ No newline at end of file diff --git a/apps/teacher/src/androidTest/java/com/instructure/teacher/ui/interaction/CourseSettingsInteractionTest.kt b/apps/teacher/src/androidTest/java/com/instructure/teacher/ui/interaction/CourseSettingsInteractionTest.kt index d653ace168..254b7265a3 100644 --- a/apps/teacher/src/androidTest/java/com/instructure/teacher/ui/interaction/CourseSettingsInteractionTest.kt +++ b/apps/teacher/src/androidTest/java/com/instructure/teacher/ui/interaction/CourseSettingsInteractionTest.kt @@ -46,7 +46,7 @@ class CourseSettingsInteractionTest : TeacherTest() { navigateToCourseSettings() courseSettingsPage.clickSetHomePage() val newCourseHomePage: String = courseSettingsPage.selectNewHomePage() - courseSettingsPage.assertHomePageChanged(newCourseHomePage) + courseSettingsPage.assertHomePageText(newCourseHomePage) } private fun navigateToCourseSettings() { diff --git a/apps/teacher/src/androidTest/java/com/instructure/teacher/ui/pages/classic/CourseSettingsPage.kt b/apps/teacher/src/androidTest/java/com/instructure/teacher/ui/pages/classic/CourseSettingsPage.kt index 4cfe0ff5cc..2d1fef16b3 100644 --- a/apps/teacher/src/androidTest/java/com/instructure/teacher/ui/pages/classic/CourseSettingsPage.kt +++ b/apps/teacher/src/androidTest/java/com/instructure/teacher/ui/pages/classic/CourseSettingsPage.kt @@ -21,6 +21,8 @@ import androidx.test.espresso.assertion.ViewAssertions.matches import com.instructure.canvas.espresso.checked import com.instructure.canvas.espresso.matchToolbarText import com.instructure.espresso.OnViewWithId +import com.instructure.espresso.assertDisabled +import com.instructure.espresso.assertEnabled import com.instructure.espresso.assertHasText import com.instructure.espresso.click import com.instructure.espresso.page.BasePage @@ -94,13 +96,32 @@ class CourseSettingsPage : BasePage() { } /** - * Asserts that the home page has been changed to the specified value. + * Selects a new home page option based on the provided option text. * - * @param newHomePage The expected new home page value. - * @throws AssertionError if the home page does not match the expected value. + * @param optionText The text of the option to select as the new home page. */ - fun assertHomePageChanged(newHomePage: String) { - courseHomePageText.assertHasText(newHomePage) + fun selectNewHomePageOption(optionText: String) { + val radioButton = onViewWithText(optionText) + val dialogOkButton = onViewWithText(android.R.string.ok) + radioButton.click() + dialogOkButton.click() + } + + /** + * Cancels the new home page selection dialog. + */ + fun cancelNewHomePageSelectionDialog() { + val dialogCancelButton = onViewWithText(R.string.cancel) + dialogCancelButton.click() + } + + /** + * Asserts that the home page has the specified value. + * + * @param expectedHomePageText The expected home page value. + */ + fun assertHomePageText(expectedHomePageText: String) { + courseHomePageText.assertHasText(expectedHomePageText) } /** @@ -123,5 +144,25 @@ class CourseSettingsPage : BasePage() { private fun assertToolbarSubtitleHasText(newCourseName: String) { toolbar.check(matches(matchToolbarText(`is`(newCourseName), false))) } + + /** + * Asserts that the radio button with the specified text is clickable (enabled). + * + * @param radioButtonText The text of the radio button to check. + * @throws AssertionError if the radio button is not enabled. + */ + fun assertRadioButtonClickable(radioButtonText: String) { + onViewWithText(radioButtonText).assertEnabled() + } + + /** + * Asserts that the radio button with the specified text is not clickable (disabled). + * + * @param radioButtonText The text of the radio button to check. + * @throws AssertionError if the radio button is enabled. + */ + fun assertRadioButtonNotClickable(radioButtonText: String) { + onViewWithText(radioButtonText).assertDisabled() + } } From 0d8874d8edbe715bf224a2c12b81819524254566 Mon Sep 17 00:00:00 2001 From: "kristof.deak" Date: Thu, 11 Dec 2025 09:45:56 +0100 Subject: [PATCH 2/2] Remove extra spaces from logs. --- .../teacher/ui/e2e/classic/CourseSettingsE2ETest.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/teacher/src/androidTest/java/com/instructure/teacher/ui/e2e/classic/CourseSettingsE2ETest.kt b/apps/teacher/src/androidTest/java/com/instructure/teacher/ui/e2e/classic/CourseSettingsE2ETest.kt index fe05774052..fe902958b3 100644 --- a/apps/teacher/src/androidTest/java/com/instructure/teacher/ui/e2e/classic/CourseSettingsE2ETest.kt +++ b/apps/teacher/src/androidTest/java/com/instructure/teacher/ui/e2e/classic/CourseSettingsE2ETest.kt @@ -183,7 +183,7 @@ class CourseSettingsE2ETest : TeacherTest() { Log.d(ASSERTION_TAG, "Assert that '${publishedPage.title}' is displayed as a FRONT page.") pageListPage.assertFrontPageDisplayed(publishedPage.title) - Log.d(STEP_TAG, " Navigate back to Course Browser Page.") + Log.d(STEP_TAG, "Navigate back to Course Browser Page.") Espresso.pressBack() Log.d(STEP_TAG, "Click on Course Settings button.") @@ -226,7 +226,7 @@ class CourseSettingsE2ETest : TeacherTest() { Log.d(ASSERTION_TAG, "Assert that '${publishedPage.title}' is displayed as a COMMON page.") pageListPage.assertPageDisplayed(publishedPage.title) - Log.d(STEP_TAG, " Navigate back to Course Browser Page.") + Log.d(STEP_TAG, "Navigate back to Course Browser Page.") Espresso.pressBack() Log.d(STEP_TAG, "Click on Course Settings button.")