Skip to content

Commit

Permalink
Merge branch 'master' into feature/signup-password
Browse files Browse the repository at this point in the history
  • Loading branch information
flacial authored Aug 4, 2022
2 parents 340201c + 0adf6c5 commit d3f78e6
Show file tree
Hide file tree
Showing 35 changed files with 890 additions and 546 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# c0d3.com

<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->

[![All Contributors](https://img.shields.io/badge/all_contributors-20-orange.svg?style=flat-square)](#contributors-)

<!-- ALL-CONTRIBUTORS-BADGE:END -->

![CI](https://github.com/garageScript/c0d3.com/workflows/CI/badge.svg)
Expand All @@ -12,8 +14,8 @@ software engineers.

## Prerequisites

- Node.JS
- Git
- [Node.js](https://nodejs.org/en/)
- [Git](https://github.com/git-guides)

## How to Start

Expand All @@ -27,9 +29,7 @@ Follow

## Contributing

Watch the video below to find out how to develop with TypeScript in React

[![React TypeScript Tutorial](http://i3.ytimg.com/vi/Z5iWr6Srsj8/hqdefault.jpg)](https://www.youtube.com/watch?v=Z5iWr6Srsj8)
[Learn how to develop with TypeScript in React (video)](https://www.youtube.com/watch?v=Z5iWr6Srsj8)

### PR Criteria

Expand Down
32 changes: 16 additions & 16 deletions __tests__/__snapshots__/storyshots.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -11119,18 +11119,18 @@ Array [
</div>
</div>
<div
className="card-footer bg-white p-0"
className="card-footer d-flex bg-white p-0"
>
<a
className="btn border-end rounded-0 px-4 py-3 noUnderline"
className="text-dark d-block border-end rounded-0 px-4 py-3 noUnderline"
href="https://www.notion.so/garagescript/JS-0-Foundations-a43ca620e54945b2b620bcda5f3cf672"
rel="noopener noreferrer"
target="_blank"
>
LESSON
</a>
<a
className="btn border-end rounded-0 px-4 py-3 noUnderline"
className="text-dark border-end rounded-0 px-4 py-3 noUnderline"
href="/curriculum/js0"
onClick={[Function]}
onMouseEnter={[Function]}
Expand Down Expand Up @@ -11189,18 +11189,18 @@ exports[`Storyshots Components/LessonLayout Just Lesson Layout 1`] = `
</div>
</div>
<div
className="card-footer bg-white p-0"
className="card-footer d-flex bg-white p-0"
>
<a
className="btn border-end rounded-0 px-4 py-3 noUnderline"
className="text-dark d-block border-end rounded-0 px-4 py-3 noUnderline"
href="https://www.notion.so/garagescript/JS-0-Foundations-a43ca620e54945b2b620bcda5f3cf672"
rel="noopener noreferrer"
target="_blank"
>
LESSON
</a>
<a
className="btn border-end rounded-0 px-4 py-3 noUnderline"
className="text-dark border-end rounded-0 px-4 py-3 noUnderline"
href="/curriculum/js0"
onClick={[Function]}
onMouseEnter={[Function]}
Expand Down Expand Up @@ -11251,18 +11251,18 @@ exports[`Storyshots Components/LessonLayout With Text 1`] = `
</div>
</div>
<div
className="card-footer bg-white p-0"
className="card-footer d-flex bg-white p-0"
>
<a
className="btn border-end rounded-0 px-4 py-3 noUnderline"
className="text-dark d-block border-end rounded-0 px-4 py-3 noUnderline"
href="https://www.notion.so/garagescript/JS-0-Foundations-a43ca620e54945b2b620bcda5f3cf672"
rel="noopener noreferrer"
target="_blank"
>
LESSON
</a>
<a
className="btn border-end rounded-0 px-4 py-3 noUnderline"
className="text-dark border-end rounded-0 px-4 py-3 noUnderline"
href="/curriculum/js0"
onClick={[Function]}
onMouseEnter={[Function]}
Expand Down Expand Up @@ -11313,18 +11313,18 @@ exports[`Storyshots Components/LessonTitleCard Basic 1`] = `
</div>
</div>
<div
className="card-footer bg-white p-0"
className="card-footer d-flex bg-white p-0"
>
<a
className="btn border-end rounded-0 px-4 py-3 noUnderline"
className="text-dark d-block border-end rounded-0 px-4 py-3 noUnderline"
href="#"
rel="noopener noreferrer"
target="_blank"
>
LESSON
</a>
<a
className="btn border-end rounded-0 px-4 py-3 noUnderline"
className="text-dark border-end rounded-0 px-4 py-3 noUnderline"
href="/curriculum/js0"
onClick={[Function]}
onMouseEnter={[Function]}
Expand Down Expand Up @@ -11371,26 +11371,26 @@ exports[`Storyshots Components/LessonTitleCard Passed Lesson 1`] = `
</div>
</div>
<div
className="card-footer bg-white p-0"
className="card-footer d-flex bg-white p-0"
>
<a
className="btn border-end rounded-0 px-4 py-3 noUnderline"
className="text-dark d-block border-end rounded-0 px-4 py-3 noUnderline"
href="#"
rel="noopener noreferrer"
target="_blank"
>
LESSON
</a>
<a
className="btn border-end rounded-0 px-4 py-3 noUnderline"
className="text-dark border-end rounded-0 px-4 py-3 noUnderline"
href="/curriculum/js0"
onClick={[Function]}
onMouseEnter={[Function]}
>
CHALLENGES
</a>
<a
className="btn border-end rounded-0 px-4 py-3 noUnderline"
className="text-dark d-block border-end rounded-0 px-4 py-3 noUnderline"
href="/review/js0"
onClick={[Function]}
onMouseEnter={[Function]}
Expand Down
147 changes: 147 additions & 0 deletions __tests__/pages/admin/lessons/new/lessons.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
import React from 'react'
import Lessons from '../../../../../pages/admin/lessons/new/index'
import { MockedProvider } from '@apollo/client/testing'
import { act, render, waitFor } from '@testing-library/react'
import dummyLessonData from '../../../../../__dummy__/lessonData'
import dummySessionData from '../../../../../__dummy__/sessionData'
import dummyAlertData from '../../../../../__dummy__/alertData'
import '@testing-library/jest-dom'
import GET_APP from '../../../../../graphql/queries/getApp'
import GET_FLAGGED_EXERCISES from '../../../../../graphql/queries/getFlaggedExercises'

const mockExercises = [
{
flaggedAt: '1651723200000',
module: {
lesson: {
title: 'Arrays'
}
}
},
{
flaggedAt: '1641099600000',
module: {
lesson: {
title: 'Arrays'
}
}
},
{
flaggedAt: '1609563600000',
module: {
lesson: {
title: 'Foundations of JavaScript'
}
}
},
{
flaggedAt: null,
module: {
lesson: {
title: 'Arrays'
}
}
},
{
flaggedAt: '1357189200000',
module: {
lesson: {
title: 'Foundations of JavaScript'
}
}
},
{
flaggedAt: '1462420800000',
module: {
lesson: {
title: 'Foundations of JavaScript'
}
}
},
{
flaggedAt: null,
module: {
lesson: {
title: 'Foundations of JavaScript'
}
}
}
]

const mocks = {
lessonsLoaded: [
{
request: { query: GET_APP },
result: {
data: {
session: dummySessionData,
lessons: dummyLessonData,
alerts: dummyAlertData
}
}
},
{
request: { query: GET_FLAGGED_EXERCISES },
result: {
data: {
exercises: mockExercises
}
}
}
],
lessonsNotLoaded: [
{
request: { query: GET_APP },
result: {
data: {
session: dummySessionData,
lessons: undefined,
alerts: dummyAlertData
}
}
},
{
request: { query: GET_FLAGGED_EXERCISES },
result: {
data: {
exercises: mockExercises
}
}
}
]
}

describe('new admin lessons page tests', () => {
test('should render adminLessonCard components and show number of pending questions', async () => {
expect.assertions(4)

const { container, getByText, getAllByText } = render(
<MockedProvider mocks={mocks.lessonsLoaded} addTypename={false}>
<Lessons />
</MockedProvider>
)

// Used to wait for the query response to arrive
await act(async () => await new Promise(res => setTimeout(res, 0)))

await waitFor(() => expect(getByText('3 Pending Questions')).toBeTruthy())
expect(() => getByText('2 Pending Questions')).toBeTruthy()
expect(() => getAllByText('0 Pending Questions')).toBeTruthy()
expect(() => getByText('Arrays')).toBeTruthy()
})

test('should not render any components if lessons data does not load', async () => {
expect.assertions(2)

const { container, getByText, getAllByText } = render(
<MockedProvider mocks={mocks.lessonsNotLoaded}>
<Lessons />
</MockedProvider>
)

await act(async () => await new Promise(res => setTimeout(res, 0)))

expect(() => getAllByText('0 Pending Questions')).toThrow()
expect(() => getByText('Arrays')).toThrow()
})
})
13 changes: 10 additions & 3 deletions __tests__/pages/curriculum/[lessonSlug].test.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ describe('Lesson Page', () => {
// Used to wait for the query response to arrive
await act(async () => await new Promise(res => setTimeout(() => res(), 0)))

await waitFor(() => expect(container).toMatchSnapshot())
expect(container).toMatchSnapshot()
})

test('Should render correctly with invalid lesson route', async () => {
Expand All @@ -131,7 +131,10 @@ describe('Lesson Page', () => {

await waitFor(() => getByText(/Page not found/i))

await waitFor(() => expect(container).toMatchSnapshot())
// Used to wait for the query response to arrive
await new Promise(res => setTimeout(res, 0))

expect(container).toMatchSnapshot()
})
test("Should correctly render challenges page for students who hadn't passed previous lessons", async () => {
query['lessonSlug'] = 'js8'
Expand All @@ -156,6 +159,7 @@ describe('Lesson Page', () => {

await waitFor(() => getByRole('heading', { name: /Trees/i }))

// Used to wait for the query response to arrive
await new Promise(res => setTimeout(res, 0))

expect(container).toMatchSnapshot()
Expand Down Expand Up @@ -183,7 +187,10 @@ describe('Lesson Page', () => {
const element = await findByText(/Internal server error/i)
expect(element).toBeTruthy()

await waitFor(() => expect(container).toMatchSnapshot())
// Used to wait for the query response to arrive
await new Promise(res => setTimeout(res, 0))

expect(container).toMatchSnapshot()
})
test('Should render with nulled submissions', async () => {
query['lessonSlug'] = 'js1'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,11 +205,11 @@ exports[`Lesson Page Should correctly render challenges page for students who ha
</div>
</div>
<div
class="card-footer bg-white p-0"
class="card-footer d-flex bg-white p-0"
>
<a
class="btn border-end rounded-0 px-4 py-3 noUnderline"
class="text-dark border-end rounded-0 px-4 py-3 noUnderline"
href="/curriculum/js8"
>
CHALLENGES
Expand Down Expand Up @@ -909,18 +909,18 @@ exports[`Lesson Page Should render correctly with valid lesson route 1`] = `
</div>
</div>
<div
class="card-footer bg-white p-0"
class="card-footer d-flex bg-white p-0"
>
<a
class="btn border-end rounded-0 px-4 py-3 noUnderline"
class="text-dark d-block border-end rounded-0 px-4 py-3 noUnderline"
href="https://www.notion.so/garagescript/JS-1-Functions-01dd8400b85f40d083966908acbfa184"
rel="noopener noreferrer"
target="_blank"
>
LESSON
</a>
<a
class="btn border-end rounded-0 px-4 py-3 noUnderline"
class="text-dark border-end rounded-0 px-4 py-3 noUnderline"
href="/curriculum/js1"
>
CHALLENGES
Expand Down
Loading

0 comments on commit d3f78e6

Please sign in to comment.