From 533f7048bfb37ff0f224a6c916aeab4005ea56e1 Mon Sep 17 00:00:00 2001 From: binarygit Date: Wed, 4 Jan 2023 16:33:21 +0545 Subject: [PATCH] [Enterprise->Create] Show correct error message when user inputs url in instagram field --- .../services/enterprise_registration_service.js.coffee | 4 ++++ app/views/registration/steps/_social.html.haml | 1 + spec/system/consumer/registration_spec.rb | 7 +++++++ 3 files changed, 12 insertions(+) diff --git a/app/assets/javascripts/darkswarm/services/enterprise_registration_service.js.coffee b/app/assets/javascripts/darkswarm/services/enterprise_registration_service.js.coffee index 485bc5a36f..614e109eac 100644 --- a/app/assets/javascripts/darkswarm/services/enterprise_registration_service.js.coffee +++ b/app/assets/javascripts/darkswarm/services/enterprise_registration_service.js.coffee @@ -55,6 +55,10 @@ angular.module('Darkswarm').factory "EnterpriseRegistrationService", ($http, Reg ).catch((response) -> Loading.clear() alert(t('failed_to_update_enterprise_unknown')) + if response.data.errors.instagram + igErr = document.querySelector("#instagram-error") + igErr.style.display = 'block' + igErr.textContent = response.data.errors.instagram[0] ) prepare: => diff --git a/app/views/registration/steps/_social.html.haml b/app/views/registration/steps/_social.html.haml index 8552b927b7..9cd86ead1c 100644 --- a/app/views/registration/steps/_social.html.haml +++ b/app/views/registration/steps/_social.html.haml @@ -37,6 +37,7 @@ .field %label{ for: 'enterprise_instagram' }= t(".instagram")+":" %input.chunky{ id: 'enterprise_instagram', placeholder: "{{'registration.steps.social.instagram_placeholder' | t}}", ng: { model: 'enterprise.instagram' } } + %span.error.small-12.columns#instagram-error{ style: "display: none" } .row.buttons .small-12.columns diff --git a/spec/system/consumer/registration_spec.rb b/spec/system/consumer/registration_spec.rb index 695455b0f4..1c17aff003 100644 --- a/spec/system/consumer/registration_spec.rb +++ b/spec/system/consumer/registration_spec.rb @@ -125,6 +125,13 @@ describe "Registration" do click_button "Continue" expect(page).to have_content 'How can people find My Awesome Enterprise online?' + # Filling in social with invalid value for instagram + fill_in "enterprise_instagram", with: "www.instagram.com/coopcircuits/ " + click_button "Continue" + accept_alert "Failed to update your enterprise." do + expect(page).to have_content "Must be user name only eg. the_prof" + end + # Filling in social fill_in 'enterprise_website', with: 'www.shop.com' fill_in 'enterprise_facebook', with: 'FaCeBoOk'