diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index fbbca2cb5..452a1b7d0 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -20,7 +20,7 @@ jobs: - name: Use Node.js uses: actions/setup-node@v1 with: - node-version: '13.14' + node-version: '12.19' - run: npm ci - run: npm run type-check - run: npm run lint diff --git a/__tests__/pages/index.test.tsx b/__tests__/pages/index.test.tsx index 94354ef14..ed5168233 100644 --- a/__tests__/pages/index.test.tsx +++ b/__tests__/pages/index.test.tsx @@ -46,7 +46,6 @@ const posts = [ frontmatter: { title: 'Third post', date: 'January 3, 1980', - spoiler: '3...', keywords: ['keyword three'], }, fields: { @@ -78,7 +77,8 @@ describe('Homepage', () => { screen.getByText('A blog by Alessia Bellisario') ).toBeInTheDocument(); - // displays 3 posts + // displays 3 posts, and expects all to be there... + // ...even the node without a spoiler expect(screen.getAllByText(/post/i)).toHaveLength(3); posts.forEach(({ node: { frontmatter, fields } }) => { expect( @@ -87,9 +87,17 @@ describe('Homepage', () => { expect( screen.getByText(frontmatter.title || fields.slug) ).toHaveAttribute('href', fields.slug); - expect(screen.getByText(frontmatter.spoiler)).toBeInTheDocument(); }); + // expects the spoilers that do exist (they are optional) + // to be in the document + expect( + screen.getByText(posts[0].node.frontmatter.spoiler || '') + ).toBeInTheDocument(); + expect( + screen.getByText(posts[1].node.frontmatter.spoiler || '') + ).toBeInTheDocument(); + // can open and close details userEvent.click(screen.getByText(/filter by tag/i)); expect( diff --git a/src/pages/index.tsx b/src/pages/index.tsx index 1d928f2a0..ffd227995 100644 --- a/src/pages/index.tsx +++ b/src/pages/index.tsx @@ -97,10 +97,7 @@ const BlogIndex = ({ }) .map(({ node: { id, fields, frontmatter } }) => (
- {fields?.slug && - frontmatter?.title && - frontmatter?.spoiler && - frontmatter?.date ? ( + {fields?.slug && frontmatter?.title ? ( <>

{frontmatter.title} diff --git a/tsconfig.json b/tsconfig.json index 87e9accfc..20a5ea27a 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -10,5 +10,5 @@ "noFallthroughCasesInSwitch": true, "allowSyntheticDefaultImports": true }, - "include": ["src/**/*"] + "include": ["src/**/*", "__tests__/**/*"] }