diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-08-20 21:42:06 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-08-20 21:42:06 +0300 |
commit | 6e4e1050d9dba2b7b2523fdd1768823ab85feef4 (patch) | |
tree | 78be5963ec075d80116a932011d695dd33910b4e /spec/features/groups | |
parent | 1ce776de4ae122aba3f349c02c17cebeaa8ecf07 (diff) |
Add latest changes from gitlab-org/gitlab@13-3-stable-ee
Diffstat (limited to 'spec/features/groups')
-rw-r--r-- | spec/features/groups/empty_states_spec.rb | 22 | ||||
-rw-r--r-- | spec/features/groups/group_settings_spec.rb | 2 | ||||
-rw-r--r-- | spec/features/groups/issues_spec.rb | 46 | ||||
-rw-r--r-- | spec/features/groups/members/manage_groups_spec.rb | 16 | ||||
-rw-r--r-- | spec/features/groups/members/manage_members_spec.rb | 6 | ||||
-rw-r--r-- | spec/features/groups/members/master_manages_access_requests_spec.rb | 1 | ||||
-rw-r--r-- | spec/features/groups/members/search_members_spec.rb | 2 | ||||
-rw-r--r-- | spec/features/groups/members/tabs_spec.rb | 112 | ||||
-rw-r--r-- | spec/features/groups/navbar_spec.rb | 11 | ||||
-rw-r--r-- | spec/features/groups/packages_spec.rb | 80 |
10 files changed, 259 insertions, 39 deletions
diff --git a/spec/features/groups/empty_states_spec.rb b/spec/features/groups/empty_states_spec.rb index aaa59108b95..4488f53a03f 100644 --- a/spec/features/groups/empty_states_spec.rb +++ b/spec/features/groups/empty_states_spec.rb @@ -7,8 +7,6 @@ RSpec.describe 'Group empty states' do let(:user) { create(:group_member, :developer, user: create(:user), group: group ).user } before do - stub_feature_flags(vue_issuables_list: false) - sign_in(user) end @@ -34,42 +32,52 @@ RSpec.describe 'Group empty states' do expect(page).not_to have_selector('.empty-state') end - it "displays link to create new #{issuable} when no open #{issuable} is found" do + it "displays link to create new #{issuable} when no open #{issuable} is found", :js do create("closed_#{issuable}", project_relation => project) issuable_link_fn = "project_#{issuable}s_path" visit public_send(issuable_link_fn, project) + wait_for_all_requests + page.within(find('.empty-state')) do expect(page).to have_content(/There are no open #{issuable.to_s.humanize.downcase}/) - expect(page).to have_selector("#new_#{issuable}_body_link") + new_issuable_path = issuable == :issue ? 'new_project_issue_path' : 'project_new_merge_request_path' + + path = public_send(new_issuable_path, project) + + expect(page.find('a')['href']).to have_content(path) end end - it 'displays link to create new issue when the current search gave no results' do + it 'displays link to create new issue when the current search gave no results', :js do create(issuable, project_relation => project) issuable_link_fn = "project_#{issuable}s_path" visit public_send(issuable_link_fn, project, author_username: 'foo', scope: 'all', state: 'opened') + wait_for_all_requests + page.within(find('.empty-state')) do expect(page).to have_content(/Sorry, your filter produced no results/) new_issuable_path = issuable == :issue ? 'new_project_issue_path' : 'project_new_merge_request_path' path = public_send(new_issuable_path, project) - expect(page).to have_selector("#new_#{issuable}_body_link[href='#{path}']") + expect(page.find('a')['href']).to have_content(path) end end - it "displays conditional text when no closed #{issuable} is found" do + it "displays conditional text when no closed #{issuable} is found", :js do create(issuable, project_relation => project) issuable_link_fn = "project_#{issuable}s_path" visit public_send(issuable_link_fn, project, state: 'closed') + wait_for_all_requests + page.within(find('.empty-state')) do expect(page).to have_content(/There are no closed #{issuable.to_s.humanize.downcase}/) end diff --git a/spec/features/groups/group_settings_spec.rb b/spec/features/groups/group_settings_spec.rb index 8972be45acb..60cd1ebbbd7 100644 --- a/spec/features/groups/group_settings_spec.rb +++ b/spec/features/groups/group_settings_spec.rb @@ -158,7 +158,7 @@ RSpec.describe 'Edit group settings' do page.within('.gs-advanced') do fill_in 'group_path', with: new_group_path - click_button 'Change group path' + click_button 'Change group URL' end end diff --git a/spec/features/groups/issues_spec.rb b/spec/features/groups/issues_spec.rb index c76e0c311a6..8ecd2beba68 100644 --- a/spec/features/groups/issues_spec.rb +++ b/spec/features/groups/issues_spec.rb @@ -11,11 +11,7 @@ RSpec.describe 'Group issues page' do let(:project_with_issues_disabled) { create(:project, :issues_disabled, group: group) } let(:path) { issues_group_path(group) } - before do - stub_feature_flags(vue_issuables_list: false) - end - - context 'with shared examples' do + context 'with shared examples', :js do let(:issuable) { create(:issue, project: project, title: "this is my created issuable")} include_examples 'project features apply to issuables', Issue @@ -30,19 +26,33 @@ RSpec.describe 'Group issues page' do user_in_group end - it_behaves_like "it has an RSS button with current_user's feed token" it_behaves_like "an autodiscoverable RSS feed with current_user's feed token" + + # Note: The one from rss_shared_example.rb uses a css pseudo-class `:has` + # which is VERY experimental and only supported in Nokogiri used by Capybara + # However,`:js` option forces Capybara to use Selenium that doesn't support`:has` + context "it has an RSS button with current_user's feed token" do + it "shows the RSS button with current_user's feed token" do + expect(find('[data-testid="rss-feed-link"]')['href']).to have_content(user.feed_token) + end + end end context 'when signed out' do let(:user) { nil } - it_behaves_like "it has an RSS button without a feed token" it_behaves_like "an autodiscoverable RSS feed without a feed token" + + # Note: please see the above + context "it has an RSS button without a feed token" do + it "shows the RSS button without a feed token" do + expect(find('[data-testid="rss-feed-link"]')['href']).not_to have_content('feed_token') + end + end end end - context 'assignee', :js do + context 'assignee' do let(:access_level) { ProjectFeature::ENABLED } let(:user) { user_in_group } let(:user2) { user_outside_group } @@ -56,7 +66,7 @@ RSpec.describe 'Group issues page' do end end - context 'issues list' do + context 'issues list', :js do let(:subgroup) { create(:group, parent: group) } let(:subgroup_project) { create(:project, :public, group: subgroup)} let(:user_in_group) { create(:group_member, :maintainer, user: create(:user), group: group ).user } @@ -100,8 +110,6 @@ RSpec.describe 'Group issues page' do find('.empty-state .js-lazy-loaded') find('.new-project-item-link').click - find('.select2-input').set(group.name) - page.within('.select2-results') do expect(page).to have_content(project.full_name) expect(page).not_to have_content(project_with_issues_disabled.full_name) @@ -110,7 +118,7 @@ RSpec.describe 'Group issues page' do end end - context 'manual ordering' do + context 'manual ordering', :js do let(:user_in_group) { create(:group_member, :maintainer, user: create(:user), group: group ).user } let!(:issue1) { create(:issue, project: project, title: 'Issue #1', relative_position: 1) } @@ -143,9 +151,11 @@ RSpec.describe 'Group issues page' do end end - it 'issues should be draggable and persist order', :js do + it 'issues should be draggable and persist order' do visit issues_group_path(group, sort: 'relative_position') + wait_for_requests + drag_to(selector: '.manual-ordering', from_index: 0, to_index: 2) @@ -159,11 +169,13 @@ RSpec.describe 'Group issues page' do check_issue_order end - it 'issues should not be draggable when user is not logged in', :js do + it 'issues should not be draggable when user is not logged in' do sign_out(user_in_group) visit issues_group_path(group, sort: 'relative_position') + wait_for_requests + drag_to(selector: '.manual-ordering', from_index: 0, to_index: 2) @@ -187,7 +199,7 @@ RSpec.describe 'Group issues page' do end end - context 'issues pagination' do + context 'issues pagination', :js do let(:user_in_group) { create(:group_member, :maintainer, user: create(:user), group: group ).user } let!(:issues) do @@ -204,7 +216,9 @@ RSpec.describe 'Group issues page' do end it 'first pagination item is active' do - expect(page).to have_css(".js-first-button a.page-link.active") + page.within('.gl-pagination') do + expect(find('.active')).to have_content('1') + end end end end diff --git a/spec/features/groups/members/manage_groups_spec.rb b/spec/features/groups/members/manage_groups_spec.rb index f1cf04417c0..faf455e4ed9 100644 --- a/spec/features/groups/members/manage_groups_spec.rb +++ b/spec/features/groups/members/manage_groups_spec.rb @@ -20,26 +20,28 @@ RSpec.describe 'Groups > Members > Manage groups', :js do add_group(shared_with_group.id, 'Reporter') + click_groups_tab + page.within(first_row) do expect(page).to have_content(shared_with_group.name) expect(page).to have_content('Reporter') end end - it 'remove user from group' do + it 'remove group from group' do create(:group_group_link, shared_group: shared_group, shared_with_group: shared_with_group, group_access: ::Gitlab::Access::DEVELOPER) visit group_group_members_path(shared_group) + click_groups_tab + expect(page).to have_content(shared_with_group.name) accept_confirm do - find(:css, '#existing_shares li', text: shared_with_group.name).find(:css, 'a.btn-remove').click + find(:css, '#tab-groups li', text: shared_with_group.name).find(:css, 'a.btn-remove').click end - wait_for_requests - expect(page).not_to have_content(shared_with_group.name) end @@ -49,6 +51,8 @@ RSpec.describe 'Groups > Members > Manage groups', :js do visit group_group_members_path(shared_group) + click_groups_tab + page.within(first_row) do click_button('Developer') click_link('Maintainer') @@ -67,4 +71,8 @@ RSpec.describe 'Groups > Members > Manage groups', :js do click_button "Invite" end end + + def click_groups_tab + click_link "Groups" + end end diff --git a/spec/features/groups/members/manage_members_spec.rb b/spec/features/groups/members/manage_members_spec.rb index 99846ecee27..0267bea2f53 100644 --- a/spec/features/groups/members/manage_members_spec.rb +++ b/spec/features/groups/members/manage_members_spec.rb @@ -69,7 +69,7 @@ RSpec.describe 'Groups > Members > Manage members' do visit group_group_members_path(group) # Open modal - find(:css, '.project-members-page li', text: user2.name).find(:css, 'button.btn-remove').click + find(:css, '.project-members-page li', text: user2.name).find(:css, 'button.btn-danger').click expect(page).to have_unchecked_field 'Also unassign this user from related issues and merge requests' @@ -101,7 +101,7 @@ RSpec.describe 'Groups > Members > Manage members' do add_user('test@example.com', 'Reporter') - click_link('Pending') + click_link('Invited') page.within('.content-list.members-list') do expect(page).to have_content('test@example.com') @@ -124,7 +124,7 @@ RSpec.describe 'Groups > Members > Manage members' do expect(page).not_to have_button 'Developer' # Can not remove user2 - expect(page).not_to have_css('a.btn-remove') + expect(page).not_to have_css('a.btn-danger') end end diff --git a/spec/features/groups/members/master_manages_access_requests_spec.rb b/spec/features/groups/members/master_manages_access_requests_spec.rb index 2a17e7d2a5c..71c9b280ebe 100644 --- a/spec/features/groups/members/master_manages_access_requests_spec.rb +++ b/spec/features/groups/members/master_manages_access_requests_spec.rb @@ -4,6 +4,7 @@ require 'spec_helper' RSpec.describe 'Groups > Members > Maintainer manages access requests' do it_behaves_like 'Maintainer manages access requests' do + let(:has_tabs) { true } let(:entity) { create(:group, :public) } let(:members_page_path) { group_group_members_path(entity) } end diff --git a/spec/features/groups/members/search_members_spec.rb b/spec/features/groups/members/search_members_spec.rb index 4c34ccf87c3..ad4f5c0b579 100644 --- a/spec/features/groups/members/search_members_spec.rb +++ b/spec/features/groups/members/search_members_spec.rb @@ -19,7 +19,7 @@ RSpec.describe 'Search group member' do end it 'renders member users' do - page.within '.user-search-form' do + page.within '[data-testid="user-search-form"]' do fill_in 'search', with: member.name find('.user-search-btn').click end diff --git a/spec/features/groups/members/tabs_spec.rb b/spec/features/groups/members/tabs_spec.rb new file mode 100644 index 00000000000..fa77d1a2ff8 --- /dev/null +++ b/spec/features/groups/members/tabs_spec.rb @@ -0,0 +1,112 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe 'Groups > Members > Tabs' do + using RSpec::Parameterized::TableSyntax + + shared_examples 'active "Members" tab' do + it 'displays "Members" tab' do + expect(page).to have_selector('.nav-link.active', text: 'Members') + end + end + + shared_examples 'active "Invited" tab' do + it 'displays "Invited" tab' do + expect(page).to have_selector('.nav-link.active', text: 'Invited') + end + end + + let(:owner) { create(:user) } + let(:group) { create(:group) } + + before do + stub_const('Groups::GroupMembersController::MEMBER_PER_PAGE_LIMIT', 1) + allow_any_instance_of(Member).to receive(:send_request).and_return(true) + + group.add_owner(owner) + sign_in(owner) + + create_list(:group_member, 2, group: group) + create_list(:group_member, 2, :invited, group: group) + create_list(:group_group_link, 2, shared_group: group) + create_list(:group_member, 2, :access_request, group: group) + end + + where(:tab, :count) do + 'Members' | 3 + 'Invited' | 2 + 'Groups' | 2 + 'Access requests' | 2 + end + + with_them do + it "renders #{params[:tab]} tab" do + visit group_group_members_path(group) + + expect(page).to have_selector('.nav-link', text: "#{tab} #{count}") + end + end + + context 'displays "Members" tab by default' do + before do + visit group_group_members_path(group) + end + + it_behaves_like 'active "Members" tab' + end + + context 'when searching "Invited"', :js do + before do + visit group_group_members_path(group) + + click_link 'Invited' + + page.within '[data-testid="user-search-form"]' do + fill_in 'search_invited', with: 'email' + find('button[type="submit"]').click + end + end + + it_behaves_like 'active "Invited" tab' + + context 'and then searching "Members"' do + before do + click_link 'Members' + + page.within '[data-testid="user-search-form"]' do + fill_in 'search', with: 'test' + find('button[type="submit"]').click + end + end + + it_behaves_like 'active "Members" tab' + end + end + + context 'when using "Invited" pagination', :js do + before do + visit group_group_members_path(group) + + click_link 'Invited' + + page.within '.pagination' do + click_link '2' + end + end + + it_behaves_like 'active "Invited" tab' + + context 'and then using "Members" pagination' do + before do + click_link 'Members' + + page.within '.pagination' do + click_link '2' + end + end + + it_behaves_like 'active "Members" tab' + end + end +end diff --git a/spec/features/groups/navbar_spec.rb b/spec/features/groups/navbar_spec.rb index 06ff33ff0eb..6803b3a5785 100644 --- a/spec/features/groups/navbar_spec.rb +++ b/spec/features/groups/navbar_spec.rb @@ -45,6 +45,8 @@ RSpec.describe 'Group navbar' do end before do + insert_package_nav(_('Kubernetes')) + stub_feature_flags(group_push_rules: false) stub_feature_flags(group_iterations: false) stub_feature_flags(group_wiki: false) @@ -62,13 +64,8 @@ RSpec.describe 'Group navbar' do before do stub_config(registry: { enabled: true }) - insert_after_nav_item( - _('Kubernetes'), - new_nav_item: { - nav_item: _('Packages & Registries'), - nav_sub_items: [_('Container Registry')] - } - ) + insert_container_nav(_('Kubernetes')) + visit group_path(group) end diff --git a/spec/features/groups/packages_spec.rb b/spec/features/groups/packages_spec.rb new file mode 100644 index 00000000000..d81e4aa70cf --- /dev/null +++ b/spec/features/groups/packages_spec.rb @@ -0,0 +1,80 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe 'Group Packages' do + let_it_be(:user) { create(:user) } + let_it_be(:group) { create(:group) } + let_it_be(:project) { create(:project, group: group) } + + before do + sign_in(user) + group.add_maintainer(user) + end + + context 'when feature is not available' do + context 'packages feature is disabled by config' do + before do + allow(Gitlab.config.packages).to receive(:enabled).and_return(false) + end + + it 'gives 404' do + visit_group_packages + + expect(page).to have_gitlab_http_status(:not_found) + end + end + end + + context 'when feature is available', :js do + before do + visit_group_packages + end + + it 'sidebar menu is open' do + sidebar = find('.nav-sidebar') + expect(sidebar).to have_link _('Package Registry') + end + + context 'when there are packages' do + let_it_be(:second_project) { create(:project, name: 'second-project', group: group) } + let_it_be(:conan_package) { create(:conan_package, project: project, name: 'zzz', created_at: 1.day.ago, version: '1.0.0') } + let_it_be(:maven_package) { create(:maven_package, project: second_project, name: 'aaa', created_at: 2.days.ago, version: '2.0.0') } + let_it_be(:packages) { [conan_package, maven_package] } + + it_behaves_like 'packages list', check_project_name: true + + it_behaves_like 'package details link' + + it 'allows you to navigate to the project page' do + page.within('[data-qa-selector="packages-table"]') do + click_link project.name + end + + expect(page).to have_current_path(project_path(project)) + expect(page).to have_content(project.name) + end + + context 'sorting' do + it_behaves_like 'shared package sorting' do + let_it_be(:package_one) { maven_package } + let_it_be(:package_two) { conan_package } + end + + it_behaves_like 'correctly sorted packages list', 'Project' do + let(:packages) { [maven_package, conan_package] } + end + + it_behaves_like 'correctly sorted packages list', 'Project', ascending: true do + let(:packages) { [conan_package, maven_package] } + end + end + end + + it_behaves_like 'when there are no packages' + end + + def visit_group_packages + visit group_packages_path(group) + end +end |