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: use correct late redemption enablement key #1132

Merged
merged 1 commit into from
Jul 24, 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 @@ -23,12 +23,13 @@ const redeemablePolicies = [
{
id: 123,
subsidyExpirationDate: mockSubsidyExpirationDate,
isLateRedemptionAllowed: false,
},
{
id: 456,
subsidyExpirationDate: mockSubsidyExpirationDate,
learnerContentAssignments: [mockContentAssignment],
isLateRedemptionEnabled: true,
isLateRedemptionAllowed: true, // all it takes is one redeemable policy to turn on the late redemption feature.
},
];
const expectedTransformedPolicies = redeemablePolicies.map((policy) => ({
Expand Down Expand Up @@ -82,15 +83,18 @@ describe('useLateEnrollmentBufferDays', () => {
expect(result.current).toEqual(LATE_ENROLLMENTS_BUFFER_DAYS);
});
it('should return undefined if no late redemption is enabled', async () => {
// Copy of redeemablePolicies but no policies have late redemption allowed.
const updatedRedeemablePolicies = [
{
id: 123,
subsidyExpirationDate: mockSubsidyExpirationDate,
isLateRedemptionAllowed: false,
},
{
id: 456,
subsidyExpirationDate: mockSubsidyExpirationDate,
learnerContentAssignments: [mockContentAssignment],
isLateRedemptionAllowed: false,
},
];
const updatedExpectedTransformedPolicies = updatedRedeemablePolicies.map((policy) => ({
Expand Down
4 changes: 2 additions & 2 deletions src/components/app/data/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -438,10 +438,10 @@ export function getLateEnrollmentBufferDays(redeemablePolicies) {
return undefined;
}
const anyPolicyHasLateRedemptionEnabled = redeemablePolicies.some((policy) => (
// is_late_redemption_enabled=True on the serialized policy represents the fact that late
// is_late_redemption_allowed=True on the serialized policy represents the fact that late
// redemption has been temporarily enabled by an operator for the policy. It will toggle
// itself back to False after a finite period of time.
policy.isLateRedemptionEnabled
policy.isLateRedemptionAllowed
Copy link
Member

Choose a reason for hiding this comment

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

😬 Oof, does this mean without this fix, the late enrollment feature might not have worked? Good catch!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yep ☠️☠️☠️

));
return anyPolicyHasLateRedemptionEnabled ? LATE_ENROLLMENTS_BUFFER_DAYS : undefined;
}
Expand Down
Loading