Skip to content

Commit

Permalink
added switch app menu item
Browse files Browse the repository at this point in the history
Added test to verify switch app menu item

Updated code to include system test for switch app menu item

updated code in user helper to remove warning messages in test suite
  • Loading branch information
sairamya93 committed Sep 9, 2024
1 parent 089985e commit da4dfb3
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 6 deletions.
4 changes: 4 additions & 0 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
href: root_path,
active: current_page?(root_path),
},
{
text: "Switch app",
href: Plek.external_url_for("signon"),
},
],
} %>

Expand Down
3 changes: 3 additions & 0 deletions spec/rails_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,7 @@
config.expose_dsl_globally = false
config.infer_spec_type_from_file_location!
config.use_transactional_fixtures = true
config.before(:each, type: :system) do
driven_by :rack_test
end
end
12 changes: 6 additions & 6 deletions spec/support/users_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ def as_other_department_user(&block)
end

def as_logged_in_user(permissions, organisation_slug, &_block)
allow(@controller).to receive(:authenticate_user!).and_return(true)
allow(@controller).to receive(:user_signed_in?).and_return(true)
allow(@controller).to receive(:current_user).and_return(User.new(permissions:, organisation_slug:))
allow_any_instance_of(ApplicationController).to receive(:authenticate_user!).and_return(true)
allow_any_instance_of(ApplicationController).to receive(:user_signed_in?).and_return(true)
allow_any_instance_of(ApplicationController).to receive(:current_user).and_return(User.new(permissions:, organisation_slug:))
yield
allow(@controller).to receive(:authenticate_user!).and_call_original
allow(@controller).to receive(:user_signed_in?).and_call_original
allow(@controller).to receive(:current_user).and_call_original
allow_any_instance_of(ApplicationController).to receive(:authenticate_user!).and_call_original
allow_any_instance_of(ApplicationController).to receive(:user_signed_in?).and_call_original
allow_any_instance_of(ApplicationController).to receive(:current_user).and_call_original
end
16 changes: 16 additions & 0 deletions spec/system/main_menu_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
require "rails_helper"

RSpec.describe "Main menu" do
context "as a normal user" do
it "shows the Services/Switch app menu items and goes to signon when Switch app is clicked" do
as_gds_editor do
visit "/admin"

within(".govuk-header__container") do
expect(page).to have_link("Services")
expect(page).to have_link("Switch app")
end
end
end
end
end

0 comments on commit da4dfb3

Please sign in to comment.