-
Notifications
You must be signed in to change notification settings - Fork 107
[MBL-16328][Teacher] Implement E2E test for quiz edit and preview #3405
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
base: master
Are you sure you want to change the base?
[MBL-16328][Teacher] Implement E2E test for quiz edit and preview #3405
Conversation
refs: MBL-16328 affects: Teacher release note:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review Summary
This PR adds a comprehensive E2E test for quiz editing and preview functionality. The test coverage is excellent and follows good testing practices with detailed logging. However, there are a few concerns that should be addressed:
Issues Found
-
Thread.sleep() usage (apps/teacher/src/androidTest/java/com/instructure/teacher/ui/pages/classic/EditQuizDetailsPage.kt:274-275): Using
Thread.sleep()in UI tests is an anti-pattern that can lead to flaky tests. Should use proper Espresso wait conditions or idling resources instead. -
Undocumented production code changes (apps/teacher/src/main/java/com/instructure/teacher/fragments/QuizPreviewWebviewFragment.kt:110, 120): The PR contains production code fixes that are not mentioned in the description:
- Setting
argumentson the fragment (line 110) - fixes a potential bug with fragment recreation - Adding
AUTHENTICATE = true(line 120) - changes authentication behavior for quiz previews
These changes should be explicitly documented and potentially tested separately.
- Setting
-
Test maintainability (apps/teacher/src/androidTest/java/com/instructure/teacher/ui/e2e/classic/QuizE2ETest.kt:203-220): Hardcoded date/time values scattered throughout the test. Consider extracting these into constants or well-named variables for better maintainability.
Positive Feedback
✅ Excellent test structure: The test is well-organized with clear step-by-step logging using PREPARATION_TAG, STEP_TAG, and ASSERTION_TAG
✅ Comprehensive coverage: Tests multiple aspects of quiz functionality including editing, previews, due dates, and overrides
✅ Good assertion pattern: Each assertion is clear and tests specific expected behavior
✅ Proper cleanup: The test includes removing overrides and verifying the state afterwards
✅ Accessibility support: Added content descriptions for testing (due_date_$index, due_time_$index) which aids in UI test stability
✅ New page object: The QuizPreviewPage is well-structured and follows the existing pattern
Recommendations
- Replace
Thread.sleep()calls with proper Espresso synchronization - Document the production code changes in the PR description
- Consider extracting magic numbers/dates into constants
- Add a comment explaining why
AUTHENTICATE = trueis needed for quiz previews
Overall, this is a solid addition to the test suite with comprehensive coverage. The main concerns are around test reliability (Thread.sleep) and documentation of production changes.
...teacher/src/androidTest/java/com/instructure/teacher/ui/pages/classic/EditQuizDetailsPage.kt
Show resolved
Hide resolved
| @JvmStatic val TITLE = "title" | ||
|
|
||
| fun newInstance(args: Bundle) = QuizPreviewWebviewFragment().apply { | ||
| arguments = args |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change fixes a bug where the fragment's arguments weren't being set, which could cause issues when the fragment is recreated. However, this is a production code fix that should be called out explicitly in the PR description and potentially covered with a unit test.
Consider adding a test to verify that the arguments are properly set when creating a new instance of this fragment.
| args.putString(URL, url) | ||
| args.putString(TITLE, title) | ||
| args.putBoolean(DARK_TOOLBAR, false) | ||
| args.putBoolean(AUTHENTICATE, true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding AUTHENTICATE = true changes the authentication behavior for quiz previews. This is another production code change that should be:
- Explicitly documented in the PR description
- Verified that it doesn't break existing functionality
- Potentially covered with a test to ensure authenticated previews work as expected
Was this missing authentication causing the preview to fail in the E2E test?
apps/teacher/src/androidTest/java/com/instructure/teacher/ui/e2e/classic/QuizE2ETest.kt
Show resolved
Hide resolved
📊 Code Coverage Report✅ Student
✅ Teacher
✅ Pandautils
📈 Overall Average
|
Summary:
Added comprehensive E2E test coverage for quiz editing and preview functionality in the Teacher app, including multi-override due date management.
Changes:
Test Coverage:
refs: MBL-16328
affects: Teacher
release note:
Checklist