diff --git a/test/integration/account/organisations_test.rb b/test/integration/account/organisations_test.rb index 405b51196..41a8eb7b2 100644 --- a/test/integration/account/organisations_test.rb +++ b/test/integration/account/organisations_test.rb @@ -33,7 +33,37 @@ class Account::OrganisationsTest < ActionDispatch::IntegrationTest visit edit_account_organisation_path - assert page.has_select? "Organisation", selected: "Postage" + assert_equal "Postage", user.reload.organisation_name + end + + context "with JavaScript enabled" do + setup do + use_javascript_driver + end + + should "allow GOVUK Admin users to change their organisation" do + current_organisation = create(:organisation, name: "Judiciary") + user = FactoryBot.create(:admin_user, organisation: current_organisation) + + create(:organisation, name: "Postage") + + visit new_user_session_path + signin_with user + + visit edit_account_organisation_path + + autocomplete_helper = AutocompleteHelper.new + autocomplete_helper.clear_selection + autocomplete_helper.select_autocomplete_option("Postage") + click_button "Change organisation" + + assert_current_url account_path + assert page.has_text? "Your organisation is now Postage" + + visit edit_account_organisation_path + + assert_equal "Postage", user.reload.organisation_name + end end end end diff --git a/test/integration/batch_inviting_users_test.rb b/test/integration/batch_inviting_users_test.rb index 8b7ee63fe..339e00cc5 100644 --- a/test/integration/batch_inviting_users_test.rb +++ b/test/integration/batch_inviting_users_test.rb @@ -114,6 +114,27 @@ class BatchInvitingUsersTest < ActionDispatch::IntegrationTest end end + context "with JavaScript enabled" do + setup do + use_javascript_driver + end + + should "allow selecting an organisation and continuing to the next step" do + visit root_path + signin_with create(:superadmin_user) + + visit new_batch_invitation_path + path = Rails.root.join("test/fixtures/users.csv") + attach_file("Upload a CSV file", path) + AutocompleteHelper.new.select_autocomplete_option(@cabinet_office.name) + + click_button "Manage permissions for new users" + assert assert_selector "h1", text: "Manage permissions for new users" + + assert_equal @cabinet_office, BatchInvitation.last.organisation + end + end + def perform_batch_invite_with_user(user, application, organisation:, fixture_file: "users.csv", user_count: 1) perform_enqueued_jobs do visit root_path diff --git a/test/support/autocomplete_helper.rb b/test/support/autocomplete_helper.rb index 0ae513d58..6c66cfc0f 100644 --- a/test/support/autocomplete_helper.rb +++ b/test/support/autocomplete_helper.rb @@ -3,6 +3,10 @@ class AutocompleteHelper include Capybara::DSL + def clear_selection + click_button "Clear selection" + end + def select_autocomplete_option(option_string) autocomplete_input_element = find(".autocomplete__input") autocomplete_input_element.fill_in with: option_string