diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-11-08 18:13:35 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-11-08 18:13:35 +0300 |
commit | 05db4ead6d5c73cf62ad95d80ccac415bc3bf3cd (patch) | |
tree | 4db17ac5879083050b2b2dad83a60f63fae8b72b /spec/features | |
parent | 6a380347147d1a55afbc6a1c16e04b567ab90d86 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/features')
-rw-r--r-- | spec/features/graphql_known_operations_spec.rb | 29 | ||||
-rw-r--r-- | spec/features/issues/form_spec.rb | 57 |
2 files changed, 66 insertions, 20 deletions
diff --git a/spec/features/graphql_known_operations_spec.rb b/spec/features/graphql_known_operations_spec.rb new file mode 100644 index 00000000000..ef406f12902 --- /dev/null +++ b/spec/features/graphql_known_operations_spec.rb @@ -0,0 +1,29 @@ +# frozen_string_literal: true + +require 'spec_helper' + +# We need to distinguish between known and unknown GraphQL operations. This spec +# tests that we set up Gitlab::Graphql::KnownOperations.default which requires +# integration of FE queries, webpack plugin, and BE. +RSpec.describe 'Graphql known operations', :js do + around do |example| + # Let's make sure we aren't receiving or leaving behind any side-effects + # https://gitlab.com/gitlab-org/gitlab/-/jobs/1743294100 + ::Gitlab::Graphql::KnownOperations.instance_variable_set(:@default, nil) + ::Gitlab::Webpack::GraphqlKnownOperations.clear_memoization! + + example.run + + ::Gitlab::Graphql::KnownOperations.instance_variable_set(:@default, nil) + ::Gitlab::Webpack::GraphqlKnownOperations.clear_memoization! + end + + it 'collects known Graphql operations from the code', :aggregate_failures do + # Check that we include some arbitrary operation name we expect + known_operations = Gitlab::Graphql::KnownOperations.default.operations.map(&:name) + + expect(known_operations).to include("searchProjects") + expect(known_operations.length).to be > 20 + expect(known_operations).to all( match(%r{^[a-z]+}i) ) + end +end diff --git a/spec/features/issues/form_spec.rb b/spec/features/issues/form_spec.rb index 4bad67acc87..bb68dcb614a 100644 --- a/spec/features/issues/form_spec.rb +++ b/spec/features/issues/form_spec.rb @@ -4,25 +4,29 @@ require 'spec_helper' RSpec.describe 'New/edit issue', :js do include ActionView::Helpers::JavaScriptHelper - include FormHelper let_it_be(:project) { create(:project) } - let_it_be(:user) { create(:user)} - let_it_be(:user2) { create(:user)} + let_it_be(:user) { create(:user) } + let_it_be(:user2) { create(:user) } let_it_be(:milestone) { create(:milestone, project: project) } let_it_be(:label) { create(:label, project: project) } let_it_be(:label2) { create(:label, project: project) } let_it_be(:issue) { create(:issue, project: project, assignees: [user], milestone: milestone) } - before do - stub_licensed_features(multiple_issue_assignees: false, issue_weights: false) + let(:current_user) { user } + before_all do project.add_maintainer(user) project.add_maintainer(user2) - sign_in(user) end - context 'new issue' do + before do + stub_licensed_features(multiple_issue_assignees: false, issue_weights: false) + + sign_in(current_user) + end + + describe 'new issue' do before do visit new_project_issue_path(project) end @@ -235,29 +239,42 @@ RSpec.describe 'New/edit issue', :js do end describe 'displays issue type options in the dropdown' do + shared_examples 'type option is visible' do |label:, identifier:| + it "shows #{identifier} option", :aggregate_failures do + page.within('[data-testid="issue-type-select-dropdown"]') do + expect(page).to have_selector(%([data-testid="issue-type-#{identifier}-icon"])) + expect(page).to have_content(label) + end + end + end + before do page.within('.issue-form') do click_button 'Issue' end end - it 'correctly displays the Issue type option with an icon', :aggregate_failures do - page.within('[data-testid="issue-type-select-dropdown"]') do - expect(page).to have_selector('[data-testid="issue-type-issue-icon"]') - expect(page).to have_content('Issue') - end - end + it_behaves_like 'type option is visible', label: 'Issue', identifier: :issue + it_behaves_like 'type option is visible', label: 'Incident', identifier: :incident - it 'correctly displays the Incident type option with an icon', :aggregate_failures do - page.within('[data-testid="issue-type-select-dropdown"]') do - expect(page).to have_selector('[data-testid="issue-type-incident-icon"]') - expect(page).to have_content('Incident') + context 'when user is guest' do + let_it_be(:guest) { create(:user) } + + let(:current_user) { guest } + + before_all do + project.add_guest(guest) end + + it_behaves_like 'type option is visible', label: 'Issue', identifier: :issue + it_behaves_like 'type option is visible', label: 'Incident', identifier: :incident end end describe 'milestone' do - let!(:milestone) { create(:milestone, title: '"><img src=x onerror=alert(document.domain)>', project: project) } + let!(:milestone) do + create(:milestone, title: '"><img src=x onerror=alert(document.domain)>', project: project) + end it 'escapes milestone' do click_button 'Milestone' @@ -274,7 +291,7 @@ RSpec.describe 'New/edit issue', :js do end end - context 'edit issue' do + describe 'edit issue' do before do visit edit_project_issue_path(project, issue) end @@ -329,7 +346,7 @@ RSpec.describe 'New/edit issue', :js do end end - context 'inline edit' do + describe 'inline edit' do before do visit project_issue_path(project, issue) end |