diff --git a/.github/workflows/test-e2e.yml b/.github/workflows/test-e2e.yml index 76527a1e..c8b7044b 100644 --- a/.github/workflows/test-e2e.yml +++ b/.github/workflows/test-e2e.yml @@ -8,25 +8,36 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 + with: + repository: datalab-mi/basegun-backend + + - uses: actions/checkout@v3 + with: + path: frontend - name: Start stack using docker compose run: docker compose up -d - - name: Setup nodejs (for cypress) - uses: actions/setup-node@v3 - with: - node-version: 18 - check-latest: true - cache: "npm" - cache-dependency-path: "frontend/package-lock.json" + # - name: Setup nodejs (for cypress) + # uses: actions/setup-node@v4 + # with: + # node-version: 18 + # cache: "npm" + # cache-dependency-path: "frontend/frontend/package-lock.json" - - name: Install npm packages (for cypress) - run: npm ci - working-directory: ./frontend + # - name: Install npm packages (for cypress) + # run: npm ci + # working-directory: ./frontend/frontend + + # - name: Test end to end (cypress) + # run: FRONTEND_HOST=localhost FRONTEND_PORT=3000 npm run test:e2e-ci - - name: Test end to end (cypress) - run: FRONTEND_HOST=localhost FRONTEND_PORT=3000 npm run test:e2e-ci - working-directory: ./frontend + - name: Cypress run + uses: cypress-io/github-action@v6 + with: + working-directory: ./frontend/frontend + start: npm run dev + command: npm run test:e2e-ci - name: Send artifacts uses: actions/upload-artifact@v3 @@ -34,4 +45,4 @@ jobs: with: name: cypress-screenshots path: | - ./frontend/cypress/screenshots/ + ./frontend/frontend/cypress/screenshots/ diff --git a/frontend/cypress/e2e/firearm-fiability.cy.js b/frontend/cypress/e2e/firearm-fiability.cy.js index 4fe45730..692b1cf1 100644 --- a/frontend/cypress/e2e/firearm-fiability.cy.js +++ b/frontend/cypress/e2e/firearm-fiability.cy.js @@ -9,10 +9,10 @@ describe('Firearm Fiability', () => { cy.contains('span', 'canon vers la droite') cy.getByDataTestid('select-file').as('fileInput') - cy.intercept('POST', '/api/upload').as('upload') + cy.intercept('POST', '/api/analyses/').as('upload') cy.get('@fileInput').selectFile('./cypress/images/pistolet-semi-auto.jpg', { force: true }) cy.wait('@upload').then(({ response }) => { - expect(response.statusCode).to.eq(200) + expect(response.statusCode).to.eq(201) }) cy.getByDataTestid('next-step').click() cy.url().should('contain', '/guide-identification/informations-complementaires') @@ -40,10 +40,10 @@ describe('Firearm Fiability', () => { cy.contains('span', 'canon vers la droite') cy.getByDataTestid('select-file').as('fileInput') - cy.intercept('POST', '/api/upload').as('upload') + cy.intercept('POST', '/api/analyses/').as('upload') cy.get('@fileInput').selectFile('./cypress/images/arme-medium.jpg', { force: true }) cy.wait('@upload').then(({ response }) => { - expect(response.statusCode).to.eq(200) + expect(response.statusCode).to.eq(201) }) cy.url().should('contain', '/guide-identification/resultat-typologie') cy.contains('p', 'Arme semi-automatique ou automatique') @@ -62,10 +62,10 @@ describe('Firearm Fiability', () => { cy.contains('span', 'canon vers la droite') cy.getByDataTestid('select-file').as('fileInput') - cy.intercept('POST', '/api/upload').as('upload') + cy.intercept('POST', '/api/analyses/').as('upload') cy.get('@fileInput').selectFile('./cypress/images/arme-low.jpg', { force: true }) cy.wait('@upload').then(({ response }) => { - expect(response.statusCode).to.eq(200) + expect(response.statusCode).to.eq(201) }) cy.url().should('contain', '/guide-identification/resultat-typologie') cy.contains('p', 'Catégorie Non déterminée') diff --git a/frontend/cypress/e2e/firearm-identification.cy.js b/frontend/cypress/e2e/firearm-identification.cy.js index fba5e0d7..fb5cf718 100644 --- a/frontend/cypress/e2e/firearm-identification.cy.js +++ b/frontend/cypress/e2e/firearm-identification.cy.js @@ -9,10 +9,10 @@ describe('Firearm Identification', () => { cy.contains('span', 'canon vers la droite') cy.getByDataTestid('select-file').as('fileInput') - cy.intercept('POST', '/api/upload').as('upload') + cy.intercept('POST', '/api/analyses/').as('upload') cy.get('@fileInput').selectFile('./cypress/images/pistolet-semi-auto.jpg', { force: true }) cy.wait('@upload').then(({ response }) => { - expect(response.statusCode).to.eq(200) + expect(response.statusCode).to.eq(201) }) cy.getByDataTestid('next-step').click() cy.url().should('contain', '/guide-identification/informations-complementaires') @@ -39,10 +39,10 @@ describe('Firearm Identification', () => { cy.contains('span', 'canon vers la droite') cy.getByDataTestid('select-file').as('fileInput') - cy.intercept('POST', '/api/upload').as('upload') + cy.intercept('POST', '/api/analyses/').as('upload') cy.get('@fileInput').selectFile('./cypress/images/pistolet-semi-auto.jpg', { force: true }) cy.wait('@upload').then(({ response }) => { - expect(response.statusCode).to.eq(200) + expect(response.statusCode).to.eq(201) }) cy.getByDataTestid('next-step').click() cy.url().should('contain', '/guide-identification/informations-complementaires') diff --git a/frontend/cypress/e2e/firearm-securing.cy.js b/frontend/cypress/e2e/firearm-securing.cy.js index acadd770..463b6e3a 100644 --- a/frontend/cypress/e2e/firearm-securing.cy.js +++ b/frontend/cypress/e2e/firearm-securing.cy.js @@ -3,10 +3,10 @@ describe('Securing Firearm and Identification', () => { cy.accueil() cy.miseEnSecurite() cy.getByDataTestid('select-file').as('fileInput') - cy.intercept('POST', '/api/upload').as('upload') + cy.intercept('POST', '/api/analyses/').as('upload') cy.get('@fileInput').selectFile('./cypress/images/pistolet-semi-auto.jpg', { force: true }) cy.wait('@upload').then(({ response }) => { - expect(response.statusCode).to.eq(200) + expect(response.statusCode).to.eq(201) }) cy.url().should('contain', '/mise-en-securite-choix-option-etape/1') cy.getByDataTestid('button-next').should('have.attr', 'disabled') diff --git a/frontend/cypress/e2e/old-mechanism-pistol-securing.cy.js b/frontend/cypress/e2e/old-mechanism-pistol-securing.cy.js index 2be7676a..fd3b2e95 100644 --- a/frontend/cypress/e2e/old-mechanism-pistol-securing.cy.js +++ b/frontend/cypress/e2e/old-mechanism-pistol-securing.cy.js @@ -3,10 +3,10 @@ describe('Old Mechanism Pistol Securing', () => { cy.accueil() cy.miseEnSecurite() cy.getByDataTestid('select-file').as('fileInput') - cy.intercept('POST', '/api/upload').as('upload') + cy.intercept('POST', '/api/analyses/').as('upload') cy.get('@fileInput').selectFile('./cypress/images/pistolet-ancien-a-percussion-monocoup.jpg', { force: true }) cy.wait('@upload').then(({ response }) => { - expect(response.statusCode).to.eq(200) + expect(response.statusCode).to.eq(201) }) cy.pasDeGuide() cy.getByDataTestid('arm-category').should('contain', 'Catégorie D') diff --git a/frontend/cypress/e2e/shoulder-bolt-rifle-securing.cy.js b/frontend/cypress/e2e/shoulder-bolt-rifle-securing.cy.js index 457b144c..3b4efa4c 100644 --- a/frontend/cypress/e2e/shoulder-bolt-rifle-securing.cy.js +++ b/frontend/cypress/e2e/shoulder-bolt-rifle-securing.cy.js @@ -3,10 +3,10 @@ describe('Shoulder Bolt Rifle Securing', () => { cy.accueil() cy.miseEnSecurite() cy.getByDataTestid('select-file').as('fileInput') - cy.intercept('POST', '/api/upload').as('upload') + cy.intercept('POST', '/api/analyses/').as('upload') cy.get('@fileInput').selectFile('./cypress/images/epaule-a-verrou.jpg', { force: true }) cy.wait('@upload').then(({ response }) => { - expect(response.statusCode).to.eq(200) + expect(response.statusCode).to.eq(201) }) cy.getVideo() cy.url().should('contain', '/mise-en-securite-tutoriel') diff --git a/frontend/cypress/e2e/typology-revolver-identification.cy.js b/frontend/cypress/e2e/typology-revolver-identification.cy.js index 7cfa5cf0..cb9d9565 100644 --- a/frontend/cypress/e2e/typology-revolver-identification.cy.js +++ b/frontend/cypress/e2e/typology-revolver-identification.cy.js @@ -9,10 +9,10 @@ describe('Typology Revolver Identification', () => { cy.contains('span', 'canon vers la droite') cy.getByDataTestid('select-file').as('fileInput') - cy.intercept('POST', '/api/upload').as('upload') + cy.intercept('POST', '/api/analyses/').as('upload') cy.get('@fileInput').selectFile('./cypress/images/revolver.jpg', { force: true }) cy.wait('@upload').then(({ response }) => { - expect(response.statusCode).to.eq(200) + expect(response.statusCode).to.eq(201) }) cy.getByDataTestid('next-step').click() cy.url().should('contain', '/guide-identification/informations-complementaires') diff --git a/frontend/cypress/e2e/typology-revolver-securing.cy.js b/frontend/cypress/e2e/typology-revolver-securing.cy.js index 20f5dca9..4838435e 100644 --- a/frontend/cypress/e2e/typology-revolver-securing.cy.js +++ b/frontend/cypress/e2e/typology-revolver-securing.cy.js @@ -3,10 +3,10 @@ describe('Typology Revolver Securing', () => { cy.accueil() cy.miseEnSecurite() cy.getByDataTestid('select-file').as('fileInput') - cy.intercept('POST', '/api/upload').as('upload') + cy.intercept('POST', '/api/analyses/').as('upload') cy.get('@fileInput').selectFile('./cypress/images/revolver.jpg', { force: true }) cy.wait('@upload').then(({ response }) => { - expect(response.statusCode).to.eq(200) + expect(response.statusCode).to.eq(201) }) cy.url().should('contain', '/mise-en-securite-choix-option-etape/1') cy.getByDataTestid('button-next').should('have.attr', 'disabled') @@ -25,10 +25,10 @@ describe('Typology Revolver Securing', () => { cy.accueil() cy.miseEnSecurite() cy.getByDataTestid('select-file').as('fileInput') - cy.intercept('POST', '/api/upload').as('upload') + cy.intercept('POST', '/api/analyses/').as('upload') cy.get('@fileInput').selectFile('./cypress/images/revolver.jpg', { force: true }) cy.wait('@upload').then(({ response }) => { - expect(response.statusCode).to.eq(200) + expect(response.statusCode).to.eq(201) }) cy.url().should('contain', '/mise-en-securite-choix-option-etape/1') cy.getByDataTestid('button-next').should('have.attr', 'disabled') @@ -57,10 +57,10 @@ describe('Typology Revolver Securing', () => { cy.accueil() cy.miseEnSecurite() cy.getByDataTestid('select-file').as('fileInput') - cy.intercept('POST', '/api/upload').as('upload') + cy.intercept('POST', '/api/analyses/').as('upload') cy.get('@fileInput').selectFile('./cypress/images/revolver.jpg', { force: true }) cy.wait('@upload').then(({ response }) => { - expect(response.statusCode).to.eq(200) + expect(response.statusCode).to.eq(201) }) cy.url().should('contain', '/mise-en-securite-choix-option-etape/1') cy.getByDataTestid('button-next').should('have.attr', 'disabled') diff --git a/frontend/package.json b/frontend/package.json index dd199ece..ab15bfa1 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -13,7 +13,7 @@ "format": "eslint . --fix --ignore-path ../.gitignore", "format:css": "stylelint --fix src/**/*.{css,vue}", "pretest:unit": "npm run lint", - "test:e2e-ci": "FRONTEND_HOST=localhost FRONTEND_PORT=3000 cypress run --e2e --browser firefox", + "test:e2e-ci": "FRONTEND_HOST=localhost FRONTEND_PORT=5173 cypress run --e2e --browser firefox", "test:e2e-open": "FRONTEND_HOST=localhost FRONTEND_PORT=5173 cypress open --e2e --browser firefox", "test:e2e-run": "FRONTEND_HOST=localhost FRONTEND_PORT=3000 cypress run --e2e --browser firefox" },