Skip to content

Commit

Permalink
Merge pull request #256 from vtexdocs/feat/tests
Browse files Browse the repository at this point in the history
Feat/Tests
  • Loading branch information
leonardoAnjos16 authored Feb 28, 2023
2 parents 205a975 + c9eb2b6 commit 6700076
Show file tree
Hide file tree
Showing 10 changed files with 3,134 additions and 3,196 deletions.
28 changes: 8 additions & 20 deletions .github/workflows/cypress.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,19 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v1
- name: Use Node.js 14.x
uses: actions/setup-node@v1
with:
node-version: 14.x
- name: Install
run: |
yarn install --immutable --immutable-cache --check-cache
- name: Build
run: |
yarn build
env:
GITHUB_PRIVATEKEY: ${{ secrets.PRIVATEKEY }}
GITHUB_APPID: ${{ secrets.APPID }}
GITHUB_INSTALLATIONID: ${{ secrets.INSTALLATIONID }}
- name: Waiting for 200 from the Netlify Preview
uses: kamranayub/wait-for-netlify-action@2.0.0
uses: jakepartusch/wait-for-netlify-action@v1.4
id: wait-for-netflify-preview
with:
site_name: 'elated-hoover-5c29bf'
max_timeout: 1800
env:
NETLIFY_TOKEN: ${{secrets.NETLIFY_TOKEN}}
NETLIFY_TOKEN: ${{ secrets.NETLIFY_TOKEN }}
- name: Fetch navigation.json
uses: wei/curl@v1
with:
args: -o src/tests/cypress/fixtures/navigation.json https://developers.vtex.com/navigation.json
- name: Cypress run
uses: cypress-io/github-action@v2
uses: cypress-io/github-action@v5
env:
CYPRESS_baseUrl: ${{ steps.wait-for-netflify-preview.outputs.url }}
with:
wait-on: ${{ steps.wait-for-netflify-preview.outputs.url }}
wait-on-timeout: 90
13 changes: 13 additions & 0 deletions cypress.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { defineConfig } from 'cypress'

export default defineConfig({
fixturesFolder: 'src/tests/cypress/fixtures',
screenshotsFolder: 'src/tests/cypress/screenshots',
videosFolder: 'src/tests/cypress/videos',
downloadsFolder: 'src/tests/cypress/downloads',
e2e: {
specPattern: 'src/tests/cypress/integration/**/*.cy.{js,jsx,ts,tsx}',
supportFile: 'src/tests/cypress/support/index.js',
baseUrl: 'http://localhost:3000',
},
})
10 changes: 0 additions & 10 deletions cypress.json

This file was deleted.

6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
"postinstall": "husky install",
"cz-commit": "cz",
"release": "standard-version",
"index": "chmod +x ./algolia/scripts/scraper.sh && ./algolia/scripts/scraper.sh"
"index": "chmod +x ./algolia/scripts/scraper.sh && ./algolia/scripts/scraper.sh",
"cypress": "cypress open"
},
"dependencies": {
"@openreplay/tracker": "^4.1.9",
Expand Down Expand Up @@ -58,6 +59,7 @@
"search-insights": "^2.3.0",
"sharp": "^0.31.2",
"swr": "^1.3.0",
"unist-builder": "^3.0.1",
"unist-util-visit": "^4.1.1",
"use-yarn": "^2.4.0",
"uuid": "^9.0.0"
Expand All @@ -73,7 +75,7 @@
"@typescript-eslint/parser": "^5.14.0",
"@vtex/prettier-config": "^1.0.0",
"@vtex/tsconfig": "^0.6.0",
"cypress": "^9.5.2",
"cypress": "12.5.1",
"cz-conventional-changelog": "^3.3.0",
"eslint": "^7.32.0",
"eslint-config-next": "13.0.6",
Expand Down
18 changes: 0 additions & 18 deletions src/tests/cypress/integration/api-guides-documentation.spec.js

This file was deleted.

13 changes: 0 additions & 13 deletions src/tests/cypress/integration/catalog-API-page.spec.js

This file was deleted.

21 changes: 21 additions & 0 deletions src/tests/cypress/integration/documentation-pages-status.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/// <reference types="cypress" />

import navigation from '../fixtures/navigation.json'

describe('Status of documentation pages', () => {
const visitDocumentationPages = (slugPrefix) => {
const visitPages = ({ slug, type, children }) => {
const page = `${slugPrefix}/${slug}`
if (type === 'markdown' || type === 'openapi')
it(`Checks page ${page}`, () => cy.visit(page))

children.forEach(visitPages)
}

return visitPages
}

navigation.navbar.forEach(({ slugPrefix, categories }) => {
categories.forEach(visitDocumentationPages(slugPrefix))
})
})
27 changes: 0 additions & 27 deletions src/tests/cypress/integration/landing-page.spec.js

This file was deleted.

4 changes: 3 additions & 1 deletion src/utils/getHeadings.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { toString } from 'mdast-util-to-string'
import { slugify } from 'utils/string-utils'
import { visit, Node } from 'unist-util-visit'
import { visit } from 'unist-util-visit'

import type { Node } from 'unist'
import type { Item } from 'components/table-of-contents'

interface Heading {
Expand Down
Loading

0 comments on commit 6700076

Please sign in to comment.