Skip to content

Commit

Permalink
feat: ❇️ add tutorial to secure a firearm (#159)
Browse files Browse the repository at this point in the history
* refactor: ♻️ remove swiper component and add page instead

* refactor: ♻️ remove swiper component and add page instead

* refactor: ♻️ refactoring StartPage

* chore: ⬆️ Upgrade dependancies

* feat: 🐛 Fix routing

* feat: ✨ Add 2 buttons on StartPage

* feat: ✨ Add new stepper to securing firearm

* style: 🎨

* style: 💄 Move stepper title inline

* feat: 💄 Update Basegun baseline

* feat: ✨ Add tutorial content to secure a firearm

* feat: 🎨 Add new identification guide

* WIP identification stepper

* fix: 🐛 Fix issues in routing

* chore: ⬆️ Upgrade dependancies

* refactor: 🎨 Replace OnboardingPage by Swiper

* refactor: 🎨

* refactor: ♻️ Refactoring on page result

* fix: 🎨 Improve navigation in identificationGuide

* style: 💄 Add style on ResultPage

* feat: ⚡ WIP : Switch to different routes for each tutorial

* add test video to secure a firearm

* feat: ✨ Add securing-firearm-util.js file

* fix: ✅ Fix tests E2E in securing branch

* split securing-firearms-utils.js in 12 specifics files

* feat: ⚡ Fix selectAmmo for dummy typologies

* WIP

* WIP MES

* upgrade dependencies

* Wip MES

* Add new photos and videos in several typologies

* Add specific select options for revolver

* Change legal category if revolver black powder

* Add step 3 options for revolver

* Add content and style on accordions title

* wip css integration

* add minified header on mobile

* style: 💄 Add whole logo only on start pages

* style: 💄 Add whole logo only on start pages

* fix DsfrRadioButton rich image ratio

* add accordion design to revolver-1873-fr

* add video parts to accordion design

* refactor: ♻️ Remove useless code and clean code

* refactor: ♻️ Renaming components

* refactor: ♻️ Add highlight bold on tutorial texts manipulations

* refactor: ♻️ remove useless const identificationTutorial

* wip-refacto

* refactor: ♻️ improve navigation in guideSecuringFirearms

* perf: ♻️ Downsize too big photos

* refactoring titles styles

* chore: ⬇️ Downgrade Cypress from 13.1.0 to 12.17.4

* refactor: ⚡ Make accordion tutorial only visible for revolver 1873 typology

* style: 💄 add new routes names and new icons on securing tutorial

* feat: ✨ add a different security message for civilians

* fix: 🐛 fix tutorial display for revolver different from 1892 and 1873fr

* style: 💄 add new images with focus for securing firearm

* style: 💄 add new photos with circle

* refactoring titles styles

* refactor: ♻️ wip refactor selectOption component

* fix: 🐛 fix navigation for revolver typology

* refactor: ♻️ Fix refactoring selectOption component

* chore: ⬆️ upgrade dependencies

* [WIP] test: 🧪 tests/e2e (#176)

* chore: 🔧 add start script

* refactor: 🔥 remove unused code

* chore: 🚨 improve eslint config

* test: ✅ add new test to identificate a firearm

* test: ✅ add new test to securing firearm

* fix: ✅ fix errors and variable name

* fix: ✅ triying to fix video loading issue

* test: ✅ add new test to identificate firearm fiability

* chore: ⬆️ upgrade dependencies in frontend

* test: ✅ add new test to identificate revolver typology

* test: ✅ add new test to identificate revolver typology

* test: ✅ add new test to securing shoulder bolt rifle

* test: ✅ add new test to securing old mechanism pistol

* test: 🔨 add new commands for tests e2e

* test: ✅ update existing tests with new commands

* test: ✅ add new test for check if it's FSI or Civilians recommendations

* test: ✅ update tests and files

* test: ✅ update tests and files

---------

Co-authored-by: Nadeige COUTHON <[email protected]>

* feat: ✨ handle video in options steps (#187)

* feat: ✨ handle video in options steps

* style: 💄 updated revolver securing first steps video

* style: 💄 updated revolver securing first steps video

* style: 💄 update revolver barrel video and instructions

* style: 💄 update revolver choice display

* style: 💄 updated shotgun videos

* test: ✅ skip fiability test

---------

Co-authored-by: David Mendy <[email protected]>
Co-authored-by: nutfdt <[email protected]>
  • Loading branch information
3 people authored and thomashbrnrd committed Oct 24, 2023
1 parent 5a738b9 commit 2ccb4f6
Show file tree
Hide file tree
Showing 208 changed files with 6,017 additions and 3,848 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ Try to find error log
* In terminal, run `docker logs basegun-backend`
* If you cannot access terminal or don't see anything, go to `localhost:5000/logs` or `preprod.basegun.fr/logs` to see latest logs.

=> Error "missing model": Download model from the url specified in the [backend Dockerfile](https://github.com/datalab-mi/Basegun/blob/develop/backend/Dockerfile).
=> ErrorPage "missing model": Download model from the url specified in the [backend Dockerfile](https://github.com/datalab-mi/Basegun/blob/develop/backend/Dockerfile).

### The website runs the analysis, but no image shows up
Use browser html inspector to find the url given in the image src.
Expand Down
33 changes: 33 additions & 0 deletions docker-compose-backend.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
version: '3.8'
services:
backend:
build:
args:
- http_proxy
- https_proxy
- no_proxy
- VERSION=${TAG:-2.0}
- CACERT_LOCATION
context: ./backend
target: ${BUILD_TARGET:-dev}
container_name: basegun-backend
environment:
- PATH_LOGS=/app/logs
- OS_USERNAME
- OS_PASSWORD
- OS_PROJECT_NAME
- http_proxy
- https_proxy
- UVICORN_LOG_LEVEL=${UVICORN_LOG_LEVEL}
- LOG_LEVEL=${UVICORN_LOG_LEVEL}
- no_proxy
- WORKSPACE=dev
- REQUESTS_CA_BUNDLE=$CACERT_LOCATION
image: basegun-backend:${TAG:-2.0}-dev
ports:
- 5000:5000
volumes:
- $PWD/backend/src:/app/src
- $PWD/backend/tests:/app/tests
- $PWD/backend/logs:/app/logs
- /app/src/weights
12 changes: 12 additions & 0 deletions frontend/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# EditorConfig is awesome: https://EditorConfig.org

# top-most EditorConfig file
root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
2 changes: 1 addition & 1 deletion frontend/src/.eslintrc.js → frontend/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ module.exports = {
},
},
{
files: ['**/src/**/*.e2e.js*'],
files: ['**/src/**/*.e2e.js*', '**/src/**/*.cy.js'],
globals: {
cy: true,
},
Expand Down
2 changes: 1 addition & 1 deletion frontend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ ARG NODE_EXTRA_CA_CERTS
COPY ./cert/. /etc/ssl/certs/

COPY ./package.json ./package-lock.json ./
RUN npm ci
RUN npm ci --legacy-peer-deps

COPY src ./src
COPY public ./public
Expand Down
10 changes: 5 additions & 5 deletions frontend/cypress.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ const frontendPort = process.env.FRONTEND_PORT

module.exports = defineConfig({
e2e: {
specPattern: "cypress/e2e/**/*.{cy,spec}.{js,ts}",
specPattern: 'cypress/e2e/**/*.{cy,spec}.{js,ts}',
baseUrl: `http://${frontendHost}:${frontendPort}`,
// NEO - Crosscall X4 - Résolution : 18:9
// Iphone XR
viewportWidth: 414,
viewportHeight: 896,
viewportWidth: 414,
viewportHeight: 896,
video: false,
}
})
},
})
76 changes: 76 additions & 0 deletions frontend/cypress/e2e/firearm-fiability.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
describe('Firearm Fiability', () => {
it.skip('should identificate firearm with high fiability', () => {
cy.accueil()
cy.getByDataTestid('identification')
.contains('J’ai déjà mis mon arme en sécurité, je veux l’identifier')
.click()
cy.url().should('contain', '/instructions')
cy.contains('h3', 'Pour un résultat optimal')
cy.contains('span', 'canon vers la droite')

cy.getByDataTestid('select-file').as('fileInput')
cy.intercept('POST', '/api/upload').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)
})
cy.getByDataTestid('next-step').click()
cy.url().should('contain', '/guide-identification/informations-complementaires')
cy.getByDataTestid('explanation').should('contain', 'questions supplémentaires')
cy.getByDataTestid('next-step').click()
cy.url().should('contain', '/guide-identification/munition-type')
cy.getByDataTestid('next-step').should('have.attr', 'disabled')
cy.contains('cartouches').first().click()
cy.getByDataTestid('next-step').should('not.have.attr', 'disabled')
cy.getByDataTestid('next-step').click()
cy.url().should('contain', '/guide-identification/resultat-final')
cy.getByDataTestid('arm-category').should('contain', 'Catégorie B')
cy.getByDataTestid('arm-category').should(() => {
expect(localStorage.getItem('confidenceLevel')).to.eq('"high"')
})
})

it.skip('should identificate firearm with medium fiability', () => {
cy.accueil()
cy.getByDataTestid('identification')
.contains('J’ai déjà mis mon arme en sécurité, je veux l’identifier')
.click()
cy.url().should('contain', '/instructions')
cy.contains('h3', 'Pour un résultat optimal')
cy.contains('span', 'canon vers la droite')

cy.getByDataTestid('select-file').as('fileInput')
cy.intercept('POST', '/api/upload').as('upload')
cy.get('@fileInput').selectFile('./cypress/images/arme-medium.jpg', { force: true })
cy.wait('@upload').then(({ response }) => {
expect(response.statusCode).to.eq(200)
})
cy.url().should('contain', '/guide-identification/resultat-typologie')
cy.contains('p', 'Arme semi-automatique ou automatique')
cy.get('h2').should(() => {
expect(localStorage.getItem('confidenceLevel')).to.eq('"medium"')
})
})

it.skip('should identificate firearm with low fiability', () => {
cy.accueil()
cy.getByDataTestid('identification')
.contains('J’ai déjà mis mon arme en sécurité, je veux l’identifier')
.click()
cy.url().should('contain', '/instructions')
cy.contains('h3', 'Pour un résultat optimal')
cy.contains('span', 'canon vers la droite')

cy.getByDataTestid('select-file').as('fileInput')
cy.intercept('POST', '/api/upload').as('upload')
cy.get('@fileInput').selectFile('./cypress/images/arme-low.jpg', { force: true })
cy.wait('@upload').then(({ response }) => {
expect(response.statusCode).to.eq(200)
})
cy.url().should('contain', '/guide-identification/resultat-typologie')
cy.contains('p', 'Catégorie Non déterminée')
cy.get('h2').should(() => {
expect(localStorage.getItem('confidenceLevel')).to.eq('"low"')
})
})
})
61 changes: 61 additions & 0 deletions frontend/cypress/e2e/firearm-identification.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
describe('Firearm Identification', () => {
it('should identificate real firearm', () => {
cy.accueil()
cy.getByDataTestid('identification')
.contains('J’ai déjà mis mon arme en sécurité, je veux l’identifier')
.click()
cy.url().should('contain', '/instructions')
cy.contains('h3', 'Pour un résultat optimal')
cy.contains('span', 'canon vers la droite')

cy.getByDataTestid('select-file').as('fileInput')
cy.intercept('POST', '/api/upload').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)
})
cy.getByDataTestid('next-step').click()
cy.url().should('contain', '/guide-identification/informations-complementaires')
cy.getByDataTestid('explanation').should('contain', 'questions supplémentaires')
cy.getByDataTestid('next-step').click()
cy.url().should('contain', '/guide-identification/munition-type')
cy.getByDataTestid('next-step').should('have.attr', 'disabled')
cy.contains('cartouches').first().click()
cy.getByDataTestid('next-step').should('not.have.attr', 'disabled')
cy.getByDataTestid('next-step').click()
cy.url().should('contain', '/guide-identification/resultat-final')
cy.getByDataTestid('arm-category').should('contain', 'Catégorie B')
cy.getByDataTestid('return-to-home-end').click()
cy.url().should('contain', '/accueil')
})

it('should identificate dummy firearm', () => {
cy.accueil()
cy.getByDataTestid('identification')
.contains('J’ai déjà mis mon arme en sécurité, je veux l’identifier')
.click()
cy.url().should('contain', '/instructions')
cy.contains('h3', 'Pour un résultat optimal')
cy.contains('span', 'canon vers la droite')

cy.getByDataTestid('select-file').as('fileInput')
cy.intercept('POST', '/api/upload').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)
})
cy.getByDataTestid('next-step').click()
cy.url().should('contain', '/guide-identification/informations-complementaires')
cy.getByDataTestid('explanation').should('contain', 'questions supplémentaires')
cy.getByDataTestid('next-step').click()
cy.getByDataTestid('next-step').should('have.attr', 'disabled')
cy.contains('billes').first().click()
cy.url().should('contain', '/guide-identification/munition-type')
cy.getByDataTestid('next-step').should('not.have.attr', 'disabled')
cy.getByDataTestid('next-step').click()
cy.url().should('contain', '/guide-identification/resultat-final')
cy.getByDataTestid('arm-category').should('contain', 'Catégorie Non Classée')
cy.getByDataTestid('return-to-home-end').click()
cy.url().should('contain', '/accueil')
})
})
30 changes: 30 additions & 0 deletions frontend/cypress/e2e/firearm-securing.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
describe('Securing Firearm and Identification', () => {
it('should secure and identificate real firearm', () => {
cy.accueil()
cy.miseEnSecurite()
cy.getByDataTestid('select-file').as('fileInput')
cy.intercept('POST', '/api/upload').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)
})
cy.url().should('contain', '/mise-en-securite-choix-option-etape/1')
cy.getByDataTestid('button-next').should('have.attr', 'disabled')
cy.contains('bouton pontet').first().click()
cy.getByDataTestid('button-next').should('not.have.attr', 'disabled')
cy.getByDataTestid('button-next').click()
cy.url().should('contain', '/mise-en-securite-tutoriel')
cy.getVideo()
cy.contains('h2', 'Mettre en sécurité mon arme')
cy.contains('li', 'Actionner la culasse')
cy.getByDataTestid('button-next').click()
cy.Identification()
cy.contains('cartouches').first().click()
cy.getByDataTestid('next-step').should('not.have.attr', 'disabled')
cy.getByDataTestid('next-step').click()
cy.url().should('contain', '/guide-identification/resultat-final')
cy.getByDataTestid('arm-category').should('contain', 'Catégorie B')
cy.getByDataTestid('return-to-home-end').click()
cy.url().should('contain', '/accueil')
})
})
45 changes: 0 additions & 45 deletions frontend/cypress/e2e/get-basegun-result.cy.js

This file was deleted.

38 changes: 21 additions & 17 deletions frontend/cypress/e2e/home.cy.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
describe('HomePage', () => {
it('shoud visit HomePage', () => {
cy.visit('/')
cy.getByDataTestid('basegun-logo').should('exist')
cy.contains('li', 'Basegun est une application')
cy.get('.swiper-button-next').click()
cy.contains('li', 'Une arme doit toujours être')
cy.get('#position-button').contains('J\'ai compris').click()
cy.url().should('contain', '/accueil')
})
it('shoud visit HomePage', () => {
cy.visit('/')
cy.getByDataTestid('basegun-logo').should('exist')
cy.contains('li', 'Basegun est une application')
cy.get('swiper-container').shadow().find('.swiper-button-next').click()
cy.contains('li', 'ne remplace en aucun cas l\'avis d\'un expert')
cy.get('#agree-button').contains('J\'ai compris').click()
cy.url().should('contain', '/accueil')
})

it('should open Menu informations', () => {
cy.visit('/')
cy.getByDataTestid('header-logo').contains('Ministère')
Expand All @@ -20,24 +20,28 @@ describe('HomePage', () => {
.click()
cy.url()
.should('contain', '/a-propos')
cy.contains('p', 'Basegun est un projet')

cy.get('#button-menu')
.click()
cy.getByRole('navigation')
.contains('a', 'Mentions légales')
.click()
cy.url()
.should('contain', '/mentions-legales')
cy.contains('p', 'basegun.fr')

cy.get('#button-menu')
.click()
cy.getByRole('navigation')
.contains('a', 'Contact')
.click()
cy.url()
.should('contain', '/contact')
cy.get('.information')
.should('exist')
.click()
cy.url().should('contain','/')
})
}
)
cy.contains('a', '[email protected]')
cy.getByRole('navigation')
.contains('a', 'Important')
.click({ force: true })
})
},
)
16 changes: 16 additions & 0 deletions frontend/cypress/e2e/old-mechanism-pistol-securing.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
describe('Old Mechanism Pistol Securing', () => {
it('should secure and identificate old mechanism pistol', () => {
cy.accueil()
cy.miseEnSecurite()
cy.getByDataTestid('select-file').as('fileInput')
cy.intercept('POST', '/api/upload').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)
})
cy.pasDeGuide()
cy.getByDataTestid('arm-category').should('contain', 'Catégorie D')
cy.getByDataTestid('return-to-home-end').click()
cy.url().should('contain', '/accueil')
})
})
Loading

0 comments on commit 2ccb4f6

Please sign in to comment.