From 49f081404205d73fae70e802dae85ccab41a4499 Mon Sep 17 00:00:00 2001 From: Shinigami92 Date: Fri, 9 Sep 2022 10:31:01 +0200 Subject: [PATCH 1/8] test: e2e tests --- cypress/tsconfig.json | 7 +++++-- tsconfig.json | 3 ++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/cypress/tsconfig.json b/cypress/tsconfig.json index 5e8cb532f20..0446ab75018 100644 --- a/cypress/tsconfig.json +++ b/cypress/tsconfig.json @@ -1,8 +1,11 @@ { "compilerOptions": { "target": "ES5", - "lib": ["ES5", "DOM"], - "types": ["cypress"] + "lib": ["ES2015", "DOM"], + "types": ["cypress"], + "esModuleInterop": true, + "noEmit": true, + "resolveJsonModule": true }, "include": ["**/*.ts"] } diff --git a/tsconfig.json b/tsconfig.json index 1944ff18532..f96902ebaf3 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -15,7 +15,8 @@ // "noImplicitAny": true, // "noImplicitThis": true, "useUnknownInCatchVariables": true, - "stripInternal": true + "stripInternal": true, + "baseUrl": "." }, "include": ["src/**/*"], "exclude": ["node_modules"] From f5e9e2fe1b8d21f3e66540e7674f840a089a1ae7 Mon Sep 17 00:00:00 2001 From: Shinigami92 Date: Fri, 9 Sep 2022 10:55:42 +0200 Subject: [PATCH 2/8] test: exec e2e tests --- .github/workflows/ci.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a1691afe74f..5320059acfe 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -72,9 +72,12 @@ jobs: - name: Install deps run: pnpm install - - name: Run E2E + - name: Build docs run: pnpm run docs:build:ci + - name: Run e2e + run: pnpm run docs:test:e2e:run + lint: runs-on: ubuntu-latest name: 'Lint: node-18, ubuntu-latest' From 9d076dc7cf64e2eaeb478cf393dbbc92c249ceee Mon Sep 17 00:00:00 2001 From: Shinigami92 Date: Fri, 9 Sep 2022 11:17:03 +0200 Subject: [PATCH 3/8] ci: test --- .github/workflows/ci.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5320059acfe..279607e2fed 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -72,6 +72,9 @@ jobs: - name: Install deps run: pnpm install + - name: Install cypress binary + run: pnpm install cypress + - name: Build docs run: pnpm run docs:build:ci From bb2c52eb55537e0d4aac96d3005092c75f8b0b3e Mon Sep 17 00:00:00 2001 From: Shinigami92 Date: Fri, 9 Sep 2022 11:18:34 +0200 Subject: [PATCH 4/8] ci: disable cache --- .github/workflows/ci.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 279607e2fed..83f2ff6a3be 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -67,14 +67,10 @@ jobs: uses: actions/setup-node@v3 with: node-version: 18 - cache: 'pnpm' - name: Install deps run: pnpm install - - name: Install cypress binary - run: pnpm install cypress - - name: Build docs run: pnpm run docs:build:ci From 66a54d26a36163afdd0b45b616e2af240e77ade5 Mon Sep 17 00:00:00 2001 From: Shinigami92 Date: Fri, 9 Sep 2022 11:21:32 +0200 Subject: [PATCH 5/8] test: simulate test error --- cypress/e2e/smoke.cy.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cypress/e2e/smoke.cy.ts b/cypress/e2e/smoke.cy.ts index eb3cf1fb098..9863039777e 100644 --- a/cypress/e2e/smoke.cy.ts +++ b/cypress/e2e/smoke.cy.ts @@ -1,7 +1,7 @@ describe('Smoke Test', () => { beforeEach(() => { cy.visit('/guide/'); - cy.get('a[href="/api/animal.html"]').as('firstSectionLink'); + cy.get('a[href="/api/animala.html"]').as('firstSectionLink'); }); it('compiles the guide page', () => { From 7d890d4dadbfc9bebeed9af476315f187d6dde49 Mon Sep 17 00:00:00 2001 From: Shinigami92 Date: Fri, 9 Sep 2022 11:52:47 +0200 Subject: [PATCH 6/8] test: add api tests --- cypress/e2e/api.cy.ts | 38 ++++++++++++++++++++++++++++++++++++++ cypress/e2e/guide.cy.ts | 13 +++++++++++++ cypress/e2e/smoke.cy.ts | 26 -------------------------- 3 files changed, 51 insertions(+), 26 deletions(-) create mode 100644 cypress/e2e/api.cy.ts create mode 100644 cypress/e2e/guide.cy.ts delete mode 100644 cypress/e2e/smoke.cy.ts diff --git a/cypress/e2e/api.cy.ts b/cypress/e2e/api.cy.ts new file mode 100644 index 00000000000..d5195cf955e --- /dev/null +++ b/cypress/e2e/api.cy.ts @@ -0,0 +1,38 @@ +describe('API Test', () => { + it('navigates to the api index search', () => { + // given + cy.visit('/'); + + // when + cy.get('a').contains('API').click(); + + // then + cy.url().should('include', '/api/'); + cy.contains('API Reference'); + }); + + describe('API Reference', () => { + beforeEach(() => { + // given + cy.visit('/api/'); + }); + + it('should at least list more than 7 modules', () => { + cy.get('.api-group').should('have.length.above', 7); + }); + + it('should include at least 1 element in each module', () => { + cy.get('.api-group').each(($el) => { + cy.wrap($el).get('li a[href]').should('have.length.above', 0); + }); + }); + + it('should not have dead links', () => { + cy.get('.api-group li a[href]').each(($el) => { + cy.wrap($el).click(); + cy.get('VPContent').should('not.contain.text', 'PAGE NOT FOUND'); + cy.go(-1); + }); + }); + }); +}); diff --git a/cypress/e2e/guide.cy.ts b/cypress/e2e/guide.cy.ts new file mode 100644 index 00000000000..6186f93808e --- /dev/null +++ b/cypress/e2e/guide.cy.ts @@ -0,0 +1,13 @@ +describe('Guide Test', () => { + it('navigates to the getting started section', () => { + // given + cy.visit('/'); + + // when + cy.get('a').contains('Get Started').click(); + + // then + cy.url().should('include', '/guide/'); + cy.contains('Getting Started'); + }); +}); diff --git a/cypress/e2e/smoke.cy.ts b/cypress/e2e/smoke.cy.ts deleted file mode 100644 index 9863039777e..00000000000 --- a/cypress/e2e/smoke.cy.ts +++ /dev/null @@ -1,26 +0,0 @@ -describe('Smoke Test', () => { - beforeEach(() => { - cy.visit('/guide/'); - cy.get('a[href="/api/animala.html"]').as('firstSectionLink'); - }); - - it('compiles the guide page', () => { - cy.contains('Getting Started'); - }); - - it('renders this last code example in the code', () => { - // Click on any section in the sidebar - cy.get('@firstSectionLink') - .click() - // Make sure the number of code examples is the same between reloads - .get('.container pre code') - .then(($codeBlocks) => { - // Trigger a reload - cy.reload() - // Give the runtime a chance to update/fail - .wait(500) - .get('.container pre code') - .should('have.length', $codeBlocks.length); - }); - }); -}); From 1622c7840ff4ccbd08d5fe6aca0f674cb96312be Mon Sep 17 00:00:00 2001 From: Shinigami92 Date: Fri, 9 Sep 2022 12:07:47 +0200 Subject: [PATCH 7/8] test: nav through all api links --- cypress/e2e/api.cy.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/cypress/e2e/api.cy.ts b/cypress/e2e/api.cy.ts index d5195cf955e..c10b14ddb19 100644 --- a/cypress/e2e/api.cy.ts +++ b/cypress/e2e/api.cy.ts @@ -27,11 +27,15 @@ describe('API Test', () => { }); }); - it('should not have dead links', () => { - cy.get('.api-group li a[href]').each(($el) => { - cy.wrap($el).click(); - cy.get('VPContent').should('not.contain.text', 'PAGE NOT FOUND'); - cy.go(-1); + it.only('should not have dead links', () => { + cy.get('.api-group li').each(($el) => { + const text = $el.find('a').text(); + const link = $el.find('a').attr('href'); + + cy.visit(`/api/${link}`); + + cy.get('h2').should('include.text', text); + cy.go('back'); }); }); }); From 63a237cc549cceec98aa10e0d1e4c22210a3d72a Mon Sep 17 00:00:00 2001 From: Shinigami92 Date: Fri, 9 Sep 2022 12:14:44 +0200 Subject: [PATCH 8/8] test: nav through all api links --- cypress/e2e/api.cy.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cypress/e2e/api.cy.ts b/cypress/e2e/api.cy.ts index c10b14ddb19..ec21d3d3dc7 100644 --- a/cypress/e2e/api.cy.ts +++ b/cypress/e2e/api.cy.ts @@ -27,7 +27,7 @@ describe('API Test', () => { }); }); - it.only('should not have dead links', () => { + it('should not have dead links', () => { cy.get('.api-group li').each(($el) => { const text = $el.find('a').text(); const link = $el.find('a').attr('href'); @@ -35,6 +35,7 @@ describe('API Test', () => { cy.visit(`/api/${link}`); cy.get('h2').should('include.text', text); + cy.get('h1').should('not.include.text', 'PAGE NOT FOUND'); cy.go('back'); }); });