diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ed68ac4fa..28c96ee12 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,8 +99,8 @@ 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 @@ -116,26 +114,32 @@ 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 + record: false + video: true env: 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: Sanitize Test File Path + run: echo "SANITIZED_FILE=$(echo ${{ matrix.file }} | sed 's/\//_/g')" >> $GITHUB_ENV + + - 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: cypress-logs + name: "${{ env.SANITIZED_FILE }}-cypress-logs" path: cypress/videos - - name: Stop Stack working-directory: ./stack run: docker compose down 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', 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') }) 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') })