diff --git a/src/components/records/NotificationState.test.js b/src/components/records/NotificationState.test.js new file mode 100644 index 00000000..216a9263 --- /dev/null +++ b/src/components/records/NotificationState.test.js @@ -0,0 +1,106 @@ +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: { + operator: { + notifications: [ + { + status: "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 "BROUILLON" state IF another notifications exists', () => { + const wrapper = mount(NotificationState, { + props: { + operator: { + notifications: [ + { + status: "BROUILLON", + }, + { + status: "ENGAGEE", + }, + ], + }, + text: true, + }, + }); + + expect(wrapper.find(".fr-icon--sm").classes()).toContain("fr-icon-success-line"); + expect( + wrapper + .find("span") + .text() + .replace(/\u00A0/g, " "), + ).toContain("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)"); + }); + + it('does not render text when "text" prop is false', () => { + const wrapper = mount(NotificationState, { + props: { + operator: { + notifications: [ + { + etatCertification: "BROUILLON", + }, + ], + }, + text: false, + }, + }); + + expect(wrapper.find(".mr-1").exists()).toBe(false); + }); + + it('applies styles and classes for "ENGAGEE" state', () => { + const wrapper = mount(NotificationState, { + props: { + operator: { + certificats: [ + { + status: "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..af1b7e9c --- /dev/null +++ b/src/components/records/NotificationState.vue @@ -0,0 +1,81 @@ + + + + Notification + {{ + stateInfo ? stateInfo.label : "-" + }} + + + + + + diff --git a/src/pages/certification/exploitations/index.vue b/src/pages/certification/exploitations/index.vue index aff53c05..8af7d675 100644 --- a/src/pages/certification/exploitations/index.vue +++ b/src/pages/certification/exploitations/index.vue @@ -48,10 +48,12 @@ meta: }}
{{ error }}