Browse Source

Spec nav bar highlighting from user perspective

pull/619/head
baarkerlounger 3 years ago
parent
commit
66621eac50
  1. 37
      spec/features/user_spec.rb
  2. 4
      spec/requests/users_controller_spec.rb

37
spec/features/user_spec.rb

@ -198,6 +198,38 @@ RSpec.describe "User Features" do
context "when signed in as a data coordinator" do
let!(:user) { FactoryBot.create(:user, :data_coordinator, last_sign_in_at: Time.zone.now) }
context "when viewing users" do
before do
visit("/logs")
fill_in("user[email]", with: user.email)
fill_in("user[password]", with: "pAssword1")
click_button("Sign in")
click_link("Users")
end
it "highlights the users navigation tab" do
expect(page).to have_css('[aria-current="page"]', text: "Users")
expect(page).not_to have_css('[aria-current="page"]', text: "About your organisation")
expect(page).not_to have_css('[aria-current="page"]', text: "Logs")
end
end
context "when viewing your organisation details" do
before do
visit("/logs")
fill_in("user[email]", with: user.email)
fill_in("user[password]", with: "pAssword1")
click_button("Sign in")
click_link("About your organisation")
end
it "highlights the users navigation tab" do
expect(page).to have_css('[aria-current="page"]', text: "About your organisation")
expect(page).not_to have_css('[aria-current="page"]', text: "Users")
expect(page).not_to have_css('[aria-current="page"]', text: "Logs")
end
end
context "when viewing your account" do
before do
visit("/logs")
@ -213,6 +245,11 @@ RSpec.describe "User Features" do
expect(page).to have_current_path("/account")
end
it "does not highlight the users navigation tab" do
visit("/account")
expect(page).not_to have_css('[aria-current="page"]', text: "Users")
end
it "can navigate to change your password page from main account page" do
visit("/account")
find('[data-qa="change-password"]').click

4
spec/requests/users_controller_spec.rb

@ -357,10 +357,6 @@ RSpec.describe UsersController, type: :request do
expect(page).to have_link("Change", text: "are you a data protection officer?")
expect(page).to have_link("Change", text: "are you a key contact?")
end
it "does not highlight the users navigation tab" do
expect(page).not_to have_css('[aria-current="page"]', text: "Users")
end
end
context "when the current user does not match the user ID" do

Loading…
Cancel
Save