Commit cb865727 authored by Bob Van Landuyt's avatar Bob Van Landuyt

Merge branch 'combined-menu-flag-feature-specs' into 'master'

combined_menu flag feature specs [RUN ALL RSPEC] [RUN AS-IF-FOSS]

See merge request gitlab-org/gitlab!60335
parents 977b92b5 fbecfe82
...@@ -6,22 +6,50 @@ RSpec.describe 'Operations dropdown navbar EE' do ...@@ -6,22 +6,50 @@ RSpec.describe 'Operations dropdown navbar EE' do
let(:user) { create(:user) } let(:user) { create(:user) }
let(:project) { create(:project) } let(:project) { create(:project) }
before do shared_examples 'combined_menu: feature flag examples' do
stub_feature_flags(combined_menu: false) before do
project.add_maintainer(user)
sign_in(user)
project.add_maintainer(user) stub_licensed_features(operations_dashboard: true)
sign_in(user)
stub_licensed_features(operations_dashboard: true) visit project_issues_path(project)
end
visit project_issues_path(project) it 'has an `Operations` link' do
pending_on_combined_menu_flag
expect(page).to have_link('Operations', href: operations_path)
end
it 'has an `Environments` link' do
pending_on_combined_menu_flag
expect(page).to have_link('Environments', href: operations_environments_path)
end
end end
it 'has an `Operations` link' do context 'with combined_menu: feature flag on' do
expect(page).to have_link('Operations', href: operations_path) let(:needs_rewrite_for_combined_menu_flag_on) { true }
before do
stub_feature_flags(combined_menu: true)
end
it_behaves_like 'combined_menu: feature flag examples'
end
context 'with combined_menu feature flag off' do
let(:needs_rewrite_for_combined_menu_flag_on) { false }
before do
stub_feature_flags(combined_menu: false)
end
it_behaves_like 'combined_menu: feature flag examples'
end end
it 'has an `Environments` link' do def pending_on_combined_menu_flag
expect(page).to have_link('Environments', href: operations_environments_path) pending 'https://gitlab.com/gitlab-org/gitlab/-/merge_requests/56587' if needs_rewrite_for_combined_menu_flag_on
end end
end end
...@@ -8,37 +8,67 @@ RSpec.describe 'Admin Mode Logout', :js do ...@@ -8,37 +8,67 @@ RSpec.describe 'Admin Mode Logout', :js do
let(:user) { create(:admin) } let(:user) { create(:admin) }
before do shared_examples 'combined_menu: feature flag examples' do
stub_feature_flags(combined_menu: false) before do
gitlab_sign_in(user)
gitlab_enable_admin_mode_sign_in(user)
visit admin_root_path
end
gitlab_sign_in(user) it 'disable removes admin mode and redirects to root page' do
gitlab_enable_admin_mode_sign_in(user) pending_on_combined_menu_flag
visit admin_root_path
end
it 'disable removes admin mode and redirects to root page' do gitlab_disable_admin_mode
gitlab_disable_admin_mode
expect(current_path).to eq root_path expect(current_path).to eq root_path
expect(page).to have_link(href: new_admin_session_path) expect(page).to have_link(href: new_admin_session_path)
end end
it 'disable shows flash notice' do
pending_on_combined_menu_flag
gitlab_disable_admin_mode
expect(page).to have_selector('.flash-notice')
end
it 'disable shows flash notice' do context 'on a read-only instance' do
gitlab_disable_admin_mode before do
allow(Gitlab::Database).to receive(:read_only?).and_return(true)
end
expect(page).to have_selector('.flash-notice') it 'disable removes admin mode and redirects to root page' do
pending_on_combined_menu_flag
gitlab_disable_admin_mode
expect(current_path).to eq root_path
expect(page).to have_link(href: new_admin_session_path)
end
end
end end
context 'on a read-only instance' do context 'with combined_menu: feature flag on' do
let(:needs_rewrite_for_combined_menu_flag_on) { true }
before do before do
allow(Gitlab::Database).to receive(:read_only?).and_return(true) stub_feature_flags(combined_menu: true)
end end
it 'disable removes admin mode and redirects to root page' do it_behaves_like 'combined_menu: feature flag examples'
gitlab_disable_admin_mode end
expect(current_path).to eq root_path context 'with combined_menu feature flag off' do
expect(page).to have_link(href: new_admin_session_path) let(:needs_rewrite_for_combined_menu_flag_on) { false }
before do
stub_feature_flags(combined_menu: false)
end end
it_behaves_like 'combined_menu: feature flag examples'
end
def pending_on_combined_menu_flag
pending 'https://gitlab.com/gitlab-org/gitlab/-/merge_requests/56587' if needs_rewrite_for_combined_menu_flag_on
end end
end end
This diff is collapsed.
...@@ -3,30 +3,56 @@ ...@@ -3,30 +3,56 @@
require 'spec_helper' require 'spec_helper'
RSpec.describe 'Dashboard Active Tab', :js do RSpec.describe 'Dashboard Active Tab', :js do
before do shared_examples 'combined_menu: feature flag examples' do
stub_feature_flags(combined_menu: false) before do
sign_in(create(:user))
end
sign_in(create(:user)) shared_examples 'page has active tab' do |title|
end it "#{title} tab" do
pending_on_combined_menu_flag
subject
shared_examples 'page has active tab' do |title| expect(page).to have_selector('.navbar-sub-nav li.active', count: 1)
it "#{title} tab" do expect(find('.navbar-sub-nav li.active')).to have_content(title)
subject end
end
context 'on dashboard projects' do
it_behaves_like 'page has active tab', 'Projects' do
subject { visit dashboard_projects_path }
end
end
expect(page).to have_selector('.navbar-sub-nav li.active', count: 1) context 'on dashboard groups' do
expect(find('.navbar-sub-nav li.active')).to have_content(title) it_behaves_like 'page has active tab', 'Groups' do
subject { visit dashboard_groups_path }
end
end end
end end
context 'on dashboard projects' do context 'with combined_menu: feature flag on' do
it_behaves_like 'page has active tab', 'Projects' do let(:needs_rewrite_for_combined_menu_flag_on) { true }
subject { visit dashboard_projects_path }
before do
stub_feature_flags(combined_menu: true)
end end
it_behaves_like 'combined_menu: feature flag examples'
end end
context 'on dashboard groups' do context 'with combined_menu feature flag off' do
it_behaves_like 'page has active tab', 'Groups' do let(:needs_rewrite_for_combined_menu_flag_on) { false }
subject { visit dashboard_groups_path }
before do
stub_feature_flags(combined_menu: false)
end end
it_behaves_like 'combined_menu: feature flag examples'
end
def pending_on_combined_menu_flag
pending 'https://gitlab.com/gitlab-org/gitlab/-/merge_requests/56587' if needs_rewrite_for_combined_menu_flag_on
end end
end end
...@@ -7,36 +7,64 @@ RSpec.describe 'The group dashboard' do ...@@ -7,36 +7,64 @@ RSpec.describe 'The group dashboard' do
let(:user) { create(:user) } let(:user) { create(:user) }
before do shared_examples 'combined_menu: feature flag examples' do
stub_feature_flags(combined_menu: false) before do
sign_in user
end
sign_in user describe 'The top navigation' do
end it 'has all the expected links' do
pending_on_combined_menu_flag
describe 'The top navigation' do visit dashboard_groups_path
it 'has all the expected links' do
visit dashboard_groups_path
within('.navbar') do within('.navbar') do
expect(page).to have_button('Projects') expect(page).to have_button('Projects')
expect(page).to have_button('Groups') expect(page).to have_button('Groups')
expect(page).to have_link('Activity') expect(page).to have_link('Activity')
expect(page).to have_link('Milestones') expect(page).to have_link('Milestones')
expect(page).to have_link('Snippets') expect(page).to have_link('Snippets')
end
end end
end
it 'hides some links when an external authorization service is enabled' do it 'hides some links when an external authorization service is enabled' do
enable_external_authorization_service_check pending_on_combined_menu_flag
visit dashboard_groups_path
enable_external_authorization_service_check
visit dashboard_groups_path
within('.navbar') do within('.navbar') do
expect(page).to have_button('Projects') expect(page).to have_button('Projects')
expect(page).to have_button('Groups') expect(page).to have_button('Groups')
expect(page).not_to have_link('Activity') expect(page).not_to have_link('Activity')
expect(page).not_to have_link('Milestones') expect(page).not_to have_link('Milestones')
expect(page).to have_link('Snippets') expect(page).to have_link('Snippets')
end
end end
end end
end end
context 'with combined_menu: feature flag on' do
let(:needs_rewrite_for_combined_menu_flag_on) { true }
before do
stub_feature_flags(combined_menu: true)
end
it_behaves_like 'combined_menu: feature flag examples'
end
context 'with combined_menu feature flag off' do
let(:needs_rewrite_for_combined_menu_flag_on) { false }
before do
stub_feature_flags(combined_menu: false)
end
it_behaves_like 'combined_menu: feature flag examples'
end
def pending_on_combined_menu_flag
pending 'https://gitlab.com/gitlab-org/gitlab/-/merge_requests/56587' if needs_rewrite_for_combined_menu_flag_on
end
end end
...@@ -3,71 +3,97 @@ ...@@ -3,71 +3,97 @@
require 'spec_helper' require 'spec_helper'
RSpec.describe 'Dashboard shortcuts', :js do RSpec.describe 'Dashboard shortcuts', :js do
before do shared_examples 'combined_menu: feature flag examples' do
stub_feature_flags(combined_menu: false) context 'logged in' do
end let(:user) { create(:user) }
let(:project) { create(:project) }
context 'logged in' do before do
let(:user) { create(:user) } project.add_developer(user)
let(:project) { create(:project) } sign_in(user)
visit root_dashboard_path
end
before do it 'navigate to tabs' do
project.add_developer(user) pending_on_combined_menu_flag
sign_in(user)
visit root_dashboard_path
end
it 'navigate to tabs' do find('body').send_keys([:shift, 'I'])
find('body').send_keys([:shift, 'I'])
check_page_title('Issues') check_page_title('Issues')
find('body').send_keys([:shift, 'M']) find('body').send_keys([:shift, 'M'])
check_page_title('Merge requests') check_page_title('Merge requests')
find('body').send_keys([:shift, 'T']) find('body').send_keys([:shift, 'T'])
check_page_title('To-Do List') check_page_title('To-Do List')
find('body').send_keys([:shift, 'G']) find('body').send_keys([:shift, 'G'])
check_page_title('Groups') check_page_title('Groups')
find('body').send_keys([:shift, 'P']) find('body').send_keys([:shift, 'P'])
check_page_title('Projects') check_page_title('Projects')
find('body').send_keys([:shift, 'A']) find('body').send_keys([:shift, 'A'])
check_page_title('Activity') check_page_title('Activity')
end
end end
end
context 'logged out' do context 'logged out' do
before do before do
visit explore_root_path visit explore_root_path
end
it 'navigate to tabs' do
pending_on_combined_menu_flag
find('body').send_keys([:shift, 'G'])
find('.nothing-here-block')
expect(page).to have_content('No public groups')
find('body').send_keys([:shift, 'S'])
find('.nothing-here-block')
expect(page).to have_content('No snippets found')
find('body').send_keys([:shift, 'P'])
find('.nothing-here-block')
expect(page).to have_content('Explore public groups to find projects to contribute to.')
end
end end
it 'navigate to tabs' do def check_page_title(title)
find('body').send_keys([:shift, 'G']) expect(find('.page-title')).to have_content(title)
end
end
find('.nothing-here-block') context 'with combined_menu: feature flag on' do
expect(page).to have_content('No public groups') let(:needs_rewrite_for_combined_menu_flag_on) { true }
find('body').send_keys([:shift, 'S']) before do
stub_feature_flags(combined_menu: true)
end
find('.nothing-here-block') it_behaves_like 'combined_menu: feature flag examples'
expect(page).to have_content('No snippets found') end
find('body').send_keys([:shift, 'P']) context 'with combined_menu feature flag off' do
let(:needs_rewrite_for_combined_menu_flag_on) { false }
find('.nothing-here-block') before do
expect(page).to have_content('Explore public groups to find projects to contribute to.') stub_feature_flags(combined_menu: false)
end end
it_behaves_like 'combined_menu: feature flag examples'
end end
def check_page_title(title) def pending_on_combined_menu_flag
expect(find('.page-title')).to have_content(title) pending 'https://gitlab.com/gitlab-org/gitlab/-/merge_requests/56587' if needs_rewrite_for_combined_menu_flag_on
end end
end end
...@@ -5,45 +5,73 @@ require 'spec_helper' ...@@ -5,45 +5,73 @@ require 'spec_helper'
RSpec.describe 'Frequently visited items', :js do RSpec.describe 'Frequently visited items', :js do
let_it_be(:user) { create(:user) } let_it_be(:user) { create(:user) }
before do shared_examples 'combined_menu: feature flag examples' do
stub_feature_flags(combined_menu: false) before do
sign_in(user)
end
sign_in(user) context 'for projects' do
end let_it_be(:project) { create(:project, :public) }
context 'for projects' do it 'increments localStorage counter when visiting the project' do
let_it_be(:project) { create(:project, :public) } pending_on_combined_menu_flag
it 'increments localStorage counter when visiting the project' do visit project_path(project)
visit project_path(project)
frequent_projects = nil frequent_projects = nil
wait_for('localStorage frequent-projects') do wait_for('localStorage frequent-projects') do
frequent_projects = page.evaluate_script("localStorage['#{user.username}/frequent-projects']") frequent_projects = page.evaluate_script("localStorage['#{user.username}/frequent-projects']")
frequent_projects.present? frequent_projects.present?
end end
expect(Gitlab::Json.parse(frequent_projects)).to contain_exactly(a_hash_including('id' => project.id, 'frequency' => 1)) expect(Gitlab::Json.parse(frequent_projects)).to contain_exactly(a_hash_including('id' => project.id, 'frequency' => 1))
end
end end
end
context 'for groups' do context 'for groups' do
let_it_be(:group) { create(:group, :public) } let_it_be(:group) { create(:group, :public) }
it 'increments localStorage counter when visiting the group' do it 'increments localStorage counter when visiting the group' do
visit group_path(group) pending_on_combined_menu_flag
frequent_groups = nil visit group_path(group)
wait_for('localStorage frequent-groups') do frequent_groups = nil
frequent_groups = page.evaluate_script("localStorage['#{user.username}/frequent-groups']")
frequent_groups.present? wait_for('localStorage frequent-groups') do
frequent_groups = page.evaluate_script("localStorage['#{user.username}/frequent-groups']")
frequent_groups.present?
end
expect(Gitlab::Json.parse(frequent_groups)).to contain_exactly(a_hash_including('id' => group.id, 'frequency' => 1))
end end
end
end
expect(Gitlab::Json.parse(frequent_groups)).to contain_exactly(a_hash_including('id' => group.id, 'frequency' => 1)) context 'with combined_menu: feature flag on' do
let(:needs_rewrite_for_combined_menu_flag_on) { true }
before do
stub_feature_flags(combined_menu: true)
end end
it_behaves_like 'combined_menu: feature flag examples'
end
context 'with combined_menu feature flag off' do
let(:needs_rewrite_for_combined_menu_flag_on) { false }
before do
stub_feature_flags(combined_menu: false)
end
it_behaves_like 'combined_menu: feature flag examples'
end
def pending_on_combined_menu_flag
pending 'https://gitlab.com/gitlab-org/gitlab/-/merge_requests/56587' if needs_rewrite_for_combined_menu_flag_on
end end
end end
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment