Skip to content

Conversation

@kdeakinstructure
Copy link
Contributor

Use dataseeding in existing discussion checkpoint tests instead of burnt in course and discussions.
Handle discussions with due dates and no due dates.
Add date converting utility function.

refs: MBL-19655
affects: Student
release note: -

  • Run E2E test suite

…rnt in course and discussions.

Handle discussions with due dates and no due dates.
Add date converting utility function.

refs: MBL-19655
affects: Student
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 improves E2E test coverage for discussions with checkpoints by removing hardcoded course IDs and using properly seeded data. The changes enable testing of both discussions with and without due dates.

Positive Changes

✅ Replaced hardcoded course IDs with dynamically seeded data - much better for test isolation
✅ Added comprehensive testing for checkpoints with different due date scenarios
✅ Improved test data setup by enrolling both students and teachers properly
✅ Added date conversion utility to handle ISO8601 format consistently
✅ Simplified DateTime scalar handling by treating it as String instead of Date object

Issues Found

  • Test flakiness concern (apps/student/src/androidTest/java/com/instructure/student/ui/e2e/classic/DiscussionsE2ETest.kt:224) - sleep(2000) introduces non-deterministic behavior. Use proper wait mechanisms instead.

  • Missing error handling (automation/espresso/src/main/kotlin/com/instructure/espresso/TestingUtils.kt:84) - SimpleDateFormat.parse() can throw ParseException which isn't handled. Also consider caching the formatter for performance.

  • Code complexity (automation/espresso/src/main/kotlin/com/instructure/canvas/espresso/common/pages/compose/AssignmentListPage.kt:166) - The assertHasAssignmentCommon() function has deeply nested conditionals that would benefit from refactoring into helper functions.

  • Magic string duplication (automation/espresso/src/main/kotlin/com/instructure/canvas/espresso/common/pages/compose/AssignmentListPage.kt:180) - The hardcoded time string " 11:59 PM" is repeated multiple times. Extract as a constant.

Test Coverage

The test coverage looks comprehensive with scenarios for:

  • Discussions with checkpoints without due dates
  • Discussions with checkpoints with due dates
  • Assignment list display validation
  • Syllabus summary event validation
  • Assignment details page validation

Overall Assessment

Good refactoring work to improve test maintainability. The main concerns are around test stability (the sleep call) and code maintainability (error handling, complexity, duplication). These are relatively minor issues that should be straightforward to address.

assignmentListPage.clickAssignment(discussionWithCheckpointsTitle)
Log.d(STEP_TAG, "Click on the expand icon for the '$discussionWithCheckpointsWithoutDueDatesTitle' discussion (to see the checkpoints' details).")
assignmentListPage.clickDiscussionCheckpointExpandCollapseIcon(discussionWithCheckpointsWithoutDueDatesTitle)
sleep(2000) // Allow some time for the collapse action to propagate
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This sleep() call is a code smell in tests. It introduces flakiness and makes tests slower. Consider using Espresso's idling resources or composeTestRule.waitForIdle() instead of hard-coded sleep delays.

val iso8601Format = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'", Locale.getDefault()).apply {
timeZone = TimeZone.getTimeZone("UTC")
}
val date = iso8601Format.parse(iso8601Date) ?: throw IllegalArgumentException("Invalid date format: $iso8601Date")
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The parse() method can throw ParseException which isn't being handled. Consider wrapping in a try-catch block or documenting this behavior. Also, creating new SimpleDateFormat instances repeatedly can be inefficient - consider caching the formatter as a constant.

}

private fun assertHasAssignmentCommon(assignmentName: String, assignmentDueAt: String?, expectedGradeLabel: String? = null, assignmentStatus: String? = null, hasCheckPoints : Boolean = false) {
private fun assertHasAssignmentCommon(assignmentName: String, assignmentDueAt: String?, secondCheckpointDueAt: String? = null, expectedGradeLabel: String? = null, assignmentStatus: String? = null, hasCheckPoints : Boolean = false) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function has become quite complex with deeply nested conditionals. Consider refactoring into smaller helper functions (e.g., assertCheckpointDueDates, assertSingleAssignmentDueDate) to improve readability and maintainability.

}
else {
if(secondCheckpointDueAt != null) {
composeTestRule.onAllNodes(
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The string " 11:59 PM" is hardcoded and duplicated multiple times. Consider extracting it as a constant to avoid duplication and make it easier to maintain.

@github-actions
Copy link

🧪 Unit Test Results

✅ 📱 Student App

  • Tests: 1241 total, 0 failed, 0 skipped
  • Duration: 0.000s
  • Success Rate: 100%

✅ 🌅 Horizon

  • Tests: 449 total, 0 failed, 0 skipped
  • Duration: 33.566s
  • Success Rate: 100%

✅ 📦 Submodules

  • Tests: 2515 total, 0 failed, 0 skipped
  • Duration: 54.446s
  • Success Rate: 100%

📊 Summary

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

Last updated: Mon, 12 Jan 2026 14:25:32 GMT

@github-actions
Copy link

📊 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

Student 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.

2 participants