Skip to content

Commit

Permalink
fix: revert "feat: Add additional messaging for no subsidy scenarios (#…
Browse files Browse the repository at this point in the history
…771)" (#784)

This reverts commit 0d007fe.
  • Loading branch information
johnnagro authored Jul 5, 2023
1 parent dc1b8bd commit 0bfb8a7
Show file tree
Hide file tree
Showing 17 changed files with 21 additions and 187 deletions.
1 change: 0 additions & 1 deletion .env.development
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ FEATURE_ENABLE_AUTO_APPLIED_LICENSES='true'
LEARNING_TYPE_FACET='true'
LEARNER_SUPPORT_URL='https://support.edx.org/hc/en-us'
LEARNER_SUPPORT_SPEND_ENROLLMENT_LIMITS_URL='http://edx.org'
LEARNER_SUPPORT_ABOUT_DEACTIVATION_URL='https://business-support.edx.org/hc/en-us/articles/15254891994391'
FEATURE_ENABLE_PATHWAYS='true'
FEATURE_ENABLE_COURSE_REVIEW=''
FEATURE_ENROLL_WITH_ENTERPRISE_OFFERS='true'
Expand Down
2 changes: 1 addition & 1 deletion src/components/course/CourseMainContent.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,8 @@ const CourseMainContent = () => {
be able to register for this course: Iran, Cuba and the Crimea region of Ukraine.
While edX has sought licenses from the U.S. Office of Foreign Assets Control (OFAC) to
offer our courses to learners in these countries and regions, the licenses we have
received are not broad enough to allow us to offer this course in all locations. EdX
truly regrets that U.S. sanctions prevent us from offering all of our courses to
received are not broad enough to allow us to offer this course in all locations. EdX
everyone, no matter where they live.
</p>
</div>
Expand Down
10 changes: 1 addition & 9 deletions src/components/course/CoursePage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,8 @@ const CoursePage = () => {
couponCodes: { couponCodes },
enterpriseOffers,
canEnrollWithEnterpriseOffers,
customerAgreementConfig,
} = useContext(UserSubsidyContext);
const {
couponsForSubsidyRequests,
catalogsForSubsidyRequests,
subsidyRequestConfiguration,
} = useContext(SubsidyRequestsContext);
const { catalogsForSubsidyRequests, subsidyRequestConfiguration } = useContext(SubsidyRequestsContext);

const {
enterpriseCuration: {
Expand Down Expand Up @@ -198,14 +193,12 @@ const CoursePage = () => {
subscriptionLicense,
courseService,
couponCodes,
couponsForSubsidyRequests,
canEnrollWithEnterpriseOffers,
enterpriseOffers,
onSubscriptionLicenseForCourseValidationError,
missingSubsidyAccessPolicyReason,
enterpriseAdminUsers,
courseListPrice,
customerAgreementConfig,
});

const [coursePrice, currency] = useCoursePriceForUserSubsidy({
Expand Down Expand Up @@ -243,7 +236,6 @@ const CoursePage = () => {
subsidyRequestConfiguration,
subsidyRequestCatalogsApplicableToCourse,
userSubsidyApplicableToCourse,
couponsForSubsidyRequests,
});

if (error) {
Expand Down
5 changes: 1 addition & 4 deletions src/components/course/SubsidyRequestButton.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { useUserHasSubsidyRequestForCourse } from './data/hooks';
import { findUserEnrollmentForCourseRun } from './data/utils';
import { ToastsContext } from '../Toasts';
import { postLicenseRequest, postCouponCodeRequest } from '../enterprise-subsidy-requests/data/service';
import { noAvailableCoupons } from './enrollment/utils';

const props = {
labels: {
Expand All @@ -30,7 +29,6 @@ const SubsidyRequestButton = () => {
const {
subsidyRequestConfiguration,
refreshSubsidyRequests,
couponsForSubsidyRequests,
} = useContext(SubsidyRequestsContext);

const { state, subsidyRequestCatalogsApplicableToCourse, userSubsidyApplicableToCourse } = useContext(CourseContext);
Expand Down Expand Up @@ -76,12 +74,11 @@ const SubsidyRequestButton = () => {
* - user has a subsidy request for course
* OR
* - course is in catalog
* - there are available coupons to request
* - user not already enrolled in crouse
* - user has no subsidy for course
*/
const hasSubsidyRequestsEnabled = subsidyRequestConfiguration?.subsidyRequestsEnabled;
const showSubsidyRequestButton = hasSubsidyRequestsEnabled && !noAvailableCoupons(couponsForSubsidyRequests) && (
const showSubsidyRequestButton = hasSubsidyRequestsEnabled && (
userHasSubsidyRequest || (
subsidyRequestCatalogsApplicableToCourse.size > 0 && !isUserEnrolled && !userSubsidyApplicableToCourse
)
Expand Down
8 changes: 0 additions & 8 deletions src/components/course/data/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,6 @@ export const REASON_USER_MESSAGES = {
ORGANIZATION_NO_FUNDS_NO_ADMINS: "You can't enroll right now because your organization doesn't have enough funds. Contact your administrator to request more.",
LEARNER_LIMITS_REACHED: "You can't enroll right now because of limits set by your organization.",
CONTENT_NOT_IN_CATALOG: "You can't enroll right now because this course is no longer available in your organization's catalog.",
SUBSCRIPTION_EXPIRED: "You can't enroll right now because your subscription expired.",
SUBSCRIPTION_DEACTIVATED: "You can't enroll right now because your subscription has been deactivated.",
};
export const DISABLED_ENROLL_REASON_TYPES = {
POLICY_NOT_ACTIVE: 'policy_not_active',
Expand All @@ -85,9 +83,6 @@ export const DISABLED_ENROLL_REASON_TYPES = {
LEARNER_MAX_ENROLLMENTS_REACHED: 'learner_max_enrollments_reached',
NO_SUBSIDY: 'no_subsidy',
NO_SUBSIDY_NO_ADMINS: 'no_subsidy_no_admin',
NO_ENROLLMENT_CODES_REMAINING: 'no_entrollment_codes_remaining',
SUBSCRIPTION_EXPIRED: 'subscription_expired',
SUBSCRIPTION_DEACTIVATED: 'subscription_deactivated',
};
export const DISABLED_ENROLL_USER_MESSAGES = {
[DISABLED_ENROLL_REASON_TYPES.CONTENT_NOT_IN_CATALOG]: REASON_USER_MESSAGES.CONTENT_NOT_IN_CATALOG,
Expand All @@ -96,9 +91,6 @@ export const DISABLED_ENROLL_USER_MESSAGES = {
[DISABLED_ENROLL_REASON_TYPES.NOT_ENOUGH_VALUE_IN_SUBSIDY]: REASON_USER_MESSAGES.ORGANIZATION_NO_FUNDS,
[DISABLED_ENROLL_REASON_TYPES.LEARNER_MAX_ENROLLMENTS_REACHED]: REASON_USER_MESSAGES.LEARNER_LIMITS_REACHED,
[DISABLED_ENROLL_REASON_TYPES.LEARNER_MAX_SPEND_REACHED]: REASON_USER_MESSAGES.LEARNER_LIMITS_REACHED,
[DISABLED_ENROLL_REASON_TYPES.NO_ENROLLMENT_CODES_REMAINING]: REASON_USER_MESSAGES.LEARNER_LIMITS_REACHED,
[DISABLED_ENROLL_REASON_TYPES.SUBSCRIPTION_EXPIRED]: REASON_USER_MESSAGES.SUBSCRIPTION_EXPIRED,
[DISABLED_ENROLL_REASON_TYPES.SUBSCRIPTION_DEACTIVATED]: REASON_USER_MESSAGES.SUBSCRIPTION_DEACTIVATED,
};

export const DATE_FORMAT = 'MMM D, YYYY';
Expand Down
21 changes: 1 addition & 20 deletions src/components/course/data/hooks.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,8 @@ import {
ENTERPRISE_OFFER_SUBSIDY_TYPE,
} from './constants';
import { pushEvent, EVENTS } from '../../../utils/optimizely';
import { getExternalCourseEnrollmentUrl, noAvailableCoupons } from '../enrollment/utils';
import { getExternalCourseEnrollmentUrl } from '../enrollment/utils';
import { createExecutiveEducationFailureMessage } from '../../executive-education-2u/ExecutiveEducation2UError';
import { LICENSE_STATUS } from '../../enterprise-user-subsidy/data/constants';

// How long to delay an event, so that we allow enough time for any async analytics event call to resolve
const CLICK_DELAY_MS = 300; // 300ms replicates Segment's ``trackLink`` function
Expand Down Expand Up @@ -659,14 +658,12 @@ export const useUserSubsidyApplicableToCourse = ({
subscriptionLicense,
courseService,
couponCodes,
couponsForSubsidyRequests,
canEnrollWithEnterpriseOffers,
enterpriseOffers,
onSubscriptionLicenseForCourseValidationError,
missingSubsidyAccessPolicyReason,
enterpriseAdminUsers: fallbackAdminUsers,
courseListPrice,
customerAgreementConfig,
}) => {
const [userSubsidyApplicableToCourse, setUserSubsidyApplicableToCourse] = useState();
const [missingUserSubsidyReason, setMissingUserSubsidyReason] = useState();
Expand Down Expand Up @@ -722,7 +719,6 @@ export const useUserSubsidyApplicableToCourse = ({
onSubscriptionLicenseForCourseValidationError(error);
}
}
return licenseApplicableToCourse;
}
const coursePrice = getCourseRunPrice({
courseDetails,
Expand Down Expand Up @@ -761,19 +757,6 @@ export const useUserSubsidyApplicableToCourse = ({
if (enterpriseAdminUsers?.length > 0) {
reasonType = DISABLED_ENROLL_REASON_TYPES.NO_SUBSIDY;
}
if (subscriptionLicense?.status === LICENSE_STATUS.REVOKED) {
reasonType = DISABLED_ENROLL_REASON_TYPES.SUBSCRIPTION_DEACTIVATED;
}
const hasExpiredSubscriptions = customerAgreementConfig?.subscriptions?.every(
(sub) => sub.daysUntilExpiration < 0,
);
if (hasExpiredSubscriptions) {
reasonType = DISABLED_ENROLL_REASON_TYPES.SUBSCRIPTION_EXPIRED;
}
const hasNoEnrollmentCodesRemaining = noAvailableCoupons(couponsForSubsidyRequests);
if (hasNoEnrollmentCodesRemaining) {
reasonType = DISABLED_ENROLL_REASON_TYPES.NO_ENROLLMENT_CODES_REMAINING;
}
// set reason type as content not in catalog if course is contained
// within any of the enterprise customer's catalog(s).
if (!containsContentItems) {
Expand Down Expand Up @@ -860,14 +843,12 @@ export const useUserSubsidyApplicableToCourse = ({
onSubscriptionLicenseForCourseValidationError,
subscriptionLicense,
couponCodes,
couponsForSubsidyRequests,
canEnrollWithEnterpriseOffers,
enterpriseOffers,
redeemableSubsidyAccessPolicy,
isPolicyRedemptionEnabled,
missingSubsidyAccessPolicyReason,
fallbackAdminUsers,
customerAgreementConfig?.subscriptions,
]);

return useMemo(() => ({
Expand Down
85 changes: 9 additions & 76 deletions src/components/course/data/tests/hooks.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ import {
mockCourseRunKey,
mockCanRedeemData,
mockSubscriptionLicense,
mockUserLicenseSubsidy,
mockRedeemableSubsidyAccessPolicy,
mockCanRedeemReason,
mockCanRedeemForContentKey,
mockRevokedSubscriptionLicense,
} from '../../tests/constants';
import * as optimizelyUtils from '../../../../utils/optimizely';
import { CourseContext } from '../../CourseContextProvider';
Expand Down Expand Up @@ -1050,7 +1050,7 @@ describe('useUserSubsidyApplicableToCourse', () => {
...baseArgs,
courseData: undefined,
};
const missingUserSubsidyMaxSpendReason = {
const missingUserSubsidyReason = {
reason: DISABLED_ENROLL_REASON_TYPES.LEARNER_MAX_SPEND_REACHED,
userMessage: REASON_USER_MESSAGES.LEARNER_LIMITS_REACHED,
metadata: { enterpriseAdministrators: ['edx@example.com'] },
Expand Down Expand Up @@ -1152,7 +1152,7 @@ describe('useUserSubsidyApplicableToCourse', () => {
it('does not have redeemable subsidy access policy and has missing subsidy access policy user message', async () => {
const args = {
...baseArgs,
missingSubsidyAccessPolicyReason: missingUserSubsidyMaxSpendReason,
missingSubsidyAccessPolicyReason: missingUserSubsidyReason,
};
const { result, waitForNextUpdate } = renderHook(() => useUserSubsidyApplicableToCourse(args));

Expand All @@ -1176,12 +1176,12 @@ describe('useUserSubsidyApplicableToCourse', () => {

expect(mockCourseService.fetchUserLicenseSubsidy).toHaveBeenCalledTimes(1);
await waitFor(() => {
expect(result.current).toEqual({
userSubsidyApplicableToCourse: expect.objectContaining({
subsidyType: LICENSE_SUBSIDY_TYPE,
}),
missingUserSubsidyReason: undefined,
});
expect(getSubsidyToApplyForCourse).toHaveBeenCalledTimes(1);
});
expect(getSubsidyToApplyForCourse).toHaveBeenCalledWith({
applicableSubscriptionLicense: mockUserLicenseSubsidy,
applicableCouponCode: undefined,
applicableEnterpriseOffer: undefined,
});

expect(result.current).toEqual({
Expand All @@ -1192,50 +1192,6 @@ describe('useUserSubsidyApplicableToCourse', () => {
});
});

it('reports expired subscription license', async () => {
getSubsidyToApplyForCourse.mockReturnValueOnce(undefined);
const args = {
...baseArgs,
enterpriseAdminUsers: [{ email: 'admin@test.com' }],
customerAgreementConfig: { subscriptions: [{ daysUntilExpiration: -1 }] },
};
const { result, waitForNextUpdate } = renderHook(() => useUserSubsidyApplicableToCourse(args));
await waitForNextUpdate();

const { missingUserSubsidyReason, userSubsidyApplicableToCourse } = result.current;
const actionHtml = JSON.stringify(missingUserSubsidyReason.actions);
expect(userSubsidyApplicableToCourse).toBeUndefined();
expect(missingUserSubsidyReason.reason).toEqual(DISABLED_ENROLL_REASON_TYPES.SUBSCRIPTION_EXPIRED);
expect(missingUserSubsidyReason.userMessage).toEqual(
DISABLED_ENROLL_USER_MESSAGES[
DISABLED_ENROLL_REASON_TYPES.SUBSCRIPTION_EXPIRED
],
);
expect(actionHtml.includes('"destination":"mailto:admin@test.com"')).toBeTruthy();
expect(actionHtml.includes('Contact admin for help')).toBeTruthy();
});

it('reports revoked subscription license', async () => {
mockCourseService.fetchUserLicenseSubsidy.mockReturnValueOnce(undefined);
const args = {
...baseArgs,
subscriptionLicense: mockRevokedSubscriptionLicense,
};
const { result, waitForNextUpdate } = renderHook(() => useUserSubsidyApplicableToCourse(args));
await waitForNextUpdate();

const { missingUserSubsidyReason, userSubsidyApplicableToCourse } = result.current;
const actionHtml = JSON.stringify(missingUserSubsidyReason.actions);
expect(userSubsidyApplicableToCourse).toBeUndefined();
expect(missingUserSubsidyReason.reason).toEqual(DISABLED_ENROLL_REASON_TYPES.SUBSCRIPTION_DEACTIVATED);
expect(missingUserSubsidyReason.userMessage).toEqual(
DISABLED_ENROLL_USER_MESSAGES[
DISABLED_ENROLL_REASON_TYPES.SUBSCRIPTION_DEACTIVATED
],
);
expect(actionHtml.includes('Learn about deactivation')).toBeTruthy();
});

it('finds applicable coupon code', async () => {
const mockCouponCode = {
catalog: mockCatalogUUID,
Expand Down Expand Up @@ -1273,29 +1229,6 @@ describe('useUserSubsidyApplicableToCourse', () => {
});
});

it('reports no coupon codes remaining', async () => {
getSubsidyToApplyForCourse.mockReturnValueOnce(undefined);

const args = {
...baseArgs,
couponsForSubsidyRequests: [{ numUnassigned: 0 }],
};
const { result, waitForNextUpdate } = renderHook(() => useUserSubsidyApplicableToCourse(args));

await waitForNextUpdate();

const { missingUserSubsidyReason, userSubsidyApplicableToCourse } = result.current;
const actionHtml = JSON.stringify(missingUserSubsidyReason.actions);
expect(userSubsidyApplicableToCourse).toBeUndefined();
expect(missingUserSubsidyReason.reason).toEqual(DISABLED_ENROLL_REASON_TYPES.NO_ENROLLMENT_CODES_REMAINING);
expect(missingUserSubsidyReason.userMessage).toEqual(
DISABLED_ENROLL_USER_MESSAGES[
DISABLED_ENROLL_REASON_TYPES.LEARNER_MAX_ENROLLMENTS_REACHED
],
);
expect(actionHtml.includes('Learn about limits')).toBeTruthy();
});

it('finds applicable enterprise offer', async () => {
const mockEnterpriseOffer = {
catalog: mockCatalogUUID,
Expand Down
9 changes: 0 additions & 9 deletions src/components/course/data/tests/utils.test.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import moment from 'moment';
import { LICENSE_STATUS } from '../../../enterprise-user-subsidy/data/constants';
import {
COUPON_CODE_SUBSIDY_TYPE, COURSE_AVAILABILITY_MAP, ENTERPRISE_OFFER_SUBSIDY_TYPE, LICENSE_SUBSIDY_TYPE,
} from '../constants';
Expand All @@ -13,7 +12,6 @@ import {
linkToCourse,
pathContainsCourseTypeSlug,
getCourseStartDate,
isActiveSubscriptionLicense,
} from '../utils';

jest.mock('@edx/frontend-platform/config', () => ({
Expand Down Expand Up @@ -558,10 +556,3 @@ describe('getCourseStartDate tests', () => {
expect(startDate).toBe(undefined);
});
});

describe('isActiveSubscriptionLicense tests', () => {
it('returns true for active subscription license', async () => {
const testSubscriptionLicense = { status: LICENSE_STATUS.ACTIVATED };
expect(isActiveSubscriptionLicense(testSubscriptionLicense)).toBeTruthy();
});
});
Loading

0 comments on commit 0bfb8a7

Please sign in to comment.