mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-05-28 18:26:54 +00:00
fix(client): uncheck chapter checkmarks when no challenges (#63560)
This commit is contained in:
@@ -16,6 +16,7 @@ function GreenNotCompleted(props: GreenNotCompletedProps): JSX.Element {
|
||||
<span className='sr-only'>{t('icons.not-passed')}</span>
|
||||
)}
|
||||
<svg
|
||||
data-testid='green-not-completed'
|
||||
aria-hidden='true'
|
||||
height='15'
|
||||
viewBox='0 0 200 200'
|
||||
|
||||
@@ -11,6 +11,7 @@ function GreenPass(props: GreenPassProps): JSX.Element {
|
||||
const { hushScreenReaderText = false, ...rest } = props;
|
||||
return (
|
||||
<svg
|
||||
data-testid='green-pass'
|
||||
{...(hushScreenReaderText && { 'aria-hidden': true })}
|
||||
{...(!hushScreenReaderText && { 'aria-label': t('icons.passed') })}
|
||||
height='15'
|
||||
|
||||
@@ -15,6 +15,7 @@ exports[`<ChallengeTitle/> > renders correctly 1`] = `
|
||||
</h1>
|
||||
<svg
|
||||
aria-label="icons.passed"
|
||||
data-testid="green-pass"
|
||||
height="15"
|
||||
viewBox="0 0 200 200"
|
||||
width="15"
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
import React from 'react';
|
||||
import { render, screen, within } from '@testing-library/react';
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { SuperBlocks } from '../../../../../shared-dist/config/curriculum';
|
||||
import { SuperBlockAccordion } from './super-block-accordion';
|
||||
|
||||
const mockStructure = {
|
||||
superBlock: SuperBlocks.RespWebDesign,
|
||||
chapters: [
|
||||
{
|
||||
dashedName: 'test-chapter',
|
||||
modules: [
|
||||
{
|
||||
dashedName: 'test-module',
|
||||
blocks: ['test-block']
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
describe('SuperBlockAccordion', () => {
|
||||
it('does not show completed checkmark when there are zero challenges in a chapter', () => {
|
||||
render(
|
||||
<SuperBlockAccordion
|
||||
challenges={[]}
|
||||
superBlock={SuperBlocks.RespWebDesign}
|
||||
structure={mockStructure}
|
||||
chosenBlock={''}
|
||||
completedChallengeIds={[]}
|
||||
/>
|
||||
);
|
||||
|
||||
expect(screen.queryByTestId('green-pass')).not.toBeInTheDocument();
|
||||
|
||||
const chapterButtons = screen.getAllByRole('button', {
|
||||
name: /test-chapter/i
|
||||
});
|
||||
const chapterButton = chapterButtons[0];
|
||||
const checkmark = within(chapterButton).getByTestId('green-not-completed');
|
||||
expect(checkmark).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
@@ -96,7 +96,7 @@ const Chapter = ({
|
||||
examSlug
|
||||
}: ChapterProps) => {
|
||||
const { t } = useTranslation();
|
||||
const isComplete = completedSteps === totalSteps;
|
||||
const isComplete = completedSteps === totalSteps && totalSteps > 0;
|
||||
const chapterLabel = t(`intro:${superBlock}.chapters.${dashedName}`);
|
||||
|
||||
const chapterButtonContent = (
|
||||
|
||||
Reference in New Issue
Block a user