feat(hamplard): add course waitlist management with automatic promotion - #275
Open
Folex1275 wants to merge 2 commits into
Open
feat(hamplard): add course waitlist management with automatic promotion#275Folex1275 wants to merge 2 commits into
Folex1275 wants to merge 2 commits into
Conversation
|
@Folex1275 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fix Test Coverage and Implement Waitlist Feature
Summary
This PR addresses three issues related to test coverage and missing functionality in the Hamplard contract:
archive_course()with pending student completionsDefaultFeeat enrollment timeChanges
Issue #142: Test archive_course() with Pending Completions
Problem: The test suite did not cover the scenario where
archive_course()is called on a course with enrolled students who have not been marked as completed. These students are silently left in an uncompletable state after archival.Solution:
test_archive_with_pending_student_completions()- verifies that archiving a course with a mix of completed and pending students correctly refunds only the pending students while preserving completed enrollmentstest_mark_completed_on_archived_course_fails()- verifies that attempting to mark a student as completed after course archival produces a clear errorFiles Modified:
contracts/hamplard/src/test.rsIssue #143: Test Missing DefaultFee Behavior
Problem: The test suite did not test the scenario where
enroll()is called beforeDataKey::DefaultFeehas been initialized. This could result in confusing panics in production if init is skipped.Solution:
test_enroll_missing_default_fee_produces_clear_error()- verifies that attempting to register a course with a custom fee below the platform default (when DefaultFee is missing) produces a clear, actionable error messageFiles Modified:
contracts/hamplard/src/test.rsIssue #147: Implement Course Waitlist
Problem: When a course reaches its
max_capacity, students who arrive later have no recourse. There was no waitlist mechanism to queue interested students and automatically enroll them when a spot opens.Solution:
DataKey::CourseWaitlist(String)to storage keys for per-course waitlist storagejoin_waitlist()- allows students to join the waitlist for a full courseleave_waitlist()- allows students to leave the waitlistget_waitlist()- returns the ordered list of waitlisted studentspromote_from_waitlist()(internal) - automatically promotes the first waitlisted student when capacity opensarchive_course()when refunds create available capacitytest_join_waitlist_success()test_join_waitlist_rejects_when_capacity_available()test_join_waitlist_duplicate_rejected()test_leave_waitlist_success()test_leave_waitlist_not_on_list()test_waitlist_promotion_on_refund()Files Modified:
contracts/hamplard/src/lib.rscontracts/hamplard/src/test.rsTesting
All new tests pass and verify:
Closes
Closes #142
Closes #143
Closes #147