diff options
Diffstat (limited to 'spec/features/issues')
-rw-r--r-- | spec/features/issues/form_spec.rb | 72 | ||||
-rw-r--r-- | spec/features/issues/issue_detail_spec.rb | 64 | ||||
-rw-r--r-- | spec/features/issues/user_creates_issue_spec.rb | 58 | ||||
-rw-r--r-- | spec/features/issues/user_edits_issue_spec.rb | 5 | ||||
-rw-r--r-- | spec/features/issues/user_toggles_subscription_spec.rb | 2 | ||||
-rw-r--r-- | spec/features/issues/user_uses_quick_actions_spec.rb | 1 |
6 files changed, 152 insertions, 50 deletions
diff --git a/spec/features/issues/form_spec.rb b/spec/features/issues/form_spec.rb index 4bad67acc87..b26f65316c5 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,61 @@ 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 + + shared_examples 'type option is missing' do |label:, identifier:| + it "does not show #{identifier} option", :aggregate_failures do + page.within('[data-testid="issue-type-select-dropdown"]') do + expect(page).not_to have_selector(%([data-testid="issue-type-#{identifier}-icon"])) + expect(page).not_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') + 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 missing', label: 'Incident', identifier: :incident end - 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 reporter' do + let_it_be(:reporter) { create(:user) } + + let(:current_user) { reporter } + + before_all do + project.add_reporter(reporter) 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 +310,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 +365,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 diff --git a/spec/features/issues/issue_detail_spec.rb b/spec/features/issues/issue_detail_spec.rb index 531c3634b5e..b37c8e9d1cf 100644 --- a/spec/features/issues/issue_detail_spec.rb +++ b/spec/features/issues/issue_detail_spec.rb @@ -3,8 +3,9 @@ require 'spec_helper' RSpec.describe 'Issue Detail', :js do + let_it_be_with_refind(:project) { create(:project, :public) } + let(:user) { create(:user) } - let(:project) { create(:project, :public) } let(:issue) { create(:issue, project: project, author: user) } let(:incident) { create(:incident, project: project, author: user) } @@ -90,7 +91,13 @@ RSpec.describe 'Issue Detail', :js do end describe 'user updates `issue_type` via the issue type dropdown' do - context 'when an issue `issue_type` is edited by a signed in user' do + let_it_be(:reporter) { create(:user) } + + before_all do + project.add_reporter(reporter) + end + + describe 'when an issue `issue_type` is edited' do before do sign_in(user) @@ -98,18 +105,33 @@ RSpec.describe 'Issue Detail', :js do wait_for_requests end - it 'routes the user to the incident details page when the `issue_type` is set to incident' do - open_issue_edit_form + context 'by non-member author' do + it 'cannot see Incident option' do + open_issue_edit_form + + page.within('[data-testid="issuable-form"]') do + expect(page).to have_content('Issue') + expect(page).not_to have_content('Incident') + end + end + end + + context 'by reporter' do + let(:user) { reporter } - page.within('[data-testid="issuable-form"]') do - update_type_select('Issue', 'Incident') + it 'routes the user to the incident details page when the `issue_type` is set to incident' do + open_issue_edit_form - expect(page).to have_current_path(project_issues_incident_path(project, issue)) + page.within('[data-testid="issuable-form"]') do + update_type_select('Issue', 'Incident') + + expect(page).to have_current_path(project_issues_incident_path(project, issue)) + end end end end - context 'when an incident `issue_type` is edited by a signed in user' do + describe 'when an incident `issue_type` is edited' do before do sign_in(user) @@ -117,13 +139,29 @@ RSpec.describe 'Issue Detail', :js do wait_for_requests end - it 'routes the user to the issue details page when the `issue_type` is set to issue' do - open_issue_edit_form + context 'by non-member author' do + it 'routes the user to the issue details page when the `issue_type` is set to issue' do + open_issue_edit_form + + page.within('[data-testid="issuable-form"]') do + update_type_select('Incident', 'Issue') + + expect(page).to have_current_path(project_issue_path(project, incident)) + end + end + end + + context 'by reporter' do + let(:user) { reporter } + + it 'routes the user to the issue details page when the `issue_type` is set to issue' do + open_issue_edit_form - page.within('[data-testid="issuable-form"]') do - update_type_select('Incident', 'Issue') + page.within('[data-testid="issuable-form"]') do + update_type_select('Incident', 'Issue') - expect(page).to have_current_path(project_issue_path(project, incident)) + expect(page).to have_current_path(project_issue_path(project, incident)) + end end end end diff --git a/spec/features/issues/user_creates_issue_spec.rb b/spec/features/issues/user_creates_issue_spec.rb index f46aa5c21b6..37e324e6ded 100644 --- a/spec/features/issues/user_creates_issue_spec.rb +++ b/spec/features/issues/user_creates_issue_spec.rb @@ -171,7 +171,7 @@ RSpec.describe "User creates issue" do end context 'form create handles issue creation by default' do - let(:project) { create(:project) } + let_it_be(:project) { create(:project) } before do visit new_project_issue_path(project) @@ -187,30 +187,22 @@ RSpec.describe "User creates issue" do end context 'form create handles incident creation' do - let(:project) { create(:project) } + let_it_be(:project) { create(:project) } before do visit new_project_issue_path(project, { issuable_template: 'incident', issue: { issue_type: 'incident' } }) end - it 'pre-fills the issue type dropdown with incident type' do - expect(find('.js-issuable-type-filter-dropdown-wrap .dropdown-toggle-text')).to have_content('Incident') - end - - it 'hides the epic select' do - expect(page).not_to have_selector('.epic-dropdown-container') + it 'does not pre-fill the issue type dropdown with incident type' do + expect(find('.js-issuable-type-filter-dropdown-wrap .dropdown-toggle-text')).not_to have_content('Incident') end it 'shows the milestone select' do expect(page).to have_selector('.qa-issuable-milestone-dropdown') # rubocop:disable QA/SelectorUsage end - it 'hides the weight input' do - expect(page).not_to have_selector('.qa-issuable-weight-input') # rubocop:disable QA/SelectorUsage - end - - it 'shows the incident help text' do - expect(page).to have_text('A modified issue to guide the resolution of incidents.') + it 'hides the incident help text' do + expect(page).not_to have_text('A modified issue to guide the resolution of incidents.') end end @@ -242,6 +234,44 @@ RSpec.describe "User creates issue" do end end + context 'when signed in as reporter', :js do + let_it_be(:project) { create(:project) } + + before_all do + project.add_reporter(user) + end + + before do + sign_in(user) + end + + context 'form create handles incident creation' do + before do + visit new_project_issue_path(project, { issuable_template: 'incident', issue: { issue_type: 'incident' } }) + end + + it 'pre-fills the issue type dropdown with incident type' do + expect(find('.js-issuable-type-filter-dropdown-wrap .dropdown-toggle-text')).to have_content('Incident') + end + + it 'hides the epic select' do + expect(page).not_to have_selector('.epic-dropdown-container') + end + + it 'shows the milestone select' do + expect(page).to have_selector('.qa-issuable-milestone-dropdown') # rubocop:disable QA/SelectorUsage + end + + it 'hides the weight input' do + expect(page).not_to have_selector('.qa-issuable-weight-input') # rubocop:disable QA/SelectorUsage + end + + it 'shows the incident help text' do + expect(page).to have_text('A modified issue to guide the resolution of incidents.') + end + end + end + context "when signed in as user with special characters in their name" do let(:user_special) { create(:user, name: "Jon O'Shea") } diff --git a/spec/features/issues/user_edits_issue_spec.rb b/spec/features/issues/user_edits_issue_spec.rb index 63c36a20adc..76cec2502e3 100644 --- a/spec/features/issues/user_edits_issue_spec.rb +++ b/spec/features/issues/user_edits_issue_spec.rb @@ -146,8 +146,7 @@ RSpec.describe "Issues > User edits issue", :js do fill_in 'Comment', with: '/label ~syzygy' click_button 'Comment' - - wait_for_requests + expect(page).to have_text('added syzygy label just now') page.within '.block.labels' do # Remove `verisimilitude` label @@ -155,8 +154,6 @@ RSpec.describe "Issues > User edits issue", :js do click_button end - wait_for_requests - expect(page).to have_text('syzygy') expect(page).not_to have_text('verisimilitude') end diff --git a/spec/features/issues/user_toggles_subscription_spec.rb b/spec/features/issues/user_toggles_subscription_spec.rb index 9809bb34d26..541bbc8a8e7 100644 --- a/spec/features/issues/user_toggles_subscription_spec.rb +++ b/spec/features/issues/user_toggles_subscription_spec.rb @@ -45,7 +45,7 @@ RSpec.describe "User toggles subscription", :js do it 'is disabled' do expect(page).to have_content('Disabled by project owner') - expect(page).to have_button('Notifications', class: 'is-disabled') + expect(page).to have_selector('[data-testid="subscription-toggle"]', class: 'is-disabled') end end end diff --git a/spec/features/issues/user_uses_quick_actions_spec.rb b/spec/features/issues/user_uses_quick_actions_spec.rb index d88b816b186..c6d743ed38f 100644 --- a/spec/features/issues/user_uses_quick_actions_spec.rb +++ b/spec/features/issues/user_uses_quick_actions_spec.rb @@ -44,5 +44,6 @@ RSpec.describe 'Issues > User uses quick actions', :js do it_behaves_like 'move quick action' it_behaves_like 'zoom quick actions' it_behaves_like 'clone quick action' + it_behaves_like 'promote_to_incident quick action' end end |