From e94b890e94e3efdbcf8bfbdbf7ecceabdc6c90c2 Mon Sep 17 00:00:00 2001 From: Hugoobx Date: Fri, 18 Oct 2024 15:16:33 +0200 Subject: [PATCH 1/4] feat: ajout du statut de notification --- .../records/NotificationState.test.js | 58 ++++++++++ src/components/records/NotificationState.vue | 64 +++++++++++ .../certification/exploitations/index.vue | 104 +++++++++++++----- src/pages/exploitations/[numeroBio]/index.vue | 15 ++- src/pages/exploitations/index.vue | 31 ++++-- src/referentiels/ab.js | 50 +++++++++ src/stores/operator.js | 3 +- src/utils/__fixtures__/operator.json | 3 +- src/utils/dates.js | 16 +++ src/utils/helper-notification.js | 60 ++++++++++ src/utils/helper-notification.test.js | 96 ++++++++++++++++ 11 files changed, 457 insertions(+), 43 deletions(-) create mode 100644 src/components/records/NotificationState.test.js create mode 100644 src/components/records/NotificationState.vue create mode 100644 src/utils/helper-notification.js create mode 100644 src/utils/helper-notification.test.js diff --git a/src/components/records/NotificationState.test.js b/src/components/records/NotificationState.test.js new file mode 100644 index 00000000..481ec8ba --- /dev/null +++ b/src/components/records/NotificationState.test.js @@ -0,0 +1,58 @@ +import { describe, expect, it } from "vitest"; +import { mount } from "@vue/test-utils"; +import NotificationState from "./NotificationState.vue"; + +describe("NotificationState", () => { + it('renders correctly for "BROUILLON" state', () => { + const wrapper = mount(NotificationState, { + props: { + record: "BROUILLON", + text: true, + }, + }); + + expect(wrapper.find(".fr-icon--sm").classes()).toContain("fr-icon-article-line"); + expect( + wrapper + .find("span") + .text() + .replace(/\u00A0/g, " "), + ).toContain("Brouillon"); + + const spanElement = wrapper.find("span"); + expect(spanElement.attributes("style")).toContain("background-color: rgb(211, 211, 211)"); + expect(spanElement.attributes("style")).toContain("color: rgb(128, 128, 128)"); + }); + + it('does not render text when "text" prop is false', () => { + const wrapper = mount(NotificationState, { + props: { + record: "BROUILLON", + text: false, + }, + }); + + expect(wrapper.find(".mr-1").exists()).toBe(false); + }); + + it('applies styles and classes for "ENGAGEE" state', () => { + const wrapper = mount(NotificationState, { + props: { + record: "ENGAGEE", + text: true, + }, + }); + + expect(wrapper.find(".fr-icon--sm").classes()).toContain("fr-icon-success-line"); + expect( + wrapper + .find("span") + .text() + .replace(/\u00A0/g, " "), + ).toContain("Notification Engagée"); + + const spanElement = wrapper.find("span"); + expect(spanElement.attributes("style")).toContain("background-color: rgb(158, 249, 190)"); + expect(spanElement.attributes("style")).toContain("color: rgb(41, 114, 84)"); + }); +}); diff --git a/src/components/records/NotificationState.vue b/src/components/records/NotificationState.vue new file mode 100644 index 00000000..745555f1 --- /dev/null +++ b/src/components/records/NotificationState.vue @@ -0,0 +1,64 @@ + + + + + diff --git a/src/pages/certification/exploitations/index.vue b/src/pages/certification/exploitations/index.vue index aff53c05..9e694fd9 100644 --- a/src/pages/certification/exploitations/index.vue +++ b/src/pages/certification/exploitations/index.vue @@ -48,10 +48,12 @@ meta: }} - - - - + + + + + + @@ -61,35 +63,36 @@ meta: code="nom" v-model="sortOrder" @update:modelValue="(v) => updateQuery({ ...v, page: 1 })" - >ExploitationExploitation (n° Bio) - + Début de conversionEngagé le - + + Notification + + Date de l'auditDernier audit - + Statut + - + Chargement des données… @@ -113,7 +117,7 @@ meta: - +