Skip to content

Commit 9b677c4

Browse files
adamNagy56claude
andauthored
[MBL-19155][Student] Add E2E test for 'Add to Home Screen' bookmark feature (#3317)
* [MBL-19155][Student] Add E2E test for 'Add to Home Screen' bookmark feature Implements E2E test for adding bookmarks to home screen: - Added addToHomeScreen() method in BookmarkPage to handle system dialog - Added testAddToHomeScreenE2E() that creates bookmark, adds to home screen, and verifies shortcut launches correct assignment - Test validates complete flow including assignment details after shortcut launch 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> * [MBL-19155][Student] Update bookmark name in E2E test Changed bookmark name from "Home Screen Bookmark" to "HomeScreen Bookmark" to avoid spacing issues in home screen shortcut detection. refs: MBL-19155 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> * PR fix refs: MBL-19155 affects: Student release note: * Attempt for PR fix refs: MBL-19155 affects: Student release note: --------- Co-authored-by: Claude <[email protected]>
1 parent 2fa679e commit 9b677c4

File tree

2 files changed

+69
-0
lines changed

2 files changed

+69
-0
lines changed

apps/student/src/androidTest/java/com/instructure/student/ui/e2e/compose/BookmarksE2ETest.kt

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package com.instructure.student.ui.e2e.compose
1919
import android.util.Log
2020
import androidx.test.espresso.Espresso
2121
import androidx.test.espresso.web.webdriver.Locator
22+
import androidx.test.uiautomator.UiSelector
2223
import com.instructure.canvas.espresso.FeatureCategory
2324
import com.instructure.canvas.espresso.Priority
2425
import com.instructure.canvas.espresso.TestCategory
@@ -167,4 +168,64 @@ class BookmarksE2ETest : StudentComposeTest() {
167168
canvasWebViewPage.runTextChecks(WebViewTextCheck(Locator.ID, "header1", "Front Page Text"))
168169
}
169170

171+
@E2E
172+
@Test
173+
@TestMetaData(Priority.COMMON, FeatureCategory.BOOKMARKS, TestCategory.E2E)
174+
fun testBookmarkAddToHomeScreenE2E() {
175+
176+
Log.d(PREPARATION_TAG, "Seeding data.")
177+
val data = seedData(students = 1, teachers = 1, courses = 1)
178+
val student = data.studentsList[0]
179+
val teacher = data.teachersList[0]
180+
val course = data.coursesList[0]
181+
182+
Log.d(PREPARATION_TAG, "Preparing an assignment which will be saved as a bookmark.")
183+
val assignment = AssignmentsApi.createAssignment(course.id, teacher.token, gradingType = GradingType.POINTS, pointsPossible = 15.0, dueAt = 1.days.fromNow.iso8601, submissionTypes = listOf(SubmissionType.ONLINE_TEXT_ENTRY))
184+
185+
Log.d(STEP_TAG, "Login with user: '${student.name}', login id: '${student.loginId}'.")
186+
tokenLogin(student)
187+
dashboardPage.waitForRender()
188+
189+
Log.d(STEP_TAG, "Navigate to assignments page and click on the prepared assignment: '${assignment.name}'.")
190+
dashboardPage.selectCourse(course)
191+
courseBrowserPage.selectAssignments()
192+
assignmentListPage.clickAssignment(assignment)
193+
194+
val bookmarkName = "HomeScreen Bookmark"
195+
Log.d(STEP_TAG, "Add a new bookmark with name: '$bookmarkName'")
196+
assignmentDetailsPage.addBookmark(bookmarkName)
197+
198+
Log.d(STEP_TAG, "Navigate back to Dashboard page.")
199+
pressBackButton(3)
200+
201+
Log.d(STEP_TAG, "Click on the 'Bookmarks' menu within the left side menu to open the Bookmarks page.")
202+
leftSideNavigationDrawerPage.clickBookmarksMenu()
203+
204+
Log.d(ASSERTION_TAG, "Assert if the newly created bookmark: '$bookmarkName' has displayed.")
205+
bookmarkPage.assertBookmarkDisplayed(bookmarkName)
206+
207+
Log.d(STEP_TAG, "Click on 'Add to Home Screen' option for the bookmark: '$bookmarkName'.")
208+
bookmarkPage.addBookmarkToHomeScreen(bookmarkName, device)
209+
210+
Log.d(ASSERTION_TAG, "Assert that we're still on the bookmarks page after adding the bookmark: '$bookmarkName' to home screen.")
211+
bookmarkPage.assertBookmarkDisplayed(bookmarkName)
212+
213+
Log.d(STEP_TAG, "Press 'Home' button to go to home screen.")
214+
device.pressHome()
215+
216+
Log.d(STEP_TAG, "Find and click the '$bookmarkName' shortcut on the home screen.")
217+
device.findObject(UiSelector().textContains(bookmarkName)).click()
218+
219+
Log.d(ASSERTION_TAG, "Assert that the bookmark shortcut opened the correct assignment: '${assignment.name}' with all details.")
220+
assignmentDetailsPage.assertAssignmentTitle(assignment.name)
221+
assignmentDetailsPage.assertAssignmentDetails(assignment)
222+
223+
Log.d(STEP_TAG, "Navigate back to the system home screen.")
224+
device.pressBack()
225+
226+
Log.d(ASSERTION_TAG, "Assert that the app returned to the system home screen by verifying the bookmark shortcut is visible.")
227+
val homeScreenShortcut = device.findObject(UiSelector().textContains(bookmarkName))
228+
assert(homeScreenShortcut.exists()) { "Expected to be on system home screen with bookmark shortcut visible, but it was not found." }
229+
}
230+
170231
}

apps/student/src/androidTest/java/com/instructure/student/ui/pages/classic/BookmarkPage.kt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ import androidx.test.espresso.matcher.ViewMatchers.isAssignableFrom
2424
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
2525
import androidx.test.espresso.matcher.ViewMatchers.withId
2626
import androidx.test.espresso.matcher.ViewMatchers.withText
27+
import androidx.test.uiautomator.UiDevice
28+
import androidx.test.uiautomator.UiSelector
2729
import com.instructure.canvas.espresso.CanvasTest
2830
import com.instructure.canvas.espresso.containsTextCaseInsensitive
2931
import com.instructure.canvas.espresso.scrollRecyclerView
@@ -85,4 +87,10 @@ class BookmarkPage : BasePage() {
8587
onView(allOf(withId(R.id.title), withText("Delete"), isDisplayed())).click()
8688
waitForView(anyOf(withText(android.R.string.ok), withText(R.string.ok))).click()
8789
}
90+
91+
fun addBookmarkToHomeScreen(bookmarkName: String, device: UiDevice) {
92+
clickOnMoreMenu(bookmarkName)
93+
onView(allOf(withId(R.id.title), containsTextCaseInsensitive("Add to Home"), isDisplayed())).click()
94+
device.findObject(UiSelector().textContains("Add automatically")).click()
95+
}
8896
}

0 commit comments

Comments
 (0)