Skip to content

Commit 6700076

Browse files
Merge pull request #256 from vtexdocs/feat/tests
Feat/Tests
2 parents 205a975 + c9eb2b6 commit 6700076

File tree

10 files changed

+3134
-3196
lines changed

10 files changed

+3134
-3196
lines changed

.github/workflows/cypress.yml

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,31 +6,19 @@ jobs:
66
steps:
77
- name: Checkout
88
uses: actions/checkout@v1
9-
- name: Use Node.js 14.x
10-
uses: actions/setup-node@v1
11-
with:
12-
node-version: 14.x
13-
- name: Install
14-
run: |
15-
yarn install --immutable --immutable-cache --check-cache
16-
- name: Build
17-
run: |
18-
yarn build
19-
env:
20-
GITHUB_PRIVATEKEY: ${{ secrets.PRIVATEKEY }}
21-
GITHUB_APPID: ${{ secrets.APPID }}
22-
GITHUB_INSTALLATIONID: ${{ secrets.INSTALLATIONID }}
239
- name: Waiting for 200 from the Netlify Preview
24-
uses: kamranayub/wait-for-netlify-action@2.0.0
10+
uses: jakepartusch/wait-for-netlify-action@v1.4
2511
id: wait-for-netflify-preview
2612
with:
2713
site_name: 'elated-hoover-5c29bf'
14+
max_timeout: 1800
2815
env:
29-
NETLIFY_TOKEN: ${{secrets.NETLIFY_TOKEN}}
16+
NETLIFY_TOKEN: ${{ secrets.NETLIFY_TOKEN }}
17+
- name: Fetch navigation.json
18+
uses: wei/curl@v1
19+
with:
20+
args: -o src/tests/cypress/fixtures/navigation.json https://developers.vtex.com/navigation.json
3021
- name: Cypress run
31-
uses: cypress-io/github-action@v2
22+
uses: cypress-io/github-action@v5
3223
env:
3324
CYPRESS_baseUrl: ${{ steps.wait-for-netflify-preview.outputs.url }}
34-
with:
35-
wait-on: ${{ steps.wait-for-netflify-preview.outputs.url }}
36-
wait-on-timeout: 90

cypress.config.mjs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { defineConfig } from 'cypress'
2+
3+
export default defineConfig({
4+
fixturesFolder: 'src/tests/cypress/fixtures',
5+
screenshotsFolder: 'src/tests/cypress/screenshots',
6+
videosFolder: 'src/tests/cypress/videos',
7+
downloadsFolder: 'src/tests/cypress/downloads',
8+
e2e: {
9+
specPattern: 'src/tests/cypress/integration/**/*.cy.{js,jsx,ts,tsx}',
10+
supportFile: 'src/tests/cypress/support/index.js',
11+
baseUrl: 'http://localhost:3000',
12+
},
13+
})

cypress.json

Lines changed: 0 additions & 10 deletions
This file was deleted.

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
"postinstall": "husky install",
1919
"cz-commit": "cz",
2020
"release": "standard-version",
21-
"index": "chmod +x ./algolia/scripts/scraper.sh && ./algolia/scripts/scraper.sh"
21+
"index": "chmod +x ./algolia/scripts/scraper.sh && ./algolia/scripts/scraper.sh",
22+
"cypress": "cypress open"
2223
},
2324
"dependencies": {
2425
"@openreplay/tracker": "^4.1.9",
@@ -58,6 +59,7 @@
5859
"search-insights": "^2.3.0",
5960
"sharp": "^0.31.2",
6061
"swr": "^1.3.0",
62+
"unist-builder": "^3.0.1",
6163
"unist-util-visit": "^4.1.1",
6264
"use-yarn": "^2.4.0",
6365
"uuid": "^9.0.0"
@@ -73,7 +75,7 @@
7375
"@typescript-eslint/parser": "^5.14.0",
7476
"@vtex/prettier-config": "^1.0.0",
7577
"@vtex/tsconfig": "^0.6.0",
76-
"cypress": "^9.5.2",
78+
"cypress": "12.5.1",
7779
"cz-conventional-changelog": "^3.3.0",
7880
"eslint": "^7.32.0",
7981
"eslint-config-next": "13.0.6",

src/tests/cypress/integration/api-guides-documentation.spec.js

Lines changed: 0 additions & 18 deletions
This file was deleted.

src/tests/cypress/integration/catalog-API-page.spec.js

Lines changed: 0 additions & 13 deletions
This file was deleted.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/// <reference types="cypress" />
2+
3+
import navigation from '../fixtures/navigation.json'
4+
5+
describe('Status of documentation pages', () => {
6+
const visitDocumentationPages = (slugPrefix) => {
7+
const visitPages = ({ slug, type, children }) => {
8+
const page = `${slugPrefix}/${slug}`
9+
if (type === 'markdown' || type === 'openapi')
10+
it(`Checks page ${page}`, () => cy.visit(page))
11+
12+
children.forEach(visitPages)
13+
}
14+
15+
return visitPages
16+
}
17+
18+
navigation.navbar.forEach(({ slugPrefix, categories }) => {
19+
categories.forEach(visitDocumentationPages(slugPrefix))
20+
})
21+
})

src/tests/cypress/integration/landing-page.spec.js

Lines changed: 0 additions & 27 deletions
This file was deleted.

src/utils/getHeadings.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import { toString } from 'mdast-util-to-string'
22
import { slugify } from 'utils/string-utils'
3-
import { visit, Node } from 'unist-util-visit'
3+
import { visit } from 'unist-util-visit'
4+
5+
import type { Node } from 'unist'
46
import type { Item } from 'components/table-of-contents'
57

68
interface Heading {

0 commit comments

Comments
 (0)