diff options
Diffstat (limited to 'spec/features')
-rw-r--r-- | spec/features/admin/admin_mode/workers_spec.rb | 8 | ||||
-rw-r--r-- | spec/features/admin/admin_settings_spec.rb | 15 | ||||
-rw-r--r-- | spec/features/cycle_analytics_spec.rb | 12 | ||||
-rw-r--r-- | spec/features/issues/csv_spec.rb | 100 | ||||
-rw-r--r-- | spec/features/merge_request/user_resolves_wip_mr_spec.rb | 48 | ||||
-rw-r--r-- | spec/features/projects/environments_pod_logs_spec.rb | 4 | ||||
-rw-r--r-- | spec/features/projects/snippets/create_snippet_spec.rb | 1 | ||||
-rw-r--r-- | spec/features/projects/snippets/user_updates_snippet_spec.rb | 1 | ||||
-rw-r--r-- | spec/features/snippets/spam_snippets_spec.rb | 1 | ||||
-rw-r--r-- | spec/features/snippets/user_creates_snippet_spec.rb | 1 | ||||
-rw-r--r-- | spec/features/snippets/user_edits_snippet_spec.rb | 1 | ||||
-rw-r--r-- | spec/features/static_site_editor_spec.rb | 19 |
12 files changed, 197 insertions, 14 deletions
diff --git a/spec/features/admin/admin_mode/workers_spec.rb b/spec/features/admin/admin_mode/workers_spec.rb index e33c9d7e64c..0ca61e6c193 100644 --- a/spec/features/admin/admin_mode/workers_spec.rb +++ b/spec/features/admin/admin_mode/workers_spec.rb @@ -8,8 +8,6 @@ describe 'Admin mode for workers', :do_not_mock_admin_mode, :request_store, :cle let(:user_to_delete) { create(:user) } before do - add_sidekiq_middleware - sign_in(user) end @@ -60,12 +58,6 @@ describe 'Admin mode for workers', :do_not_mock_admin_mode, :request_store, :cle end end - def add_sidekiq_middleware - Sidekiq::Testing.server_middleware do |chain| - chain.add Gitlab::SidekiqMiddleware::AdminMode::Server - end - end - def execute_jobs_signed_out(user) gitlab_sign_out diff --git a/spec/features/admin/admin_settings_spec.rb b/spec/features/admin/admin_settings_spec.rb index 8eb15bb6bf5..1a3da8cb373 100644 --- a/spec/features/admin/admin_settings_spec.rb +++ b/spec/features/admin/admin_settings_spec.rb @@ -348,12 +348,19 @@ describe 'Admin updates settings', :clean_gitlab_redis_shared_state, :do_not_moc it 'loads usage ping payload on click', :js do allow(ActiveRecord::Base.connection).to receive(:transaction_open?).and_return(false) - expect(page).to have_button 'Preview payload' + page.within('#js-usage-settings') do + expected_payload_content = /(?=.*"uuid")(?=.*"hostname")/m - find('.js-usage-ping-payload-trigger').click + expect(page).not_to have_content expected_payload_content - expect(page).to have_selector '.js-usage-ping-payload' - expect(page).to have_button 'Hide payload' + click_button('Preview payload') + + wait_for_requests + + expect(page).to have_selector '.js-usage-ping-payload' + expect(page).to have_button 'Hide payload' + expect(page).to have_content expected_payload_content + end end end diff --git a/spec/features/cycle_analytics_spec.rb b/spec/features/cycle_analytics_spec.rb index 4a20d1b7d60..50d9cb1c833 100644 --- a/spec/features/cycle_analytics_spec.rb +++ b/spec/features/cycle_analytics_spec.rb @@ -30,6 +30,7 @@ describe 'Value Stream Analytics', :js do expect(new_issues_counter).to have_content('-') expect(commits_counter).to have_content('-') expect(deploys_counter).to have_content('-') + expect(deployment_frequency_counter).to have_content('-') end it 'shows active stage with empty message' do @@ -53,6 +54,7 @@ describe 'Value Stream Analytics', :js do expect(new_issues_counter).to have_content('1') expect(commits_counter).to have_content('2') expect(deploys_counter).to have_content('1') + expect(deployment_frequency_counter).to have_content('0') end it 'shows data on each stage', :sidekiq_might_not_need_inline do @@ -134,7 +136,15 @@ describe 'Value Stream Analytics', :js do end def deploys_counter - find(:xpath, "//p[contains(text(),'Deploy')]/preceding-sibling::h3") + find(:xpath, "//p[contains(text(),'Deploy')]/preceding-sibling::h3", match: :first) + end + + def deployment_frequency_counter_selector + "//p[contains(text(),'Deployment Frequency')]/preceding-sibling::h3" + end + + def deployment_frequency_counter + find(:xpath, deployment_frequency_counter_selector) end def expect_issue_to_be_present diff --git a/spec/features/issues/csv_spec.rb b/spec/features/issues/csv_spec.rb new file mode 100644 index 00000000000..193c83d2a40 --- /dev/null +++ b/spec/features/issues/csv_spec.rb @@ -0,0 +1,100 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe 'Issues csv' do + let(:user) { create(:user) } + let(:project) { create(:project, :public) } + let(:milestone) { create(:milestone, title: 'v1.0', project: project) } + let(:idea_label) { create(:label, project: project, title: 'Idea') } + let(:feature_label) { create(:label, project: project, title: 'Feature', priority: 10) } + let!(:issue) { create(:issue, project: project, author: user) } + + before do + sign_in(user) + end + + def request_csv(params = {}) + visit project_issues_path(project, params) + page.within('.nav-controls') do + click_on 'Export as CSV' + end + click_on 'Export issues' + end + + def attachment + ActionMailer::Base.deliveries.last.attachments.first + end + + def csv + CSV.parse(attachment.decode_body, headers: true) + end + + it 'triggers an email export' do + expect(ExportCsvWorker).to receive(:perform_async).with(user.id, project.id, hash_including("project_id" => project.id)) + + request_csv + end + + it "doesn't send request params to ExportCsvWorker" do + expect(ExportCsvWorker).to receive(:perform_async).with(anything, anything, hash_excluding("controller" => anything, "action" => anything)) + + request_csv + end + + it 'displays flash message' do + request_csv + + expect(page).to have_content 'CSV export has started' + expect(page).to have_content "emailed to #{user.notification_email}" + end + + it 'includes a csv attachment', :sidekiq_might_not_need_inline do + request_csv + + expect(attachment.content_type).to include('text/csv') + end + + it 'ignores pagination', :sidekiq_might_not_need_inline do + create_list(:issue, 30, project: project, author: user) + + request_csv + + expect(csv.count).to eq 31 + end + + it 'uses filters from issue index', :sidekiq_might_not_need_inline do + request_csv(state: :closed) + + expect(csv.count).to eq 0 + end + + it 'ignores sorting from issue index', :sidekiq_might_not_need_inline do + issue2 = create(:labeled_issue, project: project, author: user, labels: [feature_label]) + + request_csv(sort: :label_priority) + + expected = [issue.iid.to_s, issue2.iid.to_s] + expect(csv.map { |row| row['Issue ID'] }).to eq expected + end + + it 'uses array filters, such as label_name', :sidekiq_might_not_need_inline do + issue.update!(labels: [idea_label]) + + request_csv("label_name[]" => 'Bug') + + expect(csv.count).to eq 0 + end + + it 'avoids excessive database calls' do + control_count = ActiveRecord::QueryRecorder.new { request_csv }.count + create_list(:labeled_issue, + 10, + project: project, + assignees: [user], + author: user, + milestone: milestone, + labels: [feature_label, idea_label]) + expect { request_csv }.not_to exceed_query_limit(control_count + 5) + end +end diff --git a/spec/features/merge_request/user_resolves_wip_mr_spec.rb b/spec/features/merge_request/user_resolves_wip_mr_spec.rb new file mode 100644 index 00000000000..93ef0801791 --- /dev/null +++ b/spec/features/merge_request/user_resolves_wip_mr_spec.rb @@ -0,0 +1,48 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe 'Merge request > User resolves Work in Progress', :js do + let(:project) { create(:project, :public, :repository) } + let(:user) { project.creator } + let(:merge_request) do + create(:merge_request_with_diffs, source_project: project, + author: user, + title: 'WIP: Bug NS-04', + merge_params: { force_remove_source_branch: '1' }) + end + let(:pipeline) do + create(:ci_pipeline, project: project, + sha: merge_request.diff_head_sha, + ref: merge_request.source_branch, + head_pipeline_of: merge_request) + end + + before do + project.add_maintainer(user) + end + + context 'when there is active pipeline for merge request' do + before do + create(:ci_build, pipeline: pipeline) + sign_in(user) + visit project_merge_request_path(project, merge_request) + wait_for_requests + end + + it 'retains merge request data after clicking Resolve WIP status' do + expect(page.find('.ci-widget-content')).to have_content("Pipeline ##{pipeline.id}") + expect(page).to have_content "This is a Work in Progress" + + click_button('Resolve WIP status') + + wait_for_requests + + # If we don't disable the wait here, the test will wait until the + # merge request widget refreshes, which masks missing elements + # that should already be present. + expect(page.find('.ci-widget-content', wait: 0)).to have_content("Pipeline ##{pipeline.id}") + expect(page).not_to have_content('This is a Work in Progress') + end + end +end diff --git a/spec/features/projects/environments_pod_logs_spec.rb b/spec/features/projects/environments_pod_logs_spec.rb index 2b2327940a5..a51f121bf59 100644 --- a/spec/features/projects/environments_pod_logs_spec.rb +++ b/spec/features/projects/environments_pod_logs_spec.rb @@ -57,7 +57,9 @@ describe 'Environment > Pod Logs', :js do expect(item.text).to eq(pod_names[i]) end end - expect(page).to have_content("Dec 13 14:04:22.123Z | kube-pod | Log 1 Dec 13 14:04:23.123Z | kube-pod | Log 2 Dec 13 14:04:24.123Z | kube-pod | Log 3") + expect(page).to have_content("kube-pod | Log 1") + expect(page).to have_content("kube-pod | Log 2") + expect(page).to have_content("kube-pod | Log 3") end end end diff --git a/spec/features/projects/snippets/create_snippet_spec.rb b/spec/features/projects/snippets/create_snippet_spec.rb index b55a42e07a9..d883a1fc39c 100644 --- a/spec/features/projects/snippets/create_snippet_spec.rb +++ b/spec/features/projects/snippets/create_snippet_spec.rb @@ -4,6 +4,7 @@ require 'spec_helper' shared_examples_for 'snippet editor' do before do + stub_feature_flags(snippets_edit_vue: false) stub_feature_flags(monaco_snippets: flag) end diff --git a/spec/features/projects/snippets/user_updates_snippet_spec.rb b/spec/features/projects/snippets/user_updates_snippet_spec.rb index bad3fde8a4a..cf501e55e23 100644 --- a/spec/features/projects/snippets/user_updates_snippet_spec.rb +++ b/spec/features/projects/snippets/user_updates_snippet_spec.rb @@ -11,6 +11,7 @@ describe 'Projects > Snippets > User updates a snippet', :js do before do stub_feature_flags(snippets_vue: false) + stub_feature_flags(snippets_edit_vue: false) stub_feature_flags(version_snippets: version_snippet_enabled) project.add_maintainer(user) diff --git a/spec/features/snippets/spam_snippets_spec.rb b/spec/features/snippets/spam_snippets_spec.rb index e9534dedcd3..69e3f190725 100644 --- a/spec/features/snippets/spam_snippets_spec.rb +++ b/spec/features/snippets/spam_snippets_spec.rb @@ -10,6 +10,7 @@ shared_examples_for 'snippet editor' do before do stub_feature_flags(allow_possible_spam: false) stub_feature_flags(snippets_vue: false) + stub_feature_flags(snippets_edit_vue: false) stub_feature_flags(monaco_snippets: flag) stub_env('IN_MEMORY_APPLICATION_SETTINGS', 'false') diff --git a/spec/features/snippets/user_creates_snippet_spec.rb b/spec/features/snippets/user_creates_snippet_spec.rb index 93da976dee0..5d3a84dd7bc 100644 --- a/spec/features/snippets/user_creates_snippet_spec.rb +++ b/spec/features/snippets/user_creates_snippet_spec.rb @@ -5,6 +5,7 @@ require 'spec_helper' shared_examples_for 'snippet editor' do before do stub_feature_flags(snippets_vue: false) + stub_feature_flags(snippets_edit_vue: false) stub_feature_flags(monaco_snippets: flag) sign_in(user) visit new_snippet_path diff --git a/spec/features/snippets/user_edits_snippet_spec.rb b/spec/features/snippets/user_edits_snippet_spec.rb index 0bbb92b1f3f..b4f8fbfa47e 100644 --- a/spec/features/snippets/user_edits_snippet_spec.rb +++ b/spec/features/snippets/user_edits_snippet_spec.rb @@ -14,6 +14,7 @@ describe 'User edits snippet', :js do before do stub_feature_flags(snippets_vue: false) + stub_feature_flags(snippets_edit_vue: false) stub_feature_flags(version_snippets: version_snippet_enabled) sign_in(user) diff --git a/spec/features/static_site_editor_spec.rb b/spec/features/static_site_editor_spec.rb new file mode 100644 index 00000000000..c457002f888 --- /dev/null +++ b/spec/features/static_site_editor_spec.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe 'Static Site Editor' do + let(:user) { create(:user) } + let(:project) { create(:project, :public, :repository) } + + before do + project.add_maintainer(user) + sign_in(user) + + visit project_show_sse_path(project, 'master/README.md') + end + + it 'renders Static Site Editor page' do + expect(page).to have_selector('#static-site-editor') + end +end |