Skip to content
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

fix: don't consider elapsed enrollBy in assignable course runs #1313

Merged
merged 2 commits into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ jest.mock('../../../../data/services/EnterpriseAccessApiService');

const futureStartDate = dayjs().add(5, 'days').toISOString();
const pastStartDate = dayjs().subtract(5, 'days').toISOString();
const enrollByTimestamp = dayjs().subtract(10, 'days').unix();
const enrollByTimestamp = dayjs().add(2, 'days').unix();
const enrollByDropdownText = `Enroll by ${dayjs.unix(enrollByTimestamp).format(SHORT_MONTH_DATE_FORMAT)}`;

const originalData = {
Expand Down
9 changes: 6 additions & 3 deletions src/components/learner-credit-management/data/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -660,13 +660,16 @@
}) => {
let isEligibleForEnrollment = true;
if (hasEnrollBy) {
isEligibleForEnrollment = dayjs(enrollBy).isBefore(
minimumEnrollByDateFromToday({ subsidyExpirationDatetime }),
const enrollByDate = dayjs(enrollBy);
// Determine eligibility based on the provided enrollBy is and the subsidy expiration date - refund threshold
isEligibleForEnrollment = (
!isDateBeforeToday(enrollByDate)
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe add a comment that we'll want to eventually loop back to this and allow a certain buffer to allow enrollBy to be a few days before today?

Copy link
Contributor

Choose a reason for hiding this comment

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

hm, the code below seems to consider late enrollment buffer days, so I just might be misunderstanding something...

Copy link
Contributor

Choose a reason for hiding this comment

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

oh okay that overrides this, LGTM

Copy link
Member Author

@adamstankiewicz adamstankiewicz Sep 18, 2024

Choose a reason for hiding this comment

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

Isn't this the use case for late enrollment, handled below, though? If late enrollment is not enabled for a budget, I'm not sure we'd want to expose runs that are otherwise not enrollable without late enrollment enabled? 🤔

(edit: given late enrollment is not quite the happy path; it's opt-in and will be disabled for most budgets).

Copy link
Member Author

Choose a reason for hiding this comment

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

Ha, sorry didn't see your updated comments until after submitting the above comment :)

Agreed this should be adequate.

&& enrollByDate.isBefore(minimumEnrollByDateFromToday({ subsidyExpirationDatetime }))
);
// Late redemption filter
if (isDateBeforeToday(enrollBy) && isLateRedemptionAllowed) {
const lateEnrollmentCutoff = dayjs().subtract(LATE_ENROLLMENTS_BUFFER_DAYS, 'days');
isEligibleForEnrollment = dayjs(enrollBy).isAfter(lateEnrollmentCutoff);
isEligibleForEnrollment = enrollByDate.isAfter(lateEnrollmentCutoff);

Check warning on line 672 in src/components/learner-credit-management/data/utils.js

View check run for this annotation

Codecov / codecov/patch

src/components/learner-credit-management/data/utils.js#L672

Added line #L672 was not covered by tests
return isLateEnrollmentEligible && isEligibleForEnrollment;
}
}
Expand Down