From cbbc8ded1fcb07c1b9ac3e850d22e3fd08667fcb Mon Sep 17 00:00:00 2001 From: carolineBda Date: Mon, 4 Nov 2024 15:40:42 +0100 Subject: [PATCH 1/8] Revert "fix(simulateur embauche): revert DSFR sur simulateur embauche (#6245)" This reverts commit 6a359dded859d056e405c2b5432a7eed0ea0e138. --- .../app/outils/simulateur-embauche/page.tsx | 49 +++++++++++ .../integration/light/outils/brut-net.spec.ts | 5 +- .../pages/outils/[slug].tsx | 2 - .../src/modules/layout/ContainerSimulator.tsx | 47 ++++++++++ .../src/modules/outils/queries.ts | 26 ++++++ .../simulateur-embauche/HiringSimulator.tsx | 88 +++++++++++++++++++ .../outils/simulateur-embauche/index.ts | 1 + .../src/modules/outils/type.ts | 3 + .../src/outils/SimulateurEmbauche.js | 80 ----------------- .../src/outils/index.ts | 1 - 10 files changed, 218 insertions(+), 84 deletions(-) create mode 100644 packages/code-du-travail-frontend/app/outils/simulateur-embauche/page.tsx create mode 100644 packages/code-du-travail-frontend/src/modules/layout/ContainerSimulator.tsx create mode 100644 packages/code-du-travail-frontend/src/modules/outils/simulateur-embauche/HiringSimulator.tsx create mode 100644 packages/code-du-travail-frontend/src/modules/outils/simulateur-embauche/index.ts create mode 100644 packages/code-du-travail-frontend/src/modules/outils/type.ts delete mode 100644 packages/code-du-travail-frontend/src/outils/SimulateurEmbauche.js diff --git a/packages/code-du-travail-frontend/app/outils/simulateur-embauche/page.tsx b/packages/code-du-travail-frontend/app/outils/simulateur-embauche/page.tsx new file mode 100644 index 0000000000..c86f9a3abe --- /dev/null +++ b/packages/code-du-travail-frontend/app/outils/simulateur-embauche/page.tsx @@ -0,0 +1,49 @@ +import { DsfrLayout } from "../../../src/modules/layout"; +import { HiringSimulator } from "../../../src/modules/outils/simulateur-embauche"; +import { + DocumentElasticResult, + fetchRelatedItems, +} from "../../../src/modules/documents"; +import { fetchTool } from "../../../src/modules/outils"; +import { notFound } from "next/navigation"; +import { generateDefaultMetadata } from "../../../src/modules/common/metas"; +import { ElasticTool } from "../../../src/modules/outils/type"; + +export async function generateMetadata() { + const { title, description } = await getTool(); + + return generateDefaultMetadata({ + title: `Simulateur - ${title}`, + description: description, + path: `/outils/simulateur-embauche`, + }); +} + +async function HiringSimulatorPage() { + const tool = await getTool(); + const relatedItems = await fetchRelatedItems( + { _id: tool._id }, + "simulateur-embauche" + ); + return ( + + + + ); +} + +const getTool = async () => { + const tool: DocumentElasticResult = await fetchTool( + "simulateur-embauche" + ); + + if (!tool) { + return notFound(); + } + return tool; +}; + +export default HiringSimulatorPage; diff --git a/packages/code-du-travail-frontend/cypress/integration/light/outils/brut-net.spec.ts b/packages/code-du-travail-frontend/cypress/integration/light/outils/brut-net.spec.ts index ee482c9a54..c923a4d7a0 100644 --- a/packages/code-du-travail-frontend/cypress/integration/light/outils/brut-net.spec.ts +++ b/packages/code-du-travail-frontend/cypress/integration/light/outils/brut-net.spec.ts @@ -3,7 +3,10 @@ import "cypress-iframe"; describe("Outil - Salaire brut/net", () => { it("Valider que le simulateur s'affiche correctement dans l'iframe", () => { cy.visit("/outils/simulateur-embauche"); - cy.get("h1").should("have.text", "Calculer le salaire brut/net"); + cy.findByRole("heading", { level: 1 }).should( + "have.text", + "Calculer le salaire brut/net" + ); cy.iframe("#simulateurEmbauche") .contains("Coût total employeur") .should("be.visible"); diff --git a/packages/code-du-travail-frontend/pages/outils/[slug].tsx b/packages/code-du-travail-frontend/pages/outils/[slug].tsx index bc41f877aa..18e9ed2fd9 100644 --- a/packages/code-du-travail-frontend/pages/outils/[slug].tsx +++ b/packages/code-du-travail-frontend/pages/outils/[slug].tsx @@ -19,7 +19,6 @@ import { DureePreavisDemission, DureePreavisLicenciement, HeuresRechercheEmploi, - SimulateurEmbauche, SimulateurIndemnitePrecarite, CalculateurPreavisRetraite, } from "../../src/outils"; @@ -38,7 +37,6 @@ const toolsBySlug = { "preavis-demission": DureePreavisDemission, "preavis-licenciement": DureePreavisLicenciement, "preavis-retraite": CalculateurPreavisRetraite, - "simulateur-embauche": SimulateurEmbauche, "procedure-licenciement": DismissalProcess, "indemnite-rupture-conventionnelle": CalculateurRuptureConventionnelle, }; diff --git a/packages/code-du-travail-frontend/src/modules/layout/ContainerSimulator.tsx b/packages/code-du-travail-frontend/src/modules/layout/ContainerSimulator.tsx new file mode 100644 index 0000000000..46a0213a59 --- /dev/null +++ b/packages/code-du-travail-frontend/src/modules/layout/ContainerSimulator.tsx @@ -0,0 +1,47 @@ +import { fr } from "@codegouvfr/react-dsfr"; +import { Breadcrumb, BreadcrumbProps } from "@codegouvfr/react-dsfr/Breadcrumb"; + +import { RelatedItems } from "../common/RelatedItems"; +import { Share } from "../common/Share"; +import { RelatedItem } from "../documents"; +import { Feedback } from "../layout/feedback"; + +type Props = { + relatedItems: { items: RelatedItem[]; title: string }[]; + title: string; + description: string; + children: React.ReactNode; +} & Pick; + +export const ContainerSimulator = ({ + children, + relatedItems, + title, + description, + segments = [], +}: Props) => { + return ( +
+ +
+ {children} +
+ +
+
+
+ +
+
+ +
+
+ ); +}; diff --git a/packages/code-du-travail-frontend/src/modules/outils/queries.ts b/packages/code-du-travail-frontend/src/modules/outils/queries.ts index c090a0f64e..7bc50ec8f1 100644 --- a/packages/code-du-travail-frontend/src/modules/outils/queries.ts +++ b/packages/code-du-travail-frontend/src/modules/outils/queries.ts @@ -5,6 +5,8 @@ import { } from "../../api/utils"; import { Tool } from "@socialgouv/cdtn-types"; import { SOURCES } from "@socialgouv/cdtn-utils"; +import { DocumentElasticResult, fetchDocument } from "../documents"; +import { ElasticTool } from "./type"; export const fetchAllTools = async ( fields: K[] @@ -53,3 +55,27 @@ export const fetchAllTools = async ( .map(({ _source }) => _source) .filter((source) => source !== undefined); }; + +export const fetchTool = async ( + slug: string +): Promise> => { + const result = await fetchDocument< + ElasticTool, + keyof DocumentElasticResult + >(["description", "title"], { + query: { + bool: { + filter: [ + { term: { source: SOURCES.TOOLS } }, + { term: { slug } }, + { term: { isPublished: true } }, + ], + }, + }, + size: 1, + }); + if (!result) { + throw new Error("Outils non trouvé"); + } + return result; +}; diff --git a/packages/code-du-travail-frontend/src/modules/outils/simulateur-embauche/HiringSimulator.tsx b/packages/code-du-travail-frontend/src/modules/outils/simulateur-embauche/HiringSimulator.tsx new file mode 100644 index 0000000000..309cc7ec09 --- /dev/null +++ b/packages/code-du-travail-frontend/src/modules/outils/simulateur-embauche/HiringSimulator.tsx @@ -0,0 +1,88 @@ +"use client"; +import { Highlight } from "@codegouvfr/react-dsfr/Highlight"; +import { fr } from "@codegouvfr/react-dsfr"; +import { useEffect, createRef, useState } from "react"; +import { ContainerSimulator } from "../../layout/ContainerSimulator"; +import { RelatedItem } from "../../documents"; + +type Props = { + relatedItems: { + items: RelatedItem[]; + title: string; + }[]; + description: string; +}; + +export const HiringSimulator = ({ relatedItems, description }: Props) => { + const simRef = createRef(); + const [state, setState] = useState({ + error: "", + simulator: "loading", + }); + const onError = (error) => { + setState({ error, simulator: "error" }); + }; + + const onLoad = () => { + setState({ simulator: "success", error: "" }); + if ( + !simRef.current || + !simRef.current.querySelector("#simulateurEmbauche") + ) { + setState({ error: "empty child", simulator: "error" }); + } + }; + useEffect(() => { + const script = document.createElement("script"); + + script.src = + "https://mon-entreprise.urssaf.fr/simulateur-iframe-integration.js"; + script.async = true; + script.id = "script-simulateur-embauche"; + script.onload = onLoad; + script.onerror = onError; + + if (simRef.current) { + simRef.current.appendChild(script); + } + + return () => { + if (simRef.current) { + simRef.current.removeChild(script); + } + }; + }, []); + const { simulator } = state; + return ( + +

Calculer le salaire brut/net

+ + Pour information, l'estimation du salaire net après impôt est basée + sur la situation d'une personne célibataire sans enfants ni + patrimoine. + + {simulator === "loading" &&

Chargement de l’outil

} + {simulator === "error" ? ( +

+ Le simulateur d’embauche n’est pas disponible actuellement. +
+ Retrouvez les autres simulateurs autour du thème de l’entreprise, sur + le site:{" "} + + https://mon-entreprise.urssaf.fr/ + +

+ ) : ( +
+ )} + + ); +}; diff --git a/packages/code-du-travail-frontend/src/modules/outils/simulateur-embauche/index.ts b/packages/code-du-travail-frontend/src/modules/outils/simulateur-embauche/index.ts new file mode 100644 index 0000000000..910a3e0db4 --- /dev/null +++ b/packages/code-du-travail-frontend/src/modules/outils/simulateur-embauche/index.ts @@ -0,0 +1 @@ +export * from "./HiringSimulator"; diff --git a/packages/code-du-travail-frontend/src/modules/outils/type.ts b/packages/code-du-travail-frontend/src/modules/outils/type.ts new file mode 100644 index 0000000000..99e771ea59 --- /dev/null +++ b/packages/code-du-travail-frontend/src/modules/outils/type.ts @@ -0,0 +1,3 @@ +import { DocumentElasticWithSource, Tool } from "@socialgouv/cdtn-types"; + +export type ElasticTool = DocumentElasticWithSource; diff --git a/packages/code-du-travail-frontend/src/outils/SimulateurEmbauche.js b/packages/code-du-travail-frontend/src/outils/SimulateurEmbauche.js deleted file mode 100644 index 0593abebd4..0000000000 --- a/packages/code-du-travail-frontend/src/outils/SimulateurEmbauche.js +++ /dev/null @@ -1,80 +0,0 @@ -import { Alert, PageTitle, Section, Wrapper } from "@socialgouv/cdtn-ui"; -import React from "react"; -import Spinner from "react-svg-spinner"; - -class SimulateurEmbauche extends React.PureComponent { - simRef = React.createRef(); - state = { - simulator: "loading", - }; - - onError = (error) => { - this.setState({ error, simulator: "error" }); - }; - - onLoad = () => { - this.setState({ simulator: "success" }); - if ( - !this.simRef.current || - !this.simRef.current.querySelector("#simulateurEmbauche") - ) { - this.setState({ error: "empty child", simulator: "error" }); - } - }; - - componentDidMount() { - const script = document.createElement("script"); - script.src = - "https://mon-entreprise.urssaf.fr/simulateur-iframe-integration.js"; - script.async = true; - script.dataset.couleur = "#2975D1"; - script.id = "script-simulateur-embauche"; - script.onload = this.onLoad; - script.onerror = this.onError; - - if (this.simRef.current) { - this.simRef.current.appendChild(script); - } - } - - render() { - const { simulator } = this.state; - return ( - - Calculer le salaire brut/net - -

- Pour information, l’estimation du salaire net après impôt est basée - sur la situation d’une personne célibataire sans enfants ni - patrimoine. -

-
- {simulator === "loading" && ( -

- Chargement de l’outil -

- )} - {simulator === "error" ? ( -

- Le simulateur d’embauche n’est pas disponible actuellement. -
- Retrouvez les autres simulateurs autour du thème de l’entreprise, - sur le site:{" "} - - https://mon-entreprise.urssaf.fr/ - -

- ) : ( -
-
-
- )} -
- ); - } -} - -export { SimulateurEmbauche }; diff --git a/packages/code-du-travail-frontend/src/outils/index.ts b/packages/code-du-travail-frontend/src/outils/index.ts index 8acb7da47c..82a0f5a8b9 100644 --- a/packages/code-du-travail-frontend/src/outils/index.ts +++ b/packages/code-du-travail-frontend/src/outils/index.ts @@ -5,7 +5,6 @@ export * from "./DureePreavisLicenciement"; export * from "./IndemniteLicenciement"; export * from "./HeuresRechercheEmploi"; export * from "./IndemnitePrecarite"; -export * from "./SimulateurEmbauche"; export * from "./DismissalProcess"; export * from "./RuptureCoventionnelle"; export * from "./api"; From 692a54acd0426ffbaa81d97b61cdd87ffc94a25f Mon Sep 17 00:00:00 2001 From: carolineBda Date: Mon, 4 Nov 2024 16:29:33 +0100 Subject: [PATCH 2/8] add click in test --- .../cypress/integration/light/outils/brut-net.spec.ts | 1 + .../modules/outils/simulateur-embauche/HiringSimulator.tsx | 7 ++----- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/packages/code-du-travail-frontend/cypress/integration/light/outils/brut-net.spec.ts b/packages/code-du-travail-frontend/cypress/integration/light/outils/brut-net.spec.ts index c923a4d7a0..6f9a81e4d6 100644 --- a/packages/code-du-travail-frontend/cypress/integration/light/outils/brut-net.spec.ts +++ b/packages/code-du-travail-frontend/cypress/integration/light/outils/brut-net.spec.ts @@ -7,6 +7,7 @@ describe("Outil - Salaire brut/net", () => { "have.text", "Calculer le salaire brut/net" ); + cy.findByRole("heading", { level: 1 }).click(); cy.iframe("#simulateurEmbauche") .contains("Coût total employeur") .should("be.visible"); diff --git a/packages/code-du-travail-frontend/src/modules/outils/simulateur-embauche/HiringSimulator.tsx b/packages/code-du-travail-frontend/src/modules/outils/simulateur-embauche/HiringSimulator.tsx index 309cc7ec09..204d4ec352 100644 --- a/packages/code-du-travail-frontend/src/modules/outils/simulateur-embauche/HiringSimulator.tsx +++ b/packages/code-du-travail-frontend/src/modules/outils/simulateur-embauche/HiringSimulator.tsx @@ -1,7 +1,7 @@ "use client"; import { Highlight } from "@codegouvfr/react-dsfr/Highlight"; import { fr } from "@codegouvfr/react-dsfr"; -import { useEffect, createRef, useState } from "react"; +import { createRef, useEffect, useState } from "react"; import { ContainerSimulator } from "../../layout/ContainerSimulator"; import { RelatedItem } from "../../documents"; @@ -25,10 +25,7 @@ export const HiringSimulator = ({ relatedItems, description }: Props) => { const onLoad = () => { setState({ simulator: "success", error: "" }); - if ( - !simRef.current || - !simRef.current.querySelector("#simulateurEmbauche") - ) { + if (!simRef.current?.querySelector("#simulateurEmbauche")) { setState({ error: "empty child", simulator: "error" }); } }; From 504e52171269a93744f0dcd2486357f1f9e9ab05 Mon Sep 17 00:00:00 2001 From: carolineBda Date: Tue, 5 Nov 2024 11:18:56 +0100 Subject: [PATCH 3/8] try to memoised --- .../app/outils/simulateur-embauche/page.tsx | 2 +- .../outils/simulateur-embauche/HiringSimulator.tsx | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/packages/code-du-travail-frontend/app/outils/simulateur-embauche/page.tsx b/packages/code-du-travail-frontend/app/outils/simulateur-embauche/page.tsx index c86f9a3abe..87248bcbfd 100644 --- a/packages/code-du-travail-frontend/app/outils/simulateur-embauche/page.tsx +++ b/packages/code-du-travail-frontend/app/outils/simulateur-embauche/page.tsx @@ -1,5 +1,4 @@ import { DsfrLayout } from "../../../src/modules/layout"; -import { HiringSimulator } from "../../../src/modules/outils/simulateur-embauche"; import { DocumentElasticResult, fetchRelatedItems, @@ -8,6 +7,7 @@ import { fetchTool } from "../../../src/modules/outils"; import { notFound } from "next/navigation"; import { generateDefaultMetadata } from "../../../src/modules/common/metas"; import { ElasticTool } from "../../../src/modules/outils/type"; +import HiringSimulator from "../../../src/modules/outils/simulateur-embauche/HiringSimulator"; export async function generateMetadata() { const { title, description } = await getTool(); diff --git a/packages/code-du-travail-frontend/src/modules/outils/simulateur-embauche/HiringSimulator.tsx b/packages/code-du-travail-frontend/src/modules/outils/simulateur-embauche/HiringSimulator.tsx index 204d4ec352..0aeb477fca 100644 --- a/packages/code-du-travail-frontend/src/modules/outils/simulateur-embauche/HiringSimulator.tsx +++ b/packages/code-du-travail-frontend/src/modules/outils/simulateur-embauche/HiringSimulator.tsx @@ -1,7 +1,7 @@ "use client"; import { Highlight } from "@codegouvfr/react-dsfr/Highlight"; import { fr } from "@codegouvfr/react-dsfr"; -import { createRef, useEffect, useState } from "react"; +import { createRef, memo, useEffect, useState } from "react"; import { ContainerSimulator } from "../../layout/ContainerSimulator"; import { RelatedItem } from "../../documents"; @@ -13,7 +13,10 @@ type Props = { description: string; }; -export const HiringSimulator = ({ relatedItems, description }: Props) => { +const HiringSimulator = memo(function HiringSimulator({ + relatedItems, + description, +}: Props) { const simRef = createRef(); const [state, setState] = useState({ error: "", @@ -82,4 +85,6 @@ export const HiringSimulator = ({ relatedItems, description }: Props) => { )} ); -}; +}); + +export default HiringSimulator; From 900dee3594b845f77cf9e60c3b7efbe19233335a Mon Sep 17 00:00:00 2001 From: carolineBda Date: Tue, 5 Nov 2024 15:48:12 +0100 Subject: [PATCH 4/8] update meta data --- .../app/outils/simulateur-embauche/page.tsx | 18 +++++++----------- .../src/common/tiles/CallToAction.tsx | 2 +- .../src/modules/outils/queries.ts | 2 +- .../simulateur-embauche/HiringSimulator.tsx | 13 +++++++++++-- 4 files changed, 20 insertions(+), 15 deletions(-) diff --git a/packages/code-du-travail-frontend/app/outils/simulateur-embauche/page.tsx b/packages/code-du-travail-frontend/app/outils/simulateur-embauche/page.tsx index 87248bcbfd..2984d26565 100644 --- a/packages/code-du-travail-frontend/app/outils/simulateur-embauche/page.tsx +++ b/packages/code-du-travail-frontend/app/outils/simulateur-embauche/page.tsx @@ -1,20 +1,16 @@ import { DsfrLayout } from "../../../src/modules/layout"; -import { - DocumentElasticResult, - fetchRelatedItems, -} from "../../../src/modules/documents"; +import { fetchRelatedItems } from "../../../src/modules/documents"; import { fetchTool } from "../../../src/modules/outils"; import { notFound } from "next/navigation"; import { generateDefaultMetadata } from "../../../src/modules/common/metas"; -import { ElasticTool } from "../../../src/modules/outils/type"; import HiringSimulator from "../../../src/modules/outils/simulateur-embauche/HiringSimulator"; export async function generateMetadata() { - const { title, description } = await getTool(); + const { metaTitle, metaDescription } = await getTool(); return generateDefaultMetadata({ - title: `Simulateur - ${title}`, - description: description, + title: metaTitle, + description: metaDescription, path: `/outils/simulateur-embauche`, }); } @@ -28,6 +24,8 @@ async function HiringSimulatorPage() { return ( @@ -36,9 +34,7 @@ async function HiringSimulatorPage() { } const getTool = async () => { - const tool: DocumentElasticResult = await fetchTool( - "simulateur-embauche" - ); + const tool = await fetchTool("simulateur-embauche"); if (!tool) { return notFound(); diff --git a/packages/code-du-travail-frontend/src/common/tiles/CallToAction.tsx b/packages/code-du-travail-frontend/src/common/tiles/CallToAction.tsx index 821fa43648..5fcb922de9 100644 --- a/packages/code-du-travail-frontend/src/common/tiles/CallToAction.tsx +++ b/packages/code-du-travail-frontend/src/common/tiles/CallToAction.tsx @@ -82,7 +82,7 @@ const StyledDiv = styled.div` height: 1.4rem; margin: 0 ${spacings.tiny} 0 ${spacings.small}; transition: transform ${theme.animations.transitionTiming} linear; - fill: ${theme.primary}; + fill: ${theme.colors.primary}; } } `; diff --git a/packages/code-du-travail-frontend/src/modules/outils/queries.ts b/packages/code-du-travail-frontend/src/modules/outils/queries.ts index 7bc50ec8f1..69f686ae5c 100644 --- a/packages/code-du-travail-frontend/src/modules/outils/queries.ts +++ b/packages/code-du-travail-frontend/src/modules/outils/queries.ts @@ -62,7 +62,7 @@ export const fetchTool = async ( const result = await fetchDocument< ElasticTool, keyof DocumentElasticResult - >(["description", "title"], { + >(["description", "metaDescription", "metaTitle", "title", "displayTitle"], { query: { bool: { filter: [ diff --git a/packages/code-du-travail-frontend/src/modules/outils/simulateur-embauche/HiringSimulator.tsx b/packages/code-du-travail-frontend/src/modules/outils/simulateur-embauche/HiringSimulator.tsx index 0aeb477fca..49b9bf585b 100644 --- a/packages/code-du-travail-frontend/src/modules/outils/simulateur-embauche/HiringSimulator.tsx +++ b/packages/code-du-travail-frontend/src/modules/outils/simulateur-embauche/HiringSimulator.tsx @@ -4,18 +4,23 @@ import { fr } from "@codegouvfr/react-dsfr"; import { createRef, memo, useEffect, useState } from "react"; import { ContainerSimulator } from "../../layout/ContainerSimulator"; import { RelatedItem } from "../../documents"; +import * as Sentry from "@sentry/nextjs"; type Props = { relatedItems: { items: RelatedItem[]; title: string; }[]; + title: string; + breadcrumbTitle: string; description: string; }; const HiringSimulator = memo(function HiringSimulator({ relatedItems, description, + title, + breadcrumbTitle, }: Props) { const simRef = createRef(); const [state, setState] = useState({ @@ -23,7 +28,11 @@ const HiringSimulator = memo(function HiringSimulator({ simulator: "loading", }); const onError = (error) => { + console.log(`Erreur durant le chargement de l'iframe brut/net ${error}`); setState({ error, simulator: "error" }); + Sentry.captureException( + `Erreur durant le chargement de l'iframe brut/net ${error}` + ); }; const onLoad = () => { @@ -56,11 +65,11 @@ const HiringSimulator = memo(function HiringSimulator({ return ( -

Calculer le salaire brut/net

+

{title}

Pour information, l'estimation du salaire net après impôt est basée sur la situation d'une personne célibataire sans enfants ni From 534031aa8ecb771902f8228caa175bcccb8c9e7a Mon Sep 17 00:00:00 2001 From: carolineBda Date: Tue, 5 Nov 2024 16:43:16 +0100 Subject: [PATCH 5/8] fix snapshots --- .../__snapshots__/Custom.test.js.snap | 18 +- .../simulateur-embauche/HiringSimulator.tsx | 4 +- .../__snapshots__/SearchResults.test.js.snap | 154 +++++++++--------- 3 files changed, 88 insertions(+), 88 deletions(-) diff --git a/packages/code-du-travail-frontend/src/common/tiles/__tests__/__snapshots__/Custom.test.js.snap b/packages/code-du-travail-frontend/src/common/tiles/__tests__/__snapshots__/Custom.test.js.snap index 57d582f2e9..a8b7b688cb 100644 --- a/packages/code-du-travail-frontend/src/common/tiles/__tests__/__snapshots__/Custom.test.js.snap +++ b/packages/code-du-travail-frontend/src/common/tiles/__tests__/__snapshots__/Custom.test.js.snap @@ -3,13 +3,13 @@ exports[` should render 1`] = `
should render 1`] = `

Cette tuile vous fera dire bonjour !

Bonjour diff --git a/packages/code-du-travail-frontend/src/modules/outils/simulateur-embauche/HiringSimulator.tsx b/packages/code-du-travail-frontend/src/modules/outils/simulateur-embauche/HiringSimulator.tsx index 49b9bf585b..850ee0b7fe 100644 --- a/packages/code-du-travail-frontend/src/modules/outils/simulateur-embauche/HiringSimulator.tsx +++ b/packages/code-du-travail-frontend/src/modules/outils/simulateur-embauche/HiringSimulator.tsx @@ -30,8 +30,8 @@ const HiringSimulator = memo(function HiringSimulator({ const onError = (error) => { console.log(`Erreur durant le chargement de l'iframe brut/net ${error}`); setState({ error, simulator: "error" }); - Sentry.captureException( - `Erreur durant le chargement de l'iframe brut/net ${error}` + Sentry.captureMessage( + `Erreur durant le chargement de l'iframe brut/net` ); }; diff --git a/packages/code-du-travail-frontend/src/search/__tests__/__snapshots__/SearchResults.test.js.snap b/packages/code-du-travail-frontend/src/search/__tests__/__snapshots__/SearchResults.test.js.snap index 256fa55067..bf8c8d5e4c 100644 --- a/packages/code-du-travail-frontend/src/search/__tests__/__snapshots__/SearchResults.test.js.snap +++ b/packages/code-du-travail-frontend/src/search/__tests__/__snapshots__/SearchResults.test.js.snap @@ -6,37 +6,37 @@ exports[` should render results 1`] = `

Que dit le code du travail ?

Les thèmes suivants peuvent vous intéresser

Date: Tue, 5 Nov 2024 16:50:24 +0100 Subject: [PATCH 6/8] more logging --- .../modules/outils/simulateur-embauche/HiringSimulator.tsx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/code-du-travail-frontend/src/modules/outils/simulateur-embauche/HiringSimulator.tsx b/packages/code-du-travail-frontend/src/modules/outils/simulateur-embauche/HiringSimulator.tsx index 850ee0b7fe..60f2374d81 100644 --- a/packages/code-du-travail-frontend/src/modules/outils/simulateur-embauche/HiringSimulator.tsx +++ b/packages/code-du-travail-frontend/src/modules/outils/simulateur-embauche/HiringSimulator.tsx @@ -38,7 +38,11 @@ const HiringSimulator = memo(function HiringSimulator({ const onLoad = () => { setState({ simulator: "success", error: "" }); if (!simRef.current?.querySelector("#simulateurEmbauche")) { + console.log(`Erreur durant le chargement de l'iframe brut/net, "empty child"`); setState({ error: "empty child", simulator: "error" }); + Sentry.captureMessage( + `Erreur durant le chargement de l'iframe brut/net "empty child"` + ); } }; useEffect(() => { From 367dd77368a06e3421eeb2835afea22833894296 Mon Sep 17 00:00:00 2001 From: carolineBda Date: Tue, 5 Nov 2024 16:50:48 +0100 Subject: [PATCH 7/8] sans aysnc --- .../src/modules/outils/simulateur-embauche/HiringSimulator.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/code-du-travail-frontend/src/modules/outils/simulateur-embauche/HiringSimulator.tsx b/packages/code-du-travail-frontend/src/modules/outils/simulateur-embauche/HiringSimulator.tsx index 60f2374d81..485837f964 100644 --- a/packages/code-du-travail-frontend/src/modules/outils/simulateur-embauche/HiringSimulator.tsx +++ b/packages/code-du-travail-frontend/src/modules/outils/simulateur-embauche/HiringSimulator.tsx @@ -50,7 +50,6 @@ const HiringSimulator = memo(function HiringSimulator({ script.src = "https://mon-entreprise.urssaf.fr/simulateur-iframe-integration.js"; - script.async = true; script.id = "script-simulateur-embauche"; script.onload = onLoad; script.onerror = onError; From e5f75d93e1856ce21a61148540066de27dedd654 Mon Sep 17 00:00:00 2001 From: carolineBda Date: Tue, 5 Nov 2024 17:01:44 +0100 Subject: [PATCH 8/8] fix!! --- .../__snapshots__/Custom.test.js.snap | 14 +- .../simulateur-embauche/HiringSimulator.tsx | 8 +- .../__snapshots__/SearchResults.test.js.snap | 142 +++++++++--------- 3 files changed, 82 insertions(+), 82 deletions(-) diff --git a/packages/code-du-travail-frontend/src/common/tiles/__tests__/__snapshots__/Custom.test.js.snap b/packages/code-du-travail-frontend/src/common/tiles/__tests__/__snapshots__/Custom.test.js.snap index a8b7b688cb..f6c0296898 100644 --- a/packages/code-du-travail-frontend/src/common/tiles/__tests__/__snapshots__/Custom.test.js.snap +++ b/packages/code-du-travail-frontend/src/common/tiles/__tests__/__snapshots__/Custom.test.js.snap @@ -3,13 +3,13 @@ exports[` should render 1`] = `

should render 1`] = ` class="sc-45a05aa-2 gcKsUr" >

Bonjour diff --git a/packages/code-du-travail-frontend/src/modules/outils/simulateur-embauche/HiringSimulator.tsx b/packages/code-du-travail-frontend/src/modules/outils/simulateur-embauche/HiringSimulator.tsx index 485837f964..938d534221 100644 --- a/packages/code-du-travail-frontend/src/modules/outils/simulateur-embauche/HiringSimulator.tsx +++ b/packages/code-du-travail-frontend/src/modules/outils/simulateur-embauche/HiringSimulator.tsx @@ -30,15 +30,15 @@ const HiringSimulator = memo(function HiringSimulator({ const onError = (error) => { console.log(`Erreur durant le chargement de l'iframe brut/net ${error}`); setState({ error, simulator: "error" }); - Sentry.captureMessage( - `Erreur durant le chargement de l'iframe brut/net` - ); + Sentry.captureMessage(`Erreur durant le chargement de l'iframe brut/net`); }; const onLoad = () => { setState({ simulator: "success", error: "" }); if (!simRef.current?.querySelector("#simulateurEmbauche")) { - console.log(`Erreur durant le chargement de l'iframe brut/net, "empty child"`); + console.log( + `Erreur durant le chargement de l'iframe brut/net, "empty child"` + ); setState({ error: "empty child", simulator: "error" }); Sentry.captureMessage( `Erreur durant le chargement de l'iframe brut/net "empty child"` diff --git a/packages/code-du-travail-frontend/src/search/__tests__/__snapshots__/SearchResults.test.js.snap b/packages/code-du-travail-frontend/src/search/__tests__/__snapshots__/SearchResults.test.js.snap index bf8c8d5e4c..3d0716f7dc 100644 --- a/packages/code-du-travail-frontend/src/search/__tests__/__snapshots__/SearchResults.test.js.snap +++ b/packages/code-du-travail-frontend/src/search/__tests__/__snapshots__/SearchResults.test.js.snap @@ -6,37 +6,37 @@ exports[` should render results 1`] = `