Skip to content

Commit

Permalink
temp: move restrictionType check prior to check for late redemption
Browse files Browse the repository at this point in the history
  • Loading branch information
iloveagent57 committed Oct 22, 2024
1 parent e196e52 commit 3022022
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 7 deletions.
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 @@ export const getAssignableCourseRuns = ({ courseRuns, subsidyExpirationDatetime,
// 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 @@ export const getAssignableCourseRuns = ({ courseRuns, subsidyExpirationDatetime,
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

0 comments on commit 3022022

Please sign in to comment.