diff options
Diffstat (limited to 'spec')
14 files changed, 187 insertions, 49 deletions
diff --git a/spec/controllers/concerns/analytics/cycle_analytics/value_stream_actions_spec.rb b/spec/controllers/concerns/analytics/cycle_analytics/value_stream_actions_spec.rb index 246119a8118..a6a0f2c11b4 100644 --- a/spec/controllers/concerns/analytics/cycle_analytics/value_stream_actions_spec.rb +++ b/spec/controllers/concerns/analytics/cycle_analytics/value_stream_actions_spec.rb @@ -1,8 +1,9 @@ # frozen_string_literal: true + require 'spec_helper' RSpec.describe Analytics::CycleAnalytics::ValueStreamActions, type: :controller, -feature_category: :planning_analytics do + feature_category: :planning_analytics do subject(:controller) do Class.new(ApplicationController) do include Analytics::CycleAnalytics::ValueStreamActions diff --git a/spec/features/groups/new_group_page_spec.rb b/spec/features/groups/new_group_page_spec.rb index a07c27331d9..4670df3fb5e 100644 --- a/spec/features/groups/new_group_page_spec.rb +++ b/spec/features/groups/new_group_page_spec.rb @@ -3,15 +3,14 @@ require 'spec_helper' RSpec.describe 'New group page', :js, feature_category: :subgroups do - let(:user) { create(:user) } - let(:group) { create(:group) } + let_it_be(:user) { create(:user) } + let_it_be(:parent_group) { create(:group) } before do + parent_group.add_owner(user) sign_in(user) end - it_behaves_like 'a dashboard page with sidebar', :new_group_path, :groups - describe 'new top level group alert' do context 'when a user visits the new group page' do it 'shows the new top level group alert' do @@ -22,8 +21,6 @@ RSpec.describe 'New group page', :js, feature_category: :subgroups do end context 'when a user visits the new sub group page' do - let(:parent_group) { create(:group) } - it 'does not show the new top level group alert' do visit new_group_path(parent_id: parent_group.id, anchor: 'create-group-pane') @@ -31,4 +28,19 @@ RSpec.describe 'New group page', :js, feature_category: :subgroups do end end end + + describe 'sidebar' do + context 'for a new top-level group' do + it_behaves_like 'a dashboard page with sidebar', :new_group_path, :groups + end + + context 'for a new subgroup' do + it 'shows the group sidebar of the parent group' do + visit new_group_path(parent_id: parent_group.id, anchor: 'create-group-pane') + expect(page).to have_selector( + ".nav-sidebar[aria-label=\"Group navigation\"] .context-header[title=\"#{parent_group.name}\"]" + ) + end + end + end end diff --git a/spec/features/projects/new_project_spec.rb b/spec/features/projects/new_project_spec.rb index c6a6ee68185..3cbfa14208f 100644 --- a/spec/features/projects/new_project_spec.rb +++ b/spec/features/projects/new_project_spec.rb @@ -578,4 +578,25 @@ RSpec.describe 'New project', :js, feature_category: :projects do it_behaves_like 'has instructions to enable OAuth' end end + + describe 'sidebar' do + let_it_be(:user) { create(:user) } + let_it_be(:parent_group) { create(:group) } + + before do + parent_group.add_owner(user) + sign_in(user) + end + + context 'for a new top-level project' do + it_behaves_like 'a dashboard page with sidebar', :new_project_path, :projects + end + + context 'for a new group project' do + it 'shows the group sidebar of the parent group' do + visit new_project_path(namespace_id: parent_group.id) + expect(page).to have_selector(".nav-sidebar[aria-label=\"Group navigation\"] .context-header[title=\"#{parent_group.name}\"]") + end + end + end end diff --git a/spec/frontend/batch_comments/components/preview_dropdown_spec.js b/spec/frontend/batch_comments/components/preview_dropdown_spec.js index f86e003ab5f..3a28bf4ade8 100644 --- a/spec/frontend/batch_comments/components/preview_dropdown_spec.js +++ b/spec/frontend/batch_comments/components/preview_dropdown_spec.js @@ -1,7 +1,6 @@ import Vue, { nextTick } from 'vue'; import Vuex from 'vuex'; -import { GlDisclosureDropdown } from '@gitlab/ui'; -import { shallowMount } from '@vue/test-utils'; +import { mount } from '@vue/test-utils'; import { TEST_HOST } from 'helpers/test_constants'; import { visitUrl } from '~/lib/utils/url_utility'; import PreviewDropdown from '~/batch_comments/components/preview_dropdown.vue'; @@ -46,9 +45,11 @@ function factory({ viewDiffsFileByFile = false, draftsCount = 1, sortedDrafts = }, }); - wrapper = shallowMount(PreviewDropdown, { + wrapper = mount(PreviewDropdown, { store, - stubs: { GlDisclosureDropdown }, + stubs: { + PreviewItem: true, + }, }); } @@ -59,12 +60,12 @@ describe('Batch comments preview dropdown', () => { viewDiffsFileByFile: true, sortedDrafts: [{ id: 1, file_hash: 'hash' }], }); - - findPreviewItem().vm.$emit('click'); - + findPreviewItem().trigger('click'); await nextTick(); expect(setCurrentFileHash).toHaveBeenCalledWith(expect.anything(), 'hash'); + + await nextTick(); expect(scrollToDraft).toHaveBeenCalledWith( expect.anything(), expect.objectContaining({ id: 1, file_hash: 'hash' }), @@ -77,7 +78,7 @@ describe('Batch comments preview dropdown', () => { sortedDrafts: [{ id: 1 }], }); - findPreviewItem().vm.$emit('click'); + findPreviewItem().trigger('click'); await nextTick(); @@ -93,7 +94,7 @@ describe('Batch comments preview dropdown', () => { sortedDrafts: [{ id: 1, position: { head_sha: '1234' } }], }); - findPreviewItem().vm.$emit('click'); + findPreviewItem().trigger('click'); await nextTick(); diff --git a/spec/frontend/fixtures/startup_css.rb b/spec/frontend/fixtures/startup_css.rb index bd2d63a1827..2d766086cb7 100644 --- a/spec/frontend/fixtures/startup_css.rb +++ b/spec/frontend/fixtures/startup_css.rb @@ -55,6 +55,21 @@ RSpec.describe 'Startup CSS fixtures', type: :controller do expect(response).to be_successful end + + # This Feature Flag is off by default + # This ensures that the correct css is generated for super sidebar + # When the feature flag is off, the general startup will capture it + it "startup_css/project-#{type}-super-sidebar.html" do + stub_feature_flags(super_sidebar_nav: true) + user.update!(use_new_navigation: true) + + get :show, params: { + namespace_id: project.namespace.to_param, + id: project + } + + expect(response).to be_successful + end end describe ProjectsController, '(Startup CSS fixtures)', type: :controller do diff --git a/spec/frontend/pages/groups/new/components/app_spec.js b/spec/frontend/pages/groups/new/components/app_spec.js index ab483316086..a3aa87574b5 100644 --- a/spec/frontend/pages/groups/new/components/app_spec.js +++ b/spec/frontend/pages/groups/new/components/app_spec.js @@ -23,7 +23,9 @@ describe('App component', () => { it('creates correct component for group creation', () => { createComponent(); - expect(findNewNamespacePage().props('initialBreadcrumb')).toBe('New group'); + expect(findNewNamespacePage().props('initialBreadcrumbs')).toEqual([ + { href: '#', text: 'New group' }, + ]); expect(findCreateGroupPanel().title).toBe('Create group'); }); @@ -32,7 +34,9 @@ describe('App component', () => { createComponent(props); - expect(findNewNamespacePage().props('initialBreadcrumb')).toBe('parent'); + expect(findNewNamespacePage().props('initialBreadcrumbs')).toEqual([ + { href: '#', text: 'New group' }, + ]); expect(findCreateGroupPanel().title).toBe('Create subgroup'); expect(findCreateGroupPanel().detailProps).toEqual(props); }); diff --git a/spec/frontend/vue_shared/new_namespace/new_namespace_page_spec.js b/spec/frontend/vue_shared/new_namespace/new_namespace_page_spec.js index 6115dc6e61b..40f75a0a8d6 100644 --- a/spec/frontend/vue_shared/new_namespace/new_namespace_page_spec.js +++ b/spec/frontend/vue_shared/new_namespace/new_namespace_page_spec.js @@ -14,7 +14,7 @@ describe('Experimental new project creation app', () => { const DEFAULT_PROPS = { title: 'Create something', - initialBreadcrumb: 'Something', + initialBreadcrumbs: [{ text: 'Something', href: '#' }], panels: [ { name: 'panel1', selector: '#some-selector1' }, { name: 'panel2', selector: '#some-selector2' }, @@ -46,8 +46,8 @@ describe('Experimental new project creation app', () => { expect(findWelcomePage().exists()).toBe(true); }); - it('does not render breadcrumbs', () => { - expect(findBreadcrumb().exists()).toBe(false); + it('renders breadcrumbs', () => { + expect(findBreadcrumb().exists()).toBe(true); }); }); @@ -75,7 +75,7 @@ describe('Experimental new project creation app', () => { it('renders breadcrumbs', () => { const breadcrumb = findBreadcrumb(); expect(breadcrumb.exists()).toBe(true); - expect(breadcrumb.props().items[0].text).toBe(DEFAULT_PROPS.initialBreadcrumb); + expect(breadcrumb.props().items[0].text).toBe(DEFAULT_PROPS.initialBreadcrumbs[0].text); }); }); diff --git a/spec/helpers/groups_helper_spec.rb b/spec/helpers/groups_helper_spec.rb index 8b4ac6a7cfd..ce439e5bcdd 100644 --- a/spec/helpers/groups_helper_spec.rb +++ b/spec/helpers/groups_helper_spec.rb @@ -436,7 +436,8 @@ RSpec.describe GroupsHelper do it 'returns expected hash' do expect(subgroup_creation_data(subgroup)).to eq({ import_existing_group_path: '/groups/new#import-group-pane', - parent_group_name: name + parent_group_name: name, + parent_group_url: group_url(group) }) end end @@ -445,7 +446,8 @@ RSpec.describe GroupsHelper do it 'returns expected hash' do expect(subgroup_creation_data(group)).to eq({ import_existing_group_path: '/groups/new#import-group-pane', - parent_group_name: nil + parent_group_name: nil, + parent_group_url: nil }) end end diff --git a/spec/helpers/nav/new_dropdown_helper_spec.rb b/spec/helpers/nav/new_dropdown_helper_spec.rb index 3a66fe474ab..1df0ee8c18a 100644 --- a/spec/helpers/nav/new_dropdown_helper_spec.rb +++ b/spec/helpers/nav/new_dropdown_helper_spec.rb @@ -11,8 +11,12 @@ RSpec.describe Nav::NewDropdownHelper, feature_category: :navigation do let(:with_can_create_project) { false } let(:with_can_create_group) { false } let(:with_can_create_snippet) { false } + let(:with_context) { true } + let(:title) { 'Create new...' } - subject(:view_model) { helper.new_dropdown_view_model(project: current_project, group: current_group) } + subject(:view_model) do + helper.new_dropdown_view_model(project: current_project, group: current_group, with_context: with_context) + end before do allow(helper).to receive(:current_user) { current_user } @@ -22,7 +26,7 @@ RSpec.describe Nav::NewDropdownHelper, feature_category: :navigation do allow(user).to receive(:can?).with(:create_snippet) { with_can_create_snippet } end - shared_examples 'invite member item' do + shared_examples 'invite member item' do |partial| it 'shows invite member link with emoji' do expect(view_model[:menu_sections]).to eq( expected_menu_section( @@ -30,8 +34,9 @@ RSpec.describe Nav::NewDropdownHelper, feature_category: :navigation do menu_item: ::Gitlab::Nav::TopNavMenuItem.build( id: 'invite', title: 'Invite members', - emoji: 'shaking_hands', + icon: 'shaking_hands', href: expected_href, + partial: partial, data: { track_action: 'click_link_invite_members', track_label: 'plus_menu_dropdown', @@ -54,8 +59,13 @@ RSpec.describe Nav::NewDropdownHelper, feature_category: :navigation do end context 'when group and project are nil' do - it 'has no menu sections' do - expect(view_model[:menu_sections]).to eq([]) + it 'has base results' do + results = { + title: title, + menu_sections: [] + } + + expect(view_model).to eq(results) end context 'when can create project' do @@ -145,8 +155,27 @@ RSpec.describe Nav::NewDropdownHelper, feature_category: :navigation do .to receive(:can?).with(current_user, :admin_group_member, group) { with_can_admin_in_group } end - it 'has no menu sections' do - expect(view_model[:menu_sections]).to eq([]) + it 'has base results' do + results = { + title: title, + menu_sections: [], + context: group + } + + expect(view_model).to eq(results) + end + + context 'without context' do + let(:with_context) { false } + + it 'has base results' do + results = { + title: title, + menu_sections: [] + } + + expect(view_model).to eq(results) + end end context 'when can create projects in group' do @@ -199,7 +228,7 @@ RSpec.describe Nav::NewDropdownHelper, feature_category: :navigation do let(:expected_title) { 'In this group' } let(:expected_href) { "/groups/#{group.full_path}/-/group_members" } - it_behaves_like 'invite member item' + it_behaves_like 'invite member item', 'groups/invite_members_top_nav_link' end end @@ -219,8 +248,27 @@ RSpec.describe Nav::NewDropdownHelper, feature_category: :navigation do allow(helper).to receive(:can_admin_project_member?) { with_can_admin_project_member } end - it 'has no menu sections' do - expect(view_model[:menu_sections]).to eq([]) + it 'has base results with context' do + results = { + title: title, + menu_sections: [], + context: project + } + + expect(view_model).to eq(results) + end + + context 'without context' do + let(:with_context) { false } + + it 'has base results without context' do + results = { + title: title, + menu_sections: [] + } + + expect(view_model).to eq(results) + end end context 'with show_new_issue_link?' do @@ -296,7 +344,7 @@ RSpec.describe Nav::NewDropdownHelper, feature_category: :navigation do let(:expected_title) { 'In this project' } let(:expected_href) { "/#{project.path_with_namespace}/-/project_members" } - it_behaves_like 'invite member item' + it_behaves_like 'invite member item', 'projects/invite_members_top_nav_link' end end @@ -311,22 +359,36 @@ RSpec.describe Nav::NewDropdownHelper, feature_category: :navigation do allow(helper).to receive(:can?).with(current_user, :create_projects, group).and_return(true) end - it 'gives precedence to group over project' do - group_section = expected_menu_section( - title: 'In this group', + it 'gives precedence to project over group' do + project_section = expected_menu_section( + title: 'In this project', menu_item: ::Gitlab::Nav::TopNavMenuItem.build( - id: 'new_project', - title: 'New project/repository', - href: "/projects/new?namespace_id=#{group.id}", + id: 'new_issue', + title: 'New issue', + href: "/#{project.path_with_namespace}/-/issues/new", data: { - track_action: 'click_link_new_project_group', + track_action: 'click_link_new_issue', track_label: 'plus_menu_dropdown', - track_property: 'navigation_top' + track_property: 'navigation_top', + qa_selector: 'new_issue_link' } ) ) + results = { + title: title, + menu_sections: project_section, + context: project + } + + expect(view_model).to eq(results) + end + + context 'without context' do + let(:with_context) { false } - expect(view_model[:menu_sections]).to eq(group_section) + it 'does not include context' do + expect(view_model.keys).to match_array([:title, :menu_sections]) + end end end diff --git a/spec/lib/gitlab/nav/top_nav_menu_item_spec.rb b/spec/lib/gitlab/nav/top_nav_menu_item_spec.rb index 6632a8106ca..3377da5ca3a 100644 --- a/spec/lib/gitlab/nav/top_nav_menu_item_spec.rb +++ b/spec/lib/gitlab/nav/top_nav_menu_item_spec.rb @@ -14,7 +14,7 @@ RSpec.describe ::Gitlab::Nav::TopNavMenuItem, feature_category: :navigation do view: 'view', css_class: 'css_class', data: {}, - emoji: 'smile' + partial: 'groups/some_view_partial_file' } expect(described_class.build(**item)).to eq(item.merge(type: :item)) diff --git a/spec/views/groups/group_members/index.html.haml_spec.rb b/spec/views/groups/group_members/index.html.haml_spec.rb index 0b3b149238f..fdc6b09d32a 100644 --- a/spec/views/groups/group_members/index.html.haml_spec.rb +++ b/spec/views/groups/group_members/index.html.haml_spec.rb @@ -25,7 +25,6 @@ RSpec.describe 'groups/group_members/index', :aggregate_failures, feature_catego expect(rendered).to have_selector('.js-invite-group-trigger') expect(rendered).to have_selector('.js-invite-members-trigger') - expect(response).to render_template(partial: 'groups/_invite_members_modal') end end diff --git a/spec/views/layouts/header/_new_dropdown.haml_spec.rb b/spec/views/layouts/header/_new_dropdown.haml_spec.rb index 178448022d1..ef8b859c9d9 100644 --- a/spec/views/layouts/header/_new_dropdown.haml_spec.rb +++ b/spec/views/layouts/header/_new_dropdown.haml_spec.rb @@ -8,6 +8,7 @@ RSpec.describe 'layouts/header/_new_dropdown', feature_category: :navigation do shared_examples_for 'invite member selector' do context 'with ability to invite members' do it { is_expected.to have_link('Invite members', href: href) } + it { is_expected.to have_selector('.js-invite-members-modal') } end context 'without ability to invite members' do @@ -159,6 +160,29 @@ RSpec.describe 'layouts/header/_new_dropdown', feature_category: :navigation do expect(rendered).to have_link('New snippet', href: new_snippet_path) end + context 'when partial exists in a menu item' do + it 'renders the menu item partial without rendering invite modal partial' do + view_model = { + title: '_title_', + menu_sections: [ + { + title: '_section_title_', + menu_items: [ + ::Gitlab::Nav::TopNavMenuItem + .build(id: '_id_', title: '_title_', partial: 'groups/invite_members_top_nav_link') + ] + } + ] + } + + allow(view).to receive(:new_dropdown_view_model).and_return(view_model) + + render + + expect(response).to render_template(partial: 'groups/_invite_members_top_nav_link') + end + end + context 'when the user is not allowed to do anything' do let(:user) { create(:user, :external) } # rubocop:disable RSpec/FactoryBot/AvoidCreate diff --git a/spec/views/projects/empty.html.haml_spec.rb b/spec/views/projects/empty.html.haml_spec.rb index 6077dda3c98..a782bab161f 100644 --- a/spec/views/projects/empty.html.haml_spec.rb +++ b/spec/views/projects/empty.html.haml_spec.rb @@ -73,7 +73,6 @@ RSpec.describe 'projects/empty' do expect(rendered).to have_content('Invite your team') expect(rendered).to have_content('Add members to this project and start collaborating with your team.') expect(rendered).to have_selector('.js-invite-members-trigger') - expect(rendered).to have_selector('.js-invite-members-modal') expect(rendered).to have_selector('[data-label=invite_members_empty_project]') expect(rendered).to have_selector('[data-event=click_button]') expect(rendered).to have_selector('[data-trigger-source=project-empty-page]') @@ -87,7 +86,6 @@ RSpec.describe 'projects/empty' do expect(rendered).not_to have_content('Invite your team') expect(rendered).not_to have_selector('.js-invite-members-trigger') - expect(rendered).not_to have_selector('.js-invite-members-modal') end end end diff --git a/spec/views/projects/project_members/index.html.haml_spec.rb b/spec/views/projects/project_members/index.html.haml_spec.rb index 4c4cde01cca..2fcc5c6935b 100644 --- a/spec/views/projects/project_members/index.html.haml_spec.rb +++ b/spec/views/projects/project_members/index.html.haml_spec.rb @@ -28,7 +28,6 @@ RSpec.describe 'projects/project_members/index', :aggregate_failures, feature_ca expect(rendered).to have_selector('.js-invite-group-trigger') expect(rendered).to have_selector('.js-invite-members-trigger') expect(rendered).not_to have_content('Members can be added by project') - expect(response).to render_template(partial: 'projects/_invite_members_modal') end context 'when project is not allowed to share with group' do |