From 8a9d30e14eeaa3ce7d1ce338c1a1963f76042ecd Mon Sep 17 00:00:00 2001 From: baarkerlounger Date: Tue, 30 Nov 2021 19:34:44 +0000 Subject: [PATCH] Add a feature spec for tab switching --- spec/features/organisation_spec.rb | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 spec/features/organisation_spec.rb diff --git a/spec/features/organisation_spec.rb b/spec/features/organisation_spec.rb new file mode 100644 index 000000000..26bed944e --- /dev/null +++ b/spec/features/organisation_spec.rb @@ -0,0 +1,29 @@ +require "rails_helper" +require_relative "form/helpers" + +RSpec.describe "User Features" do + include Helpers + let!(:user) { FactoryBot.create(:user) } + let(:organisation) { user.organisation } + let(:org_id) { organisation.id } + + before do + sign_in user + end + + context "Organisation page" do + it "default to organisation details" do + visit("/case_logs") + click_link("Organisation") + expect(page).to have_content(user.organisation.name) + end + + it "can switch tabs" do + visit("/organisations/#{org_id}") + click_link("Users") + expect(page).to have_current_path("/organisations/#{org_id}/users") + click_link("Details") + expect(page).to have_current_path("/organisations/#{org_id}/details") + end + end +end