diff --git a/__tests__/pages/exercises/[lessonSlug].test.js b/__tests__/pages/exercises/[lessonSlug].test.js
index ac2fb5cac..c309ff611 100644
--- a/__tests__/pages/exercises/[lessonSlug].test.js
+++ b/__tests__/pages/exercises/[lessonSlug].test.js
@@ -18,6 +18,7 @@ const session = {
describe('Exercises page', () => {
const { query } = useRouter()
query['lessonSlug'] = 'js0'
+
test('Should render correctly', async () => {
const mocks = [
{
@@ -41,6 +42,42 @@ describe('Exercises page', () => {
await waitFor(() =>
screen.getByRole('heading', { name: /Foundations of JavaScript/i })
)
+
+ screen.getByRole('link', { name: 'CHALLENGES' })
+ screen.getByRole('link', { name: 'EXERCISES' })
+ screen.getByRole('link', { name: 'LESSONS' })
+ })
+
+ test('Should not render lessons nav card tab if lesson docUrl is null', async () => {
+ const mocks = [
+ {
+ request: { query: GET_APP },
+ result: {
+ data: {
+ session,
+ lessons: dummyLessonData.map(lesson => ({
+ ...lesson,
+ docUrl: null
+ })),
+ alerts: dummyAlertData
+ }
+ }
+ }
+ ]
+
+ render(
+
+
+
+ )
+
+ await waitFor(() =>
+ screen.getByRole('heading', { name: /Foundations of JavaScript/i })
+ )
+
+ screen.getByRole('link', { name: 'CHALLENGES' })
+ screen.getByRole('link', { name: 'EXERCISES' })
+ expect(screen.queryByRole('link', { name: 'LESSONS' })).toBeNull()
})
test('Should render a 500 error page if the lesson data is null', async () => {
diff --git a/pages/exercises/[lessonSlug].tsx b/pages/exercises/[lessonSlug].tsx
index 331d7006c..df79c6f19 100644
--- a/pages/exercises/[lessonSlug].tsx
+++ b/pages/exercises/[lessonSlug].tsx
@@ -9,6 +9,7 @@ import Error, { StatusCode } from '../../components/Error'
import LoadingSpinner from '../../components/LoadingSpinner'
import GET_APP from '../../graphql/queries/getApp'
import AlertsDisplay from '../../components/AlertsDisplay'
+import NavCard from '../../components/NavCard'
const Exercises: React.FC> = ({ queryData }) => {
const { lessons, alerts } = queryData
@@ -23,9 +24,21 @@ const Exercises: React.FC> = ({ queryData }) => {
if (!currentLesson)
return
+ const tabs = [
+ ...(currentLesson.docUrl
+ ? [{ text: 'lessons', url: currentLesson.docUrl }]
+ : []),
+ { text: 'challenges', url: `/curriculum/${currentLesson.slug}` },
+ { text: 'exercises', url: `/exercises/${currentLesson.slug}` }
+ ]
+
return (
- {currentLesson.title}
+ tab.text === 'exercises')}
+ tabs={tabs}
+ />
+ {currentLesson.title}
{alerts && }
)