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
let(:user) { create(:user) }
let(:project) { create(:project) }
before do
stub_feature_flags(combined_menu: false)
shared_examples 'combined_menu: feature flag examples' do
before do
project.add_maintainer(user)
sign_in(user)
project.add_maintainer(user)
sign_in(user)
stub_licensed_features(operations_dashboard: true)
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
it 'has an `Operations` link' do
expect(page).to have_link('Operations', href: operations_path)
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
it 'has an `Environments` link' do
expect(page).to have_link('Environments', href: operations_environments_path)
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
......@@ -8,37 +8,67 @@ RSpec.describe 'Admin Mode Logout', :js do
let(:user) { create(:admin) }
before do
stub_feature_flags(combined_menu: false)
shared_examples 'combined_menu: feature flag examples' do
before do
gitlab_sign_in(user)
gitlab_enable_admin_mode_sign_in(user)
visit admin_root_path
end
gitlab_sign_in(user)
gitlab_enable_admin_mode_sign_in(user)
visit admin_root_path
end
it 'disable removes admin mode and redirects to root page' do
pending_on_combined_menu_flag
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(page).to have_link(href: new_admin_session_path)
end
expect(current_path).to eq root_path
expect(page).to have_link(href: new_admin_session_path)
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
gitlab_disable_admin_mode
context 'on a read-only instance' do
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
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
allow(Gitlab::Database).to receive(:read_only?).and_return(true)
stub_feature_flags(combined_menu: true)
end
it 'disable removes admin mode and redirects to root page' do
gitlab_disable_admin_mode
it_behaves_like 'combined_menu: feature flag examples'
end
expect(current_path).to eq root_path
expect(page).to have_link(href: new_admin_session_path)
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
This diff is collapsed.
......@@ -3,30 +3,56 @@
require 'spec_helper'
RSpec.describe 'Dashboard Active Tab', :js do
before do
stub_feature_flags(combined_menu: false)
shared_examples 'combined_menu: feature flag examples' do
before do
sign_in(create(:user))
end
sign_in(create(:user))
end
shared_examples 'page has active tab' do |title|
it "#{title} tab" do
pending_on_combined_menu_flag
subject
shared_examples 'page has active tab' do |title|
it "#{title} tab" do
subject
expect(page).to have_selector('.navbar-sub-nav li.active', count: 1)
expect(find('.navbar-sub-nav li.active')).to have_content(title)
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)
expect(find('.navbar-sub-nav li.active')).to have_content(title)
context 'on dashboard groups' do
it_behaves_like 'page has active tab', 'Groups' do
subject { visit dashboard_groups_path }
end
end
end
context 'on dashboard projects' do
it_behaves_like 'page has active tab', 'Projects' do
subject { visit dashboard_projects_path }
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 'on dashboard groups' do
it_behaves_like 'page has active tab', 'Groups' do
subject { visit dashboard_groups_path }
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
......@@ -7,36 +7,64 @@ RSpec.describe 'The group dashboard' do
let(:user) { create(:user) }
before do
stub_feature_flags(combined_menu: false)
shared_examples 'combined_menu: feature flag examples' do
before do
sign_in user
end
sign_in user
end
describe 'The top navigation' do
it 'has all the expected links' do
pending_on_combined_menu_flag
describe 'The top navigation' do
it 'has all the expected links' do
visit dashboard_groups_path
visit dashboard_groups_path
within('.navbar') do
expect(page).to have_button('Projects')
expect(page).to have_button('Groups')
expect(page).to have_link('Activity')
expect(page).to have_link('Milestones')
expect(page).to have_link('Snippets')
within('.navbar') do
expect(page).to have_button('Projects')
expect(page).to have_button('Groups')
expect(page).to have_link('Activity')
expect(page).to have_link('Milestones')
expect(page).to have_link('Snippets')
end
end
end
it 'hides some links when an external authorization service is enabled' do
enable_external_authorization_service_check
visit dashboard_groups_path
it 'hides some links when an external authorization service is enabled' do
pending_on_combined_menu_flag
enable_external_authorization_service_check
visit dashboard_groups_path
within('.navbar') do
expect(page).to have_button('Projects')
expect(page).to have_button('Groups')
expect(page).not_to have_link('Activity')
expect(page).not_to have_link('Milestones')
expect(page).to have_link('Snippets')
within('.navbar') do
expect(page).to have_button('Projects')
expect(page).to have_button('Groups')
expect(page).not_to have_link('Activity')
expect(page).not_to have_link('Milestones')
expect(page).to have_link('Snippets')
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
......@@ -3,71 +3,97 @@
require 'spec_helper'
RSpec.describe 'Dashboard shortcuts', :js do
before do
stub_feature_flags(combined_menu: false)
end
shared_examples 'combined_menu: feature flag examples' do
context 'logged in' do
let(:user) { create(:user) }
let(:project) { create(:project) }
context 'logged in' do
let(:user) { create(:user) }
let(:project) { create(:project) }
before do
project.add_developer(user)
sign_in(user)
visit root_dashboard_path
end
before do
project.add_developer(user)
sign_in(user)
visit root_dashboard_path
end
it 'navigate to tabs' do
pending_on_combined_menu_flag
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
context 'logged out' do
before do
visit explore_root_path
context 'logged out' do
before do
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
it 'navigate to tabs' do
find('body').send_keys([:shift, 'G'])
def check_page_title(title)
expect(find('.page-title')).to have_content(title)
end
end
find('.nothing-here-block')
expect(page).to have_content('No public groups')
context 'with combined_menu: feature flag on' do
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')
expect(page).to have_content('No snippets found')
it_behaves_like 'combined_menu: feature flag examples'
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')
expect(page).to have_content('Explore public groups to find projects to contribute to.')
before do
stub_feature_flags(combined_menu: false)
end
it_behaves_like 'combined_menu: feature flag examples'
end
def check_page_title(title)
expect(find('.page-title')).to have_content(title)
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
......@@ -5,45 +5,73 @@ require 'spec_helper'
RSpec.describe 'Frequently visited items', :js do
let_it_be(:user) { create(:user) }
before do
stub_feature_flags(combined_menu: false)
shared_examples 'combined_menu: feature flag examples' do
before do
sign_in(user)
end
sign_in(user)
end
context 'for projects' do
let_it_be(:project) { create(:project, :public) }
context 'for projects' do
let_it_be(:project) { create(:project, :public) }
it 'increments localStorage counter when visiting the project' do
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
frequent_projects = page.evaluate_script("localStorage['#{user.username}/frequent-projects']")
wait_for('localStorage frequent-projects') do
frequent_projects = page.evaluate_script("localStorage['#{user.username}/frequent-projects']")
frequent_projects.present?
end
frequent_projects.present?
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
context 'for groups' do
let_it_be(:group) { create(:group, :public) }
context 'for groups' do
let_it_be(:group) { create(:group, :public) }
it 'increments localStorage counter when visiting the group' do
visit group_path(group)
it 'increments localStorage counter when visiting the group' do
pending_on_combined_menu_flag
frequent_groups = nil
visit group_path(group)
wait_for('localStorage frequent-groups') do
frequent_groups = page.evaluate_script("localStorage['#{user.username}/frequent-groups']")
frequent_groups = nil
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
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
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
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