diff options
Diffstat (limited to 'spec/features/projects')
59 files changed, 657 insertions, 315 deletions
diff --git a/spec/features/projects/active_tabs_spec.rb b/spec/features/projects/active_tabs_spec.rb index 86fe59f003f..9de43e7d18c 100644 --- a/spec/features/projects/active_tabs_spec.rb +++ b/spec/features/projects/active_tabs_spec.rb @@ -79,7 +79,7 @@ RSpec.describe 'Project active tab' do visit project_merge_requests_path(project) end - it_behaves_like 'page has active tab', 'Merge Requests' + it_behaves_like 'page has active tab', 'Merge requests' end context 'on project Wiki' do diff --git a/spec/features/projects/blobs/blob_line_permalink_updater_spec.rb b/spec/features/projects/blobs/blob_line_permalink_updater_spec.rb index a65a82fab43..1a368676a5e 100644 --- a/spec/features/projects/blobs/blob_line_permalink_updater_spec.rb +++ b/spec/features/projects/blobs/blob_line_permalink_updater_spec.rb @@ -44,17 +44,6 @@ RSpec.describe 'Blob button line permalinks (BlobLinePermalinkUpdater)', :js do expect(find('.js-data-file-blob-permalink-url')['href']).to eq(get_absolute_url(project_blob_path(project, tree_join(sha, path), anchor: ending_fragment))) end - it 'changes fragment hash if icon inside line number link is clicked' do - ending_fragment = "L7" - - visit_blob - - find("##{ending_fragment}").hover - find("##{ending_fragment} svg").click - - expect(find('.js-data-file-blob-permalink-url')['href']).to eq(get_absolute_url(project_blob_path(project, tree_join(sha, path), anchor: ending_fragment))) - end - it 'with initial fragment hash, changes fragment hash if line number clicked' do fragment = "L1" ending_fragment = "L5" @@ -94,17 +83,6 @@ RSpec.describe 'Blob button line permalinks (BlobLinePermalinkUpdater)', :js do expect(find('.js-blob-blame-link')['href']).to eq(get_absolute_url(project_blame_path(project, tree_join('master', path), anchor: ending_fragment))) end - it 'changes fragment hash if icon inside line number link is clicked' do - ending_fragment = "L7" - - visit_blob - - find("##{ending_fragment}").hover - find("##{ending_fragment} svg").click - - expect(find('.js-blob-blame-link')['href']).to eq(get_absolute_url(project_blame_path(project, tree_join('master', path), anchor: ending_fragment))) - end - it 'with initial fragment hash, changes fragment hash if line number clicked' do fragment = "L1" ending_fragment = "L5" diff --git a/spec/features/projects/blobs/user_views_pipeline_editor_button_spec.rb b/spec/features/projects/blobs/user_views_pipeline_editor_button_spec.rb new file mode 100644 index 00000000000..b872fa701c8 --- /dev/null +++ b/spec/features/projects/blobs/user_views_pipeline_editor_button_spec.rb @@ -0,0 +1,42 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe 'User views pipeline editor button on root ci config file', :js do + include BlobSpecHelpers + + let_it_be(:user) { create(:user) } + let_it_be(:project) { create(:project, :public, :repository) } + + context "when the ci config is the root file" do + before do + project.add_developer(user) + sign_in(user) + end + + it 'shows the button to the Pipeline Editor' do + project.update!(ci_config_path: '.my-config.yml') + project.repository.create_file(user, project.ci_config_path_or_default, 'test', message: 'testing', branch_name: 'master') + visit project_blob_path(project, File.join('master', '.my-config.yml')) + + expect(page).to have_content('Pipeline Editor') + end + + it 'does not shows the Pipeline Editor button' do + project.repository.create_file(user, '.my-sub-config.yml', 'test', message: 'testing', branch_name: 'master') + visit project_blob_path(project, File.join('master', '.my-sub-config.yml')) + + expect(page).not_to have_content('Pipeline Editor') + end + end + + context "when user cannot collaborate" do + before do + sign_in(user) + end + it 'does not shows the Pipeline Editor button' do + visit project_blob_path(project, File.join('master', '.my-config.yml')) + expect(page).not_to have_content('Pipeline Editor') + end + end +end diff --git a/spec/features/projects/branches/user_creates_branch_spec.rb b/spec/features/projects/branches/user_creates_branch_spec.rb index 52c860bfe36..18d083f7d88 100644 --- a/spec/features/projects/branches/user_creates_branch_spec.rb +++ b/spec/features/projects/branches/user_creates_branch_spec.rb @@ -16,7 +16,7 @@ RSpec.describe "User creates branch", :js do end it "creates new branch" do - branch_name = "deploy_keys".freeze + branch_name = "deploy_keys" create_branch(branch_name) @@ -25,7 +25,7 @@ RSpec.describe "User creates branch", :js do context "when branch name is invalid" do it "does not create new branch" do - invalid_branch_name = "1.0 stable".freeze + invalid_branch_name = "1.0 stable" fill_in("branch_name", with: invalid_branch_name) page.find("body").click # defocus the branch_name input diff --git a/spec/features/projects/branches/user_deletes_branch_spec.rb b/spec/features/projects/branches/user_deletes_branch_spec.rb index c480c41709c..bebb4bb679b 100644 --- a/spec/features/projects/branches/user_deletes_branch_spec.rb +++ b/spec/features/projects/branches/user_deletes_branch_spec.rb @@ -9,12 +9,15 @@ RSpec.describe "User deletes branch", :js do before do project.add_developer(user) sign_in(user) - - visit(project_branches_path(project)) end it "deletes branch" do - fill_in("branch-search", with: "improve/awesome").native.send_keys(:enter) + visit(project_branches_path(project)) + + branch_search = find('input[data-testid="branch-search"]') + + branch_search.set('improve/awesome') + branch_search.native.send_keys(:enter) page.within(".js-branch-improve\\/awesome") do accept_alert { find(".btn-danger").click } diff --git a/spec/features/projects/branches_spec.rb b/spec/features/projects/branches_spec.rb index 4bfe8852291..f805416b03d 100644 --- a/spec/features/projects/branches_spec.rb +++ b/spec/features/projects/branches_spec.rb @@ -88,8 +88,10 @@ RSpec.describe 'Branches' do it 'shows filtered branches', :js do visit project_branches_path(project) - fill_in 'branch-search', with: 'fix' - find('#branch-search').native.send_keys(:enter) + branch_search = find('input[data-testid="branch-search"]') + + branch_search.set('fix') + branch_search.native.send_keys(:enter) expect(page).to have_content('fix') expect(find('.all-branches')).to have_selector('li', count: 1) @@ -114,20 +116,24 @@ RSpec.describe 'Branches' do expect(page).to have_content(sorted_branches(repository, count: 20, sort_by: :updated_desc)) end - it 'sorts the branches by name' do + it 'sorts the branches by name', :js do visit project_branches_filtered_path(project, state: 'all') click_button "Last updated" # Open sorting dropdown - click_link "Name" + within '[data-testid="branches-dropdown"]' do + find('p', text: 'Name').click + end expect(page).to have_content(sorted_branches(repository, count: 20, sort_by: :name)) end - it 'sorts the branches by oldest updated' do + it 'sorts the branches by oldest updated', :js do visit project_branches_filtered_path(project, state: 'all') click_button "Last updated" # Open sorting dropdown - click_link "Oldest updated" + within '[data-testid="branches-dropdown"]' do + find('p', text: 'Oldest updated').click + end expect(page).to have_content(sorted_branches(repository, count: 20, sort_by: :updated_asc)) end @@ -145,8 +151,10 @@ RSpec.describe 'Branches' do it 'shows filtered branches', :js do visit project_branches_filtered_path(project, state: 'all') - fill_in 'branch-search', with: 'fix' - find('#branch-search').native.send_keys(:enter) + branch_search = find('input[data-testid="branch-search"]') + + branch_search.set('fix') + branch_search.native.send_keys(:enter) expect(page).to have_content('fix') expect(find('.all-branches')).to have_selector('li', count: 1) @@ -157,9 +165,10 @@ RSpec.describe 'Branches' do it 'removes branch after confirmation', :js do visit project_branches_filtered_path(project, state: 'all') - fill_in 'branch-search', with: 'fix' + branch_search = find('input[data-testid="branch-search"]') - find('#branch-search').native.send_keys(:enter) + branch_search.set('fix') + branch_search.native.send_keys(:enter) expect(page).to have_content('fix') expect(find('.all-branches')).to have_selector('li', count: 1) diff --git a/spec/features/projects/clusters/gcp_spec.rb b/spec/features/projects/clusters/gcp_spec.rb index d34dde6a8f2..8c497cded8e 100644 --- a/spec/features/projects/clusters/gcp_spec.rb +++ b/spec/features/projects/clusters/gcp_spec.rb @@ -119,7 +119,7 @@ RSpec.describe 'Gcp Cluster', :js do context 'when user disables the cluster' do before do page.find(:css, '.js-cluster-enable-toggle-area .js-project-feature-toggle').click - page.within('.js-cluster-integration-form') { click_button 'Save changes' } + page.within('.js-cluster-details-form') { click_button 'Save changes' } end it 'user sees the successful message' do diff --git a/spec/features/projects/clusters/user_spec.rb b/spec/features/projects/clusters/user_spec.rb index 748eba558aa..5b60edbcf87 100644 --- a/spec/features/projects/clusters/user_spec.rb +++ b/spec/features/projects/clusters/user_spec.rb @@ -84,7 +84,7 @@ RSpec.describe 'User Cluster', :js do context 'when user disables the cluster' do before do page.find(:css, '.js-cluster-enable-toggle-area .js-project-feature-toggle').click - page.within('.js-cluster-integration-form') { click_button 'Save changes' } + page.within('.js-cluster-details-form') { click_button 'Save changes' } end it 'user sees the successful message' do diff --git a/spec/features/projects/clusters_spec.rb b/spec/features/projects/clusters_spec.rb index 6da66989b09..6b03301aa74 100644 --- a/spec/features/projects/clusters_spec.rb +++ b/spec/features/projects/clusters_spec.rb @@ -58,7 +58,7 @@ RSpec.describe 'Clusters', :js do before do click_link 'default-cluster' fill_in 'cluster_environment_scope', with: 'production/*' - within '.js-cluster-integration-form' do + within '.js-cluster-details-form' do click_button 'Save changes' end end @@ -149,7 +149,7 @@ RSpec.describe 'Clusters', :js do before do click_link 'default-cluster' fill_in 'cluster_environment_scope', with: 'production/*' - within ".js-cluster-integration-form" do + within ".js-cluster-details-form" do click_button 'Save changes' end end diff --git a/spec/features/projects/commit/cherry_pick_spec.rb b/spec/features/projects/commit/cherry_pick_spec.rb index 489a90cc8fc..cd944436228 100644 --- a/spec/features/projects/commit/cherry_pick_spec.rb +++ b/spec/features/projects/commit/cherry_pick_spec.rb @@ -91,7 +91,7 @@ RSpec.describe 'Cherry-pick Commits', :js do context 'when the project is archived' do let(:project) { create(:project, :repository, :archived, namespace: user.namespace) } - it 'does not show the cherry-pick link' do + it 'does not show the cherry-pick button' do open_dropdown expect(page).not_to have_text("Cherry-pick") @@ -106,12 +106,15 @@ RSpec.describe 'Cherry-pick Commits', :js do end def open_dropdown - find('.header-action-buttons .dropdown').click + find(dropdown_selector).click end def open_modal open_dropdown - find('[data-testid="cherry-pick-commit-link"]').click + + page.within(dropdown_selector) do + click_button 'Cherry-pick' + end end def submit_cherry_pick(create_merge_request: false) @@ -121,6 +124,10 @@ RSpec.describe 'Cherry-pick Commits', :js do end end + def dropdown_selector + '[data-testid="commit-options-dropdown"]' + end + def modal_selector '[data-testid="modal-commit"]' end diff --git a/spec/features/projects/commit/comments/user_edits_comments_spec.rb b/spec/features/projects/commit/comments/user_edits_comments_spec.rb index 787d8cdb02b..8ac15c9cb7f 100644 --- a/spec/features/projects/commit/comments/user_edits_comments_spec.rb +++ b/spec/features/projects/commit/comments/user_edits_comments_spec.rb @@ -19,7 +19,7 @@ RSpec.describe "User edits a comment on a commit", :js do end it "edits comment" do - new_comment_text = "+1 Awesome!".freeze + new_comment_text = "+1 Awesome!" page.within(".main-notes-list") do note = find(".note") diff --git a/spec/features/projects/commit/mini_pipeline_graph_spec.rb b/spec/features/projects/commit/mini_pipeline_graph_spec.rb index 7d206f76031..6de02556175 100644 --- a/spec/features/projects/commit/mini_pipeline_graph_spec.rb +++ b/spec/features/projects/commit/mini_pipeline_graph_spec.rb @@ -16,46 +16,28 @@ RSpec.describe 'Mini Pipeline Graph in Commit View', :js do let(:build) { create(:ci_build, pipeline: pipeline, status: :running) } - shared_examples 'shows ci icon and mini pipeline' do - before do - build.run - visit project_commit_path(project, project.commit.id) - end - - it 'display icon with status' do - expect(page).to have_selector('.ci-status-icon-running') - end - - it 'displays a mini pipeline graph' do - expect(page).to have_selector('.mr-widget-pipeline-graph') - - first('.mini-pipeline-graph-dropdown-toggle').click - - wait_for_requests - - page.within '.js-builds-dropdown-list' do - expect(page).to have_selector('.ci-status-icon-running') - expect(page).to have_content(build.stage) - end + before do + build.run + visit project_commit_path(project, project.commit.id) + end - build.drop - end + it 'display icon with status' do + expect(page).to have_selector('.ci-status-icon-running') end - context 'when ci_commit_pipeline_mini_graph_vue is disabled' do - before do - stub_feature_flags(ci_commit_pipeline_mini_graph_vue: false) - end + it 'displays a mini pipeline graph' do + expect(page).to have_selector('[data-testid="pipeline-mini-graph"]') - it_behaves_like 'shows ci icon and mini pipeline' - end + first('.mini-pipeline-graph-dropdown-toggle').click - context 'when ci_commit_pipeline_mini_graph_vue is enabled' do - before do - stub_feature_flags(ci_commit_pipeline_mini_graph_vue: true) + wait_for_requests + + page.within '.js-builds-dropdown-list' do + expect(page).to have_selector('.ci-status-icon-running') + expect(page).to have_content(build.stage) end - it_behaves_like 'shows ci icon and mini pipeline' + build.drop end end @@ -65,7 +47,7 @@ RSpec.describe 'Mini Pipeline Graph in Commit View', :js do end it 'does not display a mini pipeline graph' do - expect(page).not_to have_selector('.mr-widget-pipeline-graph') + expect(page).not_to have_selector('[data-testid="pipeline-mini-graph"]') end end end diff --git a/spec/features/projects/commit/user_reverts_commit_spec.rb b/spec/features/projects/commit/user_reverts_commit_spec.rb index 72c639a027e..ad327b86aa7 100644 --- a/spec/features/projects/commit/user_reverts_commit_spec.rb +++ b/spec/features/projects/commit/user_reverts_commit_spec.rb @@ -62,10 +62,10 @@ RSpec.describe 'User reverts a commit', :js do context 'when the project is archived' do let(:project) { create(:project, :repository, :archived, namespace: user.namespace) } - it 'does not show the revert link' do + it 'does not show the revert button' do open_dropdown - expect(page).not_to have_link('Revert') + expect(page).not_to have_button('Revert') end end end @@ -75,17 +75,24 @@ RSpec.describe 'User reverts a commit', :js do page.within(modal_selector) do uncheck('create_merge_request') unless create_merge_request - click_button('Revert') + click_button 'Revert' end end def open_dropdown - find('.header-action-buttons .dropdown').click + find(dropdown_selector).click end def open_modal open_dropdown - find('[data-testid="revert-commit-link"]').click + + page.within(dropdown_selector) do + click_button 'Revert' + end + end + + def dropdown_selector + '[data-testid="commit-options-dropdown"]' end def modal_selector diff --git a/spec/features/projects/commits/user_browses_commits_spec.rb b/spec/features/projects/commits/user_browses_commits_spec.rb index 4894e2b7f3e..76162fb800a 100644 --- a/spec/features/projects/commits/user_browses_commits_spec.rb +++ b/spec/features/projects/commits/user_browses_commits_spec.rb @@ -20,9 +20,14 @@ RSpec.describe 'User browses commits' do .and have_content('Side-by-side') end - it 'fill commit sha when click new tag from commit page' do + it 'fill commit sha when click new tag from commit page', :js do + dropdown_selector = '[data-testid="commit-options-dropdown"]' visit project_commit_path(project, sample_commit.id) - click_link 'Tag' + find(dropdown_selector).click + + page.within(dropdown_selector) do + click_link 'Tag' + end expect(page).to have_selector("input[value='#{sample_commit.id}']", visible: false) end diff --git a/spec/features/projects/features_visibility_spec.rb b/spec/features/projects/features_visibility_spec.rb index c94247f65d2..ab82a4750d3 100644 --- a/spec/features/projects/features_visibility_spec.rb +++ b/spec/features/projects/features_visibility_spec.rb @@ -134,7 +134,7 @@ RSpec.describe 'Edit Project Settings' do it 'renders 200 if user is member of group' do group = create(:group) project.group = group - project.save + project.save! group.add_owner(member) diff --git a/spec/features/projects/files/gitlab_ci_yml_dropdown_spec.rb b/spec/features/projects/files/gitlab_ci_yml_dropdown_spec.rb index 55b9f38d8e7..b0ccb5fca94 100644 --- a/spec/features/projects/files/gitlab_ci_yml_dropdown_spec.rb +++ b/spec/features/projects/files/gitlab_ci_yml_dropdown_spec.rb @@ -5,10 +5,14 @@ require 'spec_helper' RSpec.describe 'Projects > Files > User wants to add a .gitlab-ci.yml file', :js do include Spec::Support::Helpers::Features::EditorLiteSpecHelpers + let(:params) { {} } + let(:filename) { '.gitlab-ci.yml' } + + let_it_be(:project) { create(:project, :repository) } + before do - project = create(:project, :repository) sign_in project.owner - visit project_new_blob_path(project, 'master', file_name: '.gitlab-ci.yml') + visit project_new_blob_path(project, 'master', file_name: filename, **params) end it 'user can pick a template from the dropdown' do @@ -29,4 +33,38 @@ RSpec.describe 'Projects > Files > User wants to add a .gitlab-ci.yml file', :js expect(editor_get_value).to have_content('This file is a template, and might need editing before it works on your project') expect(editor_get_value).to have_content('jekyll build -d test') end + + context 'when template param is provided' do + let(:params) { { template: 'Jekyll' } } + + it 'uses the given template' do + wait_for_requests + + expect(page).to have_css('.gitlab-ci-yml-selector .dropdown-toggle-text', text: 'Apply a template') + expect(editor_get_value).to have_content('This file is a template, and might need editing before it works on your project') + expect(editor_get_value).to have_content('jekyll build -d test') + end + end + + context 'when provided template param is not a valid template name' do + let(:params) { { template: 'non-existing-template' } } + + it 'leaves the editor empty' do + wait_for_requests + + expect(page).to have_css('.gitlab-ci-yml-selector .dropdown-toggle-text', text: 'Apply a template') + expect(editor_get_value).to have_content('') + end + end + + context 'when template is not available for the given file' do + let(:filename) { 'Dockerfile' } + let(:params) { { template: 'Jekyll' } } + + it 'leaves the editor empty' do + wait_for_requests + + expect(editor_get_value).to have_content('') + end + end end diff --git a/spec/features/projects/files/user_creates_directory_spec.rb b/spec/features/projects/files/user_creates_directory_spec.rb index f2074c78dba..46b93d738e1 100644 --- a/spec/features/projects/files/user_creates_directory_spec.rb +++ b/spec/features/projects/files/user_creates_directory_spec.rb @@ -77,7 +77,7 @@ RSpec.describe 'Projects > Files > User creates a directory', :js do it 'creates the directory in the new branch and redirect to the merge request' do expect(page).to have_content('new-feature') expect(page).to have_content('The directory has been successfully created') - expect(page).to have_content('New Merge Request') + expect(page).to have_content('New merge request') expect(page).to have_content('From new-feature into master') expect(page).to have_content('Add new directory') diff --git a/spec/features/projects/files/user_uploads_files_spec.rb b/spec/features/projects/files/user_uploads_files_spec.rb index 944d08df3f3..54e816d3d13 100644 --- a/spec/features/projects/files/user_uploads_files_spec.rb +++ b/spec/features/projects/files/user_uploads_files_spec.rb @@ -3,8 +3,6 @@ require 'spec_helper' RSpec.describe 'Projects > Files > User uploads files' do - include DropzoneHelper - let(:user) { create(:user) } let(:project) { create(:project, :repository, name: 'Shop', creator: user) } let(:project2) { create(:project, :repository, name: 'Another Project', path: 'another-project') } @@ -17,36 +15,17 @@ RSpec.describe 'Projects > Files > User uploads files' do context 'when a user has write access' do before do visit(project_tree_path(project)) - end - - include_examples 'it uploads and commit a new text file' - - include_examples 'it uploads and commit a new image file' - it 'uploads a file to a sub-directory', :js do - click_link 'files' - - page.within('.repo-breadcrumb') do - expect(page).to have_content('files') - end - - find('.add-to-tree').click - click_link('Upload file') - drop_in_dropzone(File.join(Rails.root, 'spec', 'fixtures', 'doc_sample.txt')) + wait_for_requests + end - page.within('#modal-upload-blob') do - fill_in(:commit_message, with: 'New commit message') - end + include_examples 'it uploads and commits a new text file' - click_button('Upload file') + include_examples 'it uploads and commits a new image file' - expect(page).to have_content('New commit message') + include_examples 'it uploads and commits a new pdf file' - page.within('.repo-breadcrumb') do - expect(page).to have_content('files') - expect(page).to have_content('doc_sample.txt') - end - end + include_examples 'it uploads a file to a sub-directory' end context 'when a user does not have write access' do @@ -56,6 +35,6 @@ RSpec.describe 'Projects > Files > User uploads files' do visit(project_tree_path(project2)) end - include_examples 'it uploads and commit a new file to a forked project' + include_examples 'it uploads and commits a new file to a forked project' end end diff --git a/spec/features/projects/fork_spec.rb b/spec/features/projects/fork_spec.rb index 7abbd207b24..2b7ea70fe5a 100644 --- a/spec/features/projects/fork_spec.rb +++ b/spec/features/projects/fork_spec.rb @@ -76,7 +76,7 @@ RSpec.describe 'Project fork' do let(:forking_access_level) { ProjectFeature::PRIVATE } before do - project.update(visibility_level: Gitlab::VisibilityLevel::INTERNAL) + project.update!(visibility_level: Gitlab::VisibilityLevel::INTERNAL) end context 'user is not a team member' do @@ -118,6 +118,50 @@ RSpec.describe 'Project fork' do it_behaves_like 'fork button on project page' it_behaves_like 'create fork page', 'Fork project' + context 'fork form', :js do + let(:group) { create(:group) } + let(:user) { create(:group_member, :maintainer, user: create(:user), group: group ).user } + + def submit_form + select(group.name) + click_button 'Fork project' + end + + it 'forks the project', :sidekiq_might_not_need_inline do + visit new_project_fork_path(project) + submit_form + + expect(page).to have_content 'Forked from' + end + + it 'shows the new forked project on the forks page' do + visit new_project_fork_path(project) + submit_form + wait_for_requests + + visit project_forks_path(project) + + page.within('.js-projects-list-holder') do + expect(page).to have_content("#{group.name} / #{project.name}") + end + end + + it 'shows the filled in info forked project on the forks page' do + fork_name = 'some-name' + visit new_project_fork_path(project) + fill_in('fork-name', with: fork_name, fill_options: { clear: :backspace }) + fill_in('fork-slug', with: fork_name, fill_options: { clear: :backspace }) + submit_form + wait_for_requests + + visit project_forks_path(project) + + page.within('.js-projects-list-holder') do + expect(page).to have_content("#{group.name} / #{fork_name}") + end + end + end + context 'with fork_project_form feature flag disabled' do before do stub_feature_flags(fork_project_form: false) @@ -164,7 +208,7 @@ RSpec.describe 'Project fork' do expect(page).to have_content(/new merge request/i) page.within '.nav-sidebar' do - first(:link, 'Merge Requests').click + first(:link, 'Merge requests').click end expect(page).to have_content(/new merge request/i) diff --git a/spec/features/projects/jobs/permissions_spec.rb b/spec/features/projects/jobs/permissions_spec.rb index e87880d74b1..140d5dee270 100644 --- a/spec/features/projects/jobs/permissions_spec.rb +++ b/spec/features/projects/jobs/permissions_spec.rb @@ -12,6 +12,8 @@ RSpec.describe 'Project Jobs Permissions' do let_it_be(:job) { create(:ci_build, :running, :coverage, :trace_artifact, pipeline: pipeline) } before do + stub_feature_flags(jobs_table_vue: false) + sign_in(user) project.enable_ci diff --git a/spec/features/projects/jobs/user_browses_jobs_spec.rb b/spec/features/projects/jobs/user_browses_jobs_spec.rb index 5abebf2320e..dbcd7b5caf5 100644 --- a/spec/features/projects/jobs/user_browses_jobs_spec.rb +++ b/spec/features/projects/jobs/user_browses_jobs_spec.rb @@ -9,6 +9,7 @@ RSpec.describe 'User browses jobs' do let(:user) { create(:user) } before do + stub_feature_flags(jobs_table_vue: false) project.add_maintainer(user) project.enable_ci project.update_attribute(:build_coverage_regex, /Coverage (\d+)%/) @@ -24,14 +25,6 @@ RSpec.describe 'User browses jobs' do end end - it 'shows the "CI Lint" button' do - page.within('.nav-controls') do - ci_lint_tool_link = page.find_link('CI Lint') - - expect(ci_lint_tool_link[:href]).to end_with(project_ci_lint_path(project)) - end - end - context 'with a failed job' do let!(:build) { create(:ci_build, :coverage, :failed, pipeline: pipeline) } diff --git a/spec/features/projects/jobs_spec.rb b/spec/features/projects/jobs_spec.rb index 7811394b541..18a6ad12240 100644 --- a/spec/features/projects/jobs_spec.rb +++ b/spec/features/projects/jobs_spec.rb @@ -20,6 +20,7 @@ RSpec.describe 'Jobs', :clean_gitlab_redis_shared_state do end before do + stub_feature_flags(jobs_table_vue: false) project.add_role(user, user_access_level) sign_in(user) end @@ -32,7 +33,7 @@ RSpec.describe 'Jobs', :clean_gitlab_redis_shared_state do it 'shows the empty state page' do expect(page).to have_content('Use jobs to automate your tasks') - expect(page).to have_link('Create CI/CD configuration file', href: project.present(current_user: user).add_ci_yml_path) + expect(page).to have_link('Create CI/CD configuration file', href: project_ci_pipeline_editor_path(project)) end end @@ -1057,7 +1058,7 @@ RSpec.describe 'Jobs', :clean_gitlab_redis_shared_state do before do job.run! job.cancel! - project.update(visibility_level: Gitlab::VisibilityLevel::PUBLIC) + project.update!(visibility_level: Gitlab::VisibilityLevel::PUBLIC) sign_out(:user) sign_in(create(:user)) diff --git a/spec/features/projects/labels/user_removes_labels_spec.rb b/spec/features/projects/labels/user_removes_labels_spec.rb index 217f86b92cf..11d73a56965 100644 --- a/spec/features/projects/labels/user_removes_labels_spec.rb +++ b/spec/features/projects/labels/user_removes_labels_spec.rb @@ -18,17 +18,17 @@ RSpec.describe "User removes labels" do visit(project_labels_path(project)) end - it "removes label" do + it "removes label", :js do page.within(".other-labels") do page.first(".label-list-item") do first('.js-label-options-dropdown').click - first(".remove-row").click + first('.js-delete-label-modal-button').click end + end - expect(page).to have_content("#{label.title} will be permanently deleted from #{project.name}. This cannot be undone.") + expect(page).to have_content("#{label.title} will be permanently deleted from #{project.name}. This cannot be undone.") - first(:link, "Delete label").click - end + first(:link, "Delete label").click expect(page).to have_content("Label was removed").and have_no_content(label.title) end diff --git a/spec/features/projects/members/list_spec.rb b/spec/features/projects/members/list_spec.rb index 0830585da9b..384b8ae9929 100644 --- a/spec/features/projects/members/list_spec.rb +++ b/spec/features/projects/members/list_spec.rb @@ -175,7 +175,7 @@ RSpec.describe 'Project members list', :js do click_on 'Invite members' page.within '#invite-members-modal' do - fill_in 'Search for members to invite', with: id + fill_in 'Select members or type email addresses', with: id wait_for_requests click_button id diff --git a/spec/features/projects/members/user_requests_access_spec.rb b/spec/features/projects/members/user_requests_access_spec.rb index a339130ee3c..7073741a92d 100644 --- a/spec/features/projects/members/user_requests_access_spec.rb +++ b/spec/features/projects/members/user_requests_access_spec.rb @@ -13,7 +13,7 @@ RSpec.describe 'Projects > Members > User requests access', :js do end it 'request access feature is disabled' do - project.update(request_access_enabled: false) + project.update!(request_access_enabled: false) visit project_path(project) expect(page).not_to have_content 'Request Access' diff --git a/spec/features/projects/merge_request_button_spec.rb b/spec/features/projects/merge_request_button_spec.rb index 9547ba8a390..93bbabcc3f8 100644 --- a/spec/features/projects/merge_request_button_spec.rb +++ b/spec/features/projects/merge_request_button_spec.rb @@ -14,7 +14,9 @@ RSpec.describe 'Merge Request button' do it 'does not show Create merge request button' do visit url - expect(page).not_to have_link(label) + within '.content-wrapper' do + expect(page).not_to have_link(label) + end end end diff --git a/spec/features/projects/navbar_spec.rb b/spec/features/projects/navbar_spec.rb index 4ff3827b240..7dc3ee63669 100644 --- a/spec/features/projects/navbar_spec.rb +++ b/spec/features/projects/navbar_spec.rb @@ -13,6 +13,8 @@ RSpec.describe 'Project navbar' do before do insert_package_nav(_('Operations')) + insert_infrastructure_registry_nav + stub_config(registry: { enabled: false }) project.add_maintainer(user) sign_in(user) @@ -60,7 +62,7 @@ RSpec.describe 'Project navbar' do before do stub_config(registry: { enabled: true }) - insert_container_nav(_('Operations')) + insert_container_nav visit project_path(project) end diff --git a/spec/features/projects/new_project_spec.rb b/spec/features/projects/new_project_spec.rb index ec34640bd00..7119039d5ff 100644 --- a/spec/features/projects/new_project_spec.rb +++ b/spec/features/projects/new_project_spec.rb @@ -12,6 +12,72 @@ RSpec.describe 'New project', :js do sign_in(user) end + context 'new repo experiment', :experiment do + it 'when in control renders "project"' do + stub_experiments(new_repo: :control) + + visit new_project_path + + find('li.header-new.dropdown').click + + page.within('li.header-new.dropdown') do + expect(page).to have_selector('a', text: 'New project') + expect(page).to have_no_selector('a', text: 'New project/repository') + end + + expect(page).to have_selector('.blank-state-title', text: 'Create blank project') + expect(page).to have_no_selector('.blank-state-title', text: 'Create blank project/repository') + end + + it 'when in candidate renders "project/repository"' do + stub_experiments(new_repo: :candidate) + + visit new_project_path + + find('li.header-new.dropdown').click + + page.within('li.header-new.dropdown') do + expect(page).to have_selector('a', text: 'New project/repository') + end + + expect(page).to have_selector('.blank-state-title', text: 'Create blank project/repository') + end + + context 'with combined_menu feature disabled' do + before do + stub_feature_flags(combined_menu: false) + end + + it 'when in control it renders "project" in the new projects dropdown' do + stub_experiments(new_repo: :control) + + visit new_project_path + + find('#nav-projects-dropdown').click + + page.within('#nav-projects-dropdown') do + expect(page).to have_selector('a', text: 'Create blank project') + expect(page).to have_selector('a', text: 'Import project') + expect(page).to have_no_selector('a', text: 'Create blank project/repository') + expect(page).to have_no_selector('a', text: 'Import project/repository') + end + end + + it 'when in candidate it renders "project/repository" in the new projects dropdown' do + stub_experiments(new_repo: :candidate) + + visit new_project_path + + find('#nav-projects-dropdown').click + + page.within('#nav-projects-dropdown') do + expect(page).to have_selector('a', text: 'Create blank project/repository') + expect(page).to have_selector('a', text: 'Import project/repository') + end + end + end + end + it 'shows a message if multiple levels are restricted' do Gitlab::CurrentSettings.update!( restricted_visibility_levels: [Gitlab::VisibilityLevel::PRIVATE, Gitlab::VisibilityLevel::INTERNAL] diff --git a/spec/features/projects/pages/user_edits_settings_spec.rb b/spec/features/projects/pages/user_edits_settings_spec.rb index 6156b5243de..412ba17cf20 100644 --- a/spec/features/projects/pages/user_edits_settings_spec.rb +++ b/spec/features/projects/pages/user_edits_settings_spec.rb @@ -175,7 +175,6 @@ RSpec.describe 'Pages edits pages settings', :js do expect(page).not_to have_field(:project_pages_https_only) expect(page).not_to have_content('Force HTTPS (requires valid certificates)') - expect(page).to have_button('Save') end end end diff --git a/spec/features/projects/pipelines/pipeline_spec.rb b/spec/features/projects/pipelines/pipeline_spec.rb index 94800717677..4a0581bb5cf 100644 --- a/spec/features/projects/pipelines/pipeline_spec.rb +++ b/spec/features/projects/pipelines/pipeline_spec.rb @@ -566,7 +566,7 @@ RSpec.describe 'Pipeline', :js do end before do - pipeline.update(user: user) + pipeline.update!(user: user) end it 'shows the pipeline information' do @@ -628,7 +628,7 @@ RSpec.describe 'Pipeline', :js do context 'when user does not have access to read jobs' do before do - project.update(public_builds: false) + project.update!(public_builds: false) end describe 'GET /:project/-/pipelines/:id' do @@ -709,9 +709,9 @@ RSpec.describe 'Pipeline', :js do end end - it 'displays the PipelineSchedule in an active state' do + it 'displays the PipelineSchedule in an inactive state' do visit project_pipeline_schedules_path(project) - page.click_link('Active') + page.click_link('Inactive') expect(page).to have_selector('table.ci-table > tbody > tr > td', text: 'blocked user schedule') end @@ -1185,7 +1185,7 @@ RSpec.describe 'Pipeline', :js do let(:role) { :guest } before do - project.update(public_builds: false) + project.update!(public_builds: false) end context 'when accessing failed jobs page' do diff --git a/spec/features/projects/pipelines/pipelines_spec.rb b/spec/features/projects/pipelines/pipelines_spec.rb index 9037aa5c9a8..e375bc10dbf 100644 --- a/spec/features/projects/pipelines/pipelines_spec.rb +++ b/spec/features/projects/pipelines/pipelines_spec.rb @@ -14,7 +14,6 @@ RSpec.describe 'Pipelines', :js do sign_in(user) stub_feature_flags(graphql_pipeline_details: false) stub_feature_flags(graphql_pipeline_details_users: false) - stub_feature_flags(new_pipelines_table: false) project.add_developer(user) project.update!(auto_devops_attributes: { enabled: false }) @@ -94,12 +93,12 @@ RSpec.describe 'Pipelines', :js do wait_for_requests end - it 'renders run pipeline link' do - expect(page).to have_link('Run Pipeline') + it 'renders "CI lint" link' do + expect(page).to have_link('CI lint') end - it 'renders ci lint link' do - expect(page).to have_link('CI Lint') + it 'renders "Run pipeline" link' do + expect(page).to have_link('Run pipeline') end end @@ -534,7 +533,7 @@ RSpec.describe 'Pipelines', :js do end it 'renders a mini pipeline graph' do - expect(page).to have_selector('[data-testid="widget-mini-pipeline-graph"]') + expect(page).to have_selector('[data-testid="pipeline-mini-graph"]') expect(page).to have_selector(dropdown_selector) end @@ -677,7 +676,7 @@ RSpec.describe 'Pipelines', :js do end it 'creates a new pipeline' do - expect { click_on 'Run Pipeline' } + expect { click_on 'Run pipeline' } .to change { Ci::Pipeline.count }.by(1) expect(Ci::Pipeline.last).to be_web @@ -690,7 +689,7 @@ RSpec.describe 'Pipelines', :js do fill_in "Input variable value", with: "value" end - expect { click_on 'Run Pipeline' } + expect { click_on 'Run pipeline' } .to change { Ci::Pipeline.count }.by(1) expect(Ci::Pipeline.last.variables.map { |var| var.slice(:key, :secret_value) }) @@ -701,7 +700,7 @@ RSpec.describe 'Pipelines', :js do context 'without gitlab-ci.yml' do before do - click_on 'Run Pipeline' + click_on 'Run pipeline' end it { expect(page).to have_content('Missing CI config file') } @@ -714,44 +713,13 @@ RSpec.describe 'Pipelines', :js do click_link 'master' end - expect { click_on 'Run Pipeline' } + expect { click_on 'Run pipeline' } .to change { Ci::Pipeline.count }.by(1) end end end end - describe 'Run Pipelines' do - let(:project) { create(:project, :repository) } - - before do - stub_feature_flags(new_pipeline_form: false) - 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('.js-branch-select') - expect(find('.js-branch-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 '.dropdown-menu' do - find('.dropdown-input-field').native.send_keys('fix') - - page.within '.dropdown-content' do - expect(page).to have_content('fix') - end - end - end - end - end - describe 'Reset runner caches' do let(:project) { create(:project, :repository) } @@ -762,17 +730,17 @@ RSpec.describe 'Pipelines', :js do end it 'has a clear caches button' do - expect(page).to have_button 'Clear Runner Caches' + 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) + project.update!(jobs_cache_index: 1) end it 'increments jobs_cache_index' do - click_button 'Clear Runner Caches' + click_button 'Clear runner caches' wait_for_requests expect(page.find('.flash-notice')).to have_content 'Project cache successfully reset.' end @@ -780,7 +748,7 @@ RSpec.describe 'Pipelines', :js do context 'when project does not have jobs_cache_index' do it 'sets jobs_cache_index to 1' do - click_button 'Clear Runner Caches' + click_button 'Clear runner caches' wait_for_requests expect(page.find('.flash-notice')).to have_content 'Project cache successfully reset.' end @@ -788,6 +756,37 @@ RSpec.describe 'Pipelines', :js do end end + describe 'Run Pipelines' do + let(:project) { create(:project, :repository) } + + before do + stub_feature_flags(new_pipeline_form: false) + 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('.js-branch-select') + expect(find('.js-branch-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 '.dropdown-menu' do + find('.dropdown-input-field').native.send_keys('fix') + + page.within '.dropdown-content' do + expect(page).to have_content('fix') + end + end + end + end + end + describe 'Empty State' do let(:project) { create(:project, :repository) } diff --git a/spec/features/projects/releases/user_views_edit_release_spec.rb b/spec/features/projects/releases/user_views_edit_release_spec.rb index bb54b6be9c4..024c0a227c5 100644 --- a/spec/features/projects/releases/user_views_edit_release_spec.rb +++ b/spec/features/projects/releases/user_views_edit_release_spec.rb @@ -37,7 +37,7 @@ RSpec.describe 'User edits Release', :js do end it 'renders the edit Release form' do - expect(page).to have_content('Releases are based on Git tags. We recommend tags that use semantic versioning, for example v1.0, v2.0-pre.') + expect(page).to have_content('Releases are based on Git tags. We recommend tags that use semantic versioning, for example v1.0.0, v2.1.0-pre.') expect(find_field('Tag name', disabled: true).value).to eq(release.tag) expect(find_field('Release title').value).to eq(release.name) diff --git a/spec/features/projects/releases/user_views_release_spec.rb b/spec/features/projects/releases/user_views_release_spec.rb index 186122536ce..4410f345e56 100644 --- a/spec/features/projects/releases/user_views_release_spec.rb +++ b/spec/features/projects/releases/user_views_release_spec.rb @@ -5,7 +5,6 @@ require 'spec_helper' RSpec.describe 'User views Release', :js do let(:project) { create(:project, :repository) } let(:user) { create(:user) } - let(:graphql_feature_flag) { true } let(:release) do create(:release, @@ -15,8 +14,6 @@ RSpec.describe 'User views Release', :js do end before do - stub_feature_flags(graphql_individual_release_page: graphql_feature_flag) - project.add_developer(user) sign_in(user) @@ -26,35 +23,23 @@ RSpec.describe 'User views Release', :js do it_behaves_like 'page meta description', 'Lorem ipsum dolor sit amet' - shared_examples 'release page' do - it 'renders the breadcrumbs' do - within('.breadcrumbs') do - expect(page).to have_content("#{project.creator.name} #{project.name} Releases #{release.name}") - - expect(page).to have_link(project.creator.name, href: user_path(project.creator)) - expect(page).to have_link(project.name, href: project_path(project)) - expect(page).to have_link('Releases', href: project_releases_path(project)) - expect(page).to have_link(release.name, href: project_release_path(project, release)) - end - end + it 'renders the breadcrumbs' do + within('.breadcrumbs') do + expect(page).to have_content("#{project.creator.name} #{project.name} Releases #{release.name}") - it 'renders the release details' do - within('.release-block') do - expect(page).to have_content(release.name) - expect(page).to have_content(release.tag) - expect(page).to have_content(release.commit.short_id) - expect(page).to have_content('Lorem ipsum dolor sit amet') - end + expect(page).to have_link(project.creator.name, href: user_path(project.creator)) + expect(page).to have_link(project.name, href: project_path(project)) + expect(page).to have_link('Releases', href: project_releases_path(project)) + expect(page).to have_link(release.name, href: project_release_path(project, release)) end end - describe 'when the graphql_individual_release_page feature flag is enabled' do - it_behaves_like 'release page' - end - - describe 'when the graphql_individual_release_page feature flag is disabled' do - let(:graphql_feature_flag) { false } - - it_behaves_like 'release page' + it 'renders the release details' do + within('.release-block') do + expect(page).to have_content(release.name) + expect(page).to have_content(release.tag) + expect(page).to have_content(release.commit.short_id) + expect(page).to have_content('Lorem ipsum dolor sit amet') + end end end diff --git a/spec/features/projects/remote_mirror_spec.rb b/spec/features/projects/remote_mirror_spec.rb index 26d27c914cc..7bbffe627f6 100644 --- a/spec/features/projects/remote_mirror_spec.rb +++ b/spec/features/projects/remote_mirror_spec.rb @@ -15,7 +15,7 @@ RSpec.describe 'Project remote mirror', :feature do context 'when last_error is present but last_update_at is not' do it 'renders error message without timstamp' do - remote_mirror.update(last_error: 'Some new error', last_update_at: nil) + remote_mirror.update!(last_error: 'Some new error', last_update_at: nil) visit project_mirror_path(project) @@ -25,7 +25,7 @@ RSpec.describe 'Project remote mirror', :feature do context 'when last_error and last_update_at are present' do it 'renders error message with timestamp' do - remote_mirror.update(last_error: 'Some new error', last_update_at: Time.now - 5.minutes) + remote_mirror.update!(last_error: 'Some new error', last_update_at: Time.now - 5.minutes) visit project_mirror_path(project) diff --git a/spec/features/projects/services/disable_triggers_spec.rb b/spec/features/projects/services/disable_triggers_spec.rb index b3a3d7f0622..d9e200cf563 100644 --- a/spec/features/projects/services/disable_triggers_spec.rb +++ b/spec/features/projects/services/disable_triggers_spec.rb @@ -12,10 +12,10 @@ RSpec.describe 'Disable individual triggers', :js do end context 'service has multiple supported events' do - let(:service_name) { 'HipChat' } + let(:service_name) { 'Jenkins' } it 'shows trigger checkboxes' do - event_count = HipchatService.supported_events.count + event_count = JenkinsService.supported_events.count expect(page).to have_content "Trigger" expect(page).to have_css(checkbox_selector, visible: :all, count: event_count) diff --git a/spec/features/projects/services/user_activates_asana_spec.rb b/spec/features/projects/services/user_activates_asana_spec.rb index e95e7e89fc2..cf2290383e8 100644 --- a/spec/features/projects/services/user_activates_asana_spec.rb +++ b/spec/features/projects/services/user_activates_asana_spec.rb @@ -7,7 +7,7 @@ RSpec.describe 'User activates Asana' do it 'activates service', :js do visit_project_integration('Asana') - fill_in('Api key', with: 'verySecret') + fill_in('API key', with: 'verySecret') fill_in('Restrict to branch', with: 'verySecret') click_test_then_save_integration diff --git a/spec/features/projects/services/user_activates_atlassian_bamboo_ci_spec.rb b/spec/features/projects/services/user_activates_atlassian_bamboo_ci_spec.rb index a9d91454670..91db375be3a 100644 --- a/spec/features/projects/services/user_activates_atlassian_bamboo_ci_spec.rb +++ b/spec/features/projects/services/user_activates_atlassian_bamboo_ci_spec.rb @@ -10,19 +10,20 @@ RSpec.describe 'User activates Atlassian Bamboo CI' do end it 'activates service', :js do - visit_project_integration('Atlassian Bamboo CI') - fill_in('Bamboo url', with: 'http://bamboo.example.com') + visit_project_integration('Atlassian Bamboo') + fill_in('Bamboo URL', with: 'http://bamboo.example.com') fill_in('Build key', with: 'KEY') fill_in('Username', with: 'user') fill_in('Password', with: 'verySecret') click_test_then_save_integration(expect_test_to_fail: false) - expect(page).to have_content('Atlassian Bamboo CI settings saved and active.') + expect(page).to have_content('Atlassian Bamboo settings saved and active.') # Password field should not be filled in. - click_link('Atlassian Bamboo CI') + click_link('Atlassian Bamboo') - expect(find_field('Enter new Password').value).to be_blank + expect(find_field('Enter new password').value).to be_blank + expect(page).to have_content('Leave blank to use your current password') end end diff --git a/spec/features/projects/services/user_activates_hipchat_spec.rb b/spec/features/projects/services/user_activates_hipchat_spec.rb deleted file mode 100644 index cffb780e05d..00000000000 --- a/spec/features/projects/services/user_activates_hipchat_spec.rb +++ /dev/null @@ -1,40 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -RSpec.describe 'User activates HipChat', :js do - include_context 'project service activation' - - context 'with standard settings' do - before do - stub_request(:post, /.*api.hipchat.com.*/) - end - - it 'activates service' do - visit_project_integration('HipChat') - fill_in('Room', with: 'gitlab') - fill_in('Token', with: 'verySecret') - - click_test_then_save_integration(expect_test_to_fail: false) - - expect(page).to have_content('HipChat settings saved and active.') - end - end - - context 'with custom settings' do - before do - stub_request(:post, /.*chat.example.com.*/) - end - - it 'activates service' do - visit_project_integration('HipChat') - fill_in('Room', with: 'gitlab_custom') - fill_in('Token', with: 'secretCustom') - fill_in('Server', with: 'https://chat.example.com') - - click_test_then_save_integration(expect_test_to_fail: false) - - expect(page).to have_content('HipChat settings saved and active.') - end - end -end diff --git a/spec/features/projects/services/user_activates_jetbrains_teamcity_ci_spec.rb b/spec/features/projects/services/user_activates_jetbrains_teamcity_ci_spec.rb index 72881054c6c..17bfe8fc1e2 100644 --- a/spec/features/projects/services/user_activates_jetbrains_teamcity_ci_spec.rb +++ b/spec/features/projects/services/user_activates_jetbrains_teamcity_ci_spec.rb @@ -10,16 +10,16 @@ RSpec.describe 'User activates JetBrains TeamCity CI' do end it 'activates service', :js do - visit_project_integration('JetBrains TeamCity CI') + visit_project_integration('JetBrains TeamCity') check('Push') check('Merge Request') - fill_in('Teamcity url', with: 'http://teamcity.example.com') + fill_in('TeamCity server URL', with: 'http://teamcity.example.com') fill_in('Build type', with: 'GitlabTest_Build') fill_in('Username', with: 'user') fill_in('Password', with: 'verySecret') click_test_then_save_integration(expect_test_to_fail: false) - expect(page).to have_content('JetBrains TeamCity CI settings saved and active.') + expect(page).to have_content('JetBrains TeamCity settings saved and active.') end end diff --git a/spec/features/projects/services/user_activates_jira_spec.rb b/spec/features/projects/services/user_activates_jira_spec.rb index 85afc54be48..10f84aae93f 100644 --- a/spec/features/projects/services/user_activates_jira_spec.rb +++ b/spec/features/projects/services/user_activates_jira_spec.rb @@ -6,12 +6,13 @@ RSpec.describe 'User activates Jira', :js do include_context 'project service activation' include_context 'project service Jira context' + before do + stub_request(:get, test_url).to_return(body: { key: 'value' }.to_json) + end + describe 'user tests Jira Service' do context 'when Jira connection test succeeds' do before do - server_info = { key: 'value' }.to_json - stub_request(:get, test_url).with(basic_auth: %w(username password)).to_return(body: server_info) - visit_project_integration('Jira') fill_form click_test_then_save_integration(expect_test_to_fail: false) @@ -81,4 +82,68 @@ RSpec.describe 'User activates Jira', :js do end end end + + describe 'issue transition settings' do + it 'using custom transitions' do + visit_project_integration('Jira') + + expect(page).to have_field('Enable Jira transitions', checked: false) + + check 'Enable Jira transitions' + + expect(page).to have_field('Move to Done', checked: true) + + fill_form + choose 'Use custom transitions' + click_save_integration + + within '[data-testid="issue-transition-mode"]' do + expect(page).to have_content('This field is required.') + end + + fill_in 'service[jira_issue_transition_id]', with: '1, 2, 3' + click_save_integration + + expect(page).to have_content('Jira settings saved and active.') + expect(project.reload.jira_service.data_fields).to have_attributes( + jira_issue_transition_automatic: false, + jira_issue_transition_id: '1, 2, 3' + ) + end + + it 'using automatic transitions' do + create(:jira_service, project: project, jira_issue_transition_automatic: false, jira_issue_transition_id: '1, 2, 3') + visit_project_integration('Jira') + + expect(page).to have_field('Enable Jira transitions', checked: true) + expect(page).to have_field('Use custom transitions', checked: true) + expect(page).to have_field('service[jira_issue_transition_id]', with: '1, 2, 3') + + choose 'Move to Done' + click_save_integration + + expect(page).to have_content('Jira settings saved and active.') + expect(project.reload.jira_service.data_fields).to have_attributes( + jira_issue_transition_automatic: true, + jira_issue_transition_id: '' + ) + end + + it 'disabling issue transitions' do + create(:jira_service, project: project, jira_issue_transition_automatic: true, jira_issue_transition_id: '1, 2, 3') + visit_project_integration('Jira') + + expect(page).to have_field('Enable Jira transitions', checked: true) + expect(page).to have_field('Move to Done', checked: true) + + uncheck 'Enable Jira transitions' + click_save_integration + + expect(page).to have_content('Jira settings saved and active.') + expect(project.reload.jira_service.data_fields).to have_attributes( + jira_issue_transition_automatic: false, + jira_issue_transition_id: '' + ) + end + end end diff --git a/spec/features/projects/services/user_activates_mattermost_slash_command_spec.rb b/spec/features/projects/services/user_activates_mattermost_slash_command_spec.rb index 88812fc188b..54a501e89a2 100644 --- a/spec/features/projects/services/user_activates_mattermost_slash_command_spec.rb +++ b/spec/features/projects/services/user_activates_mattermost_slash_command_spec.rb @@ -15,7 +15,7 @@ RSpec.describe 'Set up Mattermost slash commands', :js do let(:mattermost_enabled) { true } it 'shows a help message' do - expect(page).to have_content("This service allows users to perform common") + expect(page).to have_content("Use this service to perform common") end it 'shows a token placeholder' do diff --git a/spec/features/projects/services/user_activates_pushover_spec.rb b/spec/features/projects/services/user_activates_pushover_spec.rb index 3cfd069032a..97003ab7c2a 100644 --- a/spec/features/projects/services/user_activates_pushover_spec.rb +++ b/spec/features/projects/services/user_activates_pushover_spec.rb @@ -11,7 +11,7 @@ RSpec.describe 'User activates Pushover' do it 'activates service', :js do visit_project_integration('Pushover') - fill_in('Api key', with: 'verySecret') + fill_in('API key', with: 'verySecret') fill_in('User key', with: 'verySecret') fill_in('Device', with: 'myDevice') select('High Priority', from: 'Priority') diff --git a/spec/features/projects/services/user_activates_slack_notifications_spec.rb b/spec/features/projects/services/user_activates_slack_notifications_spec.rb index 2a880e05e0f..0cba1ee1c4c 100644 --- a/spec/features/projects/services/user_activates_slack_notifications_spec.rb +++ b/spec/features/projects/services/user_activates_slack_notifications_spec.rb @@ -25,7 +25,7 @@ RSpec.describe 'User activates Slack notifications', :js do before do service.fields - service.update( + service.update!( push_channel: 1, issue_channel: 2, merge_request_channel: 3, diff --git a/spec/features/projects/services/user_views_services_spec.rb b/spec/features/projects/services/user_views_services_spec.rb index fef6b7bd991..b936a7f38f6 100644 --- a/spec/features/projects/services/user_views_services_spec.rb +++ b/spec/features/projects/services/user_views_services_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe 'User views services' do +RSpec.describe 'User views services', :js do include_context 'project service activation' it 'shows the list of available services' do @@ -10,7 +10,7 @@ RSpec.describe 'User views services' do expect(page).to have_content('Integrations') expect(page).to have_content('Campfire') - expect(page).to have_content('HipChat') + expect(page).to have_content('Jira') expect(page).to have_content('Assembla') expect(page).to have_content('Pushover') expect(page).to have_content('Atlassian Bamboo') diff --git a/spec/features/projects/settings/access_tokens_spec.rb b/spec/features/projects/settings/access_tokens_spec.rb index 45fe19deb8e..8083c851bb7 100644 --- a/spec/features/projects/settings/access_tokens_spec.rb +++ b/spec/features/projects/settings/access_tokens_spec.rb @@ -5,7 +5,8 @@ require 'spec_helper' RSpec.describe 'Project > Settings > Access Tokens', :js do let_it_be(:user) { create(:user) } let_it_be(:bot_user) { create(:user, :project_bot) } - let_it_be(:project) { create(:project) } + let_it_be(:group) { create(:group) } + let_it_be(:project) { create(:project, group: group) } before_all do project.add_maintainer(user) @@ -33,6 +34,18 @@ RSpec.describe 'Project > Settings > Access Tokens', :js do find('#created-personal-access-token').value end + context 'when user is not a project maintainer' do + before do + project.add_developer(user) + end + + it 'does not show project access token page' do + visit project_settings_access_tokens_path(project) + + expect(page).to have_content("Page Not Found") + end + end + describe 'token creation' do it 'allows creation of a project access token' do name = 'My project access token' @@ -57,6 +70,81 @@ RSpec.describe 'Project > Settings > Access Tokens', :js do expect(active_project_access_tokens).to have_text('read_api') expect(created_project_access_token).not_to be_empty end + + context 'when token creation is not allowed' do + before do + group.namespace_settings.update_column(:resource_access_token_creation_allowed, false) + end + + it 'does not show project access token creation form' do + visit project_settings_access_tokens_path(project) + + expect(page).not_to have_selector('#new_project_access_token') + end + + it 'shows project access token creation disabled text' do + visit project_settings_access_tokens_path(project) + + expect(page).to have_text('Project access token creation is disabled in this group. You can still use and manage existing tokens.') + end + + context 'with a project in a personal namespace' do + let(:personal_project) { create(:project) } + + before do + personal_project.add_maintainer(user) + end + + it 'shows project access token creation form and text' do + visit project_settings_access_tokens_path(personal_project) + + expect(page).to have_selector('#new_project_access_token') + expect(page).to have_text('You can generate an access token scoped to this project for each application to use the GitLab API.') + end + end + + context 'group settings link' do + context 'when user is not a group owner' do + before do + group.add_developer(user) + end + + it 'does not show group settings link' do + visit project_settings_access_tokens_path(project) + + expect(page).not_to have_link('group settings', href: edit_group_path(group)) + end + end + + context 'with nested groups' do + let(:subgroup) { create(:group, parent: group) } + + context 'when user is not a top level group owner' do + before do + subgroup.add_owner(user) + end + + it 'does not show group settings link' do + visit project_settings_access_tokens_path(project) + + expect(page).not_to have_link('group settings', href: edit_group_path(group)) + end + end + end + + context 'when user is a group owner' do + before do + group.add_owner(user) + end + + it 'shows group settings link' do + visit project_settings_access_tokens_path(project) + + expect(page).to have_link('group settings', href: edit_group_path(group)) + end + end + end + end end describe 'active tokens' do @@ -83,11 +171,25 @@ RSpec.describe 'Project > Settings > Access Tokens', :js do end it 'removes expired tokens from active section' do - project_access_token.update(expires_at: 5.days.ago) + project_access_token.update!(expires_at: 5.days.ago) visit project_settings_access_tokens_path(project) expect(page).to have_selector('.settings-message') expect(no_project_access_tokens_message).to have_text(no_active_tokens_text) end + + context 'when resource access token creation is not allowed' do + before do + group.namespace_settings.update_column(:resource_access_token_creation_allowed, false) + end + + it 'allows revocation of an active token' do + visit project_settings_access_tokens_path(project) + accept_confirm { click_on 'Revoke' } + + expect(page).to have_selector('.settings-message') + expect(no_project_access_tokens_message).to have_text(no_active_tokens_text) + end + end end end diff --git a/spec/features/projects/settings/forked_project_settings_spec.rb b/spec/features/projects/settings/forked_project_settings_spec.rb index f6c25d483ad..a84516e19f9 100644 --- a/spec/features/projects/settings/forked_project_settings_spec.rb +++ b/spec/features/projects/settings/forked_project_settings_spec.rb @@ -15,7 +15,7 @@ RSpec.describe 'Projects > Settings > For a forked project', :js do end shared_examples 'project settings for a forked projects' do - it 'allows deleting the link to the forked project' do + it 'allows deleting the link to the forked project', quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/327817' do visit edit_project_path(forked_project) click_button 'Remove fork relationship' @@ -25,7 +25,8 @@ RSpec.describe 'Projects > Settings > For a forked project', :js do fill_in('confirm_name_input', with: forked_project.name) click_button('Confirm') - expect(page).to have_content('The fork relationship has been removed.') + wait_for_requests + expect(forked_project.reload.forked?).to be_falsy end end diff --git a/spec/features/projects/settings/operations_settings_spec.rb b/spec/features/projects/settings/operations_settings_spec.rb index fe0ee52e4fa..ca976997142 100644 --- a/spec/features/projects/settings/operations_settings_spec.rb +++ b/spec/features/projects/settings/operations_settings_spec.rb @@ -146,7 +146,7 @@ RSpec.describe 'Projects > Settings > For a forked project', :js do click_button('Connect') - assert_text('Connection has failed. Re-check Auth Token and try again.') + assert_text('Connection failed. Check Auth Token and try again.') end end end diff --git a/spec/features/projects/settings/registry_settings_spec.rb b/spec/features/projects/settings/registry_settings_spec.rb index 6e4082d1391..bc60cdd2f8e 100644 --- a/spec/features/projects/settings/registry_settings_spec.rb +++ b/spec/features/projects/settings/registry_settings_spec.rb @@ -39,7 +39,7 @@ RSpec.describe 'Project > Settings > CI/CD > Container registry tag expiration p select('7 days', from: 'Remove tags older than:') fill_in('Remove tags matching:', with: '.*-production') - submit_button = find('.btn.gl-button.btn-success') + submit_button = find('[data-testid="save-button"') expect(submit_button).not_to be_disabled submit_button.click end @@ -53,7 +53,7 @@ RSpec.describe 'Project > Settings > CI/CD > Container registry tag expiration p within '#js-registry-policies' do fill_in('Remove tags matching:', with: '*-production') - submit_button = find('.btn.gl-button.btn-success') + submit_button = find('[data-testid="save-button"') expect(submit_button).not_to be_disabled submit_button.click 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 397c334a2b8..ebda5c9ff59 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 @@ -2,6 +2,8 @@ require 'spec_helper' RSpec.describe 'Projects > Settings > User manages merge request settings' do + include ProjectForksHelper + let(:user) { create(:user) } let(:project) { create(:project, :public, namespace: user.namespace, path: 'gitlab', name: 'sample') } @@ -198,4 +200,36 @@ RSpec.describe 'Projects > Settings > User manages merge request settings' do expect(project.reload.project_setting.squash_option).to eq('never') end end + + describe 'target project settings' do + context 'when project is a fork' do + let_it_be(:upstream) { create(:project, :public) } + + let(:project) { fork_project(upstream, user) } + + it 'allows to change merge request target project behavior' do + expect(page).to have_content 'The default target project for merge requests' + + radio = find_field('project_project_setting_attributes_mr_default_target_self_false') + expect(radio).to be_checked + + choose('project_project_setting_attributes_mr_default_target_self_true') + + within('.merge-request-settings-form') do + find('.rspec-save-merge-request-changes') + click_on('Save changes') + end + + find('.flash-notice') + radio = find_field('project_project_setting_attributes_mr_default_target_self_true') + + expect(radio).to be_checked + expect(project.reload.project_setting.mr_default_target_self).to be_truthy + end + end + + it 'does not show target project section' do + expect(page).not_to have_content 'The default target project for merge requests' + end + end end diff --git a/spec/features/projects/settings/user_searches_in_settings_spec.rb b/spec/features/projects/settings/user_searches_in_settings_spec.rb index 4c5b39d5282..9b09958bae5 100644 --- a/spec/features/projects/settings/user_searches_in_settings_spec.rb +++ b/spec/features/projects/settings/user_searches_in_settings_spec.rb @@ -4,16 +4,42 @@ require 'spec_helper' RSpec.describe 'User searches project settings', :js do let_it_be(:user) { create(:user) } - let_it_be(:project) { create(:project, :repository, namespace: user.namespace) } + let_it_be(:project) { create(:project, :repository, namespace: user.namespace, pages_https_only: false) } before do sign_in(user) end context 'in general settings page' do - let(:visit_path) { edit_project_path(project) } + before do + visit edit_project_path(project) + end + + it_behaves_like 'can search settings', 'Naming', 'Visibility' + end + + context 'in Integrations page' do + before do + visit project_settings_integrations_path(project) + end + + it_behaves_like 'can highlight results', 'third-party applications' + end + + context 'in Webhooks page' do + before do + visit project_hooks_path(project) + end - it_behaves_like 'can search settings with feature flag check', 'Naming', 'Visibility' + it_behaves_like 'can highlight results', 'Secret token' + end + + context 'in Access Tokens page' do + before do + visit project_settings_access_tokens_path(project) + end + + it_behaves_like 'can highlight results', 'Expires at' end context 'in Repository page' do @@ -37,6 +63,16 @@ RSpec.describe 'User searches project settings', :js do visit project_settings_operations_path(project) end - it_behaves_like 'can search settings', 'Alerts', 'Error tracking' + it_behaves_like 'can search settings', 'Alert integrations', 'Error tracking' + end + + context 'in Pages page' do + before do + allow(Gitlab.config.pages).to receive(:enabled).and_return(true) + + visit project_pages_path(project) + end + + it_behaves_like 'can highlight results', 'static website' end end diff --git a/spec/features/projects/settings/user_sees_revoke_deploy_token_modal_spec.rb b/spec/features/projects/settings/user_sees_revoke_deploy_token_modal_spec.rb index d0f297d2067..eed3494ef5b 100644 --- a/spec/features/projects/settings/user_sees_revoke_deploy_token_modal_spec.rb +++ b/spec/features/projects/settings/user_sees_revoke_deploy_token_modal_spec.rb @@ -13,16 +13,10 @@ RSpec.describe 'Repository Settings > User sees revoke deploy token modal', :js sign_in(user) stub_feature_flags(ajax_new_deploy_token: project) visit(project_settings_repository_path(project)) - click_link('Revoke') + click_button('Revoke') end it 'shows the revoke deploy token modal' do expect(page).to have_content('You are about to revoke') end - - it 'closes the revoke deploy token modal with escape keypress' do - find('.modal.show').send_keys(:escape) - - expect(page).not_to have_content('You are about to revoke') - end end diff --git a/spec/features/projects/show/user_sees_deletion_failure_message_spec.rb b/spec/features/projects/show/user_sees_deletion_failure_message_spec.rb index 5e878411f6a..b7af0c29b33 100644 --- a/spec/features/projects/show/user_sees_deletion_failure_message_spec.rb +++ b/spec/features/projects/show/user_sees_deletion_failure_message_spec.rb @@ -10,7 +10,7 @@ RSpec.describe 'Projects > Show > User sees a deletion failure message' do end it 'shows error message if deletion for project fails' do - project.update(delete_error: "Something went wrong", pending_delete: false) + project.update!(delete_error: "Something went wrong", pending_delete: false) visit project_path(project) diff --git a/spec/features/projects/show/user_sees_setup_shortcut_buttons_spec.rb b/spec/features/projects/show/user_sees_setup_shortcut_buttons_spec.rb index 9b51e867156..dc551158895 100644 --- a/spec/features/projects/show/user_sees_setup_shortcut_buttons_spec.rb +++ b/spec/features/projects/show/user_sees_setup_shortcut_buttons_spec.rb @@ -226,11 +226,11 @@ RSpec.describe 'Projects > Show > User sees setup shortcut buttons' do expect(project.repository.gitlab_ci_yml).to be_nil page.within('.project-buttons') do - expect(page).to have_link('Set up CI/CD', href: presenter.add_ci_yml_path) + expect(page).to have_link('Set up CI/CD', href: project_ci_pipeline_editor_path(project)) end end - it 'no "Set up CI/CD" button if the project already has a .gitlab-ci.yml' do + it '"Set up CI/CD" button is renamed if the project already has a .gitlab-ci.yml' do Files::CreateService.new( project, project.creator, @@ -247,6 +247,7 @@ RSpec.describe 'Projects > Show > User sees setup shortcut buttons' do page.within('.project-buttons') do expect(page).not_to have_link('Set up CI/CD') + expect(page).to have_link('CI/CD configuration') end end end diff --git a/spec/features/projects/show/user_uploads_files_spec.rb b/spec/features/projects/show/user_uploads_files_spec.rb index 2030c4d998a..eb230082bfa 100644 --- a/spec/features/projects/show/user_uploads_files_spec.rb +++ b/spec/features/projects/show/user_uploads_files_spec.rb @@ -17,11 +17,17 @@ RSpec.describe 'Projects > Show > User uploads files' do context 'when a user has write access' do before do visit(project_path(project)) + + wait_for_requests end - include_examples 'it uploads and commit a new text file' + include_examples 'it uploads and commits a new text file' + + include_examples 'it uploads and commits a new image file' + + include_examples 'it uploads and commits a new pdf file' - include_examples 'it uploads and commit a new image file' + include_examples 'it uploads a file to a sub-directory' end context 'when a user does not have write access' do @@ -31,7 +37,7 @@ RSpec.describe 'Projects > Show > User uploads files' do visit(project_path(project2)) end - include_examples 'it uploads and commit a new file to a forked project' + include_examples 'it uploads and commits a new file to a forked project' end context 'when in the empty_repo_upload experiment' do diff --git a/spec/features/projects/snippets/user_comments_on_snippet_spec.rb b/spec/features/projects/snippets/user_comments_on_snippet_spec.rb index b37d40c0eed..3ccb73c88ef 100644 --- a/spec/features/projects/snippets/user_comments_on_snippet_spec.rb +++ b/spec/features/projects/snippets/user_comments_on_snippet_spec.rb @@ -29,7 +29,6 @@ RSpec.describe 'Projects > Snippets > User comments on a snippet', :js do end it 'has autocomplete' do - find('#note_note').native.send_keys('') fill_in 'note[note]', with: '@' expect(page).to have_selector('.atwho-view') diff --git a/spec/features/projects/sub_group_issuables_spec.rb b/spec/features/projects/sub_group_issuables_spec.rb index 8c1d88276df..d7614201740 100644 --- a/spec/features/projects/sub_group_issuables_spec.rb +++ b/spec/features/projects/sub_group_issuables_spec.rb @@ -16,18 +16,18 @@ RSpec.describe 'Subgroup Issuables', :js do it 'shows the full subgroup title when issues index page is empty' do visit project_issues_path(project) - expect_to_have_full_subgroup_title + expect_to_have_breadcrumb_links end it 'shows the full subgroup title when merge requests index page is empty' do visit project_merge_requests_path(project) - expect_to_have_full_subgroup_title + expect_to_have_breadcrumb_links end - def expect_to_have_full_subgroup_title - title = find('.breadcrumbs-links') + def expect_to_have_breadcrumb_links + links = find('[data-testid="breadcrumb-links"]') - expect(title).to have_content 'group subgroup project' + expect(links).to have_content 'group subgroup project' end end diff --git a/spec/features/projects/user_sees_sidebar_spec.rb b/spec/features/projects/user_sees_sidebar_spec.rb index e5ba6b503cc..ff6217d02a7 100644 --- a/spec/features/projects/user_sees_sidebar_spec.rb +++ b/spec/features/projects/user_sees_sidebar_spec.rb @@ -208,7 +208,7 @@ RSpec.describe 'Projects > User sees sidebar' do it 'shows build tab if builds are public' do project.public_builds = true - project.save + project.save! visit project_path(project) diff --git a/spec/features/projects/user_sees_user_popover_spec.rb b/spec/features/projects/user_sees_user_popover_spec.rb index 52e65deae3b..e357824a533 100644 --- a/spec/features/projects/user_sees_user_popover_spec.rb +++ b/spec/features/projects/user_sees_user_popover_spec.rb @@ -35,7 +35,7 @@ RSpec.describe 'User sees user popover', :js do end end - it "displays user popover in system note" do + it 'displays user popover in system note', :sidekiq_inline do add_note("/assign @#{user.username}") find('.system-note-message .js-user-link').hover diff --git a/spec/features/projects/user_uses_shortcuts_spec.rb b/spec/features/projects/user_uses_shortcuts_spec.rb index f97c8d820e3..b6fde19e0d4 100644 --- a/spec/features/projects/user_uses_shortcuts_spec.rb +++ b/spec/features/projects/user_uses_shortcuts_spec.rb @@ -151,7 +151,7 @@ RSpec.describe 'User uses shortcuts', :js do find('body').native.send_key('g') find('body').native.send_key('m') - expect(page).to have_active_navigation('Merge Requests') + expect(page).to have_active_navigation('Merge requests') end end |