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

temp: move restrictionType check prior to check for late redemption #1340

Merged
merged 1 commit into from
Oct 22, 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
39 changes: 39 additions & 0 deletions src/components/learner-credit-management/data/tests/utils.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { createIntl } from '@edx/frontend-platform/i18n';
import dayjs from 'dayjs';
import {
getAssignableCourseRuns,
getBudgetStatus,
getTranslatedBudgetStatus,
getTranslatedBudgetTerm,
Expand Down Expand Up @@ -343,3 +344,41 @@ describe('startAndEnrollBySortLogic', () => {
expect(sortedDates).toEqual(sampleData.sort((a, b) => a.expectedOrder - b.expectedOrder));
});
});

describe('getAssignableCourseRuns', () => {
it('includes a late, non-restricted course run when late-redemption eligible', () => {
const courseRuns = [
{
key: 'the-course-run',
enrollBy: dayjs().subtract(1, 'day'),
hasEnrollBy: true,
upgradeDeadline: dayjs().add(1, 'day'),
start: dayjs().subtract(1, 'day'),
isActive: true,
},
];
const subsidyExpirationDatetime = dayjs().add(100, 'day');
const isLateRedemptionAllowed = true;

const result = getAssignableCourseRuns({ courseRuns, subsidyExpirationDatetime, isLateRedemptionAllowed });
expect(result.length).toEqual(1);
expect(result[0].key).toEqual('the-course-run');
});
it('returns an empty list given only a restricted run , even when late-redemption eligible', () => {
const courseRuns = [
{
enrollBy: dayjs().subtract(1, 'day'),
hasEnrollBy: true,
restrictionType: 'b2b-enterprise',
upgradeDeadline: dayjs().subtract(1, 'day'),
start: dayjs().subtract(1, 'day'),
isActive: true,
},
];
const subsidyExpirationDatetime = dayjs().add(100, 'day');
const isLateRedemptionAllowed = true;

const result = getAssignableCourseRuns({ courseRuns, subsidyExpirationDatetime, isLateRedemptionAllowed });
expect(result).toEqual([]);
});
});
14 changes: 7 additions & 7 deletions src/components/learner-credit-management/data/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -720,13 +720,6 @@
// the current date and subsidy expiration date have failed.
return false;
}
if (hasEnrollBy && isLateRedemptionAllowed && isDateBeforeToday(enrollBy)) {
// Special case: late enrollment has been enabled by ECS for this budget, and
// isEligibleForEnrollment already succeeded, so we know that late enrollment
// would be happy given enrollment deadline of the course. Now all we need
// to do is make sure the run itself is generally eligible for late enrollment
return isLateEnrollmentEligible;
}
// ENT-9359 (epic for Custom Presentations/Restricted Runs):
// Temporarily hide all restricted runs unconditionally on the run assignment
// dropdown during implementation of the overall feature. ENT-9411 is most likely
Expand All @@ -735,6 +728,13 @@
if (restrictionType) {
return false;
}
if (hasEnrollBy && isLateRedemptionAllowed && isDateBeforeToday(enrollBy)) {
// Special case: late enrollment has been enabled by ECS for this budget, and
// isEligibleForEnrollment already succeeded, so we know that late enrollment
// would be happy given enrollment deadline of the course. Now all we need
// to do is make sure the run itself is generally eligible for late enrollment
return isLateEnrollmentEligible;

Check warning on line 736 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#L736

Added line #L736 was not covered by tests
}
// General courseware filter
return isActive;
};
Expand Down