Skip to content

Commit

Permalink
chore: fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
brobro10000 committed Sep 5, 2024
1 parent a2f1a1f commit 6411917
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,26 @@ const execEdData = {
key: 'exec-ed-course-123x',
entitlements: [{ price: '999.00' }],
normalized_metadata: {
enroll_by_date: '2016-02-18T04:00:00Z',
enroll_by_date: dayjs(1892678399 * 1000).toISOString(),
start_date: '2016-04-18T04:00:00Z',
content_price: 999,
},
courseRuns: [
{
key: 'course-v1:edX+course-123x+3T2020',
start: '2016-04-18T04:00:00Z',
upgrade_deadline: 1892678399,
pacing_type: 'self_paced',
enroll_by: 1892678399,
},
],
advertised_course_run: {
key: 'course-v1:edX+course-123x+3T2020',
start: '2016-04-18T04:00:00Z',
upgrade_deadline: 1892678399,
pacing_type: 'self_paced',
enroll_by: 1892678399,
},
original_image_url: '',
partners: [{ logo_image_url: '', name: 'Course Provider' }],
title: 'Exec Ed Title',
Expand Down Expand Up @@ -214,7 +230,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);
Expand Down Expand Up @@ -247,7 +263,8 @@ describe('Course card works as expected', () => {
test('executive education card renders', () => {
renderWithRouter(<CourseCardWrapper {...execEdProps} />);
expect(screen.queryByText('$999')).toBeInTheDocument();
expect(screen.queryByText('Starts Apr 18, 2016 • Learner must enroll by Feb 18, 2016')).toBeInTheDocument();
userEvent.click(screen.getByText('Assign'));
expect(screen.getByText('Enroll by Dec 22, 2029')).toBeInTheDocument();
expect(screen.queryByText('Executive Education')).toBeInTheDocument();
const viewCourseCTA = screen.getByText('View course', { selector: 'a' });
expect(viewCourseCTA.href).toContain('https://enterprise.stage.edx.org/test-enterprise-slug/executive-education-2u/course/exec-ed-course-123x');
Expand All @@ -266,6 +283,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'));
Expand All @@ -283,6 +302,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');
Expand Down Expand Up @@ -383,8 +404,12 @@ describe('Course card works as expected', () => {
renderWithRouter(<CourseCardWrapper {...defaultProps} />);
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();
Expand All @@ -396,8 +421,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();
Expand All @@ -420,7 +444,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();
Expand Down Expand Up @@ -478,7 +508,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,
}),
);
Expand Down Expand Up @@ -598,7 +628,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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import omit from 'lodash/omit';
import { AxiosError } from 'axios';
import type { FormWorkflowHandlerArgs, FormWorkflowStep } from '../../forms/FormWorkflow';
import SSOConfigConnectStep, { getValidations as getSSOConfigConnectStepValidations } from './steps/NewSSOConfigConnectStep';
// TODO: Resolve dependency issue
// eslint-disable-next-line import/no-cycle
import SSOConfigConfigureStep, { getValidations as getSSOConfigConfigureStepValidations } from './steps/NewSSOConfigConfigureStep';
import SSOConfigAuthorizeStep, { getValidations as getSSOConfigAuthorizeStepValidations } from './steps/NewSSOConfigAuthorizeStep';
import SSOConfigConfirmStep from './steps/NewSSOConfigConfirmStep';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import { urlValidation } from '../../../../utils';
import { FormWorkflowStep } from '../../../forms/FormWorkflow';
import { FORM_ERROR_MESSAGE, setStepAction } from '../../../forms/data/actions';
import { INVALID_IDP_METADATA_ERROR, RECORD_UNDER_CONFIGURATIONS_ERROR } from '../../data/constants';
// TODO: Resolve dependency issue
// eslint-disable-next-line import/no-cycle
import { SSOConfigCamelCase } from '../SSOFormWorkflowConfig';

const messages = defineMessages({
Expand Down

0 comments on commit 6411917

Please sign in to comment.