From 297dfe6ab91da9e655fb2d8fc633048974bdb208 Mon Sep 17 00:00:00 2001 From: "Vitaliy @blackst0ne Klachkov" Date: Wed, 13 Sep 2017 09:50:18 +1100 Subject: [PATCH] Replace the 'profile/active_tab.feature' spinach test with an rspec analog --- .../replace_profile_active_tab-feature.yml | 5 ++++ features/profile/active_tab.feature | 29 ------------------- features/steps/profile/active_tab.rb | 25 ---------------- .../user_visits_profile_account_page_spec.rb | 16 ++++++++++ ...ts_profile_authentication_log_page_spec.rb | 16 ++++++++++ .../profiles/user_visits_profile_page_spec.rb | 16 ++++++++++ ...r_visits_profile_preferences_page_spec.rb} | 14 ++++++--- .../user_visits_profile_ssh_keys_page_spec.rb | 16 ++++++++++ 8 files changed, 79 insertions(+), 58 deletions(-) create mode 100644 changelogs/unreleased/replace_profile_active_tab-feature.yml delete mode 100644 features/profile/active_tab.feature delete mode 100644 features/steps/profile/active_tab.rb create mode 100644 spec/features/profiles/user_visits_profile_account_page_spec.rb create mode 100644 spec/features/profiles/user_visits_profile_authentication_log_page_spec.rb create mode 100644 spec/features/profiles/user_visits_profile_page_spec.rb rename spec/features/profiles/{preferences_spec.rb => user_visits_profile_preferences_page_spec.rb} (75%) create mode 100644 spec/features/profiles/user_visits_profile_ssh_keys_page_spec.rb diff --git a/changelogs/unreleased/replace_profile_active_tab-feature.yml b/changelogs/unreleased/replace_profile_active_tab-feature.yml new file mode 100644 index 00000000000..e911396a2b9 --- /dev/null +++ b/changelogs/unreleased/replace_profile_active_tab-feature.yml @@ -0,0 +1,5 @@ +--- +title: Replace the 'profile/active_tab.feature' spinach test with an rspec analog +merge_request: 14239 +author: Vitaliy @blackst0ne Klachkov +type: other diff --git a/features/profile/active_tab.feature b/features/profile/active_tab.feature deleted file mode 100644 index 21d7d6c3800..00000000000 --- a/features/profile/active_tab.feature +++ /dev/null @@ -1,29 +0,0 @@ -@profile -Feature: Profile Active Tab - Background: - Given I sign in as a user - - Scenario: On Profile Home - Given I visit profile page - Then the active main tab should be Home - And no other main tabs should be active - - Scenario: On Profile Account - Given I visit profile account page - Then the active main tab should be Account - And no other main tabs should be active - - Scenario: On Profile SSH Keys - Given I visit profile SSH keys page - Then the active main tab should be SSH Keys - And no other main tabs should be active - - Scenario: On Profile Preferences - Given I visit profile preferences page - Then the active main tab should be Preferences - And no other main tabs should be active - - Scenario: On Profile Authentication log - Given I visit Authentication log page - Then the active main tab should be Authentication log - And no other main tabs should be active diff --git a/features/steps/profile/active_tab.rb b/features/steps/profile/active_tab.rb deleted file mode 100644 index 069d4e6a23d..00000000000 --- a/features/steps/profile/active_tab.rb +++ /dev/null @@ -1,25 +0,0 @@ -class Spinach::Features::ProfileActiveTab < Spinach::FeatureSteps - include SharedAuthentication - include SharedPaths - include SharedActiveTab - - step 'the active main tab should be Home' do - ensure_active_main_tab('Profile') - end - - step 'the active main tab should be Account' do - ensure_active_main_tab('Account') - end - - step 'the active main tab should be SSH Keys' do - ensure_active_main_tab('SSH Keys') - end - - step 'the active main tab should be Preferences' do - ensure_active_main_tab('Preferences') - end - - step 'the active main tab should be Authentication log' do - ensure_active_main_tab('Authentication log') - end -end diff --git a/spec/features/profiles/user_visits_profile_account_page_spec.rb b/spec/features/profiles/user_visits_profile_account_page_spec.rb new file mode 100644 index 00000000000..8c7233c77ad --- /dev/null +++ b/spec/features/profiles/user_visits_profile_account_page_spec.rb @@ -0,0 +1,16 @@ +require 'spec_helper' + +describe 'User visits the profile account page' do + let(:user) { create(:user) } + + before do + sign_in(user) + + visit(profile_account_path) + end + + it 'shows correct menu item' do + expect(find('.sidebar-top-level-items > li.active')).to have_content('Account') + expect(page).to have_selector('.sidebar-top-level-items > li.active', count: 1) + end +end diff --git a/spec/features/profiles/user_visits_profile_authentication_log_page_spec.rb b/spec/features/profiles/user_visits_profile_authentication_log_page_spec.rb new file mode 100644 index 00000000000..ffb504cc573 --- /dev/null +++ b/spec/features/profiles/user_visits_profile_authentication_log_page_spec.rb @@ -0,0 +1,16 @@ +require 'spec_helper' + +describe 'User visits the authentication log page' do + let(:user) { create(:user) } + + before do + sign_in(user) + + visit(audit_log_profile_path) + end + + it 'shows correct menu item' do + expect(find('.sidebar-top-level-items > li.active')).to have_content('Authentication log') + expect(page).to have_selector('.sidebar-top-level-items > li.active', count: 1) + end +end diff --git a/spec/features/profiles/user_visits_profile_page_spec.rb b/spec/features/profiles/user_visits_profile_page_spec.rb new file mode 100644 index 00000000000..3bf6d718bc7 --- /dev/null +++ b/spec/features/profiles/user_visits_profile_page_spec.rb @@ -0,0 +1,16 @@ +require 'spec_helper' + +describe 'User visits the profile page' do + let(:user) { create(:user) } + + before do + sign_in(user) + + visit(profile_path) + end + + it 'shows correct menu item' do + expect(find('.sidebar-top-level-items > li.active')).to have_content('Profile') + expect(page).to have_selector('.sidebar-top-level-items > li.active', count: 1) + end +end diff --git a/spec/features/profiles/preferences_spec.rb b/spec/features/profiles/user_visits_profile_preferences_page_spec.rb similarity index 75% rename from spec/features/profiles/preferences_spec.rb rename to spec/features/profiles/user_visits_profile_preferences_page_spec.rb index c935cdfd5c4..d1776b3d7c2 100644 --- a/spec/features/profiles/preferences_spec.rb +++ b/spec/features/profiles/user_visits_profile_preferences_page_spec.rb @@ -1,14 +1,20 @@ require 'spec_helper' -describe 'Profile > Preferences', :js do +describe 'User visits the profile preferences page' do let(:user) { create(:user) } before do sign_in(user) - visit profile_preferences_path + + visit(profile_preferences_path) end - describe 'User changes their syntax highlighting theme' do + it 'shows correct menu item' do + expect(find('.sidebar-top-level-items > li.active')).to have_content('Preferences') + expect(page).to have_selector('.sidebar-top-level-items > li.active', count: 1) + end + + describe 'User changes their syntax highlighting theme', :js do it 'creates a flash message' do choose 'user_color_scheme_id_5' @@ -27,7 +33,7 @@ describe 'Profile > Preferences', :js do end end - describe 'User changes their default dashboard' do + describe 'User changes their default dashboard', :js do it 'creates a flash message' do select 'Starred Projects', from: 'user_dashboard' click_button 'Save' diff --git a/spec/features/profiles/user_visits_profile_ssh_keys_page_spec.rb b/spec/features/profiles/user_visits_profile_ssh_keys_page_spec.rb new file mode 100644 index 00000000000..0b7a63b54b4 --- /dev/null +++ b/spec/features/profiles/user_visits_profile_ssh_keys_page_spec.rb @@ -0,0 +1,16 @@ +require 'spec_helper' + +describe 'User visits the profile SSH keys page' do + let(:user) { create(:user) } + + before do + sign_in(user) + + visit(profile_keys_path) + end + + it 'shows correct menu item' do + expect(find('.sidebar-top-level-items > li.active')).to have_content('SSH Keys') + expect(page).to have_selector('.sidebar-top-level-items > li.active', count: 1) + end +end