Skip to content

Commit

Permalink
Update CI to work with new django backend
Browse files Browse the repository at this point in the history
  • Loading branch information
thomashbrnrd committed Mar 12, 2024
1 parent 272c59a commit 36ffaa3
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 40 deletions.
27 changes: 12 additions & 15 deletions .github/workflows/test-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,27 @@ 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
- name: Cypress run
uses: cypress-io/github-action@v6
with:
node-version: 18
check-latest: true
cache: "npm"
cache-dependency-path: "frontend/package-lock.json"

- name: Install npm packages (for cypress)
run: npm ci
working-directory: ./frontend

- name: Test end to end (cypress)
run: FRONTEND_HOST=localhost FRONTEND_PORT=3000 npm run test:e2e-ci
working-directory: ./frontend
working-directory: ./frontend/frontend
start: npm run start
command: npm run test:e2e-ci

- name: Send artifacts
uses: actions/upload-artifact@v3
if: ${{ failure() }}
with:
name: cypress-screenshots
path: |
./frontend/cypress/screenshots/
./frontend/frontend/cypress/screenshots/
12 changes: 6 additions & 6 deletions frontend/cypress/e2e/firearm-fiability.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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')
Expand All @@ -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')
Expand Down
8 changes: 4 additions & 4 deletions frontend/cypress/e2e/firearm-identification.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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')
Expand Down
4 changes: 2 additions & 2 deletions frontend/cypress/e2e/firearm-securing.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
4 changes: 2 additions & 2 deletions frontend/cypress/e2e/old-mechanism-pistol-securing.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
4 changes: 2 additions & 2 deletions frontend/cypress/e2e/shoulder-bolt-rifle-securing.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
4 changes: 2 additions & 2 deletions frontend/cypress/e2e/typology-revolver-identification.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
12 changes: 6 additions & 6 deletions frontend/cypress/e2e/typology-revolver-securing.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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')
Expand Down Expand Up @@ -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')
Expand Down
2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down

0 comments on commit 36ffaa3

Please sign in to comment.