From 5269bdbaa6ccf546860c8462bfddc776ebc53a64 Mon Sep 17 00:00:00 2001 From: Oluwatobi Bamidele Date: Mon, 23 Sep 2024 13:49:09 +0100 Subject: [PATCH 01/17] fix: list content of cypress directory --- .github/workflows/test.yml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ed68ac4fa..8a9db3a25 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -5,8 +5,7 @@ on: - master jobs: get-cypress-tests: - runs-on: - ubuntu-latest + runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v4 @@ -18,7 +17,6 @@ jobs: run: | find cypress/e2e -name '*.spec.js' -o -name '*.cy.ts' | jq -R -s -c 'split("\n") | map(select(. != ""))' - - name: List Cypress test files id: list-tests working-directory: ./sphinx-nav-fiber @@ -51,8 +49,8 @@ jobs: - name: Setup Node.js uses: actions/setup-node@v4 with: - node-version-file: '.nvmrc' - cache: 'yarn' + node-version-file: ".nvmrc" + cache: "yarn" - name: Clone Stack run: | git clone https://github.com/stakwork/sphinx-stack.git stack @@ -101,12 +99,15 @@ jobs: - name: Copy Node.json uses: canastro/copy-file-action@master with: - source: 'stack/relay/NODES.json' - target: 'relay/nodes.json' + source: "stack/relay/NODES.json" + target: "relay/nodes.json" - name: Install run: yarn --immutable + - name: Debug Cypress logs location + run: ls -R cypress + - name: Cypress run # Uses the official Cypress GitHub action https://github.com/cypress-io/github-action uses: cypress-io/github-action@v6 @@ -116,7 +117,7 @@ jobs: headless: true start: yarn run start-e2e spec: ${{ matrix.file }} - wait-on: 'http://localhost:3000' # Waits for above + wait-on: "http://localhost:3000" # Waits for above wait-on-timeout: 120 # Waits for 2 minutes # Records to Cypress Dashboard record: true @@ -135,7 +136,6 @@ jobs: name: cypress-logs path: cypress/videos - - name: Stop Stack working-directory: ./stack run: docker compose down From d39ca14c6c08dc02f365a181f56df1b2330410f3 Mon Sep 17 00:00:00 2001 From: Oluwatobi Bamidele Date: Mon, 23 Sep 2024 14:05:28 +0100 Subject: [PATCH 02/17] test: added always --- .github/workflows/test.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8a9db3a25..142e44fb5 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -105,9 +105,6 @@ jobs: - name: Install run: yarn --immutable - - name: Debug Cypress logs location - run: ls -R cypress - - name: Cypress run # Uses the official Cypress GitHub action https://github.com/cypress-io/github-action uses: cypress-io/github-action@v6 @@ -129,8 +126,12 @@ jobs: run: yarn run cy-comp continue-on-error: false + - name: Debug Cypress logs location + run: ls -R cypress + - name: Upload Cypress logs - if: failure() + # if: failure() + if: always() uses: actions/upload-artifact@v4 with: name: cypress-logs From f043bf23d713ca48e4c1d52172f36eb582ac295a Mon Sep 17 00:00:00 2001 From: Oluwatobi Bamidele Date: Mon, 23 Sep 2024 14:33:20 +0100 Subject: [PATCH 03/17] fix: show all files --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 142e44fb5..ea2d65301 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -127,7 +127,7 @@ jobs: continue-on-error: false - name: Debug Cypress logs location - run: ls -R cypress + run: ls -R - name: Upload Cypress logs # if: failure() From 6f6d21a9abf305f0ef280250b197cc2cdcac1395 Mon Sep 17 00:00:00 2001 From: Oluwatobi Bamidele Date: Mon, 23 Sep 2024 14:55:51 +0100 Subject: [PATCH 04/17] fix: get artifact by name --- .github/workflows/test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ea2d65301..8b58f04aa 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -127,14 +127,14 @@ jobs: continue-on-error: false - name: Debug Cypress logs location - run: ls -R + run: ls - name: Upload Cypress logs # if: failure() if: always() uses: actions/upload-artifact@v4 with: - name: cypress-logs + name: cypress-logs-${{ matrix.file }} path: cypress/videos - name: Stop Stack From 2a2e4be29476e14370c406da648a8ebe55dbb0dd Mon Sep 17 00:00:00 2001 From: Oluwatobi Bamidele Date: Mon, 23 Sep 2024 15:13:17 +0100 Subject: [PATCH 05/17] fix: allow video recording --- cypress.config.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cypress.config.ts b/cypress.config.ts index 7955b132a..80f9e2e5f 100644 --- a/cypress.config.ts +++ b/cypress.config.ts @@ -28,7 +28,7 @@ export default defineConfig({ watchForFileChanges: false, experimentalMemoryManagement: true, numTestsKeptInMemory: 1, - video: false, + video: true, }, component: { supportFile: './cypress/support/components.ts', From 5509c99518881cc6ba7c0d6bc9812164c489e4a1 Mon Sep 17 00:00:00 2001 From: Oluwatobi Bamidele Date: Mon, 23 Sep 2024 15:59:10 +0100 Subject: [PATCH 06/17] fix: load artifact on failure only --- .github/workflows/test.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8b58f04aa..f0d447437 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -130,11 +130,11 @@ jobs: run: ls - name: Upload Cypress logs - # if: failure() - if: always() + if: failure() + # if: always() uses: actions/upload-artifact@v4 with: - name: cypress-logs-${{ matrix.file }} + name: cypress-logs path: cypress/videos - name: Stop Stack From 793628735d02d5ad0ef01ee4817652afe1409505 Mon Sep 17 00:00:00 2001 From: Oluwatobi Bamidele Date: Mon, 23 Sep 2024 16:13:39 +0100 Subject: [PATCH 07/17] fix: see content of cypress test --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f0d447437..4773e132f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -127,7 +127,7 @@ jobs: continue-on-error: false - name: Debug Cypress logs location - run: ls + run: ls -R cypress - name: Upload Cypress logs if: failure() From ba5836a7c4ded36354780ceff4a2f2409c36391f Mon Sep 17 00:00:00 2001 From: Oluwatobi Bamidele Date: Mon, 23 Sep 2024 16:44:47 +0100 Subject: [PATCH 08/17] fix: ensure video is recorded --- .github/workflows/test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4773e132f..1734e944f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -118,6 +118,7 @@ jobs: wait-on-timeout: 120 # Waits for 2 minutes # Records to Cypress Dashboard record: true + video: true env: CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }} # created by the GH Action automatically From 92704e6e4f52b8c4ffa13906e3e01491559756c1 Mon Sep 17 00:00:00 2001 From: Oluwatobi Bamidele Date: Mon, 23 Sep 2024 16:55:16 +0100 Subject: [PATCH 09/17] fix: don't record --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1734e944f..a54356993 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -117,7 +117,7 @@ jobs: wait-on: "http://localhost:3000" # Waits for above wait-on-timeout: 120 # Waits for 2 minutes # Records to Cypress Dashboard - record: true + record: false video: true env: CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }} From 459532d34ad2e7f4f05e249d4a652b36847f58b9 Mon Sep 17 00:00:00 2001 From: Oluwatobi Bamidele Date: Mon, 23 Sep 2024 17:16:54 +0100 Subject: [PATCH 10/17] fix: try to figure matrix file --- .github/workflows/test.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a54356993..afd7991af 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -127,8 +127,12 @@ jobs: run: yarn run cy-comp continue-on-error: false + - name: Debug test files + run: | + echo ${{ matrix.file }} + - name: Debug Cypress logs location - run: ls -R cypress + run: ls -R - name: Upload Cypress logs if: failure() From 7ff03d4f8d3503ca16e34fbb812589c990630702 Mon Sep 17 00:00:00 2001 From: Oluwatobi Bamidele Date: Mon, 23 Sep 2024 18:04:32 +0100 Subject: [PATCH 11/17] fix: remove component test --- .github/workflows/test.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index afd7991af..b75edafef 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -123,9 +123,9 @@ jobs: CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }} # created by the GH Action automatically GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Component tests - run: yarn run cy-comp - continue-on-error: false + # - name: Component tests + # run: yarn run cy-comp + # continue-on-error: false - name: Debug test files run: | From e996158ee466a2c02420f8fff7882041bc0cc447 Mon Sep 17 00:00:00 2001 From: Oluwatobi Bamidele Date: Mon, 23 Sep 2024 18:22:52 +0100 Subject: [PATCH 12/17] fix: list cypress content --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b75edafef..2cce341e0 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -132,7 +132,7 @@ jobs: echo ${{ matrix.file }} - name: Debug Cypress logs location - run: ls -R + run: ls -R cypress - name: Upload Cypress logs if: failure() From 9c0547bc8e7a6c2794a7a821ba3736aa4a1bde15 Mon Sep 17 00:00:00 2001 From: Oluwatobi Bamidele Date: Mon, 23 Sep 2024 18:41:15 +0100 Subject: [PATCH 13/17] fix: always save all cypress test --- .github/workflows/test.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2cce341e0..b18f09565 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -135,11 +135,11 @@ jobs: run: ls -R cypress - name: Upload Cypress logs - if: failure() - # if: always() + # if: failure() + if: always() uses: actions/upload-artifact@v4 with: - name: cypress-logs + name: ${{ matrix.file }} path: cypress/videos - name: Stop Stack From 826db068a84deb29f3fabdd9360c16c4795e9fc4 Mon Sep 17 00:00:00 2001 From: Oluwatobi Bamidele Date: Mon, 23 Sep 2024 19:15:00 +0100 Subject: [PATCH 14/17] fix: use cypress file name --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b18f09565..78548ee8f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -139,7 +139,7 @@ jobs: if: always() uses: actions/upload-artifact@v4 with: - name: ${{ matrix.file }} + name: ${{ matrix.file | replace('/', '_') }}-cypress-logs path: cypress/videos - name: Stop Stack From da3f65341c55e09e24bc61c954423d3b6860400e Mon Sep 17 00:00:00 2001 From: Oluwatobi Bamidele Date: Mon, 23 Sep 2024 19:27:35 +0100 Subject: [PATCH 15/17] fix: sanitize file name --- .github/workflows/test.yml | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 78548ee8f..82a4430fa 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -127,19 +127,18 @@ jobs: # run: yarn run cy-comp # continue-on-error: false - - name: Debug test files - run: | - echo ${{ matrix.file }} + - name: Sanitize Test File Path + run: echo "SANITIZED_FILE=$(echo ${{ matrix.file }} | sed 's/\//_/g')" >> $GITHUB_ENV - - name: Debug Cypress logs location - run: ls -R cypress + - name: Debug sanitized file + run: echo "Sanitized file $SANITIZED_FILE" - name: Upload Cypress logs # if: failure() if: always() uses: actions/upload-artifact@v4 with: - name: ${{ matrix.file | replace('/', '_') }}-cypress-logs + name: "${{ env.SANITIZED_FILE }}-cypress-logs" path: cypress/videos - name: Stop Stack From 9dbf13fa255ae2c1bc218dc9285d1fb3f6e9ac03 Mon Sep 17 00:00:00 2001 From: Oluwatobi Bamidele Date: Mon, 23 Sep 2024 19:42:01 +0100 Subject: [PATCH 16/17] fix: check for 402 when adding content --- .github/workflows/test.yml | 1 - cypress/e2e/addContent/addWebpage.cy.ts | 13 ++++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 82a4430fa..28c96ee12 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -134,7 +134,6 @@ jobs: run: echo "Sanitized file $SANITIZED_FILE" - name: Upload Cypress logs - # if: failure() if: always() uses: actions/upload-artifact@v4 with: diff --git a/cypress/e2e/addContent/addWebpage.cy.ts b/cypress/e2e/addContent/addWebpage.cy.ts index 5f5276686..8224ea6d2 100644 --- a/cypress/e2e/addContent/addWebpage.cy.ts +++ b/cypress/e2e/addContent/addWebpage.cy.ts @@ -15,7 +15,18 @@ describe('Add Webpage Content', () => { cy.get('[data-testid="skip-location-btn"').click() cy.get('[data-testid="check-icon"]').click() - cy.wait('@addWebpage') + cy.wait('@addWebpage').then((interception) => { + //check we get a 402 response code, when trying to add content for the first time + expect(interception.response.statusCode).to.eq(402) + }) + + cy.intercept({ + method: 'POST', + url: 'http://localhost:8444/api/add_node*', + }).as('addWebpage2') + + cy.wait('@addWebpage2') + cy.get('.Toastify__toast-body').should('have.text', 'Content Added') cy.get('#addContent').should('not.exist') }) From dacc5747891499b9bf5121fd4671581c6fd63164 Mon Sep 17 00:00:00 2001 From: Oluwatobi Bamidele Date: Mon, 23 Sep 2024 19:43:19 +0100 Subject: [PATCH 17/17] fix: also check for 402 when adding youtube --- cypress/e2e/addContent/addYoutube.cy.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/cypress/e2e/addContent/addYoutube.cy.ts b/cypress/e2e/addContent/addYoutube.cy.ts index 799f10913..288569bbf 100644 --- a/cypress/e2e/addContent/addYoutube.cy.ts +++ b/cypress/e2e/addContent/addYoutube.cy.ts @@ -15,7 +15,18 @@ describe('Add Youtube Content', () => { cy.get('[data-testid="skip-location-btn"').click() cy.get('[data-testid="check-icon"]').click() - cy.wait('@addYoutube') + cy.wait('@addYoutube').then((interception) => { + //check we get a 402 response code, when trying to add content for the first time + expect(interception.response.statusCode).to.eq(402) + }) + + cy.intercept({ + method: 'POST', + url: 'http://localhost:8444/api/add_node*', + }).as('addYoutube2') + + cy.wait('@addYoutube2') + cy.get('.Toastify__toast-body').should('have.text', 'Content Added') cy.get('#addContent').should('not.exist') })