diff --git a/src/course-outline/section-card/SectionCard.jsx b/src/course-outline/section-card/SectionCard.jsx index ebbf4b1e90..47bafc29bf 100644 --- a/src/course-outline/section-card/SectionCard.jsx +++ b/src/course-outline/section-card/SectionCard.jsx @@ -180,7 +180,7 @@ const SectionCard = ({ isSelfPaced={isSelfPaced} isCustomRelativeDatesActive={isCustomRelativeDatesActive} item={section} - /> + />
- ) + ); const gradingTypeDiv = () => (
@@ -118,7 +117,7 @@ const XBlockStatus = ({ {gradingType || intl.formatMessage(messages.ungradedText)}
- ) + ); const dueDateDiv = () => { if (dueDate && isInstructorPaced) { @@ -126,9 +125,10 @@ const XBlockStatus = ({
{intl.formatMessage(messages.dueLabel)} {dueDate}
- ) + ); } - } + return null; + }; const selfPacedRelativeDueWeeksDiv = () => (
@@ -137,13 +137,13 @@ const XBlockStatus = ({ {intl.formatMessage(messages.customDueDateLabel, { relativeWeeksDue })}
- ) + ); const explanatoryMessageDiv = () => ( - + {explanatoryMessage} - ) + ); const renderGradingTypeAndDueDate = () => { const showRelativeWeeks = isSelfPaced && isCustomRelativeDatesActive && relativeWeeksDue; @@ -160,8 +160,8 @@ const XBlockStatus = ({ {showRelativeWeeks && (selfPacedRelativeDueWeeksDiv())} - ) - } else if ((dueDate && !isSelfPaced) || graded) { + ); + } if ((dueDate && !isSelfPaced) || graded) { return ( <>
@@ -170,16 +170,17 @@ const XBlockStatus = ({
{showRelativeWeeks && (selfPacedRelativeDueWeeksDiv())} - ) - } else if (showRelativeWeeks) { + ); + } if (showRelativeWeeks) { return ( <> {gradingTypeDiv()} {selfPacedRelativeDueWeeksDiv()} - ) + ); } - } + return null; + }; const hideAfterDueMessage = () => (
@@ -190,7 +191,7 @@ const XBlockStatus = ({ : intl.formatMessage(messages.hiddenAfterDueDate)}
- ) + ); const renderGradingPolicyAlert = () => { let gradingPolicyMismatch = false; @@ -211,9 +212,10 @@ const XBlockStatus = ({ {intl.formatMessage(messages.gradingPolicyMismatchText, { gradingType })} - ) + ); } - } + return null; + }; const renderStatusMessages = () => { if (statusMessages.length > 0) { @@ -226,22 +228,23 @@ const XBlockStatus = ({ ))} - ) + ); } - } + return null; + }; return (
{!isVertical && ( - explanatoryMessage ? explanatoryMessageDiv(): isInstructorPaced && releaseStatusDiv() + explanatoryMessage ? explanatoryMessageDiv() : isInstructorPaced && releaseStatusDiv() )} {!isVertical && renderGradingTypeAndDueDate()} {hideAfterDue && hideAfterDueMessage()} {renderStatusMessages()} {renderGradingPolicyAlert()}
- ) -} + ); +}; XBlockStatus.defaultProps = { isCustomRelativeDatesActive: false, @@ -269,14 +272,14 @@ XBlockStatus.propTypes = { selectedGroupsLabel: PropTypes.string.isRequired, }), hasPartitionGroupComponents: PropTypes.bool.isRequired, - gradingType: PropTypes.string, + format: PropTypes.string, dueDate: PropTypes.string, relativeWeeksDue: PropTypes.number, isTimeLimited: PropTypes.bool, graded: PropTypes.bool, courseGraders: PropTypes.arrayOf(PropTypes.string.isRequired).isRequired, hideAfterDue: PropTypes.bool, - }) + }).isRequired, }; export default XBlockStatus; diff --git a/src/course-outline/xblock-status/XBlockStatus.test.jsx b/src/course-outline/xblock-status/XBlockStatus.test.jsx index 55100e44ce..1cc232e6d3 100644 --- a/src/course-outline/xblock-status/XBlockStatus.test.jsx +++ b/src/course-outline/xblock-status/XBlockStatus.test.jsx @@ -1,7 +1,5 @@ import React from 'react'; -import { - act, render, fireEvent, within, -} from '@testing-library/react'; +import { render } from '@testing-library/react'; import { IntlProvider } from '@edx/frontend-platform/i18n'; import { AppProvider } from '@edx/frontend-platform/react'; import { initializeMockApp } from '@edx/frontend-platform'; @@ -40,7 +38,7 @@ const section = { staffOnlyMessage: false, userPartitionInfo: { selectedPartitionIndex: -1, - selectedGroupsLabel: "", + selectedGroupsLabel: '', }, hasPartitionGroupComponents: false, format: 'Homework', @@ -83,7 +81,7 @@ describe(' for Instructor paced Section', () => { item: { ...section, explanatoryMessage: 'some explanatory message', - } + }, }); expect(queryByTestId('explanatory-message-span')).toBeInTheDocument(); @@ -99,7 +97,7 @@ describe(' for Instructor paced Section', () => { const releaseStatusDiv = queryByTestId('release-status-div'); expect(releaseStatusDiv).toBeInTheDocument(); expect(releaseStatusDiv).toHaveTextContent( - `${messages.releasedLabel.defaultMessage}${section.releaseDate}` + `${messages.releasedLabel.defaultMessage}${section.releaseDate}`, ); // check grading type @@ -114,7 +112,7 @@ describe(' for Instructor paced Section', () => { const dueDateDiv = queryByTestId('due-date-div'); expect(dueDateDiv).toBeInTheDocument(); expect(dueDateDiv).toHaveTextContent( - `${messages.dueLabel.defaultMessage} ${section.dueDate}` + `${messages.dueLabel.defaultMessage} ${section.dueDate}`, ); // self paced weeks should not be visible as // isSelfPaced is false as well as isCustomRelativeDatesActive is false @@ -170,7 +168,7 @@ describe(' for self paced Section', () => { const selfPacedRelativeDueWeeksDiv = queryByTestId('self-paced-relative-due-weeks-div'); expect(selfPacedRelativeDueWeeksDiv).toBeInTheDocument(); expect(selfPacedRelativeDueWeeksDiv).toHaveTextContent( - messages.customDueDateLabel.defaultMessage + messages.customDueDateLabel.defaultMessage, ); // check hide after due date message @@ -225,7 +223,7 @@ const subsection = { staffOnlyMessage: false, userPartitionInfo: { selectedPartitionIndex: -1, - selectedGroupsLabel: "", + selectedGroupsLabel: '', }, hasPartitionGroupComponents: false, format: 'Homework', @@ -259,7 +257,7 @@ describe(' for Instructor paced Subsection', () => { const releaseStatusDiv = queryByTestId('release-status-div'); expect(releaseStatusDiv).toBeInTheDocument(); expect(releaseStatusDiv).toHaveTextContent( - `${messages.scheduledLabel.defaultMessage}${subsection.releaseDate}` + `${messages.scheduledLabel.defaultMessage}${subsection.releaseDate}`, ); // check grading type @@ -274,7 +272,7 @@ describe(' for Instructor paced Subsection', () => { const dueDateDiv = queryByTestId('due-date-div'); expect(dueDateDiv).toBeInTheDocument(); expect(dueDateDiv).toHaveTextContent( - `${messages.dueLabel.defaultMessage} ${subsection.dueDate}` + `${messages.dueLabel.defaultMessage} ${subsection.dueDate}`, ); // self paced weeks should not be visible as // isSelfPaced is false as well as isCustomRelativeDatesActive is false @@ -358,7 +356,7 @@ describe(' for Instructor paced Subsection', () => { const dueDateDiv = queryByTestId('due-date-div'); expect(dueDateDiv).toBeInTheDocument(); expect(dueDateDiv).toHaveTextContent( - `${messages.dueLabel.defaultMessage} ${subsection.dueDate}` + `${messages.dueLabel.defaultMessage} ${subsection.dueDate}`, ); // self paced weeks should not be visible as // isSelfPaced is false as well as isCustomRelativeDatesActive is false @@ -405,7 +403,7 @@ describe(' for self paced Subsection', () => { const selfPacedRelativeDueWeeksDiv = queryByTestId('self-paced-relative-due-weeks-div'); expect(selfPacedRelativeDueWeeksDiv).toBeInTheDocument(); expect(selfPacedRelativeDueWeeksDiv).toHaveTextContent( - messages.customDueDateLabel.defaultMessage + messages.customDueDateLabel.defaultMessage, ); // check hide after due date message @@ -437,7 +435,7 @@ const unit = { staffOnlyMessage: false, userPartitionInfo: { selectedPartitionIndex: 1, - selectedGroupsLabel: "Some label", + selectedGroupsLabel: 'Some label', }, hasPartitionGroupComponents: false, format: 'Homework', @@ -493,7 +491,7 @@ describe(' for unit', () => { hasPartitionGroupComponents: true, userPartitionInfo: { selectedPartitionIndex: -1, - selectedGroupsLabel: "", + selectedGroupsLabel: '', }, }, }); diff --git a/src/course-outline/xblock-status/messages.js b/src/course-outline/xblock-status/messages.js index 79e018fc2a..33f3397624 100644 --- a/src/course-outline/xblock-status/messages.js +++ b/src/course-outline/xblock-status/messages.js @@ -76,4 +76,3 @@ const messages = defineMessages({ }); export default messages; -