From d4c864a11831ec653693196e4c84eef08039c7c5 Mon Sep 17 00:00:00 2001 From: cyrillefr Date: Mon, 17 Jul 2023 11:26:28 +0200 Subject: [PATCH] Add testing for modal warning that name is already in use --- spec/system/consumer/registration_spec.rb | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/spec/system/consumer/registration_spec.rb b/spec/system/consumer/registration_spec.rb index a568f068fb..cd81ee00a6 100644 --- a/spec/system/consumer/registration_spec.rb +++ b/spec/system/consumer/registration_spec.rb @@ -160,12 +160,15 @@ describe "Registration" do end context "Enterprise name is already taken" do + let(:owner) do + Spree::User.create!(email: "penny.profile@example.org", password: "cannotbeblank") + end + before do address = Spree::Address.create!(firstname: 'John', lastname: 'Doe', address1: '1400 Sesame street', zipcode: '3070', city: 'Southcote', phone: '12 3456 7890', country_id: 1, state_id: 1, company: 'unused') - owner = Spree::User.create!(email: "penny.profile@example.org", password: "cannotbeblank") Enterprise.create(name: 'My Awesome Enterprise', address:, owner:) end @@ -191,7 +194,15 @@ describe "Registration" do click_button "Continue" click_button "Create Profile" click_link "producer-panel" - click_button "Create Profile" + alert_text = <<~TEXT.strip + Name has already been taken. If this is your enterprise and you would \ + like to claim ownership, or if you would like to trade with this \ + enterprise please contact the current manager of this profile at \ + #{owner.email}. + TEXT + accept_alert(alert_text) do + click_button "Create Profile" + end expect(page).to have_button "Create Profile", disabled: false end end