From 15d56c0b6156435f52ec6c67d9ed2f44a19f634c Mon Sep 17 00:00:00 2001 From: Samuel Young Date: Fri, 30 Jan 2026 14:14:50 +0000 Subject: [PATCH] CLDC-4114: Restructure data protection confirmation banner tests --- ...tion_confirmation_banner_component_spec.rb | 81 +------------------ 1 file changed, 1 insertion(+), 80 deletions(-) diff --git a/spec/components/data_protection_confirmation_banner_component_spec.rb b/spec/components/data_protection_confirmation_banner_component_spec.rb index 587a5c2c0..6dbb1e666 100644 --- a/spec/components/data_protection_confirmation_banner_component_spec.rb +++ b/spec/components/data_protection_confirmation_banner_component_spec.rb @@ -86,7 +86,7 @@ RSpec.describe DataProtectionConfirmationBannerComponent, type: :component do end end - context "when org has a signed data sharing agremeent" do + context "when org has a signed data sharing agreemeent" do it "does not display banner" do expect(component.display_banner?).to eq(false) expect(render.content).to be_empty @@ -126,84 +126,5 @@ RSpec.describe DataProtectionConfirmationBannerComponent, type: :component do end end end - - context "when org does not have a DPO" do - before do - organisation.users.where(is_dpo: true).destroy_all - end - - it "doesn't display the banner" do - expect(component.display_banner?).to eq(false) - expect(render.content).to be_empty - end - end - - context "when org has a DPO" do - context "when org does not have a signed data sharing agreement" do - context "when user is not a DPO" do - let(:organisation) { create(:organisation, :without_dpc) } - let(:user) { create(:user, organisation:, with_dsa: false) } - let!(:dpo) { create(:user, :data_protection_officer, organisation:, with_dsa: false) } - - it "displays the banner and shows DPOs" do - expect(component.display_banner?).to eq(true) - expect(render.css("a")).to be_empty - expect(render).to have_selector("p", text: "Your data protection officer must accept the Data Sharing Agreement on CORE before you can create any logs.") - expect(render).to have_selector("p", text: "You can ask: #{dpo.name}") - end - - context "and has a parent organisation that owns stock and has signed DSA" do - before do - parent_organisation = create(:organisation, holds_own_stock: true) - create(:organisation_relationship, child_organisation: organisation, parent_organisation:) - end - - it "displays the banner and shows DPOs" do - expect(component.display_banner?).to eq(true) - expect(render.css("a")).to be_empty - expect(render).to have_selector("p", text: "Your data protection officer must accept the Data Sharing Agreement on CORE before you can create any logs.") - expect(render).to have_selector("p", text: "You can ask: #{dpo.name}") - end - end - end - - context "when user is a DPO" do - let(:organisation) { create(:organisation, :without_dpc) } - let(:user) { create(:user, :data_protection_officer, organisation:, with_dsa: false) } - - it "displays the banner and asks to sign" do - expect(component.display_banner?).to eq(true) - expect(render).to have_link( - "Read the Data Sharing Agreement", - href: "/organisations/#{organisation.id}/data-sharing-agreement", - ) - expect(render).to have_selector("p", text: "Your organisation must accept the Data Sharing Agreement before you can create any logs.") - end - - context "and has a parent organisation that owns stock and has signed DSA" do - before do - parent_organisation = create(:organisation, holds_own_stock: true) - create(:organisation_relationship, child_organisation: organisation, parent_organisation:) - end - - it "displays the banner and asks to sign" do - expect(component.display_banner?).to eq(true) - expect(render).to have_link( - "Read the Data Sharing Agreement", - href: "/organisations/#{organisation.id}/data-sharing-agreement", - ) - expect(render).to have_selector("p", text: "Your organisation must accept the Data Sharing Agreement before you can create any logs.") - end - end - end - end - - context "when org has a signed data sharing agremeent" do - it "does not display banner" do - expect(component.display_banner?).to eq(false) - expect(render.content).to be_empty - end - end - end end end