-
Notifications
You must be signed in to change notification settings - Fork 108
[MBL-19326][Teacher] Refactor testFilesE2E test and add comment's attachment file #3471
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-19326][Teacher] Refactor testFilesE2E test and add comment's attachment file #3471
Conversation
refs: MBL-19326 affects: Teacher release note:
refs: MBL-19326 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 enhances the E2E test for file attachments in SpeedGrader by adding comment attachment testing functionality. The overall approach is solid, but there are several areas that need attention for improved test reliability and code quality.
Positive Aspects
✅ Good test coverage expansion - Adding comment attachment tests fills an important gap in the test suite
✅ New FileChooserPage object - Well-structured page object with clear, reusable methods
✅ Proper logging - Comprehensive logging throughout the test for debugging
✅ Assertion improvements - Good use of comment count assertions to verify state changes
Issues Found
- File cleanup missing (FilesE2ETest.kt:163-177) - The PDF file created in Downloads is never deleted, causing test pollution
- Thread.sleep anti-pattern (FilesE2ETest.kt:215) - Hardcoded 5-second sleep makes tests slow and unreliable; use proper wait conditions instead
- Brittle file picker navigation (FilesE2ETest.kt:188-210) - UIAutomator logic relies on device-specific UI text that may vary across Android versions
- Resource leak potential (FilesE2ETest.kt:163-177) - PDF document creation doesn't use
useblocks, risking resource leaks if exceptions occur - Storage location concerns (FilesE2ETest.kt:163) - Using DIRECTORY_DOWNLOADS may require runtime permissions and behaves inconsistently across devices
- Missing newline (FileChooserPage.kt:102) - File should end with a newline per Kotlin style guide
Recommendations
- Refactor file handling: Move test files to app-specific directories using
getExternalFilesDir()to avoid permission issues - Add cleanup: Implement an
@Aftermethod or try-finally block to ensure test files are deleted - Replace Thread.sleep: Use Espresso IdlingResource or explicit wait conditions
- Extract file picker logic: Create a reusable helper method for UIAutomator file selection with better error handling
- Use proper resource management: Wrap PdfDocument and FileOutputStream in
useblocks
Test Coverage Note
The test currently validates:
- Comment attachment display
- Comment count updates
- File upload workflow
Consider adding negative test cases:
- Upload cancellation
- Invalid file types
- Network failure scenarios
Overall, this is a valuable addition to the test suite that improves comment attachment coverage. With the issues addressed, it will be much more reliable across different devices and Android versions.
apps/teacher/src/androidTest/java/com/instructure/teacher/ui/e2e/classic/FilesE2ETest.kt
Show resolved
Hide resolved
apps/teacher/src/androidTest/java/com/instructure/teacher/ui/e2e/classic/FilesE2ETest.kt
Show resolved
Hide resolved
apps/teacher/src/androidTest/java/com/instructure/teacher/ui/e2e/classic/FilesE2ETest.kt
Show resolved
Hide resolved
apps/teacher/src/androidTest/java/com/instructure/teacher/ui/pages/classic/FileChooserPage.kt
Show resolved
Hide resolved
apps/teacher/src/androidTest/java/com/instructure/teacher/ui/e2e/classic/FilesE2ETest.kt
Show resolved
Hide resolved
📊 Code Coverage Report✅ Student
✅ Teacher
✅ Pandautils
📈 Overall Average
|
🧪 Unit Test Results✅ 📱 Teacher App
✅ 📦 Submodules
📊 Summary
Last updated: Wed, 14 Jan 2026 10:41:44 GMT |
Adds test case for attaching PDF file to SpeedGrader comments in FilesE2E test.
refs: MBL-19326
affects: Teacher
release note:
Checklist