Skip to content

Conversation

@adamNagy56
Copy link
Contributor

Adds test case for attaching PDF file to SpeedGrader comments in FilesE2E test.

refs: MBL-19326
affects: Teacher
release note:

Checklist

  • Run E2E test suite

refs: MBL-19326
affects: Teacher
release note:
refs: MBL-19326
affects: Teacher
release note:
Copy link

@claude claude bot left a 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 use blocks, 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

  1. Refactor file handling: Move test files to app-specific directories using getExternalFilesDir() to avoid permission issues
  2. Add cleanup: Implement an @After method or try-finally block to ensure test files are deleted
  3. Replace Thread.sleep: Use Espresso IdlingResource or explicit wait conditions
  4. Extract file picker logic: Create a reusable helper method for UIAutomator file selection with better error handling
  5. Use proper resource management: Wrap PdfDocument and FileOutputStream in use blocks

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.

@github-actions
Copy link

github-actions bot commented Jan 8, 2026

📊 Code Coverage Report

✅ Student

  • PR Coverage: 43.51%
  • Master Coverage: 43.51%
  • Delta: +0.00%

✅ Teacher

  • PR Coverage: 25.61%
  • Master Coverage: 25.61%
  • Delta: +0.00%

✅ Pandautils

  • PR Coverage: 22.91%
  • Master Coverage: 22.91%
  • Delta: +0.00%

📈 Overall Average

  • PR Coverage: 30.68%
  • Master Coverage: 30.68%
  • Delta: +0.00%

@github-actions
Copy link

github-actions bot commented Jan 8, 2026

🧪 Unit Test Results

✅ 📱 Teacher App

  • Tests: 369 total, 0 failed, 0 skipped
  • Duration: 28.739s
  • Success Rate: 100%

✅ 📦 Submodules

  • Tests: 2556 total, 0 failed, 0 skipped
  • Duration: 53.169s
  • Success Rate: 100%

📊 Summary

  • Total Tests: 2925
  • Failed: 0
  • Skipped: 0
  • Status: ✅ All tests passed!

Last updated: Wed, 14 Jan 2026 10:41:44 GMT

@github-actions
Copy link

github-actions bot commented Jan 8, 2026

Teacher Install Page

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants