Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't show the number of concepts if Syllabus is disabled #3458

Merged
merged 2 commits into from Feb 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 11 additions & 8 deletions app/javascript/components/student/tracks-list/Track.tsx
Expand Up @@ -24,7 +24,7 @@ export const Track = ({ track }: { track: StudentTrack }): JSX.Element => {
<h3 className="--title">{track.title}</h3>
{!track.isJoined && (
<div className="items-center hidden md:flex">
{track.numConcepts > 5 ? (
{track.course ? (
<div className="--v3"> Learning Mode </div>
) : track.isNew ? (
<div className="--new">
Expand All @@ -50,13 +50,16 @@ export const Track = ({ track }: { track: StudentTrack }): JSX.Element => {
: `${track.numCompletedExercises}/`}
{track.numExercises} {pluralize('exercise', track.numExercises)}
</li>
<li>
<Icon icon="concepts" alt="Number of concepts" />
{track.numCompletedConcepts == undefined
? null
: `${track.numCompletedConcepts}/`}
{track.numConcepts} {pluralize('concept', track.numConcepts)}
</li>

{track.course && (
<li>
<Icon icon="concepts" alt="Number of concepts" />
{track.numCompletedConcepts == undefined
? null
: `${track.numCompletedConcepts}/`}
{track.numConcepts} {pluralize('concept', track.numConcepts)}
</li>
)}
</ul>

{track.isJoined && (
Expand Down
1 change: 1 addition & 0 deletions app/javascript/components/types.ts
Expand Up @@ -246,6 +246,7 @@ export type MentorSessionExercise = {
}

export type StudentTrack = {
course: boolean
slug: string
webUrl: string
iconUrl: string
Expand Down
5 changes: 2 additions & 3 deletions test/javascript/components/student/TracksList.test.jsx
Expand Up @@ -92,9 +92,8 @@ test('shows empty state and allows resetting', async () => {
userEvent.click(await screen.findByLabelText('Windows'))
userEvent.click(screen.getByRole('button', { name: /apply/i }))

await waitFor(() =>
expect(screen.getByText('No results found')).toBeInTheDocument()
)
const noResultsFound = await screen.findByText('No results found')
expect(noResultsFound).toBeInTheDocument()

userEvent.click(
screen.getByRole('button', { name: /reset search and filters/i })
Expand Down
37 changes: 19 additions & 18 deletions test/javascript/components/student/TracksList/Track.test.jsx
Expand Up @@ -4,25 +4,22 @@ import '@testing-library/jest-dom/extend-expect'
import { Track } from '../../../../../app/javascript/components/student/tracks-list/Track'

test('hides progress bar if track is unjoined', () => {
const { queryByTestId } = render(
<Track track={{ isJoined: false, isNew: false, tags: [] }} />
)
render(<Track track={{ isJoined: false, isNew: false, tags: [] }} />)

expect(queryByTestId('track-progress-bar')).not.toBeInTheDocument()
expect(screen.queryByTestId('track-progress-bar')).not.toBeInTheDocument()
})

test('hides joined status if track is unjoined', () => {
const { queryByText } = render(
<Track track={{ isJoined: false, isNew: false, tags: [] }} />
)
render(<Track track={{ isJoined: false, isNew: false, tags: [] }} />)

expect(queryByText('Joined')).not.toBeInTheDocument()
expect(screen.queryByText('Joined')).not.toBeInTheDocument()
})

test('shows completed concept exercises if track is joined', () => {
const { queryByText } = render(
render(
<Track
track={{
course: true,
isJoined: false,
isNew: false,
tags: [],
Expand All @@ -32,13 +29,14 @@ test('shows completed concept exercises if track is joined', () => {
/>
)

expect(queryByText('1/2 concepts')).toBeInTheDocument()
expect(screen.queryByText('1/2 concepts')).toBeInTheDocument()
})

test('shows number of concept exercises if track is unjoined', () => {
const { queryByText } = render(
render(
<Track
track={{
course: true,
isJoined: false,
isNew: false,
tags: [],
Expand All @@ -47,11 +45,11 @@ test('shows number of concept exercises if track is unjoined', () => {
/>
)

expect(queryByText('2 concepts')).toBeInTheDocument()
expect(screen.queryByText('2 concepts')).toBeInTheDocument()
})

test('shows completed practice exercises if track is joined', () => {
const { queryByText } = render(
render(
<Track
track={{
isJoined: false,
Expand All @@ -63,11 +61,11 @@ test('shows completed practice exercises if track is joined', () => {
/>
)

expect(queryByText('3/5 exercises')).toBeInTheDocument()
expect(screen.queryByText('3/5 exercises')).toBeInTheDocument()
})

test('shows number of practice exercises if track is unjoined', () => {
const { queryByText } = render(
render(
<Track
track={{
isJoined: false,
Expand All @@ -78,7 +76,7 @@ test('shows number of practice exercises if track is unjoined', () => {
/>
)

expect(queryByText('5 exercises')).toBeInTheDocument()
expect(screen.queryByText('5 exercises')).toBeInTheDocument()
})

test('shows new tag if track is new', () => {
Expand Down Expand Up @@ -126,10 +124,11 @@ test('hides new tag if track is joined', () => {
expect(screen.queryByText('New')).not.toBeInTheDocument()
})

test('shows learning mode tag if track has more than 5 concepts', () => {
test('shows learning mode tag if course mode is enabled', () => {
render(
<Track
track={{
course: true,
isJoined: false,
isNew: true,
tags: [],
Expand All @@ -139,12 +138,14 @@ test('shows learning mode tag if track has more than 5 concepts', () => {
)

expect(screen.getByText('Learning Mode')).toBeInTheDocument()
expect(screen.getByText('6 concepts')).toBeInTheDocument()
})

test('hides learning mode tag if track has less than 5 concepts', () => {
test('hides learning mode tag if course mode is disabled', () => {
render(
<Track
track={{
course: false,
isJoined: false,
isNew: true,
tags: [],
Expand Down
6 changes: 3 additions & 3 deletions yarn.lock
Expand Up @@ -2971,9 +2971,9 @@ caniuse-api@^3.0.0:
lodash.uniq "^4.5.0"

caniuse-lite@^1.0.0, caniuse-lite@^1.0.30001286, caniuse-lite@^1.0.30001297, caniuse-lite@^1.0.30001312:
version "1.0.30001374"
resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001374.tgz"
integrity sha512-mWvzatRx3w+j5wx/mpFN5v5twlPrabG8NqX2c6e45LCpymdoGqNvRkRutFUqpRTXKFQFNQJasvK0YT7suW6/Hw==
version "1.0.30001451"
resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001451.tgz"
integrity sha512-XY7UbUpGRatZzoRft//5xOa69/1iGJRBlrieH6QYrkKLIFn3m7OVEJ81dSrKoy2BnKsdbX5cLrOispZNYo9v2w==

capture-exit@^2.0.0:
version "2.0.0"
Expand Down