Skip to content

Commit

Permalink
test: add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
navinkarkera committed Jan 26, 2024
1 parent 12fb5e0 commit 7b447d7
Show file tree
Hide file tree
Showing 3 changed files with 526 additions and 15 deletions.
31 changes: 18 additions & 13 deletions src/course-outline/xblock-status/XBlockStatus.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,14 @@ const XBlockStatus = ({
})
}

if (!staffOnlyMessage) {
if (!staffOnlyMessage && isVertical) {
const { selectedPartitionIndex, selectedGroupsLabel } = userPartitionInfo;
if (selectedPartitionIndex !== -1 && !isNaN(selectedPartitionIndex) && isVertical) {
if (selectedPartitionIndex !== -1 && !isNaN(selectedPartitionIndex)) {
statusMessages.push({
icon: GroupsIcon,
text: intl.formatMessage(messages.restrictedUnitAccess, { selectedGroupsLabel }),
});
} else if (hasPartitionGroupComponents && isVertical) {
} else if (hasPartitionGroupComponents) {
statusMessages.push({
icon: GroupsIcon,
text: intl.formatMessage(messages.restrictedUnitAccessToSomeContent),
Expand All @@ -98,7 +98,7 @@ const XBlockStatus = ({
}

const releaseStatusDiv = () => (
<div className="d-flex align-items-center">
<div className="d-flex align-items-center" data-testid="release-status-div">
<span className="sr-only status-release-label">
{intl.formatMessage(messages.releaseStatusScreenReaderTitle)}
</span>
Expand All @@ -109,7 +109,7 @@ const XBlockStatus = ({
)

const gradingTypeDiv = () => (
<div className="d-flex align-items-center mr-1">
<div className="d-flex align-items-center mr-1" data-testid="grading-type-div">
<span className="sr-only status-grading-label">
{intl.formatMessage(messages.gradedAsScreenReaderLabel)}
</span>
Expand All @@ -123,15 +123,15 @@ const XBlockStatus = ({
const dueDateDiv = () => {
if (dueDate && isInstructorPaced) {
return (
<div className="status-grading-date">
<div className="status-grading-date" data-testid="due-date-div">
{intl.formatMessage(messages.dueLabel)} {dueDate}
</div>
)
}
}

const selfPacedRelativeDueWeeksDiv = () => (
<div className="d-flex align-items-center">
<div className="d-flex align-items-center" data-testid="self-paced-relative-due-weeks-div">
<Icon className="mr-1" size="sm" src={CalendarIcon} />
<span className="status-custom-grading-date">
{intl.formatMessage(messages.customDueDateLabel, { relativeWeeksDue })}
Expand All @@ -140,7 +140,9 @@ const XBlockStatus = ({
)

const explanatoryMessageDiv = () => (
<span>{explanatoryMessage}</span>
<span data-testid='explanatory-message-span'>
{explanatoryMessage}
</span>
)

const renderGradingTypeAndDueDate = () => {
Expand All @@ -150,8 +152,10 @@ const XBlockStatus = ({
<>
<div className="d-flex align-items-center">
{gradingTypeDiv()} -
<span className="sr-only status-proctored-exam-label">{intl.formatMessage(examValue)}</span>
<span className="mx-2">{intl.formatMessage(examValue)}</span>
<span className="sr-only">{intl.formatMessage(examValue)}</span>
<span className="mx-2" data-testid="exam-value-span">
{intl.formatMessage(examValue)}
</span>
{dueDateDiv()}
</div>
{showRelativeWeeks && (selfPacedRelativeDueWeeksDiv())}
Expand All @@ -178,7 +182,7 @@ const XBlockStatus = ({
}

const hideAfterDueMessage = () => (
<div className="d-flex align-items-center">
<div className="d-flex align-items-center" data-testid="hide-after-due-message">
<Icon className="mr-1" size="sm" src={HideIcon} />
<span className="status-hide-after-due-value">
{isSelfPaced
Expand All @@ -202,6 +206,7 @@ const XBlockStatus = ({
return (
<div
className="grading-mismatch-alert d-flex align-items-center p-4 mt-2 rounded shadow"
data-testid="grading-mismatch-alert"
>
<Icon className="mr-1 text-warning" size="lg" src={WarningIcon} />
{intl.formatMessage(messages.gradingPolicyMismatchText, { gradingType })}
Expand All @@ -213,9 +218,9 @@ const XBlockStatus = ({
const renderStatusMessages = () => {
if (statusMessages.length > 0) {
return (
<div className="border-top border-light mt-2 text-dark">
<div className="border-top border-light mt-2 text-dark" data-testid="status-messages-div">
{statusMessages.map(({ icon, text }) => (
<div className="d-flex align-items-center pt-1">
<div key={text} className="d-flex align-items-center pt-1">
<Icon className="mr-1" size="sm" src={icon} />
{text}
</div>
Expand Down
Loading

0 comments on commit 7b447d7

Please sign in to comment.