diff options
Diffstat (limited to 'spec/features/projects')
34 files changed, 2421 insertions, 586 deletions
diff --git a/spec/features/projects/active_tabs_spec.rb b/spec/features/projects/active_tabs_spec.rb index 2601dcf55c9..ff97d3c9503 100644 --- a/spec/features/projects/active_tabs_spec.rb +++ b/spec/features/projects/active_tabs_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' RSpec.describe 'Project active tab' do - let_it_be(:project) { create(:project, :repository) } + let_it_be(:project) { create(:project, :repository, :with_namespace_settings) } let(:user) { project.first_owner } diff --git a/spec/features/projects/blobs/blame_spec.rb b/spec/features/projects/blobs/blame_spec.rb new file mode 100644 index 00000000000..bb3b5cd931c --- /dev/null +++ b/spec/features/projects/blobs/blame_spec.rb @@ -0,0 +1,67 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe 'File blame', :js do + include TreeHelper + + let_it_be(:project) { create(:project, :public, :repository) } + + let(:path) { 'CHANGELOG' } + + def visit_blob_blame(path) + visit project_blame_path(project, tree_join('master', path)) + wait_for_all_requests + end + + it 'displays the blame page without pagination' do + visit_blob_blame(path) + + expect(page).to have_css('.blame-commit') + expect(page).not_to have_css('.gl-pagination') + end + + context 'when blob length is over the blame range limit' do + before do + stub_const('Projects::BlameService::PER_PAGE', 2) + end + + it 'displays two first lines of the file with pagination' do + visit_blob_blame(path) + + expect(page).to have_css('.blame-commit') + expect(page).to have_css('.gl-pagination') + + expect(page).to have_css('#L1') + expect(page).not_to have_css('#L3') + expect(find('.page-link.active')).to have_text('1') + end + + context 'when user clicks on the next button' do + before do + visit_blob_blame(path) + + find('.js-next-button').click + end + + it 'displays next two lines of the file with pagination' do + expect(page).not_to have_css('#L1') + expect(page).to have_css('#L3') + expect(find('.page-link.active')).to have_text('2') + end + end + + context 'when feature flag disabled' do + before do + stub_feature_flags(blame_page_pagination: false) + end + + it 'displays the blame page without pagination' do + visit_blob_blame(path) + + expect(page).to have_css('.blame-commit') + expect(page).not_to have_css('.gl-pagination') + end + end + end +end diff --git a/spec/features/projects/ci/editor_spec.rb b/spec/features/projects/ci/editor_spec.rb index ad4381a526a..2f960c09936 100644 --- a/spec/features/projects/ci/editor_spec.rb +++ b/spec/features/projects/ci/editor_spec.rb @@ -12,6 +12,8 @@ RSpec.describe 'Pipeline Editor', :js do let(:other_branch) { 'test' } before do + stub_feature_flags(pipeline_editor_file_tree: false) + sign_in(user) project.add_developer(user) @@ -22,11 +24,7 @@ RSpec.describe 'Pipeline Editor', :js do wait_for_requests end - it 'user sees the Pipeline Editor page' do - expect(page).to have_content('Pipeline Editor') - end - - describe 'Branch switcher' do + shared_examples 'default branch switcher behavior' do def switch_to_branch(branch) find('[data-testid="branch-selector"]').click @@ -53,7 +51,7 @@ RSpec.describe 'Pipeline Editor', :js do end it 'displays new branch as selected after commiting on a new branch' do - find('#target-branch-field').set('new_branch', clear: :backspace) + find('#source-branch-field').set('new_branch', clear: :backspace) page.within('#source-editor-') do find('textarea').send_keys '123' @@ -68,6 +66,28 @@ RSpec.describe 'Pipeline Editor', :js do end end + it 'user sees the Pipeline Editor page' do + expect(page).to have_content('Pipeline Editor') + end + + describe 'Branch Switcher (pipeline_editor_file_tree disabled)' do + it_behaves_like 'default branch switcher behavior' + end + + describe 'Branch Switcher (pipeline_editor_file_tree enabled)' do + before do + stub_feature_flags(pipeline_editor_file_tree: true) + + visit project_ci_pipeline_editor_path(project) + wait_for_requests + + # close button for the popover + find('[data-testid="close-button"]').click + end + + it_behaves_like 'default branch switcher behavior' + end + describe 'Editor navigation' do context 'when no change is made' do it 'user can navigate away without a browser alert' do @@ -112,7 +132,7 @@ RSpec.describe 'Pipeline Editor', :js do it 'user who creates a MR is taken to the merge request page without warnings' do expect(page).not_to have_content('New merge request') - find_field('Target Branch').set 'new_branch' + find_field('Branch').set 'new_branch' find_field('Start a new merge request with these changes').click click_button 'Commit changes' diff --git a/spec/features/projects/ci/secure_files_spec.rb b/spec/features/projects/ci/secure_files_spec.rb index 65c41eaf2ac..a0e9d663d35 100644 --- a/spec/features/projects/ci/secure_files_spec.rb +++ b/spec/features/projects/ci/secure_files_spec.rb @@ -7,13 +7,55 @@ RSpec.describe 'Secure Files', :js do let(:user) { create(:user) } before do + stub_feature_flags(ci_secure_files_read_only: false) project.add_maintainer(user) sign_in(user) + end + it 'user sees the Secure Files list component' do visit project_ci_secure_files_path(project) + expect(page).to have_content('There are no records to show') end - it 'user sees the Secure Files list component' do + it 'prompts the user to confirm before deleting a file' do + file = create(:ci_secure_file, project: project) + + visit project_ci_secure_files_path(project) + + expect(page).to have_content(file.name) + + find('button.btn-danger').click + + expect(page).to have_content("Delete #{file.name}?") + + click_on('Delete secure file') + + visit project_ci_secure_files_path(project) + + expect(page).not_to have_content(file.name) + end + + it 'displays an uploaded file in the file list' do + visit project_ci_secure_files_path(project) expect(page).to have_content('There are no records to show') + + page.attach_file('spec/fixtures/ci_secure_files/upload-keystore.jks') do + click_button 'Upload File' + end + + expect(page).to have_content('upload-keystore.jks') + end + + it 'displays an error when a duplicate file upload is attempted' do + create(:ci_secure_file, project: project, name: 'upload-keystore.jks') + visit project_ci_secure_files_path(project) + + expect(page).to have_content('upload-keystore.jks') + + page.attach_file('spec/fixtures/ci_secure_files/upload-keystore.jks') do + click_button 'Upload File' + end + + expect(page).to have_content('A file with this name already exists.') end end diff --git a/spec/features/projects/clusters/eks_spec.rb b/spec/features/projects/clusters/eks_spec.rb deleted file mode 100644 index 7e599ff1198..00000000000 --- a/spec/features/projects/clusters/eks_spec.rb +++ /dev/null @@ -1,36 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -RSpec.describe 'AWS EKS Cluster', :js do - let(:project) { create(:project) } - let(:user) { create(:user) } - - before do - project.add_maintainer(user) - gitlab_sign_in(user) - allow(Projects::ClustersController).to receive(:STATUS_POLLING_INTERVAL) { 100 } - stub_application_setting(eks_integration_enabled: true) - end - - context 'when user does not have a cluster and visits cluster index page' do - let(:project_id) { 'test-project-1234' } - - before do - visit project_clusters_path(project) - - click_button(class: 'dropdown-toggle-split') - click_link 'Create a cluster (certificate - deprecated)' - end - - context 'when user creates a cluster on AWS EKS' do - before do - click_link 'Amazon EKS' - end - - it 'highlights Amazon EKS logo' do - expect(page).to have_css('.js-create-aws-cluster-button.active') - end - end - end -end diff --git a/spec/features/projects/clusters/gcp_spec.rb b/spec/features/projects/clusters/gcp_spec.rb index 491121a3743..a8a23ba1c85 100644 --- a/spec/features/projects/clusters/gcp_spec.rb +++ b/spec/features/projects/clusters/gcp_spec.rb @@ -14,11 +14,6 @@ RSpec.describe 'Gcp Cluster', :js do allow(Projects::ClustersController).to receive(:STATUS_POLLING_INTERVAL) { 100 } end - def submit_form - execute_script('document.querySelector(".js-gke-cluster-creation-submit").removeAttribute("disabled")') - execute_script('document.querySelector(".js-gke-cluster-creation-submit").click()') - end - context 'when user has signed with Google' do let(:project_id) { 'test-project-1234' } @@ -29,82 +24,7 @@ RSpec.describe 'Gcp Cluster', :js do .to receive(:expires_at_in_session).and_return(1.hour.since.to_i.to_s) end - context 'when user does not have a cluster and visits cluster index page' do - before do - visit project_clusters_path(project) - - visit_create_cluster_page - click_link 'Google GKE' - end - - it 'highlights Google GKE logo' do - expect(page).to have_css('.js-create-gcp-cluster-button.active') - end - - context 'when user filled form with valid parameters' do - subject { submit_form } - - before do - allow_any_instance_of(GoogleApi::CloudPlatform::Client) - .to receive(:projects_zones_clusters_create) do - double( - 'cluster', - self_link: 'projects/gcp-project-12345/zones/us-central1-a/operations/ope-123', - status: 'RUNNING' - ) - end - - allow(WaitForClusterCreationWorker).to receive(:perform_in).and_return(nil) - - expect(page).to have_css('.js-gcp-project-id-dropdown') - - execute_script('document.querySelector(".js-gcp-project-id-dropdown input").setAttribute("type", "text")') - execute_script('document.querySelector(".js-gcp-zone-dropdown input").setAttribute("type", "text")') - execute_script('document.querySelector(".js-gcp-machine-type-dropdown input").setAttribute("type", "text")') - - fill_in 'cluster[name]', with: 'dev-cluster' - fill_in 'cluster[provider_gcp_attributes][gcp_project_id]', with: 'gcp-project-123' - fill_in 'cluster[provider_gcp_attributes][zone]', with: 'us-central1-a' - fill_in 'cluster[provider_gcp_attributes][machine_type]', with: 'n1-standard-2' - end - - it 'users sees a form with the GCP token' do - expect(page).to have_selector(:css, 'form[data-token="token"]') - end - - it 'user sees a cluster details page and creation status' do - subject - - expect(page).to have_content('Kubernetes cluster is being created...') - - Clusters::Cluster.last.provider.make_created! - - expect(page).to have_content('Kubernetes cluster was successfully created') - end - - it 'user sees a error if something wrong during creation' do - subject - - expect(page).to have_content('Kubernetes cluster is being created...') - - Clusters::Cluster.last.provider.make_errored!('Something wrong!') - - expect(page).to have_content('Something wrong!') - end - end - - context 'when user filled form with invalid parameters' do - before do - submit_form - end - - it 'user sees a validation error' do - expect(page).to have_css('.gl-field-error') - end - end - end - - context 'when user does have a cluster and visits cluster page' do + context 'when user have a cluster and visits cluster page' do let(:cluster) { create(:cluster, :provided_by_gcp, projects: [project]) } before do @@ -167,12 +87,6 @@ RSpec.describe 'Gcp Cluster', :js do it 'user sees offer on cluster index page' do expect(page).to have_css('.gcp-signup-offer') end - - it 'user sees offer on cluster create page' do - visit_create_cluster_page - - expect(page).to have_css('.gcp-signup-offer') - end end context 'when user has dismissed GCP signup offer' do @@ -187,8 +101,6 @@ RSpec.describe 'Gcp Cluster', :js do find('.gcp-signup-offer .js-close').click wait_for_requests - visit_create_cluster_page - expect(page).not_to have_css('.gcp-signup-offer') end end @@ -216,9 +128,4 @@ RSpec.describe 'Gcp Cluster', :js do expect(page).not_to have_css('.gcp-signup-offer') end end - - def visit_create_cluster_page - click_button(class: 'dropdown-toggle-split') - click_link 'Create a cluster (certificate - deprecated)' - end end diff --git a/spec/features/projects/clusters_spec.rb b/spec/features/projects/clusters_spec.rb index 0ecd7795964..9e1d66bc73e 100644 --- a/spec/features/projects/clusters_spec.rb +++ b/spec/features/projects/clusters_spec.rb @@ -81,101 +81,6 @@ RSpec.describe 'Clusters', :js do end end end - - context 'when user adds a Google Kubernetes Engine cluster' do - before do - allow_any_instance_of(Projects::ClustersController) - .to receive(:token_in_session).and_return('token') - allow_any_instance_of(Projects::ClustersController) - .to receive(:expires_at_in_session).and_return(1.hour.since.to_i.to_s) - - allow_any_instance_of(Projects::ClustersController).to receive(:authorize_google_project_billing) - allow_any_instance_of(Projects::ClustersController).to receive(:google_project_billing_status).and_return(true) - - allow_any_instance_of(GoogleApi::CloudPlatform::Client) - .to receive(:projects_zones_clusters_create) do - double( - 'cluster_control', - self_link: 'projects/gcp-project-12345/zones/us-central1-a/operations/ope-123', - status: 'RUNNING' - ) - end - - allow(WaitForClusterCreationWorker).to receive(:perform_in).and_return(nil) - - create(:cluster, :provided_by_gcp, name: 'default-cluster', environment_scope: '*', projects: [project]) - visit project_clusters_path(project) - click_link 'Certificate' - end - - context 'when user filled form with environment scope' do - before do - visit_create_cluster_page - click_link 'Google GKE' - - sleep 2 # wait for ajax - execute_script('document.querySelector(".js-gcp-project-id-dropdown input").setAttribute("type", "text")') - execute_script('document.querySelector(".js-gcp-zone-dropdown input").setAttribute("type", "text")') - execute_script('document.querySelector(".js-gcp-machine-type-dropdown input").setAttribute("type", "text")') - execute_script('document.querySelector(".js-gke-cluster-creation-submit").removeAttribute("disabled")') - - fill_in 'cluster_name', with: 'staging-cluster' - fill_in 'cluster_environment_scope', with: 'staging/*' - fill_in 'cluster[provider_gcp_attributes][gcp_project_id]', with: 'gcp-project-123' - fill_in 'cluster[provider_gcp_attributes][zone]', with: 'us-central1-a' - fill_in 'cluster[provider_gcp_attributes][machine_type]', with: 'n1-standard-2' - click_button 'Create Kubernetes cluster' - - # The frontend won't show the details until the cluster is - # created, and we don't want to make calls out to GCP. - provider = Clusters::Cluster.last.provider - provider.make_created - end - - it 'user sees a cluster details page' do - expect(page).to have_content('GitLab Integration') - expect(page.find_field('cluster[environment_scope]').value).to eq('staging/*') - end - end - - context 'when user updates environment scope' do - before do - click_link 'default-cluster' - fill_in 'cluster_environment_scope', with: 'production/*' - within ".js-cluster-details-form" do - click_button 'Save changes' - end - end - - it 'updates the environment scope' do - expect(page.find_field('cluster[environment_scope]').value).to eq('production/*') - end - end - - context 'when user updates duplicated environment scope' do - before do - visit_create_cluster_page - click_link 'Google GKE' - - sleep 2 # wait for ajax - execute_script('document.querySelector(".js-gcp-project-id-dropdown input").setAttribute("type", "text")') - execute_script('document.querySelector(".js-gcp-zone-dropdown input").setAttribute("type", "text")') - execute_script('document.querySelector(".js-gcp-machine-type-dropdown input").setAttribute("type", "text")') - execute_script('document.querySelector(".js-gke-cluster-creation-submit").removeAttribute("disabled")') - - fill_in 'cluster_name', with: 'staging-cluster' - fill_in 'cluster_environment_scope', with: '*' - fill_in 'cluster[provider_gcp_attributes][gcp_project_id]', with: 'gcp-project-123' - fill_in 'cluster[provider_gcp_attributes][zone]', with: 'us-central1-a' - fill_in 'cluster[provider_gcp_attributes][machine_type]', with: 'n1-standard-2' - click_button 'Create Kubernetes cluster' - end - - it 'users sees an environment scope validation error' do - expect(page).to have_content('cannot add duplicated environment scope') - end - end - end end context 'when user has a cluster and visits cluster index page' do @@ -221,7 +126,7 @@ RSpec.describe 'Clusters', :js do visit project_clusters_path(project) click_button(class: 'dropdown-toggle-split') - click_link 'Create a cluster (certificate - deprecated)' + click_link 'Create a cluster' end def visit_connect_cluster_page diff --git a/spec/features/projects/commit/mini_pipeline_graph_spec.rb b/spec/features/projects/commit/mini_pipeline_graph_spec.rb index 57b35d81bb8..e472cff38ce 100644 --- a/spec/features/projects/commit/mini_pipeline_graph_spec.rb +++ b/spec/features/projects/commit/mini_pipeline_graph_spec.rb @@ -29,7 +29,7 @@ RSpec.describe 'Mini Pipeline Graph in Commit View', :js do it 'displays a mini pipeline graph' do expect(page).to have_selector('[data-testid="commit-box-mini-graph"]') - first('.mini-pipeline-graph-dropdown-toggle').click + first('[data-testid="mini-pipeline-graph-dropdown"]').click wait_for_requests diff --git a/spec/features/projects/graph_spec.rb b/spec/features/projects/graph_spec.rb index 7e039a087c7..0b628ad1e9a 100644 --- a/spec/features/projects/graph_spec.rb +++ b/spec/features/projects/graph_spec.rb @@ -63,6 +63,23 @@ RSpec.describe 'Project Graph', :js do end end + context 'charts graph ref switcher' do + it 'switches ref to branch' do + ref_name = 'feature' + visit charts_project_graph_path(project, 'master') + first('.js-project-refs-dropdown').click + + page.within '.project-refs-form' do + click_link ref_name + end + + expect(page).to have_selector '.dropdown-menu-toggle', text: ref_name + page.within '.tree-ref-header' do + expect(page).to have_content ref_name + end + end + end + context 'when CI enabled' do before do project.enable_ci diff --git a/spec/features/projects/integrations/prometheus_external_alerts_spec.rb b/spec/features/projects/integrations/prometheus_external_alerts_spec.rb deleted file mode 100644 index 7e56ca13e23..00000000000 --- a/spec/features/projects/integrations/prometheus_external_alerts_spec.rb +++ /dev/null @@ -1,34 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -RSpec.describe 'Prometheus external alerts', :js do - include_context 'project integration activation' - - let(:alerts_section_selector) { '.js-prometheus-alerts' } - let(:alerts_section) { page.find(alerts_section_selector) } - - context 'with manual configuration' do - before do - create(:prometheus_integration, project: project, api_url: 'http://prometheus.example.com', manual_configuration: '1', active: true) - end - - it 'shows the Alerts section' do - visit_project_integration('Prometheus') - - expect(alerts_section).to have_content('Alerts') - expect(alerts_section).to have_content('Receive alerts from manually configured Prometheus servers.') - expect(alerts_section).to have_content('URL') - expect(alerts_section).to have_content('Authorization key') - end - end - - context 'with no configuration' do - it 'does not show the Alerts section' do - visit_project_integration('Prometheus') - wait_for_requests - - expect(page).not_to have_css(alerts_section_selector) - end - end -end diff --git a/spec/features/projects/integrations/user_activates_prometheus_spec.rb b/spec/features/projects/integrations/user_activates_prometheus_spec.rb index 80629af6fce..56b895919b8 100644 --- a/spec/features/projects/integrations/user_activates_prometheus_spec.rb +++ b/spec/features/projects/integrations/user_activates_prometheus_spec.rb @@ -9,14 +9,13 @@ RSpec.describe 'User activates Prometheus' do stub_request(:get, /.*prometheus.example.com.*/) end - it 'does not activate integration and informs about deprecation', :js do + it 'saves and activates integration', :js do visit_project_integration('Prometheus') check('Active') fill_in('API URL', with: 'http://prometheus.example.com') click_button('Save changes') - expect(page).not_to have_content('Prometheus settings saved and active.') - expect(page).to have_content('Fields on this page have been deprecated.') + expect(page).to have_content('Prometheus settings saved and active.') end end diff --git a/spec/features/projects/issues/design_management/user_uploads_designs_spec.rb b/spec/features/projects/issues/design_management/user_uploads_designs_spec.rb index 48ae70d3ec9..27d0be23aec 100644 --- a/spec/features/projects/issues/design_management/user_uploads_designs_spec.rb +++ b/spec/features/projects/issues/design_management/user_uploads_designs_spec.rb @@ -10,9 +10,6 @@ RSpec.describe 'User uploads new design', :js do let(:issue) { create(:issue, project: project) } before do - # Cause of raising query limiting threshold https://gitlab.com/gitlab-org/gitlab/-/issues/358845 - stub_const("Gitlab::QueryLimiting::Transaction::THRESHOLD", 106) - sign_in(user) enable_design_management(feature_enabled) visit project_issue_path(project, issue) diff --git a/spec/features/projects/jobs/user_browses_jobs_spec.rb b/spec/features/projects/jobs/user_browses_jobs_spec.rb index 3b70d177fce..07b7a54974a 100644 --- a/spec/features/projects/jobs/user_browses_jobs_spec.rb +++ b/spec/features/projects/jobs/user_browses_jobs_spec.rb @@ -19,7 +19,7 @@ RSpec.describe 'User browses jobs' do stub_feature_flags(jobs_table_vue: false) project.add_maintainer(user) project.enable_ci - project.update_attribute(:build_coverage_regex, /Coverage (\d+)%/) + build.update!(coverage_regex: '/Coverage (\d+)%/') sign_in(user) diff --git a/spec/features/projects/jobs_spec.rb b/spec/features/projects/jobs_spec.rb index b34a615e651..befaf85fc1e 100644 --- a/spec/features/projects/jobs_spec.rb +++ b/spec/features/projects/jobs_spec.rb @@ -484,7 +484,7 @@ RSpec.describe 'Jobs', :clean_gitlab_redis_shared_state do end context 'when job has an initial trace' do - it 'loads job trace' do + it 'loads job logs' do expect(page).to have_content 'BUILD TRACE' job.trace.write(+'a+b') do |stream| diff --git a/spec/features/projects/members/groups_with_access_list_spec.rb b/spec/features/projects/members/groups_with_access_list_spec.rb index 9bd6476f836..821b9249aa8 100644 --- a/spec/features/projects/members/groups_with_access_list_spec.rb +++ b/spec/features/projects/members/groups_with_access_list_spec.rb @@ -9,7 +9,7 @@ RSpec.describe 'Projects > Members > Groups with access list', :js do let_it_be(:user) { create(:user) } let_it_be(:group) { create(:group, :public) } - let_it_be(:project) { create(:project, :public) } + let_it_be(:project) { create(:project, :public, :with_namespace_settings) } let_it_be(:expiration_date) { 5.days.from_now.to_date } let(:additional_link_attrs) { {} } diff --git a/spec/features/projects/members/invite_group_spec.rb b/spec/features/projects/members/manage_groups_spec.rb index a48229249e0..006fa3b6eff 100644 --- a/spec/features/projects/members/invite_group_spec.rb +++ b/spec/features/projects/members/manage_groups_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe 'Project > Members > Invite group', :js do +RSpec.describe 'Project > Members > Manage groups', :js do include ActionView::Helpers::DateHelper include Spec::Support::Helpers::Features::MembersHelpers include Spec::Support::Helpers::Features::InviteMembersModalHelper @@ -126,7 +126,7 @@ RSpec.describe 'Project > Members > Invite group', :js do end describe 'setting an expiration date for a group link' do - let(:project) { create(:project) } + let(:project) { create(:project, :with_namespace_settings) } let!(:group) { create(:group) } let_it_be(:expiration_date) { 5.days.from_now.to_date } @@ -153,81 +153,18 @@ RSpec.describe 'Project > Members > Invite group', :js do end end - describe 'the groups dropdown' do + describe 'group search results' do let_it_be(:parent_group) { create(:group, :public) } let_it_be(:project_group) { create(:group, :public, parent: parent_group) } let_it_be(:project) { create(:project, group: project_group) } - context 'with instance admin considerations' do - let_it_be(:group_to_share) { create(:group) } - - context 'when user is an admin' do - let_it_be(:admin) { create(:admin) } - - before do - sign_in(admin) - gitlab_enable_admin_mode_sign_in(admin) - end - - it 'shows groups where the admin has no direct membership' do - visit project_project_members_path(project) - - click_on 'Invite a group' - click_on 'Select a group' - wait_for_requests - - page.within(group_dropdown_selector) do - expect_to_have_group(group_to_share) - end - end - - it 'shows groups where the admin has at least guest level membership' do - group_to_share.add_guest(admin) - - visit project_project_members_path(project) - - click_on 'Invite a group' - click_on 'Select a group' - wait_for_requests - - page.within(group_dropdown_selector) do - expect_to_have_group(group_to_share) - end - end - end - - context 'when user is not an admin' do - before do - project.add_maintainer(maintainer) - sign_in(maintainer) - end - - it 'does not show groups where the user has no direct membership' do - visit project_project_members_path(project) - - click_on 'Invite a group' - click_on 'Select a group' - wait_for_requests - - page.within(group_dropdown_selector) do - expect_not_to_have_group(group_to_share) - end - end - - it 'shows groups where the user has at least guest level membership' do - group_to_share.add_guest(maintainer) - - visit project_project_members_path(project) - - click_on 'Invite a group' - click_on 'Select a group' - wait_for_requests - - page.within(group_dropdown_selector) do - expect_to_have_group(group_to_share) - end - end - end + it_behaves_like 'inviting groups search results' do + let_it_be(:user) { maintainer } + let_it_be(:group) { parent_group } + let_it_be(:group_within_hierarchy) { create(:group, parent: group) } + let_it_be(:project_within_hierarchy) { create(:project, group: group_within_hierarchy)} + let_it_be(:members_page_path) { project_project_members_path(project) } + let_it_be(:members_page_path_within_hierarchy) { project_project_members_path(project_within_hierarchy) } end context 'for a project in a nested group' do diff --git a/spec/features/projects/members/master_adds_member_with_expiration_date_spec.rb b/spec/features/projects/members/master_adds_member_with_expiration_date_spec.rb index 830ada29a2e..bd0874316ac 100644 --- a/spec/features/projects/members/master_adds_member_with_expiration_date_spec.rb +++ b/spec/features/projects/members/master_adds_member_with_expiration_date_spec.rb @@ -8,7 +8,7 @@ RSpec.describe 'Projects > Members > Maintainer adds member with expiration date include Spec::Support::Helpers::Features::InviteMembersModalHelper let_it_be(:maintainer) { create(:user) } - let_it_be(:project) { create(:project) } + let_it_be(:project) { create(:project, :with_namespace_settings) } let_it_be(:three_days_from_now) { 3.days.from_now.to_date } let_it_be(:five_days_from_now) { 5.days.from_now.to_date } diff --git a/spec/features/projects/members/master_manages_access_requests_spec.rb b/spec/features/projects/members/master_manages_access_requests_spec.rb index 4c3eaa93352..f4e8c55e3cc 100644 --- a/spec/features/projects/members/master_manages_access_requests_spec.rb +++ b/spec/features/projects/members/master_manages_access_requests_spec.rb @@ -4,7 +4,7 @@ require 'spec_helper' RSpec.describe 'Projects > Members > Maintainer manages access requests' do it_behaves_like 'Maintainer manages access requests' do - let(:entity) { create(:project, :public) } + let(:entity) { create(:project, :public, :with_namespace_settings) } let(:members_page_path) { project_project_members_path(entity) } end end diff --git a/spec/features/projects/members/member_leaves_project_spec.rb b/spec/features/projects/members/member_leaves_project_spec.rb index 78a0a384d2c..67c40c1dbee 100644 --- a/spec/features/projects/members/member_leaves_project_spec.rb +++ b/spec/features/projects/members/member_leaves_project_spec.rb @@ -6,7 +6,7 @@ RSpec.describe 'Projects > Members > Member leaves project' do include Spec::Support::Helpers::Features::MembersHelpers let(:user) { create(:user) } - let(:project) { create(:project, :repository) } + let(:project) { create(:project, :repository, :with_namespace_settings) } before do project.add_developer(user) diff --git a/spec/features/projects/navbar_spec.rb b/spec/features/projects/navbar_spec.rb index 5098908857a..023601b0b1e 100644 --- a/spec/features/projects/navbar_spec.rb +++ b/spec/features/projects/navbar_spec.rb @@ -17,7 +17,7 @@ RSpec.describe 'Project navbar' do stub_config(registry: { enabled: false }) stub_feature_flags(harbor_registry_integration: false) - insert_package_nav(_('Infrastructure')) + insert_package_nav(_('Deployments')) insert_infrastructure_registry_nav insert_infrastructure_google_cloud_nav end @@ -49,7 +49,7 @@ RSpec.describe 'Project navbar' do stub_config(pages: { enabled: true }) insert_after_sub_nav_item( - _('Monitor'), + _('CI/CD'), within: _('Settings'), new_sub_nav_item_name: _('Pages') ) @@ -67,7 +67,7 @@ RSpec.describe 'Project navbar' do insert_container_nav insert_after_sub_nav_item( - _('Monitor'), + _('CI/CD'), within: _('Settings'), new_sub_nav_item_name: _('Packages & Registries') ) diff --git a/spec/features/projects/packages_spec.rb b/spec/features/projects/packages_spec.rb index 8180f6b9aff..f518cc1fc63 100644 --- a/spec/features/projects/packages_spec.rb +++ b/spec/features/projects/packages_spec.rb @@ -47,7 +47,8 @@ RSpec.describe 'Packages' do let_it_be(:package) { create(:package, project: project) } it 'allows you to delete a package' do - first('[title="Remove package"]').click + find('[data-testid="delete-dropdown"]').click + find('[data-testid="action-delete"]').click click_button('Delete package') expect(page).to have_content 'Package deleted successfully' diff --git a/spec/features/projects/pipelines/legacy_pipeline_spec.rb b/spec/features/projects/pipelines/legacy_pipeline_spec.rb new file mode 100644 index 00000000000..a29cef393a8 --- /dev/null +++ b/spec/features/projects/pipelines/legacy_pipeline_spec.rb @@ -0,0 +1,1073 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe 'Pipeline', :js do + include RoutesHelpers + include ProjectForksHelper + include ::ExclusiveLeaseHelpers + + let_it_be(:project) { create(:project) } + + let(:user) { create(:user) } + let(:role) { :developer } + + before do + sign_in(user) + project.add_role(user, role) + stub_feature_flags(pipeline_tabs_vue: false) + end + + shared_context 'pipeline builds' do + let!(:build_passed) do + create(:ci_build, :success, + pipeline: pipeline, stage: 'build', stage_idx: 0, name: 'build') + end + + let!(:build_failed) do + create(:ci_build, :failed, + pipeline: pipeline, stage: 'test', stage_idx: 1, name: 'test') + end + + let!(:build_preparing) do + create(:ci_build, :preparing, + pipeline: pipeline, stage: 'deploy', stage_idx: 2, name: 'prepare') + end + + let!(:build_running) do + create(:ci_build, :running, + pipeline: pipeline, stage: 'deploy', stage_idx: 3, name: 'deploy') + end + + let!(:build_manual) do + create(:ci_build, :manual, + pipeline: pipeline, stage: 'deploy', stage_idx: 3, name: 'manual-build') + end + + let!(:build_scheduled) do + create(:ci_build, :scheduled, + pipeline: pipeline, stage: 'deploy', stage_idx: 3, name: 'delayed-job') + end + + let!(:build_external) do + create(:generic_commit_status, status: 'success', + pipeline: pipeline, + name: 'jenkins', + stage: 'external', + ref: 'master', + target_url: 'http://gitlab.com/status') + end + end + + describe 'GET /:project/-/pipelines/:id' do + include_context 'pipeline builds' + + let_it_be(:group) { create(:group) } + let_it_be(:project, reload: true) { create(:project, :repository, group: group) } + + let(:pipeline) { create(:ci_pipeline, project: project, ref: 'master', sha: project.commit.id, user: user) } + + subject(:visit_pipeline) { visit project_pipeline_path(project, pipeline) } + + it 'shows the pipeline graph' do + visit_pipeline + + expect(page).to have_selector('.js-pipeline-graph') + expect(page).to have_content('Build') + expect(page).to have_content('Test') + expect(page).to have_content('Deploy') + expect(page).to have_content('Retry') + expect(page).to have_content('Cancel running') + end + + it 'shows Pipeline tab pane as active' do + visit_pipeline + + expect(page).to have_css('#js-tab-pipeline.active') + end + + it 'shows link to the pipeline ref' do + visit_pipeline + + expect(page).to have_link(pipeline.ref) + end + + it 'shows the pipeline information' do + visit_pipeline + + within '.pipeline-info' do + expect(page).to have_content("#{pipeline.statuses.count} jobs " \ + "for #{pipeline.ref}") + expect(page).to have_link(pipeline.ref, + href: project_commits_path(pipeline.project, pipeline.ref)) + end + end + + describe 'related merge requests' do + context 'when there are no related merge requests' do + it 'shows a "no related merge requests" message' do + visit_pipeline + + within '.related-merge-request-info' do + expect(page).to have_content('No related merge requests found.') + end + end + end + + context 'when there is one related merge request' do + let!(:merge_request) do + create(:merge_request, + source_project: project, + source_branch: pipeline.ref) + end + + it 'shows a link to the merge request' do + visit_pipeline + + within '.related-merge-requests' do + expect(page).to have_content('1 related merge request: ') + expect(page).to have_selector('.js-truncated-mr-list') + expect(page).to have_link("#{merge_request.to_reference} #{merge_request.title}") + + expect(page).not_to have_selector('.js-full-mr-list') + expect(page).not_to have_selector('.text-expander') + end + end + end + + context 'when there are two related merge requests' do + let!(:merge_request1) do + create(:merge_request, + source_project: project, + source_branch: pipeline.ref) + end + + let!(:merge_request2) do + create(:merge_request, + source_project: project, + source_branch: pipeline.ref, + target_branch: 'fix') + end + + it 'links to the most recent related merge request' do + visit_pipeline + + within '.related-merge-requests' do + expect(page).to have_content('2 related merge requests: ') + expect(page).to have_link("#{merge_request2.to_reference} #{merge_request2.title}") + expect(page).to have_selector('.text-expander') + expect(page).to have_selector('.js-full-mr-list', visible: false) + end + end + + it 'expands to show links to all related merge requests' do + visit_pipeline + + within '.related-merge-requests' do + find('.text-expander').click + + expect(page).to have_selector('.js-full-mr-list', visible: true) + + pipeline.all_merge_requests.map do |merge_request| + expect(page).to have_link(href: project_merge_request_path(project, merge_request)) + end + end + end + end + end + + describe 'pipelines details view' do + let!(:status) { create(:user_status, user: pipeline.user, emoji: 'smirk', message: 'Authoring this object') } + + it 'pipeline header shows the user status and emoji' do + visit project_pipeline_path(project, pipeline) + + within '[data-testid="ci-header-content"]' do + expect(page).to have_selector("[data-testid='#{status.message}']") + expect(page).to have_selector("[data-name='#{status.emoji}']") + end + end + end + + describe 'pipeline graph' do + before do + visit_pipeline + end + + context 'when pipeline has running builds' do + it 'shows a running icon and a cancel action for the running build' do + page.within('#ci-badge-deploy') do + expect(page).to have_selector('.js-ci-status-icon-running') + expect(page).to have_selector('.js-icon-cancel') + expect(page).to have_content('deploy') + end + end + + it 'cancels the running build and shows retry button', :sidekiq_might_not_need_inline do + find('#ci-badge-deploy .ci-action-icon-container').click + + page.within('#ci-badge-deploy') do + expect(page).to have_css('.js-icon-retry') + end + end + end + + context 'when pipeline has preparing builds' do + it 'shows a preparing icon and a cancel action' do + page.within('#ci-badge-prepare') do + expect(page).to have_selector('.js-ci-status-icon-preparing') + expect(page).to have_selector('.js-icon-cancel') + expect(page).to have_content('prepare') + end + end + + it 'cancels the preparing build and shows retry button', :sidekiq_might_not_need_inline do + find('#ci-badge-deploy .ci-action-icon-container').click + + page.within('#ci-badge-deploy') do + expect(page).to have_css('.js-icon-retry') + end + end + end + + context 'when pipeline has successful builds' do + it 'shows the success icon and a retry action for the successful build' do + page.within('#ci-badge-build') do + expect(page).to have_selector('.js-ci-status-icon-success') + expect(page).to have_content('build') + end + + page.within('#ci-badge-build .ci-action-icon-container.js-icon-retry') do + expect(page).to have_selector('svg') + end + end + + it 'is possible to retry the success job', :sidekiq_might_not_need_inline do + find('#ci-badge-build .ci-action-icon-container').click + wait_for_requests + + expect(page).not_to have_content('Retry job') + within('.js-pipeline-header-container') do + expect(page).to have_selector('.js-ci-status-icon-running') + end + end + end + + context 'when pipeline has a delayed job' do + let(:project) { create(:project, :repository, group: group) } + + it 'shows the scheduled icon and an unschedule action for the delayed job' do + page.within('#ci-badge-delayed-job') do + expect(page).to have_selector('.js-ci-status-icon-scheduled') + expect(page).to have_content('delayed-job') + end + + page.within('#ci-badge-delayed-job .ci-action-icon-container.js-icon-time-out') do + expect(page).to have_selector('svg') + end + end + + it 'unschedules the delayed job and shows play button as a manual job', :sidekiq_might_not_need_inline do + find('#ci-badge-delayed-job .ci-action-icon-container').click + + page.within('#ci-badge-delayed-job') do + expect(page).to have_css('.js-icon-play') + end + end + end + + context 'when pipeline has failed builds' do + it 'shows the failed icon and a retry action for the failed build' do + page.within('#ci-badge-test') do + expect(page).to have_selector('.js-ci-status-icon-failed') + expect(page).to have_content('test') + end + + page.within('#ci-badge-test .ci-action-icon-container.js-icon-retry') do + expect(page).to have_selector('svg') + end + end + + it 'is possible to retry the failed build', :sidekiq_might_not_need_inline do + find('#ci-badge-test .ci-action-icon-container').click + wait_for_requests + + expect(page).not_to have_content('Retry job') + within('.js-pipeline-header-container') do + expect(page).to have_selector('.js-ci-status-icon-running') + end + end + + it 'includes the failure reason' do + page.within('#ci-badge-test') do + build_link = page.find('.js-pipeline-graph-job-link') + expect(build_link['title']).to eq('test - failed - (unknown failure)') + end + end + end + + context 'when pipeline has manual jobs' do + it 'shows the skipped icon and a play action for the manual build' do + page.within('#ci-badge-manual-build') do + expect(page).to have_selector('.js-ci-status-icon-manual') + expect(page).to have_content('manual') + end + + page.within('#ci-badge-manual-build .ci-action-icon-container.js-icon-play') do + expect(page).to have_selector('svg') + end + end + + it 'is possible to play the manual job', :sidekiq_might_not_need_inline do + find('#ci-badge-manual-build .ci-action-icon-container').click + wait_for_requests + + expect(page).not_to have_content('Play job') + within('.js-pipeline-header-container') do + expect(page).to have_selector('.js-ci-status-icon-running') + end + end + end + + context 'when pipeline has external job' do + it 'shows the success icon and the generic comit status build' do + expect(page).to have_selector('.js-ci-status-icon-success') + expect(page).to have_content('jenkins') + expect(page).to have_link('jenkins', href: 'http://gitlab.com/status') + end + end + end + + context 'when the pipeline has manual stage' do + before do + create(:ci_build, :manual, pipeline: pipeline, stage_idx: 10, stage: 'publish', name: 'CentOS') + create(:ci_build, :manual, pipeline: pipeline, stage_idx: 10, stage: 'publish', name: 'Debian') + create(:ci_build, :manual, pipeline: pipeline, stage_idx: 10, stage: 'publish', name: 'OpenSUDE') + + # force to update stages statuses + Ci::ProcessPipelineService.new(pipeline).execute + + visit_pipeline + end + + it 'displays play all button' do + expect(page).to have_selector('.js-stage-action') + end + end + + context 'page tabs' do + before do + visit_pipeline + end + + it 'shows Pipeline, Jobs, DAG and Failed Jobs tabs with link' do + expect(page).to have_link('Pipeline') + expect(page).to have_link('Jobs') + expect(page).to have_link('Needs') + expect(page).to have_link('Failed Jobs') + end + + it 'shows counter in Jobs tab' do + expect(page.find('.js-builds-counter').text).to eq(pipeline.total_size.to_s) + end + + it 'shows Pipeline tab as active' do + expect(page).to have_css('.js-pipeline-tab-link .active') + end + + context 'without permission to access builds' do + let(:project) { create(:project, :public, :repository, public_builds: false) } + let(:role) { :guest } + + it 'does not show the pipeline details page' do + expect(page).to have_content('Not Found') + end + end + end + + context 'retrying jobs' do + before do + visit_pipeline + end + + it { expect(page).not_to have_content('retried') } + + context 'when retrying' do + before do + find('[data-testid="retryPipeline"]').click + wait_for_requests + end + + it 'does not show a "Retry" button', :sidekiq_might_not_need_inline do + expect(page).not_to have_content('Retry') + end + + it 'shows running status in pipeline header', :sidekiq_might_not_need_inline do + within('.js-pipeline-header-container') do + expect(page).to have_selector('.js-ci-status-icon-running') + end + end + end + end + + context 'canceling jobs' do + before do + visit_pipeline + end + + it { expect(page).not_to have_selector('.ci-canceled') } + + context 'when canceling' do + before do + click_on 'Cancel running' + end + + it 'does not show a "Cancel running" button', :sidekiq_might_not_need_inline do + expect(page).not_to have_content('Cancel running') + end + end + end + + context 'when user can not delete' do + before do + visit_pipeline + end + + it { expect(page).not_to have_button('Delete') } + end + + context 'when deleting' do + before do + group.add_owner(user) + + visit_pipeline + + click_button 'Delete' + click_button 'Delete pipeline' + end + + it 'redirects to pipeline overview page', :sidekiq_inline do + expect(page).to have_content('The pipeline has been deleted') + expect(page).to have_current_path(project_pipelines_path(project), ignore_query: true) + end + end + + context 'when pipeline ref does not exist in repository anymore' do + let(:pipeline) do + create(:ci_empty_pipeline, project: project, + ref: 'non-existent', + sha: project.commit.id, + user: user) + end + + before do + visit_pipeline + end + + it 'does not render link to the pipeline ref' do + expect(page).not_to have_link(pipeline.ref) + expect(page).to have_content(pipeline.ref) + end + + it 'does not render render raw HTML to the pipeline ref' do + page.within '.pipeline-info' do + expect(page).not_to have_content('<span class="ref-name"') + end + end + end + + context 'when pipeline is detached merge request pipeline' do + let(:source_project) { project } + let(:target_project) { project } + + let(:merge_request) do + create(:merge_request, + :with_detached_merge_request_pipeline, + source_project: source_project, + target_project: target_project) + end + + let(:pipeline) do + merge_request.all_pipelines.last + end + + it 'shows the pipeline information' do + visit_pipeline + + within '.pipeline-info' do + expect(page).to have_content("#{pipeline.statuses.count} jobs " \ + "for !#{merge_request.iid} " \ + "with #{merge_request.source_branch}") + expect(page).to have_link("!#{merge_request.iid}", + href: project_merge_request_path(project, merge_request)) + expect(page).to have_link(merge_request.source_branch, + href: project_commits_path(merge_request.source_project, merge_request.source_branch)) + end + end + + context 'when source branch does not exist' do + before do + project.repository.rm_branch(user, merge_request.source_branch) + end + + it 'does not link to the source branch commit path' do + visit_pipeline + + within '.pipeline-info' do + expect(page).not_to have_link(merge_request.source_branch) + expect(page).to have_content(merge_request.source_branch) + end + end + end + + context 'when source project is a forked project' do + let(:source_project) { fork_project(project, user, repository: true) } + + before do + visit project_pipeline_path(source_project, pipeline) + end + + it 'shows the pipeline information', :sidekiq_might_not_need_inline do + within '.pipeline-info' do + expect(page).to have_content("#{pipeline.statuses.count} jobs " \ + "for !#{merge_request.iid} " \ + "with #{merge_request.source_branch}") + expect(page).to have_link("!#{merge_request.iid}", + href: project_merge_request_path(project, merge_request)) + expect(page).to have_link(merge_request.source_branch, + href: project_commits_path(merge_request.source_project, merge_request.source_branch)) + end + end + end + end + + context 'when pipeline is merge request pipeline' do + let(:project) { create(:project, :repository, group: group) } + let(:source_project) { project } + let(:target_project) { project } + + let(:merge_request) do + create(:merge_request, + :with_merge_request_pipeline, + source_project: source_project, + target_project: target_project, + merge_sha: project.commit.id) + end + + let(:pipeline) do + merge_request.all_pipelines.last + end + + before do + pipeline.update!(user: user) + end + + it 'shows the pipeline information' do + visit_pipeline + + within '.pipeline-info' do + expect(page).to have_content("#{pipeline.statuses.count} jobs " \ + "for !#{merge_request.iid} " \ + "with #{merge_request.source_branch} " \ + "into #{merge_request.target_branch}") + expect(page).to have_link("!#{merge_request.iid}", + href: project_merge_request_path(project, merge_request)) + expect(page).to have_link(merge_request.source_branch, + href: project_commits_path(merge_request.source_project, merge_request.source_branch)) + expect(page).to have_link(merge_request.target_branch, + href: project_commits_path(merge_request.target_project, merge_request.target_branch)) + end + end + + context 'when target branch does not exist' do + before do + project.repository.rm_branch(user, merge_request.target_branch) + end + + it 'does not link to the target branch commit path' do + visit_pipeline + + within '.pipeline-info' do + expect(page).not_to have_link(merge_request.target_branch) + expect(page).to have_content(merge_request.target_branch) + end + end + end + + context 'when source project is a forked project' do + let(:source_project) { fork_project(project, user, repository: true) } + + before do + visit project_pipeline_path(source_project, pipeline) + end + + it 'shows the pipeline information', :sidekiq_might_not_need_inline do + within '.pipeline-info' do + expect(page).to have_content("#{pipeline.statuses.count} jobs " \ + "for !#{merge_request.iid} " \ + "with #{merge_request.source_branch} " \ + "into #{merge_request.target_branch}") + expect(page).to have_link("!#{merge_request.iid}", + href: project_merge_request_path(project, merge_request)) + expect(page).to have_link(merge_request.source_branch, + href: project_commits_path(merge_request.source_project, merge_request.source_branch)) + expect(page).to have_link(merge_request.target_branch, + href: project_commits_path(merge_request.target_project, merge_request.target_branch)) + end + end + end + end + end + + context 'when user does not have access to read jobs' do + before do + project.update!(public_builds: false) + end + + describe 'GET /:project/-/pipelines/:id' do + include_context 'pipeline builds' + + let_it_be(:project) { create(:project, :repository) } + + let(:pipeline) { create(:ci_pipeline, project: project, ref: 'master', sha: project.commit.id, user: user) } + + before do + visit project_pipeline_path(project, pipeline) + end + + it 'shows the pipeline graph' do + expect(page).to have_selector('.js-pipeline-graph') + expect(page).to have_content('Build') + expect(page).to have_content('Test') + expect(page).to have_content('Deploy') + expect(page).to have_content('Retry') + expect(page).to have_content('Cancel running') + end + + it 'does not link to job' do + expect(page).not_to have_selector('.js-pipeline-graph-job-link') + end + end + end + + context 'when a bridge job exists' do + include_context 'pipeline builds' + + let(:project) { create(:project, :repository) } + let(:downstream) { create(:project, :repository) } + + let(:pipeline) do + create(:ci_pipeline, project: project, + ref: 'master', + sha: project.commit.id, + user: user) + end + + let!(:bridge) do + create(:ci_bridge, pipeline: pipeline, + name: 'cross-build', + user: user, + downstream: downstream) + end + + describe 'GET /:project/-/pipelines/:id' do + before do + visit project_pipeline_path(project, pipeline) + end + + it 'shows the pipeline with a bridge job' do + expect(page).to have_selector('.js-pipeline-graph') + expect(page).to have_content('cross-build') + end + + context 'when a scheduled pipeline is created by a blocked user' do + let(:project) { create(:project, :repository) } + + let(:schedule) do + create(:ci_pipeline_schedule, + project: project, + owner: project.first_owner, + description: 'blocked user schedule' + ).tap do |schedule| + schedule.update_column(:next_run_at, 1.minute.ago) + end + end + + before do + schedule.owner.block! + + begin + PipelineScheduleWorker.new.perform + rescue Ci::CreatePipelineService::CreateError + # Do nothing, assert view code after the Pipeline failed to create. + end + end + + it 'displays the PipelineSchedule in an inactive state' do + visit project_pipeline_schedules_path(project) + page.click_link('Inactive') + + expect(page).to have_selector('table.ci-table > tbody > tr > td', text: 'blocked user schedule') + end + + it 'does not create a new Pipeline' do + visit project_pipelines_path(project) + + expect(page).not_to have_selector('.ci-table') + expect(schedule.last_pipeline).to be_nil + end + end + end + + describe 'GET /:project/-/pipelines/:id/builds' do + before do + visit builds_project_pipeline_path(project, pipeline) + end + + it 'shows a bridge job on a list' do + expect(page).to have_content('cross-build') + expect(page).to have_content(bridge.id) + end + end + end + + context 'when build requires resource', :sidekiq_inline do + let_it_be(:project) { create(:project, :repository) } + + let(:pipeline) { create(:ci_pipeline, project: project) } + let(:resource_group) { create(:ci_resource_group, project: project) } + + let!(:test_job) do + create(:ci_build, :pending, stage: 'test', name: 'test', + stage_idx: 1, pipeline: pipeline, project: project) + end + + let!(:deploy_job) do + create(:ci_build, :created, stage: 'deploy', name: 'deploy', + stage_idx: 2, pipeline: pipeline, project: project, resource_group: resource_group) + end + + describe 'GET /:project/-/pipelines/:id' do + subject { visit project_pipeline_path(project, pipeline) } + + it 'shows deploy job as created' do + subject + + within('.js-pipeline-header-container') do + expect(page).to have_content('pending') + end + + within('.js-pipeline-graph') do + within(all('[data-testid="stage-column"]')[0]) do + expect(page).to have_content('test') + expect(page).to have_css('.ci-status-icon-pending') + end + + within(all('[data-testid="stage-column"]')[1]) do + expect(page).to have_content('deploy') + expect(page).to have_css('.ci-status-icon-created') + end + end + end + + context 'when test job succeeded' do + before do + test_job.success! + end + + it 'shows deploy job as pending' do + subject + + within('.js-pipeline-header-container') do + expect(page).to have_content('running') + end + + within('.js-pipeline-graph') do + within(all('[data-testid="stage-column"]')[0]) do + expect(page).to have_content('test') + expect(page).to have_css('.ci-status-icon-success') + end + + within(all('[data-testid="stage-column"]')[1]) do + expect(page).to have_content('deploy') + expect(page).to have_css('.ci-status-icon-pending') + end + end + end + end + + context 'when test job succeeded but there are no available resources' do + let(:another_job) { create(:ci_build, :running, project: project, resource_group: resource_group) } + + before do + resource_group.assign_resource_to(another_job) + test_job.success! + end + + it 'shows deploy job as waiting for resource' do + subject + + within('.js-pipeline-header-container') do + expect(page).to have_content('waiting') + end + + within('.js-pipeline-graph') do + within(all('[data-testid="stage-column"]')[1]) do + expect(page).to have_content('deploy') + expect(page).to have_css('.ci-status-icon-waiting-for-resource') + end + end + end + + context 'when resource is released from another job' do + before do + another_job.success! + end + + it 'shows deploy job as pending' do + subject + + within('.js-pipeline-header-container') do + expect(page).to have_content('running') + end + + within('.js-pipeline-graph') do + within(all('[data-testid="stage-column"]')[1]) do + expect(page).to have_content('deploy') + expect(page).to have_css('.ci-status-icon-pending') + end + end + end + end + + context 'when deploy job is a bridge to trigger a downstream pipeline' do + let!(:deploy_job) do + create(:ci_bridge, :created, stage: 'deploy', name: 'deploy', + stage_idx: 2, pipeline: pipeline, project: project, resource_group: resource_group) + end + + it 'shows deploy job as waiting for resource' do + subject + + within('.js-pipeline-header-container') do + expect(page).to have_content('waiting') + end + + within('.js-pipeline-graph') do + within(all('[data-testid="stage-column"]')[1]) do + expect(page).to have_content('deploy') + expect(page).to have_css('.ci-status-icon-waiting-for-resource') + end + end + end + end + + context 'when deploy job is a bridge to trigger a downstream pipeline' do + let!(:deploy_job) do + create(:ci_bridge, :created, stage: 'deploy', name: 'deploy', + stage_idx: 2, pipeline: pipeline, project: project, resource_group: resource_group) + end + + it 'shows deploy job as waiting for resource' do + subject + + within('.js-pipeline-header-container') do + expect(page).to have_content('waiting') + end + + within('.js-pipeline-graph') do + within(all('[data-testid="stage-column"]')[1]) do + expect(page).to have_content('deploy') + expect(page).to have_css('.ci-status-icon-waiting-for-resource') + end + end + end + end + end + end + end + + describe 'GET /:project/-/pipelines/:id/dag' do + include_context 'pipeline builds' + + let_it_be(:project) { create(:project, :repository) } + + let(:pipeline) { create(:ci_pipeline, project: project, ref: 'master', sha: project.commit.id) } + + before do + visit dag_project_pipeline_path(project, pipeline) + end + + it 'shows DAG tab pane as active' do + expect(page).to have_css('#js-tab-dag.active', visible: false) + end + + context 'page tabs' do + it 'shows Pipeline, Jobs and DAG tabs with link' do + expect(page).to have_link('Pipeline') + expect(page).to have_link('Jobs') + expect(page).to have_link('DAG') + end + + it 'shows counter in Jobs tab' do + expect(page.find('.js-builds-counter').text).to eq(pipeline.total_size.to_s) + end + + it 'shows DAG tab as active' do + expect(page).to have_css('li.js-dag-tab-link .active') + end + end + end + + context 'when user sees pipeline flags in a pipeline detail page' do + let_it_be(:project) { create(:project, :repository) } + + context 'when pipeline is latest' do + include_context 'pipeline builds' + + let(:pipeline) do + create(:ci_pipeline, + project: project, + ref: 'master', + sha: project.commit.id, + user: user) + end + + before do + visit project_pipeline_path(project, pipeline) + end + + it 'contains badge that indicates it is the latest build' do + page.within(all('.well-segment')[1]) do + expect(page).to have_content 'latest' + end + end + end + + context 'when pipeline has configuration errors' do + let(:pipeline) do + create(:ci_pipeline, + :invalid, + project: project, + ref: 'master', + sha: project.commit.id, + user: user) + end + + before do + visit project_pipeline_path(project, pipeline) + end + + it 'contains badge that indicates errors' do + page.within(all('.well-segment')[1]) do + expect(page).to have_content 'yaml invalid' + end + end + + it 'contains badge with tooltip which contains error' do + expect(pipeline).to have_yaml_errors + + page.within(all('.well-segment')[1]) do + expect(page).to have_selector( + %Q{span[title="#{pipeline.yaml_errors}"]}) + end + end + + it 'contains badge that indicates failure reason' do + expect(page).to have_content 'error' + end + + it 'contains badge with tooltip which contains failure reason' do + expect(pipeline.failure_reason?).to eq true + + page.within(all('.well-segment')[1]) do + expect(page).to have_selector( + %Q{span[title="#{pipeline.present.failure_reason}"]}) + end + end + + it 'contains a pipeline header with title' do + expect(page).to have_content "Pipeline ##{pipeline.id}" + end + end + + context 'when pipeline is stuck' do + include_context 'pipeline builds' + + let(:pipeline) do + create(:ci_pipeline, + project: project, + ref: 'master', + sha: project.commit.id, + user: user) + end + + before do + create(:ci_build, :pending, pipeline: pipeline) + visit project_pipeline_path(project, pipeline) + end + + it 'contains badge that indicates being stuck' do + page.within(all('.well-segment')[1]) do + expect(page).to have_content 'stuck' + end + end + end + + context 'when pipeline uses auto devops' do + include_context 'pipeline builds' + + let(:project) { create(:project, :repository, auto_devops_attributes: { enabled: true }) } + let(:pipeline) do + create(:ci_pipeline, + :auto_devops_source, + project: project, + ref: 'master', + sha: project.commit.id, + user: user) + end + + before do + visit project_pipeline_path(project, pipeline) + end + + it 'contains badge that indicates using auto devops' do + page.within(all('.well-segment')[1]) do + expect(page).to have_content 'Auto DevOps' + end + end + end + + context 'when pipeline runs in a merge request context' do + include_context 'pipeline builds' + + let(:pipeline) do + create(:ci_pipeline, + source: :merge_request_event, + project: merge_request.source_project, + ref: 'feature', + sha: merge_request.diff_head_sha, + user: user, + merge_request: merge_request) + end + + let(:merge_request) do + create(:merge_request, + source_project: project, + source_branch: 'feature', + target_project: project, + target_branch: 'master') + end + + before do + visit project_pipeline_path(project, pipeline) + end + + it 'contains badge that indicates detached merge request pipeline' do + page.within(all('.well-segment')[1]) do + expect(page).to have_content 'merge request' + end + end + end + end +end diff --git a/spec/features/projects/pipelines/legacy_pipelines_spec.rb b/spec/features/projects/pipelines/legacy_pipelines_spec.rb new file mode 100644 index 00000000000..3f89e344c51 --- /dev/null +++ b/spec/features/projects/pipelines/legacy_pipelines_spec.rb @@ -0,0 +1,847 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe 'Pipelines', :js do + include ProjectForksHelper + include Spec::Support::Helpers::ModalHelpers + + let(:project) { create(:project) } + let(:expected_detached_mr_tag) {'merge request'} + + context 'when user is logged in' do + let(:user) { create(:user) } + + before do + sign_in(user) + + project.add_developer(user) + project.update!(auto_devops_attributes: { enabled: false }) + + stub_feature_flags(pipeline_tabs_vue: false) + end + + describe 'GET /:project/-/pipelines' do + let(:project) { create(:project, :repository) } + + let!(:pipeline) do + create( + :ci_empty_pipeline, + project: project, + ref: 'master', + status: 'running', + sha: project.commit.id + ) + end + + context 'scope' do + before do + create(:ci_empty_pipeline, status: 'pending', project: project, sha: project.commit.id, ref: 'master') + create(:ci_empty_pipeline, status: 'running', project: project, sha: project.commit.id, ref: 'master') + create(:ci_empty_pipeline, status: 'created', project: project, sha: project.commit.id, ref: 'master') + create(:ci_empty_pipeline, status: 'success', project: project, sha: project.commit.id, ref: 'master') + end + + [:all, :running, :pending, :finished, :branches].each do |scope| + context "when displaying #{scope}" do + before do + visit_project_pipelines(scope: scope) + end + + it 'contains pipeline commit short SHA' do + expect(page).to have_content(pipeline.short_sha) + end + + it 'contains branch name' do + expect(page).to have_content(pipeline.ref) + end + end + end + end + + context 'header tabs' do + before do + visit project_pipelines_path(project) + wait_for_requests + end + + it 'shows a tab for All pipelines and count' do + expect(page.find('.js-pipelines-tab-all').text).to include('All') + expect(page.find('.js-pipelines-tab-all .badge').text).to include('1') + end + + it 'shows a tab for Finished pipelines and count' do + expect(page.find('.js-pipelines-tab-finished').text).to include('Finished') + end + + it 'shows a tab for Branches' do + expect(page.find('.js-pipelines-tab-branches').text).to include('Branches') + end + + it 'shows a tab for Tags' do + expect(page.find('.js-pipelines-tab-tags').text).to include('Tags') + end + + it 'updates content when tab is clicked' do + page.find('.js-pipelines-tab-finished').click + wait_for_requests + expect(page).to have_content('There are currently no finished pipelines.') + end + end + + context 'navigation links' do + before do + visit project_pipelines_path(project) + wait_for_requests + end + + it 'renders "CI lint" link' do + expect(page).to have_link('CI lint') + end + + it 'renders "Run pipeline" link' do + expect(page).to have_link('Run pipeline') + end + end + + context 'when pipeline is cancelable' do + let!(:build) do + create(:ci_build, pipeline: pipeline, + stage: 'test') + end + + before do + build.run + visit_project_pipelines + end + + it 'indicates that pipeline can be canceled' do + expect(page).to have_selector('.js-pipelines-cancel-button') + expect(page).to have_selector('.ci-running') + end + + context 'when canceling' do + before do + find('.js-pipelines-cancel-button').click + click_button 'Stop pipeline' + wait_for_requests + end + + it 'indicated that pipelines was canceled', :sidekiq_might_not_need_inline do + expect(page).not_to have_selector('.js-pipelines-cancel-button') + expect(page).to have_selector('.ci-canceled') + end + end + end + + context 'when pipeline is retryable', :sidekiq_might_not_need_inline do + let!(:build) do + create(:ci_build, pipeline: pipeline, + stage: 'test') + end + + before do + build.drop + visit_project_pipelines + end + + it 'indicates that pipeline can be retried' do + expect(page).to have_selector('.js-pipelines-retry-button') + expect(page).to have_selector('.ci-failed') + end + + context 'when retrying' do + before do + find('.js-pipelines-retry-button').click + wait_for_requests + end + + it 'shows running pipeline that is not retryable' do + expect(page).not_to have_selector('.js-pipelines-retry-button') + expect(page).to have_selector('.ci-running') + end + end + end + + context 'when pipeline is detached merge request pipeline' do + let(:merge_request) do + create(:merge_request, + :with_detached_merge_request_pipeline, + source_project: source_project, + target_project: target_project) + end + + let!(:pipeline) { merge_request.all_pipelines.first } + let(:source_project) { project } + let(:target_project) { project } + + before do + visit project_pipelines_path(source_project) + end + + shared_examples_for 'detached merge request pipeline' do + it 'shows pipeline information without pipeline ref', :sidekiq_might_not_need_inline do + within '.pipeline-tags' do + expect(page).to have_content(expected_detached_mr_tag) + + expect(page).to have_link(merge_request.iid, + href: project_merge_request_path(project, merge_request)) + + expect(page).not_to have_link(pipeline.ref) + end + end + end + + it_behaves_like 'detached merge request pipeline' + + context 'when source project is a forked project' do + let(:source_project) { fork_project(project, user, repository: true) } + + it_behaves_like 'detached merge request pipeline' + end + end + + context 'when pipeline is merge request pipeline' do + let(:merge_request) do + create(:merge_request, + :with_merge_request_pipeline, + source_project: source_project, + target_project: target_project, + merge_sha: target_project.commit.sha) + end + + let!(:pipeline) { merge_request.all_pipelines.first } + let(:source_project) { project } + let(:target_project) { project } + + before do + visit project_pipelines_path(source_project) + end + + shared_examples_for 'Correct merge request pipeline information' do + it 'does not show detached tag for the pipeline, and shows the link of the merge request' \ + 'and does not show the ref of the pipeline', :sidekiq_might_not_need_inline do + within '.pipeline-tags' do + expect(page).not_to have_content(expected_detached_mr_tag) + + expect(page).to have_link(merge_request.iid, + href: project_merge_request_path(project, merge_request)) + + expect(page).not_to have_link(pipeline.ref) + end + end + end + + it_behaves_like 'Correct merge request pipeline information' + + context 'when source project is a forked project' do + let(:source_project) { fork_project(project, user, repository: true) } + + it_behaves_like 'Correct merge request pipeline information' + end + end + + context 'when pipeline has configuration errors' do + let(:pipeline) do + create(:ci_pipeline, :invalid, project: project) + end + + before do + visit_project_pipelines + end + + it 'contains badge that indicates errors' do + expect(page).to have_content 'yaml invalid' + end + + it 'contains badge with tooltip which contains error' do + expect(pipeline).to have_yaml_errors + expect(page).to have_selector( + %Q{span[title="#{pipeline.yaml_errors}"]}) + end + + it 'contains badge that indicates failure reason' do + expect(page).to have_content 'error' + end + + it 'contains badge with tooltip which contains failure reason' do + expect(pipeline.failure_reason?).to eq true + expect(page).to have_selector( + %Q{span[title="#{pipeline.present.failure_reason}"]}) + end + end + + context 'with manual actions' do + let!(:manual) do + create(:ci_build, :manual, + pipeline: pipeline, + name: 'manual build', + stage: 'test') + end + + before do + visit_project_pipelines + end + + it 'has a dropdown with play button' do + expect(page).to have_selector('[data-testid="pipelines-manual-actions-dropdown"] [data-testid="play-icon"]') + end + + it 'has link to the manual action' do + find('[data-testid="pipelines-manual-actions-dropdown"]').click + + expect(page).to have_button('manual build') + end + + context 'when manual action was played' do + before do + find('[data-testid="pipelines-manual-actions-dropdown"]').click + click_button('manual build') + end + + it 'enqueues manual action job' do + expect(page).to have_selector( + '[data-testid="pipelines-manual-actions-dropdown"] .gl-dropdown-toggle:disabled' + ) + end + end + end + + context 'when there is a delayed job' do + let!(:delayed_job) do + create(:ci_build, :scheduled, + pipeline: pipeline, + name: 'delayed job 1', + stage: 'test') + end + + before do + stub_feature_flags(bootstrap_confirmation_modals: false) + visit_project_pipelines + end + + it 'has a dropdown for actionable jobs' do + expect(page).to have_selector('[data-testid="pipelines-manual-actions-dropdown"] [data-testid="play-icon"]') + end + + it "has link to the delayed job's action" do + find('[data-testid="pipelines-manual-actions-dropdown"]').click + + time_diff = [0, delayed_job.scheduled_at - Time.zone.now].max + expect(page).to have_button('delayed job 1') + expect(page).to have_content(Time.at(time_diff).utc.strftime("%H:%M:%S")) + end + + context 'when delayed job is expired already' do + let!(:delayed_job) do + create(:ci_build, :expired_scheduled, + pipeline: pipeline, + name: 'delayed job 1', + stage: 'test') + end + + it "shows 00:00:00 as the remaining time" do + find('[data-testid="pipelines-manual-actions-dropdown"]').click + + expect(page).to have_content("00:00:00") + end + end + + context 'when user played a delayed job immediately' do + before do + find('[data-testid="pipelines-manual-actions-dropdown"]').click + accept_gl_confirm do + click_button 'delayed job 1' + end + wait_for_requests + end + + it 'enqueues the delayed job', :js do + expect(delayed_job.reload).to be_pending + end + end + end + + context 'for generic statuses' do + context 'when preparing' do + let!(:pipeline) do + create(:ci_empty_pipeline, + status: 'preparing', project: project) + end + + let!(:status) do + create(:generic_commit_status, + :preparing, pipeline: pipeline) + end + + before do + visit_project_pipelines + end + + it 'is cancelable' do + expect(page).to have_selector('.js-pipelines-cancel-button') + end + + it 'shows the pipeline as preparing' do + expect(page).to have_selector('.ci-preparing') + end + end + + context 'when running' do + let!(:running) do + create(:generic_commit_status, + status: 'running', + pipeline: pipeline, + stage: 'test') + end + + before do + visit_project_pipelines + end + + it 'is cancelable' do + expect(page).to have_selector('.js-pipelines-cancel-button') + end + + it 'has pipeline running' do + expect(page).to have_selector('.ci-running') + end + + context 'when canceling' do + before do + find('.js-pipelines-cancel-button').click + click_button 'Stop pipeline' + end + + it 'indicates that pipeline was canceled', :sidekiq_might_not_need_inline do + expect(page).not_to have_selector('.js-pipelines-cancel-button') + expect(page).to have_selector('.ci-canceled') + end + end + end + + context 'when failed' do + let!(:status) do + create(:generic_commit_status, :pending, + pipeline: pipeline, + stage: 'test') + end + + before do + status.drop + visit_project_pipelines + end + + it 'is not retryable' do + expect(page).not_to have_selector('.js-pipelines-retry-button') + end + + it 'has failed pipeline', :sidekiq_might_not_need_inline do + expect(page).to have_selector('.ci-failed') + end + end + end + + context 'downloadable pipelines' do + context 'with artifacts' do + let!(:with_artifacts) do + build = create(:ci_build, :success, + pipeline: pipeline, + name: 'rspec tests', + stage: 'test') + + create(:ci_job_artifact, :codequality, job: build) + end + + before do + visit_project_pipelines + end + + it 'has artifacts dropdown' do + expect(page).to have_selector('[data-testid="pipeline-multi-actions-dropdown"]') + end + end + + context 'with artifacts expired' do + let!(:with_artifacts_expired) do + create(:ci_build, :expired, :success, + pipeline: pipeline, + name: 'rspec', + stage: 'test') + end + + before do + visit_project_pipelines + end + + it { expect(page).not_to have_selector('[data-testid="artifact-item"]') } + end + + context 'without artifacts' do + let!(:without_artifacts) do + create(:ci_build, :success, + pipeline: pipeline, + name: 'rspec', + stage: 'test') + end + + before do + visit_project_pipelines + end + + it { expect(page).not_to have_selector('[data-testid="artifact-item"]') } + end + + context 'with trace artifact' do + before do + create(:ci_build, :success, :trace_artifact, pipeline: pipeline) + + visit_project_pipelines + end + + it 'does not show trace artifact as artifacts' do + expect(page).not_to have_selector('[data-testid="artifact-item"]') + end + end + end + + context 'mini pipeline graph' do + let!(:build) do + create(:ci_build, :pending, pipeline: pipeline, + stage: 'build', + name: 'build') + end + + dropdown_selector = '[data-testid="mini-pipeline-graph-dropdown"]' + + before do + visit_project_pipelines + end + + it 'renders a mini pipeline graph' do + expect(page).to have_selector('[data-testid="pipeline-mini-graph"]') + expect(page).to have_selector(dropdown_selector) + end + + context 'when clicking a stage badge' do + it 'opens a dropdown' do + find(dropdown_selector).click + + expect(page).to have_link build.name + end + + it 'is possible to cancel pending build' do + find(dropdown_selector).click + find('.js-ci-action').click + wait_for_requests + + expect(build.reload).to be_canceled + end + end + + context 'for a failed pipeline' do + let!(:build) do + create(:ci_build, :failed, pipeline: pipeline, + stage: 'build', + name: 'build') + end + + it 'displays the failure reason' do + find(dropdown_selector).click + + within('.js-builds-dropdown-list') do + build_element = page.find('.mini-pipeline-graph-dropdown-item') + expect(build_element['title']).to eq('build - failed - (unknown failure)') + end + end + end + end + + context 'with pagination' do + before do + allow(Ci::Pipeline).to receive(:default_per_page).and_return(1) + create(:ci_empty_pipeline, project: project) + end + + it 'renders pagination' do + visit project_pipelines_path(project) + wait_for_requests + + expect(page).to have_selector('.gl-pagination') + end + + it 'renders second page of pipelines' do + visit project_pipelines_path(project, page: '2') + wait_for_requests + + expect(page).to have_selector('.gl-pagination .page-link', count: 4) + end + + it 'shows updated content' do + visit project_pipelines_path(project) + wait_for_requests + page.find('.page-link.next-page-item').click + + expect(page).to have_selector('.gl-pagination .page-link', count: 4) + end + end + + context 'with pipeline key selection' do + before do + visit project_pipelines_path(project) + wait_for_requests + end + + it 'changes the Pipeline ID column for Pipeline IID' do + page.find('[data-testid="pipeline-key-dropdown"]').click + + within '.gl-new-dropdown-contents' do + dropdown_options = page.find_all '.gl-new-dropdown-item' + + dropdown_options[1].click + end + + expect(page.find('[data-testid="pipeline-th"]')).to have_content 'Pipeline' + expect(page.find('[data-testid="pipeline-url-link"]')).to have_content "##{pipeline.iid}" + end + end + end + + describe 'GET /:project/-/pipelines/show' do + let(:project) { create(:project, :repository) } + + let(:pipeline) do + create(:ci_empty_pipeline, + project: project, + sha: project.commit.id, + user: user) + end + + before do + create_build('build', 0, 'build', :success) + create_build('test', 1, 'rspec 0:2', :pending) + create_build('test', 1, 'rspec 1:2', :running) + create_build('test', 1, 'spinach 0:2', :created) + create_build('test', 1, 'spinach 1:2', :created) + create_build('test', 1, 'audit', :created) + create_build('deploy', 2, 'production', :created) + + create( + :generic_commit_status, + pipeline: pipeline, + stage: 'external', + name: 'jenkins', + stage_idx: 3, + ref: 'master' + ) + + visit project_pipeline_path(project, pipeline) + wait_for_requests + end + + it 'shows a graph with grouped stages' do + expect(page).to have_css('.js-pipeline-graph') + + # header + expect(page).to have_text("##{pipeline.id}") + expect(page).to have_selector(%Q(img[src="#{pipeline.user.avatar_url}"])) + expect(page).to have_link(pipeline.user.name, href: user_path(pipeline.user)) + + # stages + expect(page).to have_text('Build') + expect(page).to have_text('Test') + expect(page).to have_text('Deploy') + expect(page).to have_text('External') + + # builds + expect(page).to have_text('rspec') + expect(page).to have_text('spinach') + expect(page).to have_text('rspec') + expect(page).to have_text('production') + expect(page).to have_text('jenkins') + end + + def create_build(stage, stage_idx, name, status) + create(:ci_build, pipeline: pipeline, stage: stage, stage_idx: stage_idx, name: name, status: status) + end + end + + describe 'POST /:project/-/pipelines' do + let(:project) { create(:project, :repository) } + + before do + visit new_project_pipeline_path(project) + end + + context 'for valid commit', :js do + before do + click_button project.default_branch + wait_for_requests + + find('p', text: 'master').click + wait_for_requests + end + + context 'with gitlab-ci.yml', :js do + before do + stub_ci_pipeline_to_return_yaml_file + end + + it 'creates a new pipeline' do + expect do + click_on 'Run pipeline' + wait_for_requests + end + .to change { Ci::Pipeline.count }.by(1) + + expect(Ci::Pipeline.last).to be_web + end + + context 'when variables are specified' do + it 'creates a new pipeline with variables' do + page.within(find("[data-testid='ci-variable-row']")) do + find("[data-testid='pipeline-form-ci-variable-key']").set('key_name') + find("[data-testid='pipeline-form-ci-variable-value']").set('value') + end + + expect do + click_on 'Run pipeline' + wait_for_requests + end + .to change { Ci::Pipeline.count }.by(1) + + expect(Ci::Pipeline.last.variables.map { |var| var.slice(:key, :secret_value) }) + .to eq [{ key: "key_name", secret_value: "value" }.with_indifferent_access] + end + end + end + + context 'without gitlab-ci.yml' do + before do + click_on 'Run pipeline' + wait_for_requests + end + + it { expect(page).to have_content('Missing CI config file') } + it 'creates a pipeline after first request failed and a valid gitlab-ci.yml file' \ + 'is available when trying again' do + stub_ci_pipeline_to_return_yaml_file + + expect do + click_on 'Run pipeline' + wait_for_requests + end + .to change { Ci::Pipeline.count }.by(1) + end + end + end + end + + describe 'Reset runner caches' do + let(:project) { create(:project, :repository) } + + before do + create(:ci_empty_pipeline, status: 'success', project: project, sha: project.commit.id, ref: 'master') + project.add_maintainer(user) + visit project_pipelines_path(project) + end + + it 'has a clear caches button' do + expect(page).to have_button 'Clear runner caches' + end + + describe 'user clicks the button' do + context 'when project already has jobs_cache_index' do + before do + project.update!(jobs_cache_index: 1) + end + + it 'increments jobs_cache_index' do + click_button 'Clear runner caches' + wait_for_requests + expect(page.find('[data-testid="alert-info"]')).to have_content 'Project cache successfully reset.' + end + end + + context 'when project does not have jobs_cache_index' do + it 'sets jobs_cache_index to 1' do + click_button 'Clear runner caches' + wait_for_requests + expect(page.find('[data-testid="alert-info"]')).to have_content 'Project cache successfully reset.' + end + end + end + end + + describe 'Run Pipelines' do + let(:project) { create(:project, :repository) } + + before do + visit new_project_pipeline_path(project) + end + + describe 'new pipeline page' do + it 'has field to add a new pipeline' do + expect(page).to have_selector('[data-testid="ref-select"]') + expect(find('[data-testid="ref-select"]')).to have_content project.default_branch + expect(page).to have_content('Run for') + end + end + + describe 'find pipelines' do + it 'shows filtered pipelines', :js do + click_button project.default_branch + + page.within '[data-testid="ref-select"]' do + find('[data-testid="search-refs"]').native.send_keys('fix') + + page.within '.gl-new-dropdown-contents' do + expect(page).to have_content('fix') + end + end + end + end + end + + describe 'Empty State' do + let(:project) { create(:project, :repository) } + + before do + visit project_pipelines_path(project) + end + + it 'renders empty state' do + expect(page).to have_content 'Try test template' + end + end + end + + context 'when user is not logged in' do + before do + project.update!(auto_devops_attributes: { enabled: false }) + visit project_pipelines_path(project) + end + + context 'when project is public' do + let(:project) { create(:project, :public, :repository) } + + context 'without pipelines' do + it { expect(page).to have_content 'This project is not currently set up to run pipelines.' } + end + end + + context 'when project is private' do + let(:project) { create(:project, :private, :repository) } + + it 'redirects the user to sign_in and displays the flash alert' do + expect(page).to have_content 'You need to sign in' + expect(page).to have_current_path("/users/sign_in") + end + end + end + + def visit_project_pipelines(**query) + visit project_pipelines_path(project, query) + wait_for_requests + end +end diff --git a/spec/features/projects/pipelines/pipeline_spec.rb b/spec/features/projects/pipelines/pipeline_spec.rb index 219c8ec0070..9eda05f695d 100644 --- a/spec/features/projects/pipelines/pipeline_spec.rb +++ b/spec/features/projects/pipelines/pipeline_spec.rb @@ -15,7 +15,6 @@ RSpec.describe 'Pipeline', :js do before do sign_in(user) project.add_role(user, role) - stub_feature_flags(pipeline_tabs_vue: false) end shared_context 'pipeline builds' do @@ -80,12 +79,6 @@ RSpec.describe 'Pipeline', :js do expect(page).to have_content('Cancel running') end - it 'shows Pipeline tab pane as active' do - visit_pipeline - - expect(page).to have_css('#js-tab-pipeline.active') - end - it 'shows link to the pipeline ref' do visit_pipeline @@ -190,11 +183,11 @@ RSpec.describe 'Pipeline', :js do end describe 'pipeline graph' do - before do - visit_pipeline - end - context 'when pipeline has running builds' do + before do + visit_pipeline + end + it 'shows a running icon and a cancel action for the running build' do page.within('#ci-badge-deploy') do expect(page).to have_selector('.js-ci-status-icon-running') @@ -213,6 +206,10 @@ RSpec.describe 'Pipeline', :js do end context 'when pipeline has preparing builds' do + before do + visit_pipeline + end + it 'shows a preparing icon and a cancel action' do page.within('#ci-badge-prepare') do expect(page).to have_selector('.js-ci-status-icon-preparing') @@ -231,6 +228,10 @@ RSpec.describe 'Pipeline', :js do end context 'when pipeline has successful builds' do + before do + visit_pipeline + end + it 'shows the success icon and a retry action for the successful build' do page.within('#ci-badge-build') do expect(page).to have_selector('.js-ci-status-icon-success') @@ -254,6 +255,10 @@ RSpec.describe 'Pipeline', :js do end context 'when pipeline has a delayed job' do + before do + visit_pipeline + end + let(:project) { create(:project, :repository, group: group) } it 'shows the scheduled icon and an unschedule action for the delayed job' do @@ -277,6 +282,10 @@ RSpec.describe 'Pipeline', :js do end context 'when pipeline has failed builds' do + before do + visit_pipeline + end + it 'shows the failed icon and a retry action for the failed build' do page.within('#ci-badge-test') do expect(page).to have_selector('.js-ci-status-icon-failed') @@ -307,6 +316,10 @@ RSpec.describe 'Pipeline', :js do end context 'when pipeline has manual jobs' do + before do + visit_pipeline + end + it 'shows the skipped icon and a play action for the manual build' do page.within('#ci-badge-manual-build') do expect(page).to have_selector('.js-ci-status-icon-manual') @@ -330,12 +343,139 @@ RSpec.describe 'Pipeline', :js do end context 'when pipeline has external job' do + before do + visit_pipeline + end + it 'shows the success icon and the generic comit status build' do expect(page).to have_selector('.js-ci-status-icon-success') expect(page).to have_content('jenkins') expect(page).to have_link('jenkins', href: 'http://gitlab.com/status') end end + + context 'when pipeline has a downstream pipeline' do + let(:downstream_project) { create(:project, :repository, group: group) } + let(:downstream_pipeline) do + create(:ci_pipeline, + status, + user: user, + project: downstream_project, + ref: 'master', + sha: downstream_project.commit.id, + child_of: pipeline ) + end + + let!(:build) { create(:ci_build, status, pipeline: downstream_pipeline, user: user) } + + before do + downstream_pipeline.project.add_developer(user) + end + + context 'and user has permission' do + before do + visit_pipeline + end + + context 'with a successful downstream' do + let(:status) { :success } + + it 'does not show the cancel or retry action' do + expect(page).to have_selector('.ci-status-icon-success') + expect(page).not_to have_selector('button[aria-label="Retry downstream pipeline"]') + expect(page).not_to have_selector('button[aria-label="Cancel downstream pipeline"]') + end + end + + context 'with a running downstream' do + let(:status) { :running } + + it 'shows the cancel action' do + expect(page).to have_selector('button[aria-label="Cancel downstream pipeline"]') + end + + context 'when canceling' do + before do + find('button[aria-label="Cancel downstream pipeline"]').click + wait_for_requests + end + + it 'shows the pipeline as canceled with the retry action' do + expect(page).to have_selector('button[aria-label="Retry downstream pipeline"]') + expect(page).to have_selector('.ci-status-icon-canceled') + end + end + end + + context 'with a failed downstream' do + let(:status) { :failed } + + it 'indicates that pipeline can be retried' do + expect(page).to have_selector('button[aria-label="Retry downstream pipeline"]') + end + + context 'and the FF downstream_retry_action is disabled' do + before do + stub_feature_flags(downstream_retry_action: false) + end + + it 'does not show the retry action' do + expect(page).not_to have_selector('button[aria-label="Retry downstream pipeline"]') + end + end + + context 'when retrying' do + before do + find('button[aria-label="Retry downstream pipeline"]').click + wait_for_requests + end + + it 'shows running pipeline with the cancel action' do + expect(page).to have_selector('.ci-status-icon-running') + expect(page).to have_selector('button[aria-label="Cancel downstream pipeline"]') + end + end + end + + context 'with a canceled downstream' do + let(:status) { :canceled } + + it 'indicates that pipeline can be retried' do + expect(page).to have_selector('button[aria-label="Retry downstream pipeline"]') + end + + context 'when retrying' do + before do + find('button[aria-label="Retry downstream pipeline"]').click + wait_for_requests + end + + it 'shows running pipeline with the cancel action' do + expect(page).to have_selector('.ci-status-icon-running') + expect(page).to have_selector('button[aria-label="Cancel downstream pipeline"]') + end + end + end + end + + context 'when user does not have permissions' do + let(:status) { :failed } + + before do + new_user = create(:user) + project.add_role(new_user, :guest) + downstream_project.add_role(new_user, :guest) + sign_in(new_user) + + visit_pipeline + end + + it 'does not show the retry button' do + expect(page).to have_selector('.ci-status-icon-failed') + expect(page).not_to have_selector('button[aria-label="Retry downstream pipeline"]') + end + end + end end context 'when the pipeline has manual stage' do @@ -357,7 +497,6 @@ RSpec.describe 'Pipeline', :js do context 'page tabs' do before do - stub_feature_flags(pipeline_tabs_vue: false) visit_pipeline end @@ -369,13 +508,10 @@ RSpec.describe 'Pipeline', :js do end it 'shows counter in Jobs tab' do + skip('Enable in jobs `pipeline_tabs_vue` MR') expect(page.find('.js-builds-counter').text).to eq(pipeline.total_size.to_s) end - it 'shows Pipeline tab as active' do - expect(page).to have_css('.js-pipeline-tab-link .active') - end - context 'without permission to access builds' do let(:project) { create(:project, :public, :repository, public_builds: false) } let(:role) { :guest } @@ -753,6 +889,7 @@ RSpec.describe 'Pipeline', :js do describe 'GET /:project/-/pipelines/:id/builds' do before do + stub_feature_flags(pipeline_tabs_vue: false) visit builds_project_pipeline_path(project, pipeline) end @@ -893,28 +1030,6 @@ RSpec.describe 'Pipeline', :js do end end end - - context 'when deploy job is a bridge to trigger a downstream pipeline' do - let!(:deploy_job) do - create(:ci_bridge, :created, stage: 'deploy', name: 'deploy', - stage_idx: 2, pipeline: pipeline, project: project, resource_group: resource_group) - end - - it 'shows deploy job as waiting for resource' do - subject - - within('.js-pipeline-header-container') do - expect(page).to have_content('waiting') - end - - within('.js-pipeline-graph') do - within(all('[data-testid="stage-column"]')[1]) do - expect(page).to have_content('deploy') - expect(page).to have_css('.ci-status-icon-waiting-for-resource') - end - end - end - end end end end @@ -943,15 +1058,7 @@ RSpec.describe 'Pipeline', :js do expect(page).to have_button('Play') end - it 'shows jobs tab pane as active' do - expect(page).to have_css('#js-tab-builds.active') - end - context 'page tabs' do - before do - stub_feature_flags(pipeline_tabs_vue: false) - end - it 'shows Pipeline, Jobs and DAG tabs with link' do expect(page).to have_link('Pipeline') expect(page).to have_link('Jobs') @@ -959,12 +1066,9 @@ RSpec.describe 'Pipeline', :js do end it 'shows counter in Jobs tab' do + skip('unskip when jobs tab is implemented with ff `pipeline_tabs_vue`') expect(page.find('.js-builds-counter').text).to eq(pipeline.total_size.to_s) end - - it 'shows Jobs tab as active' do - expect(page).to have_css('li.js-builds-tab-link .active') - end end context 'retrying jobs' do @@ -1022,14 +1126,14 @@ RSpec.describe 'Pipeline', :js do end describe 'GET /:project/-/pipelines/:id/failures' do - before do - stub_feature_flags(pipeline_tabs_vue: false) - end - let(:pipeline) { create(:ci_pipeline, project: project, ref: 'master', sha: '1234') } let(:pipeline_failures_page) { failures_project_pipeline_path(project, pipeline) } let!(:failed_build) { create(:ci_build, :failed, pipeline: pipeline) } + before do + stub_feature_flags(pipeline_tabs_vue: false) + end + subject { visit pipeline_failures_page } context 'with failed build' do @@ -1037,13 +1141,6 @@ RSpec.describe 'Pipeline', :js do failed_build.trace.set('4 examples, 1 failure') end - it 'shows jobs tab pane as active' do - subject - - expect(page).to have_content('Failed Jobs') - expect(page).to have_css('#js-tab-failures.active') - end - it 'lists failed builds' do subject @@ -1063,12 +1160,43 @@ RSpec.describe 'Pipeline', :js do expect(page).to have_content('There is an unknown failure, please try again') end + context 'when failed_jobs_tab_vue feature flag is disabled' do + before do + stub_feature_flags(failed_jobs_tab_vue: false) + end + + context 'when user does not have permission to retry build' do + it 'shows retry button for failed build' do + subject + + page.within(find('.build-failures', match: :first)) do + expect(page).not_to have_link('Retry') + end + end + end + + context 'when user does have permission to retry build' do + before do + create(:protected_branch, :developers_can_merge, + name: pipeline.ref, project: project) + end + + it 'shows retry button for failed build' do + subject + + page.within(find('.build-failures', match: :first)) do + expect(page).to have_link('Retry') + end + end + end + end + context 'when user does not have permission to retry build' do it 'shows retry button for failed build' do subject - page.within(find('.build-failures', match: :first)) do - expect(page).not_to have_link('Retry') + page.within(find('#js-tab-failures', match: :first)) do + expect(page).not_to have_button('Retry') end end end @@ -1082,21 +1210,14 @@ RSpec.describe 'Pipeline', :js do it 'shows retry button for failed build' do subject - page.within(find('.build-failures', match: :first)) do - expect(page).to have_link('Retry') + page.within(find('#js-tab-failures', match: :first)) do + expect(page).to have_button('Retry') end end end end context 'when missing build logs' do - it 'shows jobs tab pane as active' do - subject - - expect(page).to have_content('Failed Jobs') - expect(page).to have_css('#js-tab-failures.active') - end - it 'lists failed builds' do subject @@ -1133,11 +1254,17 @@ RSpec.describe 'Pipeline', :js do failed_build.update!(status: :success) end + it 'does not show the failure tab' do + skip('unskip when the failure tab has been implemented in ff `pipeline_tabs_vue`') + subject + + expect(page).not_to have_content('Failed Jobs') + end + it 'displays the pipeline graph' do subject expect(page).to have_current_path(pipeline_path(pipeline), ignore_query: true) - expect(page).not_to have_content('Failed Jobs') expect(page).to have_selector('.js-pipeline-graph') end end @@ -1151,27 +1278,14 @@ RSpec.describe 'Pipeline', :js do let(:pipeline) { create(:ci_pipeline, project: project, ref: 'master', sha: project.commit.id) } before do - stub_feature_flags(pipeline_tabs_vue: false) visit dag_project_pipeline_path(project, pipeline) end - it 'shows DAG tab pane as active' do - expect(page).to have_css('#js-tab-dag.active', visible: false) - end - context 'page tabs' do it 'shows Pipeline, Jobs and DAG tabs with link' do expect(page).to have_link('Pipeline') expect(page).to have_link('Jobs') - expect(page).to have_link('DAG') - end - - it 'shows counter in Jobs tab' do - expect(page.find('.js-builds-counter').text).to eq(pipeline.total_size.to_s) - end - - it 'shows DAG tab as active' do - expect(page).to have_css('li.js-dag-tab-link .active') + expect(page).to have_link('Needs') end end end diff --git a/spec/features/projects/pipelines/pipelines_spec.rb b/spec/features/projects/pipelines/pipelines_spec.rb index 8b1a22ae05a..a18bf7c5caf 100644 --- a/spec/features/projects/pipelines/pipelines_spec.rb +++ b/spec/features/projects/pipelines/pipelines_spec.rb @@ -623,7 +623,6 @@ RSpec.describe 'Pipelines', :js do create(:generic_commit_status, pipeline: pipeline, stage: 'external', name: 'jenkins', stage_idx: 3, ref: 'master') - stub_feature_flags(pipeline_tabs_vue: false) visit project_pipeline_path(project, pipeline) wait_for_requests end @@ -794,12 +793,29 @@ RSpec.describe 'Pipelines', :js do describe 'Empty State' do let(:project) { create(:project, :repository) } - before do - visit project_pipelines_path(project) + context 'when `ios_specific_templates` is not enabled' do + before do + visit project_pipelines_path(project) + end + + it 'renders empty state' do + expect(page).to have_content 'Try test template' + end end - it 'renders empty state' do - expect(page).to have_content 'Try test template' + describe 'when the `ios_specific_templates` experiment is enabled and the "Set up a runner" button is clicked' do + before do + stub_experiments(ios_specific_templates: :candidate) + create(:project_setting, project: project, target_platforms: %w(ios)) + visit project_pipelines_path(project) + click_button 'Set up a runner' + end + + it 'displays a modal with the macOS platform selected and an explanation popover' do + expect(page).to have_button 'macOS', class: 'selected' + expect(page).to have_selector('#runner-instructions-modal___BV_modal_content_') + expect(page).to have_selector('.popover') + end end end end diff --git a/spec/features/projects/serverless/functions_spec.rb b/spec/features/projects/serverless/functions_spec.rb deleted file mode 100644 index db8c2a24f2f..00000000000 --- a/spec/features/projects/serverless/functions_spec.rb +++ /dev/null @@ -1,88 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -RSpec.describe 'Functions', :js do - include KubernetesHelpers - include ReactiveCachingHelpers - - let(:project) { create(:project, :repository) } - let(:user) { create(:user) } - - before do - project.add_maintainer(user) - gitlab_sign_in(user) - end - - shared_examples "it's missing knative installation" do - before do - functions_finder = Projects::Serverless::FunctionsFinder.new(project) - visit project_serverless_functions_path(project) - allow(Projects::Serverless::FunctionsFinder) - .to receive(:new) - .and_return(functions_finder) - synchronous_reactive_cache(functions_finder) - end - - it 'sees an empty state require Knative installation' do - expect(page).to have_selector('.empty-state') - end - end - - context 'when user does not have a cluster and visits the serverless page' do - it_behaves_like "it's missing knative installation" - end - - context 'when the user does have a cluster and visits the serverless page' do - let(:cluster) { create(:cluster, :project, :provided_by_gcp) } - - it_behaves_like "it's missing knative installation" - end - - context 'when the user has a cluster and knative installed and visits the serverless page', :kubeclient do - let(:cluster) { create(:cluster, :project, :provided_by_gcp, projects: [project]) } - let(:service) { cluster.platform_kubernetes } - let(:environment) { create(:environment, project: project) } - let!(:deployment) { create(:deployment, :success, cluster: cluster, environment: environment) } - let(:knative_services_finder) { environment.knative_services_finder } - let(:namespace) do - create(:cluster_kubernetes_namespace, - cluster: cluster, - project: cluster.cluster_project.project, - environment: environment) - end - - before do - allow(Clusters::KnativeServicesFinder) - .to receive(:new) - .and_return(knative_services_finder) - synchronous_reactive_cache(knative_services_finder) - stub_kubeclient_knative_services(stub_get_services_options) - stub_kubeclient_service_pods(nil, namespace: namespace.namespace) - visit project_serverless_functions_path(project) - end - - context 'when there are no functions' do - let(:stub_get_services_options) do - { - namespace: namespace.namespace, - response: kube_response({ "kind" => "ServiceList", "items" => [] }) - } - end - - it 'sees an empty listing of serverless functions' do - expect(page).to have_selector('.empty-state') - expect(page).not_to have_selector('.content-list') - end - end - - context 'when there are functions' do - let(:stub_get_services_options) { { namespace: namespace.namespace } } - - it 'does not see an empty listing of serverless functions' do - expect(page).not_to have_selector('.empty-state') - expect(page).to have_selector('.content-list') - end - end - end -end diff --git a/spec/features/projects/settings/pipelines_settings_spec.rb b/spec/features/projects/settings/pipelines_settings_spec.rb index 39c4315bf0f..a64f81430d1 100644 --- a/spec/features/projects/settings/pipelines_settings_spec.rb +++ b/spec/features/projects/settings/pipelines_settings_spec.rb @@ -25,24 +25,6 @@ RSpec.describe "Projects > Settings > Pipelines settings" do context 'for maintainer' do let(:role) { :maintainer } - it 'be allowed to change' do - visit project_settings_ci_cd_path(project) - - fill_in('Test coverage parsing', with: 'coverage_regex') - - page.within '#js-general-pipeline-settings' do - click_on 'Save changes' - end - - expect(page.status_code).to eq(200) - - page.within '#js-general-pipeline-settings' do - expect(page).to have_button('Save changes', disabled: false) - end - - expect(page).to have_field('Test coverage parsing', with: 'coverage_regex') - end - it 'updates auto_cancel_pending_pipelines' do visit project_settings_ci_cd_path(project) diff --git a/spec/features/projects/settings/secure_files_settings_spec.rb b/spec/features/projects/settings/secure_files_settings_spec.rb new file mode 100644 index 00000000000..c7c9cafc420 --- /dev/null +++ b/spec/features/projects/settings/secure_files_settings_spec.rb @@ -0,0 +1,46 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe 'Secure Files Settings' do + let_it_be(:maintainer) { create(:user) } + let_it_be(:project) { create(:project, creator_id: maintainer.id) } + + before_all do + project.add_maintainer(maintainer) + end + + context 'when the :ci_secure_files feature flag is enabled' do + before do + stub_feature_flags(ci_secure_files: true) + + sign_in(user) + visit project_settings_ci_cd_path(project) + end + + context 'authenticated user with admin permissions' do + let(:user) { maintainer } + + it 'shows the secure files settings' do + expect(page).to have_content('Secure Files') + end + end + end + + context 'when the :ci_secure_files feature flag is disabled' do + before do + stub_feature_flags(ci_secure_files: false) + + sign_in(user) + visit project_settings_ci_cd_path(project) + end + + context 'authenticated user with admin permissions' do + let(:user) { maintainer } + + it 'does not shows the secure files settings' do + expect(page).not_to have_content('Secure Files') + end + end + end +end diff --git a/spec/features/projects/settings/user_manages_merge_requests_settings_spec.rb b/spec/features/projects/settings/user_manages_merge_requests_settings_spec.rb index 77be351f3d8..6aa59f72d2a 100644 --- a/spec/features/projects/settings/user_manages_merge_requests_settings_spec.rb +++ b/spec/features/projects/settings/user_manages_merge_requests_settings_spec.rb @@ -50,7 +50,7 @@ RSpec.describe 'Projects > Settings > User manages merge request settings' do context 'when Pipelines are initially enabled' do it 'shows the Merge Requests settings' do expect(page).to have_content 'Pipelines must succeed' - expect(page).to have_content 'All discussions must be resolved' + expect(page).to have_content 'All threads must be resolved' within('.sharing-permissions-form') do find('.project-feature-controls[data-for="project[project_feature_attributes][merge_requests_access_level]"] .gl-toggle').click @@ -58,7 +58,7 @@ RSpec.describe 'Projects > Settings > User manages merge request settings' do end expect(page).not_to have_content 'Pipelines must succeed' - expect(page).not_to have_content 'All discussions must be resolved' + expect(page).not_to have_content 'All threads must be resolved' end end @@ -70,7 +70,7 @@ RSpec.describe 'Projects > Settings > User manages merge request settings' do it 'shows the Merge Requests settings that do not depend on Builds feature' do expect(page).to have_content 'Pipelines must succeed' - expect(page).to have_content 'All discussions must be resolved' + expect(page).to have_content 'All threads must be resolved' within('.sharing-permissions-form') do find('.project-feature-controls[data-for="project[project_feature_attributes][builds_access_level]"] .gl-toggle').click @@ -78,7 +78,7 @@ RSpec.describe 'Projects > Settings > User manages merge request settings' do end expect(page).to have_content 'Pipelines must succeed' - expect(page).to have_content 'All discussions must be resolved' + expect(page).to have_content 'All threads must be resolved' end end end @@ -91,7 +91,7 @@ RSpec.describe 'Projects > Settings > User manages merge request settings' do it 'does not show the Merge Requests settings' do expect(page).not_to have_content 'Pipelines must succeed' - expect(page).not_to have_content 'All discussions must be resolved' + expect(page).not_to have_content 'All threads must be resolved' within('.sharing-permissions-form') do find('.project-feature-controls[data-for="project[project_feature_attributes][merge_requests_access_level]"] .gl-toggle').click @@ -99,7 +99,7 @@ RSpec.describe 'Projects > Settings > User manages merge request settings' do end expect(page).to have_content 'Pipelines must succeed' - expect(page).to have_content 'All discussions must be resolved' + expect(page).to have_content 'All threads must be resolved' end end diff --git a/spec/features/projects/settings/user_manages_project_members_spec.rb b/spec/features/projects/settings/user_manages_project_members_spec.rb index 2fe06414b32..1d258582b3a 100644 --- a/spec/features/projects/settings/user_manages_project_members_spec.rb +++ b/spec/features/projects/settings/user_manages_project_members_spec.rb @@ -7,7 +7,7 @@ RSpec.describe 'Projects > Settings > User manages project members' do include Spec::Support::Helpers::ModalHelpers let(:group) { create(:group, name: 'OpenSource') } - let(:project) { create(:project) } + let(:project) { create(:project, :with_namespace_settings) } let(:project2) { create(:project) } let(:user) { create(:user) } let(:user_dmitriy) { create(:user, name: 'Dmitriy') } diff --git a/spec/features/projects/show/user_uploads_files_spec.rb b/spec/features/projects/show/user_uploads_files_spec.rb index 92b54d83ef3..a222d6b42ab 100644 --- a/spec/features/projects/show/user_uploads_files_spec.rb +++ b/spec/features/projects/show/user_uploads_files_spec.rb @@ -55,16 +55,4 @@ RSpec.describe 'Projects > Show > User uploads files' do include_examples 'uploads and commits a new text file via "upload file" button', drop: value end end - - context 'with a nonempty repo' do - let(:project) { create(:project, :repository, creator: user) } - - before do - visit(project_path(project)) - end - - [true, false].each do |value| - include_examples 'uploads and commits a new text file via "upload file" button', drop: value - end - end end diff --git a/spec/features/projects/snippets/create_snippet_spec.rb b/spec/features/projects/snippets/create_snippet_spec.rb index 0ed9e23c7f8..cbdf6d6852e 100644 --- a/spec/features/projects/snippets/create_snippet_spec.rb +++ b/spec/features/projects/snippets/create_snippet_spec.rb @@ -85,13 +85,4 @@ RSpec.describe 'Projects > Snippets > Create Snippet', :js do expect(page).to have_content('New Snippet') end end - - it 'does not allow submitting the form without title and content' do - snippet_fill_in_title(title) - - expect(page).not_to have_button('Create snippet') - - snippet_fill_in_form(title: title, content: file_content) - expect(page).to have_button('Create snippet') - end end diff --git a/spec/features/projects/tags/user_views_tags_spec.rb b/spec/features/projects/tags/user_views_tags_spec.rb index e1962ad3df5..dfb5d5d9221 100644 --- a/spec/features/projects/tags/user_views_tags_spec.rb +++ b/spec/features/projects/tags/user_views_tags_spec.rb @@ -2,6 +2,36 @@ require 'spec_helper' RSpec.describe 'User views tags', :feature do + context 'with html' do + let(:project) { create(:project, :repository, visibility_level: Gitlab::VisibilityLevel::PUBLIC) } + let(:user) { create(:user) } + let(:tag_name) { "stable" } + let!(:release) { create(:release, project: project, tag: tag_name) } + + before do + project.add_developer(user) + project.repository.add_tag(user, tag_name, project.default_branch_or_main) + + sign_in(user) + end + + shared_examples 'renders the tag index page' do + it do + visit project_tags_path(project) + + expect(page).to have_content tag_name + end + end + + it_behaves_like 'renders the tag index page' + + context 'when tag name contains a slash' do + let(:tag_name) { "stable/v0.1" } + + it_behaves_like 'renders the tag index page' + end + end + context 'rss' do shared_examples 'has access to the tags RSS feed' do it do diff --git a/spec/features/projects/tree/tree_show_spec.rb b/spec/features/projects/tree/tree_show_spec.rb index cd94e6da018..53e89cd2959 100644 --- a/spec/features/projects/tree/tree_show_spec.rb +++ b/spec/features/projects/tree/tree_show_spec.rb @@ -81,7 +81,7 @@ RSpec.describe 'Projects tree', :js do wait_for_requests page.within('.project-last-commit') do - expect(page).to have_selector('.user-avatar-link') + expect(page).to have_selector('.gl-avatar') expect(page).to have_content('Merge branch') end end @@ -152,4 +152,18 @@ RSpec.describe 'Projects tree', :js do end end end + + context 'ref switcher' do + it 'switches ref to branch' do + ref_name = 'feature' + visit project_tree_path(project, 'master') + first('.js-project-refs-dropdown').click + + page.within '.project-refs-form' do + click_link ref_name + end + + expect(page).to have_selector '.dropdown-menu-toggle', text: ref_name + end + end end |