diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-10-25 03:10:30 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-10-25 03:10:30 +0300 |
commit | e4d18499293fbc9510a87611acb7d9787a581b78 (patch) | |
tree | d9e5a7a87dd96dbe5473a3636f4e67b042d6b422 /spec | |
parent | 774f6e6e9824de147c12dcec745b16a049f86146 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r-- | spec/features/help_dropdown_spec.rb | 89 | ||||
-rw-r--r-- | spec/features/users/snippets_spec.rb | 12 | ||||
-rw-r--r-- | spec/features/users/user_browses_projects_on_user_page_spec.rb | 8 | ||||
-rw-r--r-- | spec/features/whats_new_spec.rb | 50 |
4 files changed, 77 insertions, 82 deletions
diff --git a/spec/features/help_dropdown_spec.rb b/spec/features/help_dropdown_spec.rb index 08d7dba4d79..3e4c0bc55fe 100644 --- a/spec/features/help_dropdown_spec.rb +++ b/spec/features/help_dropdown_spec.rb @@ -3,24 +3,19 @@ require 'spec_helper' RSpec.describe "Help Dropdown", :js, feature_category: :shared do - let_it_be(:user) { create(:user, :no_super_sidebar) } - let_it_be(:admin) { create(:admin, :no_super_sidebar) } + let_it_be(:user) { create(:user) } + let_it_be(:admin) { create(:admin) } before do stub_application_setting(version_check_enabled: true) end - context 'when logged in as non-admin' do - before do - sign_in(user) - visit root_path - end - - it 'does not render version data' do - page.within '.header-help' do - find('.header-help-dropdown-toggle').click + shared_examples 'no version check badge' do + it 'does not render version check badge' do + within_testid('super-sidebar') do + click_on 'Help' - expect(page).not_to have_text('Your GitLab Version') + expect(page).not_to have_text('Your GitLab version') expect(page).not_to have_text("#{Gitlab.version_info.major}.#{Gitlab.version_info.minor}") expect(page).not_to have_selector('.version-check-badge') expect(page).not_to have_text('Up to date') @@ -28,45 +23,53 @@ RSpec.describe "Help Dropdown", :js, feature_category: :shared do end end - context 'when logged in as admin' do - before do - sign_in(admin) - gitlab_enable_admin_mode_sign_in(admin) - end + shared_examples 'correct version check badge' do |ui_text, severity| + context "when severity is #{severity}" do + before do + sign_in(admin) + gitlab_enable_admin_mode_sign_in(admin) - describe 'does render version data' do - where(:response, :ui_text) do - [ - [{ "severity" => "success" }, 'Up to date'], - [{ "severity" => "warning" }, 'Update available'], - [{ "severity" => "danger" }, 'Update ASAP'] - ] + allow_next_instance_of(VersionCheck) do |instance| + allow(instance).to receive(:response).and_return({ "severity" => severity }) + end + visit root_path end - with_them do - before do - allow_next_instance_of(VersionCheck) do |instance| - allow(instance).to receive(:response).and_return(response) - end - visit root_path - end + it 'renders correct version check badge variant' do + within_testid('super-sidebar') do + click_on 'Help' - it 'renders correct version badge variant', - quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/369850' do - page.within '.header-help' do - find('.header-help-dropdown-toggle').click + expect(page).to have_text('Your GitLab version') + expect(page).to have_text("#{Gitlab.version_info.major}.#{Gitlab.version_info.minor}") - expect(page).to have_text('Your GitLab Version') - expect(page).to have_text("#{Gitlab.version_info.major}.#{Gitlab.version_info.minor}") - expect(page).to have_selector('.version-check-badge') - expect(page).to have_selector( - 'a[data-testid="gitlab-version-container"][href="/help/update/index"]' - ) - expect(page).to have_selector('.version-check-badge[href="/help/update/index"]') - expect(page).to have_text(ui_text) + within page.find_link(href: help_page_path('update/index')) do + expect(page).to have_selector(".version-check-badge.badge-#{severity}", text: ui_text) end end end end end + + context 'when anonymous user' do + before do + visit user_path(user) + end + + include_examples 'no version check badge' + end + + context 'when logged in as non-admin' do + before do + sign_in(user) + visit root_path + end + + include_examples 'no version check badge' + end + + context 'when logged in as admin' do + include_examples 'correct version check badge', 'Up to date', 'success' + include_examples 'correct version check badge', 'Update available', 'warning' + include_examples 'correct version check badge', 'Update ASAP', 'danger' + end end diff --git a/spec/features/users/snippets_spec.rb b/spec/features/users/snippets_spec.rb index 98ac9fa5f92..3a56b371a8c 100644 --- a/spec/features/users/snippets_spec.rb +++ b/spec/features/users/snippets_spec.rb @@ -4,10 +4,10 @@ require 'spec_helper' RSpec.describe 'Snippets tab on a user profile', :js, feature_category: :source_code_management do context 'when the user has snippets' do - let(:user) { create(:user, :no_super_sidebar) } + let(:user) { create(:user) } before do - stub_feature_flags(profile_tabs_vue: false, super_sidebar_logged_out: false) + stub_feature_flags(profile_tabs_vue: false) end context 'pagination' do @@ -16,7 +16,7 @@ RSpec.describe 'Snippets tab on a user profile', :js, feature_category: :source_ before do allow(Snippet).to receive(:default_per_page).and_return(1) visit user_path(user) - page.within('.user-profile-nav') { click_link 'Snippets' } + within_testid('super-sidebar') { click_link 'Snippets' } wait_for_requests end @@ -30,9 +30,9 @@ RSpec.describe 'Snippets tab on a user profile', :js, feature_category: :source_ let!(:other_snippet) { create(:snippet, :public) } it 'contains only internal and public snippets of a user when a user is logged in' do - sign_in(create(:user, :no_super_sidebar)) + sign_in(create(:user)) visit user_path(user) - page.within('.user-profile-nav') { click_link 'Snippets' } + within_testid('super-sidebar') { click_link 'Snippets' } wait_for_requests expect(page).to have_selector('.snippet-row', count: 2) @@ -43,7 +43,7 @@ RSpec.describe 'Snippets tab on a user profile', :js, feature_category: :source_ it 'contains only public snippets of a user when a user is not logged in' do visit user_path(user) - page.within('.user-profile-nav') { click_link 'Snippets' } + within_testid('super-sidebar') { click_link 'Snippets' } wait_for_requests expect(page).to have_selector('.snippet-row', count: 1) diff --git a/spec/features/users/user_browses_projects_on_user_page_spec.rb b/spec/features/users/user_browses_projects_on_user_page_spec.rb index 5e047192e7b..039b1bbe5b1 100644 --- a/spec/features/users/user_browses_projects_on_user_page_spec.rb +++ b/spec/features/users/user_browses_projects_on_user_page_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' RSpec.describe 'Users > User browses projects on user page', :js, feature_category: :groups_and_projects do - let!(:user) { create(:user, :no_super_sidebar) } + let!(:user) { create(:user) } let!(:private_project) do create :project, :private, name: 'private', namespace: user.namespace do |project| project.add_maintainer(user) @@ -23,13 +23,13 @@ RSpec.describe 'Users > User browses projects on user page', :js, feature_catego end def click_nav_link(name) - page.within '.nav-links' do + within_testid('super-sidebar') do click_link name end end before do - stub_feature_flags(profile_tabs_vue: false, super_sidebar_logged_out: false) + stub_feature_flags(profile_tabs_vue: false) end it 'hides loading spinner after load', :js do @@ -87,7 +87,7 @@ RSpec.describe 'Users > User browses projects on user page', :js, feature_catego end context 'when signed in as another user' do - let(:another_user) { create(:user, :no_super_sidebar) } + let(:another_user) { create(:user) } before do sign_in(another_user) diff --git a/spec/features/whats_new_spec.rb b/spec/features/whats_new_spec.rb index c8bcf5f6ef0..887994106b6 100644 --- a/spec/features/whats_new_spec.rb +++ b/spec/features/whats_new_spec.rb @@ -2,36 +2,28 @@ require "spec_helper" -RSpec.describe "renders a `whats new` dropdown item", feature_category: :onboarding do - let_it_be(:user) { create(:user, :no_super_sidebar) } +RSpec.describe "renders a `whats new` dropdown item", :js, feature_category: :onboarding do + let_it_be(:user) { create(:user) } context 'when not logged in' do - before do - stub_feature_flags(super_sidebar_logged_out: false) - end - it 'and on SaaS it renders', :saas do visit user_path(user) - page.within '.header-help' do - find('.header-help-dropdown-toggle').click + within_testid('super-sidebar') { click_on 'Help' } - expect(page).to have_button(text: "What's new") - end + expect(page).to have_button(text: "What's new") end it "doesn't render what's new" do visit user_path(user) - page.within '.header-help' do - find('.header-help-dropdown-toggle').click + within_testid('super-sidebar') { click_on 'Help' } - expect(page).not_to have_button(text: "What's new") - end + expect(page).not_to have_button(text: "What's new") end end - context 'when logged in', :js do + context 'when logged in' do before do sign_in(user) end @@ -40,7 +32,7 @@ RSpec.describe "renders a `whats new` dropdown item", feature_category: :onboard Gitlab::CurrentSettings.update!(whats_new_variant: ApplicationSetting.whats_new_variants[:all_tiers]) visit root_dashboard_path - find('.header-help-dropdown-toggle').click + within_testid('super-sidebar') { click_on 'Help' } expect(page).to have_button(text: "What's new") end @@ -49,7 +41,7 @@ RSpec.describe "renders a `whats new` dropdown item", feature_category: :onboard Gitlab::CurrentSettings.update!(whats_new_variant: ApplicationSetting.whats_new_variants[:disabled]) visit root_dashboard_path - find('.header-help-dropdown-toggle').click + within_testid('super-sidebar') { click_on 'Help' } expect(page).not_to have_button(text: "What's new") end @@ -57,24 +49,24 @@ RSpec.describe "renders a `whats new` dropdown item", feature_category: :onboard it 'shows notification dot and count and removes it once viewed' do visit root_dashboard_path - page.within '.header-help' do - expect(page).to have_selector('.notification-dot', visible: true) + within_testid('super-sidebar') do + click_on 'Help' + button = find_button(text: "What's new") - find('.header-help-dropdown-toggle').click + has_testid?('notification-dot', visible: true) + expect(button).to have_selector('.badge-pill') - expect(page).to have_button(text: "What's new") - expect(page).to have_selector('.js-whats-new-notification-count') - - find('button', text: "What's new").click + button.click end find('.whats-new-drawer .gl-drawer-close-button').click - find('.header-help-dropdown-toggle').click - page.within '.header-help' do - expect(page).not_to have_selector('.notification-dot', visible: true) - expect(page).to have_button(text: "What's new") - expect(page).not_to have_selector('.js-whats-new-notification-count') + within_testid('super-sidebar') do + click_on 'Help' + button = find_button(text: "What's new") + + has_testid?('notification-dot', visible: false) + expect(button).not_to have_selector('.badge-pill') end end end |