From f280a613370917836d68bf602a214129c070524a Mon Sep 17 00:00:00 2001 From: LionelB Date: Tue, 10 Dec 2019 19:22:13 +0100 Subject: [PATCH] fix(contribution): fix ccn matching when using siret2idcc fix #1901 --- .../src/contributions/Contribution.js | 4 +++- .../contributions/__tests__/Contribution.test.js | 16 ++++++++-------- .../__snapshots__/Contribution.test.js.snap | 6 +++--- yarn.lock | 8 ++++---- 4 files changed, 18 insertions(+), 16 deletions(-) diff --git a/packages/code-du-travail-frontend/src/contributions/Contribution.js b/packages/code-du-travail-frontend/src/contributions/Contribution.js index 2b32979710..205e61cdc4 100644 --- a/packages/code-du-travail-frontend/src/contributions/Contribution.js +++ b/packages/code-du-travail-frontend/src/contributions/Contribution.js @@ -62,7 +62,9 @@ const References = ({ references }) => { // search CC + display filtered answer const AnswersConventions = ({ answers }) => { const [ccInfo, setCcInfo] = useConventionState(null); - const answer = ccInfo && answers.find(a => a.idcc === ccInfo.num); + const answer = + ccInfo && + answers.find(a => parseInt(a.idcc, 10) === parseInt(ccInfo.num, 10)); // ensure we have valid data in ccInfo const isCcDetected = ccInfo && ccInfo.id && ccInfo.num && ccInfo.title; return ( diff --git a/packages/code-du-travail-frontend/src/contributions/__tests__/Contribution.test.js b/packages/code-du-travail-frontend/src/contributions/__tests__/Contribution.test.js index 4d48d3f5c6..e4333b77a0 100644 --- a/packages/code-du-travail-frontend/src/contributions/__tests__/Contribution.test.js +++ b/packages/code-du-travail-frontend/src/contributions/__tests__/Contribution.test.js @@ -40,7 +40,7 @@ describe("", () => { conventions: [ { id: 123, - idcc: 456, + idcc: "456", markdown: "hello **123**" } ] @@ -54,7 +54,7 @@ describe("", () => { conventions: [ { id: 123, - idcc: 456, + idcc: "456", markdown: "hello **123**" } ] @@ -65,7 +65,7 @@ describe("", () => { it("should render preselected convention", () => { mockPreselectedConvention = { title: "preselected convention", - num: "idcc-preselected", + num: "0044", id: 123 }; const answers = { @@ -73,7 +73,7 @@ describe("", () => { conventions: [ { id: 123, - idcc: "idcc-preselected", + idcc: "0044", markdown: "hello **123**" } ] @@ -86,7 +86,7 @@ describe("", () => { it("should NOT render invalid preselected convention", () => { mockPreselectedConvention = { title: "unknown convention", - num: "idcc-unknown", + num: "0000", id: 456 }; const answers = { @@ -94,7 +94,7 @@ describe("", () => { conventions: [ { id: 123, - idcc: "idcc-preselected", + idcc: "0044", markdown: "hello **123**" } ] @@ -107,7 +107,7 @@ describe("", () => { it("should render answer references", () => { mockPreselectedConvention = { title: "preselected convention", - num: "idcc-preselected", + num: "0044", id: 123 }; const answers = { @@ -115,7 +115,7 @@ describe("", () => { conventions: [ { id: 123, - idcc: "idcc-preselected", + idcc: "0044", markdown: "hello **123**", references: [ { diff --git a/packages/code-du-travail-frontend/src/contributions/__tests__/__snapshots__/Contribution.test.js.snap b/packages/code-du-travail-frontend/src/contributions/__tests__/__snapshots__/Contribution.test.js.snap index d348497fd6..19f46fd26e 100644 --- a/packages/code-du-travail-frontend/src/contributions/__tests__/__snapshots__/Contribution.test.js.snap +++ b/packages/code-du-travail-frontend/src/contributions/__tests__/__snapshots__/Contribution.test.js.snap @@ -182,7 +182,7 @@ exports[` should NOT render invalid preselected convention 1`] = > unknown convention (IDCC - idcc-unknown + 0000 ) @@ -372,7 +372,7 @@ exports[` should render answer references 1`] = ` > preselected convention (IDCC - idcc-preselected + 0044 ) @@ -604,7 +604,7 @@ exports[` should render preselected convention 1`] = ` > preselected convention (IDCC - idcc-preselected + 0044 ) diff --git a/yarn.lock b/yarn.lock index d048b31010..3d88d65081 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2374,10 +2374,10 @@ eslint-plugin-jest "^23.1.1" eslint-plugin-prettier "~3.1.1" -"@socialgouv/fiches-vdd@^1.0.52": - version "1.0.52" - resolved "https://registry.yarnpkg.com/@socialgouv/fiches-vdd/-/fiches-vdd-1.0.52.tgz#d8efd8fee9f779a4e33ff38dbcb596abe41f7240" - integrity sha512-Sz+lHIvh/MGdOmHKWGyIiKp9+qFHWk0fJesi/+l/t4DvnCPLqg1sEpscVupQ+BVB3zDFHNCVlgs6RAHHyof0rw== +"@socialgouv/fiches-vdd@^1.0.53": + version "1.0.53" + resolved "https://registry.yarnpkg.com/@socialgouv/fiches-vdd/-/fiches-vdd-1.0.53.tgz#5f2ab2a67ebbedbcef4d86e633079b814f697c20" + integrity sha512-mrqfF2n756+13pf6xh7uY/oC8cCBhdHrZProKiX92knF4pEPjlzEUf231vrQCzc+2y6dQ9MHWXWZdIyFWKH2Pg== dependencies: node-fetch "^2.6.0" ora "^4.0.3"