-
Notifications
You must be signed in to change notification settings - Fork 126
[MBL-19944] Learner Dashboard - Add E2E Tests #4022
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
suhaibabsi-inst
wants to merge
3
commits into
master
from
chore/MBL-19944-LearnerDashboard-E2E-Tests
Closed
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
89 changes: 89 additions & 0 deletions
89
Core/TestsFoundation/UITestHelperNamespaces/LearnerDashboardHelper.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| // | ||
| // This file is part of Canvas. | ||
| // Copyright (C) 2025-present Instructure, Inc. | ||
| // | ||
| // This program is free software: you can redistribute it and/or modify | ||
| // it under the terms of the GNU Affero General Public License as | ||
| // published by the Free Software Foundation, either version 3 of the | ||
| // License, or (at your option) any later version. | ||
| // | ||
| // This program is distributed in the hope that it will be useful, | ||
| // but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| // GNU Affero General Public License for more details. | ||
| // | ||
| // You should have received a copy of the GNU Affero General Public License | ||
| // along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
| // | ||
|
|
||
| import XCTest | ||
|
|
||
| public class LearnerDashboardHelper: BaseHelper { | ||
| public static var bottomSettingsButton: XCUIElement { app.find(id: "Dashboard.bottomSettingsButton", type: .button) } | ||
|
|
||
| public struct Settings { | ||
| public static var doneButton: XCUIElement { app.find(id: "DashboardSettings.doneButton", type: .button) } | ||
| public static var newDashboardToggle: XCUIElement { app.find(id: "DashboardSettings.newDashboardToggle") } | ||
| public static var feedbackButton: XCUIElement { app.find(id: "Dashboard.Settings.feedbackButton") } | ||
|
suhaibabsi-inst marked this conversation as resolved.
|
||
| public static var showGradesToggle: XCUIElement { app.find(id: "Dashboard.Settings.showGradesToggle") } | ||
|
|
||
| public enum WidgetID: String { | ||
| case helloWidget | ||
| case coursesAndGroups | ||
| case weeklySummary | ||
| case todo | ||
| } | ||
|
|
||
| public static func widgetToggle(id: WidgetID) -> XCUIElement { | ||
| app.find(id: "Dashboard.Settings.widgetToggle.\(id.rawValue)") | ||
| } | ||
| } | ||
|
|
||
| public struct CoursesWidget { | ||
| public static var coursesHeader: XCUIElement { app.find(id: "Dashboard.Courses.coursesHeader") } | ||
| public static var groupsHeader: XCUIElement { app.find(id: "Dashboard.Courses.groupsHeader") } | ||
| public static var allCoursesButton: XCUIElement { app.find(id: "Dashboard.Courses.allCoursesButton") } | ||
| public static var courseCardGradePill: XCUIElement { app.find(id: "Dashboard.Courses.CourseCard.gradePill") } | ||
| public static var courseCardCustomizeButton: XCUIElement { app.find(id: "Dashboard.Courses.CourseCard.customizeButton") } | ||
| public static var courseCardAnnouncementsButton: XCUIElement { app.find(id: "Dashboard.Courses.CourseCard.announcementsButton") } | ||
|
|
||
| public static func courseCard(courseID: String) -> XCUIElement { | ||
| app.find(id: "Dashboard.Courses.CourseCard.cardButton.\(courseID)") | ||
| } | ||
| } | ||
|
|
||
| public struct AnnouncementsWidget { | ||
| public static var cardButton: XCUIElement { app.find(id: "Dashboard.Announcements.GlobalAnnouncement.cardButton") } | ||
| public static var detailsDismissButton: XCUIElement { app.find(id: "Dashboard.Announcements.GlobalAnnouncementDetails.dismissButton") } | ||
|
|
||
| public static func announcementCard(announcement: DSAccountNotification) -> XCUIElement { | ||
| app.find(id: "Dashboard.Announcements.GlobalAnnouncement.Id.\(announcement.id)") | ||
| } | ||
| } | ||
|
|
||
| public struct WeeklySummaryWidget { | ||
| public static var currentWeekButton: XCUIElement { app.find(id: "Dashboard.Forecast.currentWeekButton") } | ||
| public static var prevWeekButton: XCUIElement { app.find(id: "Dashboard.Forecast.prevWeekButton") } | ||
| public static var nextWeekButton: XCUIElement { app.find(id: "Dashboard.Forecast.nextWeekButton") } | ||
| public static var dueButton: XCUIElement { app.find(id: "Dashboard.Forecast.CategorySelector.dueButton") } | ||
| public static var missingButton: XCUIElement { app.find(id: "Dashboard.Forecast.CategorySelector.missingButton") } | ||
| public static var newGradesButton: XCUIElement { app.find(id: "Dashboard.Forecast.CategorySelector.newGradesButton") } | ||
| public static var itemCellButton: XCUIElement { app.find(id: "Dashboard.Forecast.Item.cellButton") } | ||
| } | ||
|
|
||
| public struct ToDoWidget { | ||
| public static var todayButton: XCUIElement { app.find(id: "Dashboard.Todo.todayButton") } | ||
| public static var showCompletedToggle: XCUIElement { app.find(id: "Dashboard.Todo.showCompletedToggle") } | ||
| public static var addTodoButton: XCUIElement { app.find(id: "Dashboard.Todo.TodoList.addTodoButton") } | ||
| public static var todoItem: XCUIElement { app.find(id: "Dashboard.Todo.TodoList.Item") } | ||
| } | ||
|
|
||
| public struct InvitationsWidget { | ||
| public static var acceptButton: XCUIElement { app.find(id: "Dashboard.Invitations.CourseInvitation.acceptButton") } | ||
| public static var declineButton: XCUIElement { app.find(id: "Dashboard.Invitations.CourseInvitation.declineButton") } | ||
|
|
||
| public static func invitationCard(enrollmentId: String) -> XCUIElement { | ||
| app.find(id: "Dashboard.Invitations.CourseInvitation.Id.\(enrollmentId)") | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
176 changes: 176 additions & 0 deletions
176
Student/StudentE2ETests/LearnerDashboard/LearnerDashboardTests.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,176 @@ | ||
| // | ||
| // This file is part of Canvas. | ||
| // Copyright (C) 2025-present Instructure, Inc. | ||
| // | ||
| // This program is free software: you can redistribute it and/or modify | ||
| // it under the terms of the GNU Affero General Public License as | ||
| // published by the Free Software Foundation, either version 3 of the | ||
| // License, or (at your option) any later version. | ||
| // | ||
| // This program is distributed in the hope that it will be useful, | ||
| // but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| // GNU Affero General Public License for more details. | ||
| // | ||
| // You should have received a copy of the GNU Affero General Public License | ||
| // along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
| // | ||
|
|
||
| import TestsFoundation | ||
| import XCTest | ||
|
|
||
| class LearnerDashboardTests: E2ETestCase { | ||
| typealias Helper = LearnerDashboardHelper | ||
|
|
||
| func testCoursesWidgetShowsCourses() { | ||
| // MARK: Seed the usual stuff | ||
| let student = seeder.createUser() | ||
| let course = seeder.createCourse() | ||
| seeder.enrollStudent(student, in: course) | ||
|
|
||
| // MARK: Login and check courses widget shows the course | ||
| logInDSUser(student) | ||
| let coursesHeader = Helper.CoursesWidget.coursesHeader.waitUntil(.visible) | ||
| XCTAssertVisible(coursesHeader) | ||
|
|
||
| let courseCard = Helper.CoursesWidget.courseCard(courseID: course.id).waitUntil(.visible) | ||
| XCTAssertVisible(courseCard) | ||
| XCTAssertContains(courseCard.label, course.name) | ||
| } | ||
|
|
||
| func testCustomizeDashboardButtonOpensSettings() { | ||
| // MARK: Seed the usual stuff | ||
| let student = seeder.createUser() | ||
| let course = seeder.createCourse() | ||
| seeder.enrollStudent(student, in: course) | ||
|
|
||
| // MARK: Login and check for Customize Dashboard button | ||
| logInDSUser(student) | ||
| let bottomSettingsButton = Helper.bottomSettingsButton.waitUntil(.visible) | ||
| XCTAssertVisible(bottomSettingsButton) | ||
|
|
||
| // MARK: Tap button and verify settings screen | ||
| bottomSettingsButton.hit() | ||
| let doneButton = Helper.Settings.doneButton.waitUntil(.visible) | ||
| XCTAssertVisible(doneButton) | ||
|
|
||
| let newDashboardToggle = Helper.Settings.newDashboardToggle.waitUntil(.visible) | ||
| XCTAssertVisible(newDashboardToggle) | ||
| XCTAssertEqual(newDashboardToggle.stringValue, "on") | ||
|
|
||
| // MARK: Dismiss settings | ||
| doneButton.hit() | ||
| XCTAssertTrue(doneButton.waitUntil(.vanish).isVanished) | ||
| } | ||
|
|
||
| func testAllCoursesButtonNavigation() { | ||
| // MARK: Seed the usual stuff | ||
| let student = seeder.createUser() | ||
| let course = seeder.createCourse() | ||
| seeder.enrollStudent(student, in: course) | ||
|
|
||
| // MARK: Login and tap All Courses button | ||
| logInDSUser(student) | ||
| let allCoursesButton = Helper.CoursesWidget.allCoursesButton.waitUntil(.visible) | ||
| XCTAssertVisible(allCoursesButton) | ||
|
|
||
| // MARK: Verify All Courses screen shows the enrolled course | ||
| allCoursesButton.hit() | ||
| let courseItem = DashboardHelper.AllCourses.courseItem(course: course).waitUntil(.visible) | ||
| XCTAssertVisible(courseItem) | ||
| XCTAssertContains(courseItem.label, course.name) | ||
| } | ||
|
|
||
| func testToggleCoursesWidgetOffHidesWidget() { | ||
| // MARK: Seed the usual stuff | ||
| let student = seeder.createUser() | ||
| let course = seeder.createCourse() | ||
| seeder.enrollStudent(student, in: course) | ||
|
|
||
| // MARK: Login and verify courses widget is visible | ||
| logInDSUser(student) | ||
| var coursesHeader = Helper.CoursesWidget.coursesHeader.waitUntil(.visible) | ||
| XCTAssertVisible(coursesHeader) | ||
|
|
||
| // MARK: Open settings and toggle Courses & Groups widget off | ||
| Helper.bottomSettingsButton.hit() | ||
| let coursesWidgetToggle = Helper.Settings.widgetToggle(id: .coursesAndGroups).waitUntil(.visible) | ||
| XCTAssertVisible(coursesWidgetToggle) | ||
| XCTAssertEqual(coursesWidgetToggle.stringValue, "on") | ||
|
|
||
| coursesWidgetToggle.hit() | ||
| XCTAssertEqual(coursesWidgetToggle.stringValue, "off") | ||
|
|
||
| Helper.Settings.doneButton.hit() | ||
|
|
||
| // MARK: Verify courses header is no longer visible on dashboard | ||
| coursesHeader = Helper.CoursesWidget.coursesHeader.waitUntil(.vanish) | ||
| XCTAssertTrue(coursesHeader.isVanished) | ||
| } | ||
|
|
||
| func testCourseCardGradeVisibility() { | ||
| // MARK: Seed the usual stuff with a graded assignment | ||
| let student = seeder.createUser() | ||
| let course = seeder.createCourse() | ||
| let pointsPossible: Float = 10 | ||
| let totalGrade = "100%" | ||
| seeder.enrollStudent(student, in: course) | ||
|
|
||
| let assignment = AssignmentsHelper.createAssignment(course: course, pointsPossible: Float(pointsPossible), gradingType: .percent) | ||
| GradesHelper.submitAssignment(course: course, student: student, assignment: assignment) | ||
| GradesHelper.gradeAssignment(grade: String(pointsPossible), course: course, assignment: assignment, user: student) | ||
|
|
||
| // MARK: Login and verify grade pill is not shown by default | ||
| logInDSUser(student) | ||
| Helper.CoursesWidget.courseCard(courseID: course.id).waitUntil(.visible) | ||
|
|
||
| var gradePill = Helper.CoursesWidget.courseCardGradePill.waitUntil(.vanish) | ||
| XCTAssertTrue(gradePill.isVanished) | ||
|
|
||
| // MARK: Open settings and enable Show Grades | ||
| Helper.bottomSettingsButton.hit() | ||
| let showGradesToggle = Helper.Settings.showGradesToggle.waitUntil(.visible) | ||
| XCTAssertVisible(showGradesToggle) | ||
| XCTAssertEqual(showGradesToggle.stringValue, "off") | ||
|
|
||
| showGradesToggle.hit() | ||
| XCTAssertEqual(showGradesToggle.stringValue, "on") | ||
|
|
||
| Helper.Settings.doneButton.hit() | ||
|
|
||
| // MARK: Verify grade pill appears with correct grade value | ||
| gradePill = Helper.CoursesWidget.courseCardGradePill.waitUntil(.visible) | ||
| XCTAssertVisible(gradePill) | ||
| gradePill.actionUntilElementCondition(action: .pullToRefresh, condition: .labelHasPrefix(expected: totalGrade)) | ||
| XCTAssertTrue(gradePill.label.hasPrefix(totalGrade)) | ||
| } | ||
|
|
||
| func testGlobalAnnouncementShownAndDismissed() { | ||
| // MARK: Seed the usual stuff | ||
| let student = seeder.createUser() | ||
| let course = seeder.createCourse() | ||
| seeder.enrollStudent(student, in: course) | ||
|
|
||
| // MARK: Login and post a global announcement | ||
| logInDSUser(student) | ||
| let announcement = AnnouncementsHelper.postAccountNotification() | ||
| app.pullToRefresh() | ||
|
|
||
| // MARK: Verify the announcement card is visible in the widget | ||
| let announcementCard = Helper.AnnouncementsWidget.announcementCard(announcement: announcement).waitUntil(.visible) | ||
| XCTAssertVisible(announcementCard) | ||
|
|
||
| // MARK: Tap the card button and verify details screen opens | ||
| let cardButton = Helper.AnnouncementsWidget.cardButton.waitUntil(.visible) | ||
| XCTAssertVisible(cardButton) | ||
|
|
||
| cardButton.hit() | ||
|
|
||
| let dismissButton = Helper.AnnouncementsWidget.detailsDismissButton.waitUntil(.visible) | ||
| XCTAssertVisible(dismissButton) | ||
|
|
||
| // MARK: Dismiss the details screen | ||
| dismissButton.hit() | ||
| XCTAssertTrue(dismissButton.waitUntil(.vanish).isVanished) | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.