Skip to content

Commit

Permalink
feat: ✨ add dummy identification for lever rifle and semi-automatic o…
Browse files Browse the repository at this point in the history
…r automatic long gun
  • Loading branch information
nutfdt committed Oct 15, 2024
1 parent d11b30c commit 6915ab8
Show file tree
Hide file tree
Showing 12 changed files with 145 additions and 19 deletions.
42 changes: 42 additions & 0 deletions frontend/cypress/e2e/shotgun-identification.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
describe("Shotgun identification", () => {
it("should identificate real shotgun", () => {
cy.Identification();
cy.getByDataTestid("select-file").as("fileInput");
cy.intercept("POST", "/api/upload").as("upload");
cy.get("@fileInput").selectFile("./cypress/images/fusil-a-pompe.jpg", {
force: true,
});
cy.wait("@upload").then(({ response }) => {
expect(response.statusCode).to.eq(200);
});
cy.url().should("contain", "/carte-manquante");
cy.getByDataTestid("button-next").click();
cy.IdentificationRealShotgun();
cy.url().should("contain", "/guide-identification/resultat-final");
cy.getByDataTestid("arm-category").should("contain", "Catégorie B ou C");
cy.getByDataTestid("return-to-home-end").click();
cy.url().should("contain", "/accueil");
});

it("should identificate dummy shotgun", () => {
cy.Identification();
cy.getByDataTestid("select-file").as("fileInput");
cy.intercept("POST", "/api/upload").as("upload");
cy.get("@fileInput").selectFile("./cypress/images/fusil-a-pompe.jpg", {
force: true,
});
cy.wait("@upload").then(({ response }) => {
expect(response.statusCode).to.eq(200);
});
cy.url().should("contain", "/carte-manquante");
cy.getByDataTestid("button-next").click();
cy.IdentificationDummyShotgun();
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");
});
});
27 changes: 27 additions & 0 deletions frontend/cypress/e2e/shotgun-securing.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
describe("Shotgun securing", () => {
it("should secure and identificate real shotgun", () => {
cy.miseEnSecurite();
cy.getByDataTestid("select-file").as("fileInput");
cy.intercept("POST", "/api/upload").as("upload");
cy.get("@fileInput").selectFile("./cypress/images/fusil-a-pompe.jpg", {
force: true,
});
cy.wait("@upload").then(({ response }) => {
expect(response.statusCode).to.eq(200);
});
cy.url().should("contain", "/mise-en-securite-tutoriel");
cy.getVideo();
cy.contains("h1", "Mettre en sécurité mon arme");
cy.contains("li", "Si la pompe est bloquée");
cy.getByDataTestid("button-next").click();
cy.contains("h1", "Fin de la mise en sécurité");
cy.getByDataTestid("go-to-identification").click();
cy.url().should("contain", "/carte-manquante");
cy.getByDataTestid("button-next").click();
cy.IdentificationRealShotgun();
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");
});
});
Binary file added frontend/cypress/images/fusil-a-pompe.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 28 additions & 0 deletions frontend/cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,3 +198,31 @@ Cypress.Commands.add("pasDeGuide", () => {
cy.getByDataTestid("go-to-identification").click();
cy.url().should("contain", "/guide-identification/resultat-typologie");
});

Cypress.Commands.add("IdentificationRealShotgun", () => {
cy.getByDataTestid("next-step").click();
cy.url().should(
"contain",
"guide-identification/informations-complementaires",
);
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();
});

Cypress.Commands.add("IdentificationDummyShotgun", () => {
cy.getByDataTestid("next-step").click();
cy.url().should(
"contain",
"guide-identification/informations-complementaires",
);
cy.getByDataTestid("next-step").click();
cy.url().should("contain", "/guide-identification/munition-type");
cy.getByDataTestid("next-step").should("have.attr", "disabled");
cy.contains("Billes").first().click();
cy.getByDataTestid("next-step").should("not.have.attr", "disabled");
cy.getByDataTestid("next-step").click();
});
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions frontend/src/utils/firearms-utils/epaule-a-levier-sous-garde.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import levierSousGardeMagasinAvantImg from "@/assets/guide-mise-en-securite/phot
import levierSousGardePasMagasinImg from "@/assets/guide-mise-en-securite/photos/epaule_a_levier_sous_garde/epaule_levier_ss_garde_magasin_fixe.jpg";
import levierSousGardeMagasinAvantVideo from "@/assets/guide-mise-en-securite/videos/epaule_a_levier_sous_garde/epaule_levier_ss_garde_magasin_avant.mp4";
import levierSousGardePasMagasinVideo from "@/assets/guide-mise-en-securite/videos/epaule_a_levier_sous_garde/epaule_levier_ss_garde_magasin_fixe.mp4";
import levierSousGardeCartridges from "@/assets/guide-identification/photos/epaule_a_verrou/epaule_a_verrou_chargeur_cartouche.jpg";
import levierSousGardeBalls from "@/assets/guide-identification/photos/epaule_a_verrou/epaule_a_verrou_chargeur_bille.jpg";
import {
getEpaulLevierVerrouDisclaimer,
getCommonCategory,
Expand Down Expand Up @@ -51,5 +53,17 @@ export const epaule_a_levier_sous_garde = {
],
},
],
dummyOptions: [
{
label: "Balles",
value: "cartouches",
img_ammo: levierSousGardeCartridges,
},
{
label: "Billes ou trou pour billes",
value: "billes",
img_ammo: levierSousGardeBalls,
},
],
getDisclaimer: getEpaulLevierVerrouDisclaimer,
} as const;
8 changes: 4 additions & 4 deletions frontend/src/utils/firearms-utils/epaule-a-pompe.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import epaulePompeSimpleVideo from "@/assets/guide-mise-en-securite/videos/epaule_a_pompe/epaule_pompe_simple.mp4";
import pistoletSemiAutoModerneCartridges from "@/assets/guide-identification/photos/pistolet_semi_auto_moderne/pistolet_sa_moderne_chargeur_cartouche.jpg";
import pistoletSemiAutoModerneBalls from "@/assets/guide-identification/photos/pistolet_semi_auto_moderne/pistolet_sa_moderne_chargeur_bille.jpg";
import epaulePompeCartridges from "@/assets/guide-identification/photos/epaule_a_pompe/epaule_a_pompe_chargeur_cartouche.jpeg";
import epaulePompeModerneBalls from "@/assets/guide-identification/photos/epaule_a_pompe/epaule_a_pompe_chargeur_bille.jpg";

export const epaule_a_pompe = {
displayLabel: "Arme d'épaule à pompe",
Expand Down Expand Up @@ -34,12 +34,12 @@ export const epaule_a_pompe = {
{
label: "Cartouches",
value: "cartouches",
img_ammo: pistoletSemiAutoModerneCartridges, // Mettre la bonne image
img_ammo: epaulePompeCartridges,
},
{
label: "Billes",
value: "billes",
img_ammo: pistoletSemiAutoModerneBalls, // Mettre la bonne image
img_ammo: epaulePompeModerneBalls,
},
],
getDisclaimer: (category: string) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,23 @@
import semiAutoMilitaireCartridges from "@/assets/guide-identification/photos/semi_auto_militaire_autre/semi_automatique_militaire_autre_chargeur_cartouche.jpg";
import semiAutoMilitaireBalls from "@/assets/guide-identification/photos/semi_auto_militaire_autre/semi_automatique_militaire_autre_chargeur_billes.jpg";
/*
Armes d’épaule semi-automatiques ou automatiques type militaire milieu 20e
*/
export const epaule_semi_auto_style_militaire_milieu_20e = {
displayLabel: "Arme d’épaule semi-automatique ou automatique",
getCategory: () => "A ou B",
dummyOptions: [
{
label: "Cartouches",
value: "cartouches",
img_ammo: semiAutoMilitaireCartridges,
},
{
label: "Billes",
value: "billes",
img_ammo: semiAutoMilitaireBalls,
},
],
getDisclaimer: () =>
"<strong>Catégorie A</strong> si à l'origine l’arme était à <strong>répétition automatique</strong> puis a été <strong>transformée</strong> en arme <strong>semi automatique</strong>, ou si l’arme possède <strong>une crosse rétractable / pliable</strong> et qu’en configuration la plus courte elle <strong>mesure moins de 60 cm</strong>.",
} as const;
14 changes: 14 additions & 0 deletions frontend/src/utils/firearms-utils/epaule-semi-auto-style-chasse.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { getCommonCategory } from "@/utils/firearms-utils/index";
import epaulePompeCartridges from "@/assets/guide-identification/photos/epaule_a_pompe/epaule_a_pompe_chargeur_cartouche.jpeg";
import epaulePompeModerneBalls from "@/assets/guide-identification/photos/epaule_a_pompe/epaule_a_pompe_chargeur_bille.jpg";

const DISCLAIMERS = {
short:
Expand All @@ -12,6 +14,18 @@ Armes d’épaule semi-automatiques ou automatiques type chasse
export const epaule_semi_auto_style_chasse = {
displayLabel: "Arme d’épaule semi-automatique",
getCategory: getCommonCategory,
dummyOptions: [
{
label: "Cartouches",
value: "cartouches",
img_ammo: epaulePompeCartridges,
},
{
label: "Billes",
value: "billes",
img_ammo: epaulePompeModerneBalls,
},
],
getDisclaimer: (category: string, isCardDetected: boolean) => {
if (["B ou C", "C"].includes(category)) {
if (isCardDetected === false) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@ import { useStore } from "@/stores/result";
import TransparentMagazine from "@/assets/guide-identification/photos/semi_auto_militaire_autre/autre-epaule-transparent-magazine.jpg";
import FocusTransparentMagazine from "@/assets/guide-identification/photos/semi_auto_militaire_autre/autre-epaule-transparent-magazine-focus.jpg";
import { TYPOLOGIES } from "@/utils/firearms-utils/index";
import { epaule_a_verrou } from "@/utils/firearms-utils/epaule-a-verrou"; // eslint-disable-line camelcase
import type { pistolet_semi_auto_moderne } from "@/utils/firearms-utils/pistolet-semi-auto-moderne"; // eslint-disable-line camelcase
import type { semi_auto_style_militaire_autre } from "@/utils/firearms-utils/semi-auto-style-militaire-autre"; // eslint-disable-line camelcase
import type { revolver } from "@/utils/firearms-utils/revolver";
import type { epaule_a_pompe } from "@/utils/firearms-utils/epaule-a-pompe";
const store = useStore();
Expand Down Expand Up @@ -53,14 +48,6 @@ onMounted(() => {
showModal.value = false;
}
});
// eslint-disable-next-line camelcase
type HasDummyOptions =
| typeof epaule_a_verrou
| typeof pistolet_semi_auto_moderne
| typeof semi_auto_style_militaire_autre
| typeof revolver
| typeof epaule_a_pompe;
</script>

<template>
Expand Down Expand Up @@ -124,8 +111,7 @@ type HasDummyOptions =
</div>
<div>
<template
v-for="option in (TYPOLOGIES[typology] as HasDummyOptions)
?.dummyOptions"
v-for="option in TYPOLOGIES[typology]?.dummyOptions"
:key="option.value"
>
<div class="item">
Expand Down
1 change: 1 addition & 0 deletions frontend/src/views/MissingCardPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ const store = useStore();
<button
class="fr-btn w-100 text-center"
@click="$router.push({ name: 'IdentificationTypologyResult' })"
data-testid="button-next"
>
Je souhaite tout de même poursuivre
</button>
Expand Down

0 comments on commit 6915ab8

Please sign in to comment.