Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-05-20 17:34:42 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-05-20 17:34:42 +0300
commit9f46488805e86b1bc341ea1620b866016c2ce5ed (patch)
treef9748c7e287041e37d6da49e0a29c9511dc34768 /spec/features/issues
parentdfc92d081ea0332d69c8aca2f0e745cb48ae5e6d (diff)
Add latest changes from gitlab-org/gitlab@13-0-stable-ee
Diffstat (limited to 'spec/features/issues')
-rw-r--r--spec/features/issues/bulk_assignment_labels_spec.rb2
-rw-r--r--spec/features/issues/filtered_search/filter_issues_spec.rb47
-rw-r--r--spec/features/issues/filtered_search/visual_tokens_spec.rb18
-rw-r--r--spec/features/issues/spam_issues_spec.rb121
-rw-r--r--spec/features/issues/update_issues_spec.rb2
-rw-r--r--spec/features/issues/user_creates_branch_and_merge_request_spec.rb12
-rw-r--r--spec/features/issues/user_sees_sidebar_updates_in_realtime_spec.rb32
7 files changed, 191 insertions, 43 deletions
diff --git a/spec/features/issues/bulk_assignment_labels_spec.rb b/spec/features/issues/bulk_assignment_labels_spec.rb
index d036fde5657..fc9176715c3 100644
--- a/spec/features/issues/bulk_assignment_labels_spec.rb
+++ b/spec/features/issues/bulk_assignment_labels_spec.rb
@@ -274,7 +274,7 @@ describe 'Issues > Labels bulk assignment' do
expect(find("#issue_#{issue2.id}")).to have_content 'First Release'
check 'check-all-issues'
- open_milestone_dropdown(['No Milestone'])
+ open_milestone_dropdown(['No milestone'])
update_issues
expect(find("#issue_#{issue1.id}")).to have_content 'bug'
diff --git a/spec/features/issues/filtered_search/filter_issues_spec.rb b/spec/features/issues/filtered_search/filter_issues_spec.rb
index 5e2b5921e06..3ee5840e1b9 100644
--- a/spec/features/issues/filtered_search/filter_issues_spec.rb
+++ b/spec/features/issues/filtered_search/filter_issues_spec.rb
@@ -81,6 +81,26 @@ describe 'Filter issues', :js do
expect_filtered_search_input(search_term)
end
+ context 'with the NOT queries feature flag disabled' do
+ before do
+ stub_feature_flags(not_issuable_queries: false)
+ visit project_issues_path(project)
+ end
+
+ it 'does not have the != option' do
+ input_filtered_search("label:", submit: false)
+
+ wait_for_requests
+ within('#js-dropdown-operator') do
+ tokens = all(:css, 'li.filter-dropdown-item')
+ expect(tokens.count).to eq(1)
+ button = tokens[0].find('button')
+ expect(button).to have_content('=')
+ expect(button).not_to have_content('!=')
+ end
+ end
+ end
+
describe 'filter issues by author' do
context 'only author' do
it 'filters issues by searched author' do
@@ -153,16 +173,16 @@ describe 'Filter issues', :js do
expect_filtered_search_input_empty
end
- it 'filters issues by no label' do
- input_filtered_search('label:=none')
+ it 'filters issues by any label' do
+ input_filtered_search('label:=any')
- expect_tokens([label_token('None', false)])
+ expect_tokens([label_token('Any', false)])
expect_issues_list_count(4)
expect_filtered_search_input_empty
end
it 'filters issues by no label' do
- input_filtered_search('label:!=none')
+ input_filtered_search('label:=none')
expect_tokens([label_token('None', false)])
expect_issues_list_count(4)
@@ -351,14 +371,6 @@ describe 'Filter issues', :js do
expect_filtered_search_input_empty
end
- it 'filters issues by negation of no milestone' do
- input_filtered_search("milestone:!=none ")
-
- expect_tokens([milestone_token('None', false, '!=')])
- expect_issues_list_count(5)
- expect_filtered_search_input_empty
- end
-
it 'filters issues by upcoming milestones' do
create(:milestone, project: project, due_date: 1.month.from_now) do |future_milestone|
create(:issue, project: project, milestone: future_milestone, author: user)
@@ -376,10 +388,14 @@ describe 'Filter issues', :js do
create(:issue, project: project, milestone: future_milestone, author: user)
end
+ create(:milestone, project: project, due_date: 3.days.ago) do |past_milestone|
+ create(:issue, project: project, milestone: past_milestone, author: user)
+ end
+
input_filtered_search("milestone:!=upcoming")
expect_tokens([milestone_token('Upcoming', false, '!=')])
- expect_issues_list_count(8)
+ expect_issues_list_count(1)
expect_filtered_search_input_empty
end
@@ -392,10 +408,13 @@ describe 'Filter issues', :js do
end
it 'filters issues by negation of started milestones' do
+ milestone2 = create(:milestone, title: "9", project: project, start_date: 2.weeks.from_now)
+ create(:issue, project: project, author: user, title: "something else", milestone: milestone2)
+
input_filtered_search("milestone:!=started")
expect_tokens([milestone_token('Started', false, '!=')])
- expect_issues_list_count(3)
+ expect_issues_list_count(1)
expect_filtered_search_input_empty
end
diff --git a/spec/features/issues/filtered_search/visual_tokens_spec.rb b/spec/features/issues/filtered_search/visual_tokens_spec.rb
index 3c50cb4c997..d34253b3c5e 100644
--- a/spec/features/issues/filtered_search/visual_tokens_spec.rb
+++ b/spec/features/issues/filtered_search/visual_tokens_spec.rb
@@ -113,7 +113,7 @@ describe 'Visual tokens', :js do
describe 'add new token after editing existing token' do
before do
input_filtered_search('author:=@root assignee:=none', submit: false)
- first('.tokens-container .filtered-search-token').double_click
+ first('.tokens-container .filtered-search-token').click
filtered_search.send_keys(' ')
end
@@ -175,4 +175,20 @@ describe 'Visual tokens', :js do
expect(token.find('.name').text).to eq('Label')
expect(token.find('.operator').text).to eq('=')
end
+
+ describe 'Any/None option' do
+ it 'hidden when NOT operator is selected' do
+ input_filtered_search('milestone:!=', extra_space: false, submit: false)
+
+ expect(page).not_to have_selector("#js-dropdown-milestone", text: 'Any')
+ expect(page).not_to have_selector("#js-dropdown-milestone", text: 'None')
+ end
+
+ it 'shown when EQUAL operator is selected' do
+ input_filtered_search('milestone:=', extra_space: false, submit: false)
+
+ expect(page).to have_selector("#js-dropdown-milestone", text: 'Any')
+ expect(page).to have_selector("#js-dropdown-milestone", text: 'None')
+ end
+ end
end
diff --git a/spec/features/issues/spam_issues_spec.rb b/spec/features/issues/spam_issues_spec.rb
index b59cd2d632a..47e7022011d 100644
--- a/spec/features/issues/spam_issues_spec.rb
+++ b/spec/features/issues/spam_issues_spec.rb
@@ -23,9 +23,13 @@ describe 'New issue', :js do
sign_in(user)
end
- context 'when identified as spam' do
+ context 'when SpamVerdictService disallows' do
+ include_context 'includes Spam constants'
+
before do
- WebMock.stub_request(:any, /.*akismet.com.*/).to_return(body: "true", status: 200)
+ allow_next_instance_of(Spam::SpamVerdictService) do |verdict_service|
+ allow(verdict_service).to receive(:execute).and_return(DISALLOW)
+ end
visit new_project_issue_path(project)
end
@@ -33,23 +37,22 @@ describe 'New issue', :js do
context 'when allow_possible_spam feature flag is false' do
before do
stub_feature_flags(allow_possible_spam: false)
- end
- it 'creates an issue after solving reCaptcha' do
fill_in 'issue_title', with: 'issue title'
fill_in 'issue_description', with: 'issue description'
+ end
+ it 'rejects issue creation' do
click_button 'Submit issue'
- # it is impossible to test recaptcha automatically and there is no possibility to fill in recaptcha
- # recaptcha verification is skipped in test environment and it always returns true
+ expect(page).to have_content('discarded')
+ expect(page).not_to have_content('potential spam')
expect(page).not_to have_content('issue title')
- expect(page).to have_css('.recaptcha')
-
- click_button 'Submit issue'
+ end
- expect(page.find('.issue-details h2.title')).to have_content('issue title')
- expect(page.find('.issue-details .description')).to have_content('issue description')
+ it 'creates a spam log record' do
+ expect { click_button 'Submit issue' }
+ .to log_spam(title: 'issue title', description: 'issue description', user_id: user.id, noteable_type: 'Issue')
end
end
@@ -59,10 +62,9 @@ describe 'New issue', :js do
fill_in 'issue_description', with: 'issue description'
end
- it 'creates an issue without a need to solve reCaptcha' do
+ it 'allows issue creation' do
click_button 'Submit issue'
- expect(page).not_to have_css('.recaptcha')
expect(page.find('.issue-details h2.title')).to have_content('issue title')
expect(page.find('.issue-details .description')).to have_content('issue description')
end
@@ -74,9 +76,98 @@ describe 'New issue', :js do
end
end
- context 'when not identified as spam' do
+ context 'when SpamVerdictService requires recaptcha' do
+ include_context 'includes Spam constants'
+
before do
- WebMock.stub_request(:any, /.*akismet.com.*/).to_return(body: 'false', status: 200)
+ allow_next_instance_of(Spam::SpamVerdictService) do |verdict_service|
+ allow(verdict_service).to receive(:execute).and_return(REQUIRE_RECAPTCHA)
+ end
+
+ visit new_project_issue_path(project)
+ end
+
+ context 'when recaptcha is enabled' do
+ before do
+ stub_application_setting(recaptcha_enabled: true)
+ end
+
+ context 'when allow_possible_spam feature flag is false' do
+ before do
+ stub_feature_flags(allow_possible_spam: false)
+ end
+
+ it 'creates an issue after solving reCaptcha' do
+ fill_in 'issue_title', with: 'issue title'
+ fill_in 'issue_description', with: 'issue description'
+
+ click_button 'Submit issue'
+
+ # it is impossible to test reCAPTCHA automatically and there is no possibility to fill in recaptcha
+ # reCAPTCHA verification is skipped in test environment and it always returns true
+ expect(page).not_to have_content('issue title')
+ expect(page).to have_css('.recaptcha')
+
+ click_button 'Submit issue'
+
+ expect(page.find('.issue-details h2.title')).to have_content('issue title')
+ expect(page.find('.issue-details .description')).to have_content('issue description')
+ end
+ end
+
+ context 'when allow_possible_spam feature flag is true' do
+ before do
+ fill_in 'issue_title', with: 'issue title'
+ fill_in 'issue_description', with: 'issue description'
+ end
+
+ it 'creates an issue without a need to solve reCAPTCHA' do
+ click_button 'Submit issue'
+
+ expect(page).not_to have_css('.recaptcha')
+ expect(page.find('.issue-details h2.title')).to have_content('issue title')
+ expect(page.find('.issue-details .description')).to have_content('issue description')
+ end
+
+ it 'creates a spam log record' do
+ expect { click_button 'Submit issue' }
+ .to log_spam(title: 'issue title', description: 'issue description', user_id: user.id, noteable_type: 'Issue')
+ end
+ end
+ end
+
+ context 'when reCAPTCHA is not enabled' do
+ before do
+ stub_application_setting(recaptcha_enabled: false)
+ end
+
+ context 'when allow_possible_spam feature flag is true' do
+ before do
+ fill_in 'issue_title', with: 'issue title'
+ fill_in 'issue_description', with: 'issue description'
+ end
+
+ it 'creates an issue without a need to solve reCaptcha' do
+ click_button 'Submit issue'
+
+ expect(page).not_to have_css('.recaptcha')
+ expect(page.find('.issue-details h2.title')).to have_content('issue title')
+ expect(page.find('.issue-details .description')).to have_content('issue description')
+ end
+
+ it 'creates a spam log record' do
+ expect { click_button 'Submit issue' }
+ .to log_spam(title: 'issue title', description: 'issue description', user_id: user.id, noteable_type: 'Issue')
+ end
+ end
+ end
+ end
+
+ context 'when the SpamVerdictService allows' do
+ before do
+ allow_next_instance_of(Spam::SpamVerdictService) do |verdict_service|
+ allow(verdict_service).to receive(:execute).and_return(ALLOW)
+ end
visit new_project_issue_path(project)
end
diff --git a/spec/features/issues/update_issues_spec.rb b/spec/features/issues/update_issues_spec.rb
index 45a0b1932a2..98f70df1c8b 100644
--- a/spec/features/issues/update_issues_spec.rb
+++ b/spec/features/issues/update_issues_spec.rb
@@ -95,7 +95,7 @@ describe 'Multiple issue updating from issues#index', :js do
find('#check-all-issues').click
find('.issues-bulk-update .js-milestone-select').click
- find('.dropdown-menu-milestone a', text: "No Milestone").click
+ find('.dropdown-menu-milestone a', text: "No milestone").click
click_update_issues_button
expect(find('.issue:first-child')).not_to have_content milestone.title
diff --git a/spec/features/issues/user_creates_branch_and_merge_request_spec.rb b/spec/features/issues/user_creates_branch_and_merge_request_spec.rb
index 7eecfd1ccf4..848dbbb85a6 100644
--- a/spec/features/issues/user_creates_branch_and_merge_request_spec.rb
+++ b/spec/features/issues/user_creates_branch_and_merge_request_spec.rb
@@ -164,17 +164,7 @@ describe 'User creates branch and merge request on issue page', :js do
context 'when issue is confidential' do
let(:issue) { create(:issue, :confidential, project: project) }
- it 'disables the create branch button' do
- stub_feature_flags(create_confidential_merge_request: false)
-
- visit project_issue_path(project, issue)
-
- expect(page).not_to have_css('.create-mr-dropdown-wrap')
- end
-
- it 'enables the create branch button when feature flag is enabled' do
- stub_feature_flags(create_confidential_merge_request: true)
-
+ it 'enables the create branch button' do
visit project_issue_path(project, issue)
expect(page).to have_css('.create-mr-dropdown-wrap')
diff --git a/spec/features/issues/user_sees_sidebar_updates_in_realtime_spec.rb b/spec/features/issues/user_sees_sidebar_updates_in_realtime_spec.rb
new file mode 100644
index 00000000000..c3f17227701
--- /dev/null
+++ b/spec/features/issues/user_sees_sidebar_updates_in_realtime_spec.rb
@@ -0,0 +1,32 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+describe 'Issues > Real-time sidebar', :js do
+ let_it_be(:project) { create(:project, :public) }
+ let_it_be(:issue) { create(:issue, project: project) }
+ let_it_be(:user) { create(:user) }
+
+ before_all do
+ project.add_developer(user)
+ end
+
+ it 'updates the assignee in real-time' do
+ Capybara::Session.new(:other_session)
+
+ using_session :other_session do
+ visit project_issue_path(project, issue)
+ expect(page.find('.assignee')).to have_content 'None'
+ end
+
+ gitlab_sign_in(user)
+ visit project_issue_path(project, issue)
+ expect(page.find('.assignee')).to have_content 'None'
+
+ click_button 'assign yourself'
+
+ using_session :other_session do
+ expect(page.find('.assignee')).to have_content user.name
+ end
+ end
+end