From 5473422b06a8814581b7ecf0750ef31cd1aa4b5a Mon Sep 17 00:00:00 2001 From: Hamzah Ullah Date: Thu, 5 Sep 2024 10:37:35 -0400 Subject: [PATCH] chore: fix tests --- .../cards/tests/CourseCard.test.jsx | 26 ++++++++++++++----- 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/src/components/learner-credit-management/cards/tests/CourseCard.test.jsx b/src/components/learner-credit-management/cards/tests/CourseCard.test.jsx index b42374330e..c1b9ac6757 100644 --- a/src/components/learner-credit-management/cards/tests/CourseCard.test.jsx +++ b/src/components/learner-credit-management/cards/tests/CourseCard.test.jsx @@ -214,7 +214,7 @@ describe('Course card works as expected', () => { expect(screen.getByText('$100')).toBeInTheDocument(); userEvent.click(screen.getByText('Assign')); expect(screen.getByText('Per learner price')).toBeInTheDocument(); - expect(screen.getByText('Upcoming • Learner must enroll by Feb 18, 2016')).toBeInTheDocument(); + expect(screen.getByText('Enroll by Dec 22, 2029')).toBeInTheDocument(); expect(screen.getByText('Course')).toBeInTheDocument(); // Has card image defined even though the course metadata does not contain an image URL const cardImage = screen.getByAltText(imageAltText); @@ -266,6 +266,8 @@ describe('Course card works as expected', () => { const assignCourseCTA = getButtonElement('Assign'); expect(assignCourseCTA).toBeInTheDocument(); userEvent.click(assignCourseCTA); + expect(screen.getByText('Enroll by Dec 22, 2029')).toBeInTheDocument(); + userEvent.click(screen.getByText('Enroll by Dec 22, 2029')); expect(sendEnterpriseTrackEvent).toHaveBeenCalledTimes(1); const assignmentModal = within(screen.getByRole('dialog')); @@ -283,6 +285,8 @@ describe('Course card works as expected', () => { const assignCourseCTA = getButtonElement('Assign'); expect(assignCourseCTA).toBeInTheDocument(); userEvent.click(assignCourseCTA); + expect(screen.getByText('Enroll by Dec 22, 2029')).toBeInTheDocument(); + userEvent.click(screen.getByText('Enroll by Dec 22, 2029')); expect(sendEnterpriseTrackEvent).toHaveBeenCalledTimes(1); const helpCenterButton = screen.getByText('Help Center: Course Assignments'); @@ -383,8 +387,12 @@ describe('Course card works as expected', () => { renderWithRouter(); const assignCourseCTA = getButtonElement('Assign'); expect(assignCourseCTA).toBeInTheDocument(); + userEvent.click(assignCourseCTA); + expect(screen.getByText('Enroll by Dec 22, 2029')).toBeInTheDocument(); + userEvent.click(screen.getByText('Enroll by Dec 22, 2029')); + const assignmentModal = within(screen.getByRole('dialog')); expect(assignmentModal.getByText('Assign this course')).toBeInTheDocument(); @@ -396,8 +404,7 @@ describe('Course card works as expected', () => { expect(modalCourseCard.getByText(defaultProps.original.partners[0].name)).toBeInTheDocument(); expect(modalCourseCard.getByText('$100')).toBeInTheDocument(); expect(modalCourseCard.getByText('Per learner price')).toBeInTheDocument(); - expect(modalCourseCard.getByText('Upcoming • Learner must enroll by Feb 18, 2016')).toBeInTheDocument(); - expect(modalCourseCard.getByText('Course')).toBeInTheDocument(); + expect(screen.getByText('Enroll by Dec 22, 2029')).toBeInTheDocument(); const cardImage = modalCourseCard.getByAltText(imageAltText); expect(cardImage).toBeInTheDocument(); expect(cardImage.src).toBeDefined(); @@ -420,7 +427,13 @@ describe('Course card works as expected', () => { const expectedAvailableBalance = formatPrice(mockSubsidyAccessPolicy.aggregates.spendAvailableUsd); expect(assignmentModal.getByText(expectedAvailableBalance)).toBeInTheDocument(); - // Verify collapsibles + // Verify important dates + expect(assignmentModal.getByText('Enroll-by date')).toBeInTheDocument(); + expect(assignmentModal.getByText('Dec 22, 2029')).toBeInTheDocument(); + expect(assignmentModal.getByText('Course started')).toBeInTheDocument(); + expect(assignmentModal.getByText('Apr 18, 2016')).toBeInTheDocument(); + + // Verify collapsible expect(assignmentModal.getByText('How assigning this course works')).toBeInTheDocument(); expect(assignmentModal.getByText('Next steps for assigned learners')).toBeInTheDocument(); expect(assignmentModal.getByText('Learners will be notified of this course assignment by email.')).toBeInTheDocument(); @@ -478,7 +491,7 @@ describe('Course card works as expected', () => { mockSubsidyAccessPolicy.uuid, expect.objectContaining({ content_price_cents: 10000, - content_key: 'course-123x', + content_key: 'course-v1:edX+course-123x+3T2020', learner_emails: mockLearnerEmails, }), ); @@ -598,7 +611,8 @@ describe('Course card works as expected', () => { const assignCourseCTA = getButtonElement('Assign'); expect(assignCourseCTA).toBeInTheDocument(); userEvent.click(assignCourseCTA); - + expect(screen.getByText('Enroll by Dec 22, 2029')).toBeInTheDocument(); + userEvent.click(screen.getByText('Enroll by Dec 22, 2029')); const assignmentModal = within(screen.getByRole('dialog')); // Verify "Assign" CTA is disabled