diff --git a/src/components/app/data/hooks/useCourseMetadata.js b/src/components/app/data/hooks/useCourseMetadata.js index 060457ebc7..cf0fba080d 100644 --- a/src/components/app/data/hooks/useCourseMetadata.js +++ b/src/components/app/data/hooks/useCourseMetadata.js @@ -3,7 +3,7 @@ import { useParams, useSearchParams } from 'react-router-dom'; import { queryCourseMetadata } from '../queries'; import { - determineAllocatedCourseRunAssignmentsForCourse, + determineAllocatedAssignmentsForCourse, getAvailableCourseRuns, transformCourseMetadataByAllocatedCourseRunAssignments, } from '../utils'; @@ -23,10 +23,7 @@ export default function useCourseMetadata(queryOptions = {}) { allocatedCourseRunAssignmentKeys, hasAssignedCourseRuns, hasMultipleAssignedCourseRuns, - } = determineAllocatedCourseRunAssignmentsForCourse({ - courseKey, - redeemableLearnerCreditPolicies, - }); + } = determineAllocatedAssignmentsForCourse({ courseKey, redeemableLearnerCreditPolicies }); // `requestUrl.searchParams` uses `URLSearchParams`, which decodes `+` as a space, so we // need to replace it with `+` again to be a valid course run key. let courseRunKey = searchParams.get('course_run_key')?.replaceAll(' ', '+'); diff --git a/src/components/app/data/utils.js b/src/components/app/data/utils.js index 4eb8145c4d..837aa00098 100644 --- a/src/components/app/data/utils.js +++ b/src/components/app/data/utils.js @@ -806,7 +806,7 @@ export function isEnrollmentUpgradeable(enrollment) { * } * } */ -export function determineAllocatedCourseRunAssignmentsForCourse({ +export function determineAllocatedAssignmentsForCourse({ redeemableLearnerCreditPolicies, courseKey, }) { @@ -814,19 +814,37 @@ export function determineAllocatedCourseRunAssignmentsForCourse({ // note: checking the non-happy path first, with early return so happy path code isn't nested in conditional. if (!learnerContentAssignments.hasAllocatedAssignments) { return { + isCourseAssigned: false, + allocatedAssignmentsForCourse: [], allocatedCourseRunAssignmentKeys: [], allocatedCourseRunAssignments: [], hasAssignedCourseRuns: false, hasMultipleAssignedCourseRuns: false, }; } - const allocatedCourseRunAssignments = learnerContentAssignments.allocatedAssignments.filter((assignment) => ( - assignment.isAssignedCourseRun && assignment.parentContentKey === courseKey - )); + + const allocatedAssignmentsForCourse = []; + const allocatedCourseRunAssignments = []; + + learnerContentAssignments.allocatedAssignments.forEach((assignment) => { + const isCourseRunAssignment = assignment.isAssignedCourseRun && assignment.parentContentKey === courseKey; + const isCourseAssignment = !assignment.isAssignedCourseRun && assignment.contentKey === courseKey; + if (isCourseRunAssignment || isCourseAssignment) { + allocatedAssignmentsForCourse.push(assignment); + } + if (isCourseRunAssignment) { + allocatedCourseRunAssignments.push(assignment); + } + }); + + const isCourseAssigned = allocatedAssignmentsForCourse.length > 0; const allocatedCourseRunAssignmentKeys = allocatedCourseRunAssignments.map(assignment => assignment.contentKey); const hasAssignedCourseRuns = allocatedCourseRunAssignmentKeys.length > 0; const hasMultipleAssignedCourseRuns = allocatedCourseRunAssignmentKeys.length > 1; + return { + isCourseAssigned, + allocatedAssignmentsForCourse, allocatedCourseRunAssignmentKeys, allocatedCourseRunAssignments, hasAssignedCourseRuns, diff --git a/src/components/course/CourseSidebarPrice.jsx b/src/components/course/CourseSidebarPrice.jsx index 3baba501f0..1dcd9c8b92 100644 --- a/src/components/course/CourseSidebarPrice.jsx +++ b/src/components/course/CourseSidebarPrice.jsx @@ -20,7 +20,7 @@ const CourseSidebarPrice = () => { const intl = useIntl(); const { data: enterpriseCustomer } = useEnterpriseCustomer(); const { coursePrice, currency } = useCoursePrice(); - const isCourseAssigned = useIsCourseAssigned(); + const { isCourseAssigned } = useIsCourseAssigned(); const canRequestSubsidy = useCanUserRequestSubsidyForCourse(); const { userSubsidyApplicableToCourse } = useUserSubsidyApplicableToCourse(); diff --git a/src/components/course/course-header/CourseHeader.jsx b/src/components/course/course-header/CourseHeader.jsx index 25008f771b..d71e15b1a1 100644 --- a/src/components/course/course-header/CourseHeader.jsx +++ b/src/components/course/course-header/CourseHeader.jsx @@ -37,7 +37,7 @@ const CourseHeader = () => { const { data: { isPolicyRedemptionEnabled } } = useCourseRedemptionEligibility(); const { data: { containsContentItems } } = useEnterpriseCustomerContainsContent([courseKey]); const isAssignmentsOnlyLearner = useIsAssignmentsOnlyLearner(); - const isCourseAssigned = useIsCourseAssigned(); + const { isCourseAssigned } = useIsCourseAssigned(); const isCourseArchived = courseMetadata.courseRuns.every((courseRun) => isArchived(courseRun)); const [partners] = useCoursePartners(courseMetadata); const defaultProgram = useMemo( diff --git a/src/components/course/course-header/CourseImportantDates.jsx b/src/components/course/course-header/CourseImportantDates.jsx index dba1a26235..f598562931 100644 --- a/src/components/course/course-header/CourseImportantDates.jsx +++ b/src/components/course/course-header/CourseImportantDates.jsx @@ -3,17 +3,17 @@ import { } from '@openedx/paragon'; import { Calendar } from '@openedx/paragon/icons'; import dayjs from 'dayjs'; -import { useParams, useSearchParams } from 'react-router-dom'; +import { useSearchParams } from 'react-router-dom'; import { defineMessages, useIntl } from '@edx/frontend-platform/i18n'; import PropTypes from 'prop-types'; import { - DATE_FORMAT, DATETIME_FORMAT, getSoonestEarliestPossibleExpirationData, hasCourseStarted, + DATE_FORMAT, + DATETIME_FORMAT, + getSoonestEarliestPossibleExpirationData, + hasCourseStarted, + useIsCourseAssigned, } from '../data'; -import { - determineAllocatedCourseRunAssignmentsForCourse, - useCourseMetadata, - useRedeemablePolicies, -} from '../../app/data'; +import { useCourseMetadata } from '../../app/data'; const messages = defineMessages({ importantDates: { @@ -61,18 +61,13 @@ CourseImportantDate.propTypes = { }; const CourseImportantDates = () => { - const { courseKey } = useParams(); - const { data: redeemableLearnerCreditPolicies } = useRedeemablePolicies(); const { data: courseMetadata } = useCourseMetadata(); const intl = useIntl(); const { allocatedCourseRunAssignments, allocatedCourseRunAssignmentKeys, hasAssignedCourseRuns, - } = determineAllocatedCourseRunAssignmentsForCourse({ - redeemableLearnerCreditPolicies, - courseKey, - }); + } = useIsCourseAssigned(); const [searchParams] = useSearchParams(); const courseRunKey = searchParams.get('course_run_key')?.replaceAll(' ', '+'); diff --git a/src/components/course/course-header/tests/CourseImportantDates.test.jsx b/src/components/course/course-header/tests/CourseImportantDates.test.jsx index 5d9a498d1d..57eeb70ca7 100644 --- a/src/components/course/course-header/tests/CourseImportantDates.test.jsx +++ b/src/components/course/course-header/tests/CourseImportantDates.test.jsx @@ -7,15 +7,19 @@ import dayjs from 'dayjs'; import CourseImportantDates from '../CourseImportantDates'; import { renderWithRouterProvider } from '../../../../utils/tests'; import { authenticatedUserFactory } from '../../../app/data/services/data/__factories__'; -import { useCourseMetadata, useRedeemablePolicies } from '../../../app/data'; -import { COURSE_PACING_MAP, DATE_FORMAT, DATETIME_FORMAT } from '../../data'; +import { useCourseMetadata } from '../../../app/data'; +import { + COURSE_PACING_MAP, + DATE_FORMAT, + DATETIME_FORMAT, + useIsCourseAssigned, +} from '../../data'; import { TEST_OWNER } from '../../tests/data/constants'; const mockAuthenticatedUser = authenticatedUserFactory(); jest.mock('../../../app/data', () => ({ ...jest.requireActual('../../../app/data'), - useRedeemablePolicies: jest.fn(), useCourseMetadata: jest.fn(), })); @@ -24,6 +28,11 @@ jest.mock('react-router-dom', () => ({ useParams: jest.fn(), })); +jest.mock('../../data', () => ({ + ...jest.requireActual('../../data'), + useIsCourseAssigned: jest.fn(), +})); + const futureEarliestExpiration = dayjs().add(5, 'days').toISOString(); const pastEarliestExpiration = dayjs().subtract(5, 'days').toISOString(); const now = dayjs().toISOString(); @@ -55,40 +64,6 @@ const mockAllocatedAssignments = [{ reason: 'subsidy_expired', }, }]; -const mockLearnerContentAssignments = { - allocatedAssignments: mockAllocatedAssignments, - hasAllocatedAssignments: mockAllocatedAssignments.length > 0, -}; - -const mockBaseRedeemablePolicies = { - redeemablePolicies: [], - expiredPolicies: [], - unexpiredPolicies: [], - learnerContentAssignments: { - assignments: [], - hasAssignments: false, - allocatedAssignments: [], - hasAllocatedAssignments: false, - acceptedAssignments: [], - hasAcceptedAssignments: false, - canceledAssignments: [], - hasCanceledAssignments: false, - expiredAssignments: [], - hasExpiredAssignments: false, - erroredAssignments: [], - hasErroredAssignments: false, - assignmentsForDisplay: [], - hasAssignmentsForDisplay: false, - }, -}; - -const mockRedeemablePoliciesWithAllocatedAssignments = { - ...mockBaseRedeemablePolicies, - learnerContentAssignments: { - ...mockBaseRedeemablePolicies.learnerContentAssignments, - ...mockLearnerContentAssignments, - }, -}; const mockCourseStartDate = dayjs().add(10, 'days').toISOString(); @@ -132,14 +107,25 @@ describe('', () => { beforeEach(() => { jest.clearAllMocks(); useParams.mockReturnValue({ courseKey: 'edX+DemoX' }); - useRedeemablePolicies.mockReturnValue({ data: mockBaseRedeemablePolicies }); useCourseMetadata.mockReturnValue({ data: mockCourseMetadata }); + useIsCourseAssigned.mockReturnValue({ + allocatedCourseRunAssignments: mockAllocatedAssignments, + allocatedCourseRunAssignmentKeys: mockAllocatedAssignments.map((assignment) => assignment.contentKey), + hasAssignedCourseRuns: mockAllocatedAssignments.length > 0, + }); }); - it('renders without crashing', () => { - useRedeemablePolicies.mockReturnValue({ - data: mockRedeemablePoliciesWithAllocatedAssignments, + + it('does not render without run-based assignments', () => { + useIsCourseAssigned.mockReturnValue({ + allocatedCourseRunAssignments: [], + allocatedCourseRunAssignmentKeys: [], + hasAssignedCourseRuns: false, }); + const { container } = renderWithRouterProvider(); + expect(container).toBeEmptyDOMElement(); + }); + it('renders expected dates for run-based assignments', () => { renderWithRouterProvider(); expect(screen.getByText('Important dates')).toBeInTheDocument(); @@ -149,6 +135,7 @@ describe('', () => { expect(screen.getByText(dayjs(now).format(DATETIME_FORMAT))).toBeInTheDocument(); expect(screen.getByText(dayjs(mockCourseStartDate).format(DATE_FORMAT))).toBeInTheDocument(); }); + it.each([{ courseStartDate: futureEarliestExpiration, expected: 'Course starts', @@ -156,7 +143,7 @@ describe('', () => { { courseStartDate: pastEarliestExpiration, expected: 'Course started', - }])('renders the correct tense based on course start date', ({ + }])('renders the correct tense based on course start date (%s)', ({ courseStartDate, expected, }) => { @@ -170,9 +157,6 @@ describe('', () => { courseRuns: [updatedMockCourseRun], availableCourseRuns: [updatedMockCourseRun], }; - useRedeemablePolicies.mockReturnValue({ - data: mockRedeemablePoliciesWithAllocatedAssignments, - }); useCourseMetadata.mockReturnValue({ data: updatedMockCourseMetadata }); renderWithRouterProvider(); diff --git a/src/components/course/data/courseLoader.ts b/src/components/course/data/courseLoader.ts index d2642d6aef..ba0eda2a7a 100644 --- a/src/components/course/data/courseLoader.ts +++ b/src/components/course/data/courseLoader.ts @@ -1,7 +1,7 @@ import { generatePath, redirect } from 'react-router-dom'; import { - determineAllocatedCourseRunAssignmentsForCourse, + determineAllocatedAssignmentsForCourse, determineLearnerHasContentAssignmentsOnly, extractEnterpriseCustomer, getCatalogsForSubsidyRequests, @@ -80,7 +80,7 @@ const makeCourseLoader: Types.MakeRouteLoaderFunctionWithQueryClient = function allocatedCourseRunAssignmentKeys, hasAssignedCourseRuns, hasMultipleAssignedCourseRuns, - } = determineAllocatedCourseRunAssignmentsForCourse({ + } = determineAllocatedAssignmentsForCourse({ courseKey, redeemableLearnerCreditPolicies, }); diff --git a/src/components/course/data/hooks.jsx b/src/components/course/data/hooks.jsx index 4ff7f3a8bb..f8be855bc2 100644 --- a/src/components/course/data/hooks.jsx +++ b/src/components/course/data/hooks.jsx @@ -50,6 +50,7 @@ import { useSubscriptions, COUPON_CODE_SUBSIDY_TYPE, LICENSE_SUBSIDY_TYPE, + determineAllocatedAssignmentsForCourse, } from '../../app/data'; import { LICENSE_STATUS } from '../../enterprise-user-subsidy/data/constants'; import { CourseContext } from '../CourseContextProvider'; @@ -735,13 +736,27 @@ export const useExternalEnrollmentFailureReason = () => { * @returns {boolean} - Returns true if the course is assigned to the learner, false otherwise. */ export const useIsCourseAssigned = () => { - const { data: { learnerContentAssignments } } = useRedeemablePolicies(); + const { data: redeemableLearnerCreditPolicies } = useRedeemablePolicies(); const { data: courseMetadata } = useCourseMetadata(); - if (!learnerContentAssignments.hasAllocatedAssignments) { - return false; - } - const isCourseAssigned = learnerContentAssignments.allocatedAssignments.some( - (assignment) => assignment.contentKey === courseMetadata.key, - ); - return isCourseAssigned; + + const { + isCourseAssigned, + allocatedAssignmentsForCourse, + allocatedCourseRunAssignmentKeys, + allocatedCourseRunAssignments, + hasAssignedCourseRuns, + hasMultipleAssignedCourseRuns, + } = determineAllocatedAssignmentsForCourse({ + courseKey: courseMetadata.key, + redeemableLearnerCreditPolicies, + }); + + return { + isCourseAssigned, + allocatedAssignmentsForCourse, + allocatedCourseRunAssignmentKeys, + allocatedCourseRunAssignments, + hasAssignedCourseRuns, + hasMultipleAssignedCourseRuns, + }; }; diff --git a/src/components/course/data/tests/hooks.test.jsx b/src/components/course/data/tests/hooks.test.jsx index 1c4b9ad8b7..aec4267673 100644 --- a/src/components/course/data/tests/hooks.test.jsx +++ b/src/components/course/data/tests/hooks.test.jsx @@ -1481,6 +1481,7 @@ describe('useMinimalCourseMetadata', () => { describe('useIsCourseAssigned', () => { const mockContentKey = 'edX+DemoX'; + const mockContentKeyAsRun = 'course-v1:edX+DemoX+T2024a'; beforeEach(() => { jest.clearAllMocks(); useEnterpriseCustomer.mockReturnValue({ data: mockEnterpriseCustomer }); @@ -1498,7 +1499,14 @@ describe('useIsCourseAssigned', () => { useRedeemablePolicies.mockReturnValue({ data: { learnerContentAssignments } }); const { result } = renderHook(() => useIsCourseAssigned(), { wrapper: Wrapper }); - expect(result.current).toEqual(false); + expect(result.current).toEqual({ + isCourseAssigned: false, + allocatedAssignmentsForCourse: [], + allocatedCourseRunAssignmentKeys: [], + allocatedCourseRunAssignments: [], + hasAssignedCourseRuns: false, + hasMultipleAssignedCourseRuns: false, + }); }); it('should return false if there is NO matching allocated assignment to the course key', () => { @@ -1519,7 +1527,14 @@ describe('useIsCourseAssigned', () => { { wrapper: Wrapper }, ); - expect(result.current).toEqual(false); + expect(result.current).toEqual({ + isCourseAssigned: false, + allocatedAssignmentsForCourse: [], + allocatedCourseRunAssignmentKeys: [], + allocatedCourseRunAssignments: [], + hasAssignedCourseRuns: false, + hasMultipleAssignedCourseRuns: false, + }); }); it('should return false if matching assignment(s) are canceled', () => { @@ -1542,10 +1557,17 @@ describe('useIsCourseAssigned', () => { { wrapper: Wrapper }, ); - expect(result.current).toEqual(false); + expect(result.current).toEqual({ + isCourseAssigned: false, + allocatedAssignmentsForCourse: [], + allocatedCourseRunAssignmentKeys: [], + allocatedCourseRunAssignments: [], + hasAssignedCourseRuns: false, + hasMultipleAssignedCourseRuns: false, + }); }); - it('should return true if there is a matching allocated assignment to the course key', () => { + it('should return true if there is a matching allocated course-based assignment to the course key', () => { const learnerContentAssignments = { hasAllocatedAssignments: true, allocatedAssignments: [ @@ -1562,7 +1584,57 @@ describe('useIsCourseAssigned', () => { () => useIsCourseAssigned(), { wrapper: Wrapper }, ); - expect(result.current).toEqual(true); + expect(result.current).toEqual({ + isCourseAssigned: true, + allocatedAssignmentsForCourse: [ + { + contentKey: mockContentKey, + state: 'allocated', + }, + ], + allocatedCourseRunAssignmentKeys: [], + allocatedCourseRunAssignments: [], + hasAssignedCourseRuns: false, + hasMultipleAssignedCourseRuns: false, + }); + }); + + it.each([ + { hasMultipleAssignedCourseRuns: true }, + { hasMultipleAssignedCourseRuns: false }, + ])('should return true if there is a matching allocated course run-based assignment to the course key (%s)', ({ hasMultipleAssignedCourseRuns }) => { + const mockRunBasedAssignment = { + isAssignedCourseRun: true, + contentKey: mockContentKeyAsRun, + parentContentKey: mockContentKey, + state: 'allocated', + }; + const allocatedAssignments = [mockRunBasedAssignment]; + if (hasMultipleAssignedCourseRuns) { + allocatedAssignments.push({ + ...mockRunBasedAssignment, + contentKey: 'course-v1:edX+DemoX+T2024b', + }); + } + const learnerContentAssignments = { + hasAllocatedAssignments: true, + allocatedAssignments, + }; + useRedeemablePolicies.mockReturnValue({ data: { learnerContentAssignments } }); + useCourseMetadata.mockReturnValue({ data: { key: mockContentKey } }); + + const { result } = renderHook( + () => useIsCourseAssigned(), + { wrapper: Wrapper }, + ); + expect(result.current).toEqual({ + isCourseAssigned: true, + allocatedAssignmentsForCourse: allocatedAssignments, + allocatedCourseRunAssignmentKeys: allocatedAssignments.map(assignment => assignment.contentKey), + allocatedCourseRunAssignments: allocatedAssignments, + hasAssignedCourseRuns: true, + hasMultipleAssignedCourseRuns, + }); }); }); diff --git a/src/components/course/data/utils.jsx b/src/components/course/data/utils.jsx index 727b7739f0..a2864cc0af 100644 --- a/src/components/course/data/utils.jsx +++ b/src/components/course/data/utils.jsx @@ -928,7 +928,7 @@ export function getSoonestEarliestPossibleExpirationData({ const sortedByExpirationDate = assignmentsWithExpiration.sort( (a, b) => (dayjs(a.earliestPossibleExpiration.date).isBefore(b.earliestPossibleExpiration.date) ? -1 : 1), ); - let { date: soonestExpirationDate } = sortedByExpirationDate[0].earliestPossibleExpiration.date; + let soonestExpirationDate = sortedByExpirationDate[0].earliestPossibleExpiration.date; if (dateFormat) { soonestExpirationDate = dayjs(soonestExpirationDate).format(dateFormat); } diff --git a/src/components/course/routes/ExternalCourseEnrollment.jsx b/src/components/course/routes/ExternalCourseEnrollment.jsx index 63fc05b62c..2f85378332 100644 --- a/src/components/course/routes/ExternalCourseEnrollment.jsx +++ b/src/components/course/routes/ExternalCourseEnrollment.jsx @@ -33,7 +33,7 @@ const ExternalCourseEnrollment = () => { const config = getConfig(); const { externalCourseFormSubmissionError } = useContext(CourseContext); const { data: enterpriseCustomer } = useEnterpriseCustomer(); - const isCourseAssigned = useIsCourseAssigned(); + const { isCourseAssigned } = useIsCourseAssigned(); const { data: minimalCourseMetadata } = useMinimalCourseMetadata(); const { userSubsidyApplicableToCourse } = useUserSubsidyApplicableToCourse(); const { data: { redeemabilityPerContentKey } } = useCourseRedemptionEligibility(); diff --git a/src/components/course/tests/CourseSidebarPrice.test.jsx b/src/components/course/tests/CourseSidebarPrice.test.jsx index 3df388e3d4..0c637273b7 100644 --- a/src/components/course/tests/CourseSidebarPrice.test.jsx +++ b/src/components/course/tests/CourseSidebarPrice.test.jsx @@ -65,7 +65,7 @@ describe(' ', () => { useEnterpriseCustomer.mockReturnValue({ data: mockEnterpriseCustomer }); useUserSubsidyApplicableToCourse.mockReturnValue({ userSubsidyApplicableToCourse: null }); useCoursePrice.mockReturnValue({ coursePrice: { list: 7.5, discounted: 7.5 }, currency: 'USD' }); - useIsCourseAssigned.mockReturnValue(false); + useIsCourseAssigned.mockReturnValue({ isCourseAssigned: false }); useCanUserRequestSubsidyForCourse.mockReturnValue(false); }); @@ -167,7 +167,7 @@ describe(' ', () => { }); test('assigned course, shows no price, correct message', () => { - useIsCourseAssigned.mockReturnValue(true); + useIsCourseAssigned.mockReturnValue({ isCourseAssigned: true }); useCoursePrice.mockReturnValue({ coursePrice: { list: 7.5, discounted: 0 }, currency: 'USD' }); useUserSubsidyApplicableToCourse.mockReturnValue({ userSubsidyApplicableToCourse: { subsidyType: LEARNER_CREDIT_SUBSIDY_TYPE }, @@ -229,7 +229,7 @@ describe(' ', () => { expect(screen.queryByText('This course is assigned to you. The price of this course is already covered by your organization.')).not.toBeInTheDocument(); }); test('assigned course, shows orig price, correct message', () => { - useIsCourseAssigned.mockReturnValue(true); + useIsCourseAssigned.mockReturnValue({ isCourseAssigned: true }); useCoursePrice.mockReturnValue({ coursePrice: { list: 7.5, discounted: 0 }, currency: 'USD' }); useUserSubsidyApplicableToCourse.mockReturnValue({ userSubsidyApplicableToCourse: { subsidyType: LEARNER_CREDIT_SUBSIDY_TYPE }, diff --git a/src/components/microlearning/VideoBanner.jsx b/src/components/microlearning/VideoBanner.jsx index 22f48f1412..94ff9a3943 100644 --- a/src/components/microlearning/VideoBanner.jsx +++ b/src/components/microlearning/VideoBanner.jsx @@ -1,31 +1,23 @@ -import { - Card, Button, -} from '@openedx/paragon'; -import './styles/VideoDetailPage.scss'; +import { Card, Button } from '@openedx/paragon'; import { Link } from 'react-router-dom'; import { sendEnterpriseTrackEvent } from '@edx/frontend-enterprise-utils'; -import { AppContext } from '@edx/frontend-platform/react'; -import { useContext } from 'react'; import { FormattedMessage } from '@edx/frontend-platform/i18n'; import BetaBadge from './BetaBadge'; import { useEnterpriseCustomer } from '../app/data'; +import './styles/VideoDetailPage.scss'; const VideoBanner = () => { const { data: enterpriseCustomer } = useEnterpriseCustomer(); - const { authenticatedUser: { userId } } = useContext(AppContext); const sendPushEvent = () => { sendEnterpriseTrackEvent( enterpriseCustomer.uuid, 'edx.ui.enterprise.learner_portal.video_banner.explore_videos_clicked', - { - userId, - }, ); }; return (
- +

{ > diff --git a/src/components/microlearning/tests/VideoBanner.test.jsx b/src/components/microlearning/tests/VideoBanner.test.jsx index cd57310c92..fb07e19bee 100644 --- a/src/components/microlearning/tests/VideoBanner.test.jsx +++ b/src/components/microlearning/tests/VideoBanner.test.jsx @@ -46,21 +46,18 @@ describe('VideoBanner', () => { it('renders the explore videos button', () => { renderWithRouter(); - expect(screen.getByText('Explore Videos')).toBeInTheDocument(); + expect(screen.getByText('Explore videos')).toBeInTheDocument(); }); it('calls sendEnterpriseTrackEvent when explore videos button is clicked', () => { renderWithRouter(); - const exploreVideosButton = screen.getByText('Explore Videos'); + const exploreVideosButton = screen.getByText('Explore videos'); exploreVideosButton.click(); expect(sendEnterpriseTrackEvent).toHaveBeenCalledWith( mockEnterpriseCustomer.uuid, 'edx.ui.enterprise.learner_portal.video_banner.explore_videos_clicked', - { - userId: mockAuthenticatedUser.userId, - }, ); }); it('hover on Beta badge', async () => {