diff options
Diffstat (limited to 'spec/features/projects')
37 files changed, 813 insertions, 211 deletions
diff --git a/spec/features/projects/badges/coverage_spec.rb b/spec/features/projects/badges/coverage_spec.rb index 5c1bc1ad239..7555e567c37 100644 --- a/spec/features/projects/badges/coverage_spec.rb +++ b/spec/features/projects/badges/coverage_spec.rb @@ -191,7 +191,7 @@ RSpec.describe 'test coverage badge' do def show_test_coverage_badge(job: nil, min_good: nil, min_acceptable: nil, min_medium: nil) visit coverage_project_badges_path(project, ref: :master, job: job, min_good: min_good, - min_acceptable: min_acceptable, min_medium: min_medium, format: :svg) + min_acceptable: min_acceptable, min_medium: min_medium, format: :svg) end def expect_coverage_badge(coverage) diff --git a/spec/features/projects/blobs/blame_spec.rb b/spec/features/projects/blobs/blame_spec.rb index 3b2b74b469e..5287d5e4f7d 100644 --- a/spec/features/projects/blobs/blame_spec.rb +++ b/spec/features/projects/blobs/blame_spec.rb @@ -14,11 +14,32 @@ RSpec.describe 'File blame', :js do wait_for_all_requests end + context 'as a developer' do + let(:user) { create(:user) } + let(:role) { :developer } + + before do + project.add_role(user, role) + sign_in(user) + end + + it 'does not display lock, replace and delete buttons' do + visit_blob_blame(path) + + expect(page).not_to have_button("Lock") + expect(page).not_to have_button("Replace") + expect(page).not_to have_button("Delete") + end + 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') + within '[data-testid="blob-content-holder"]' do + expect(page).to have_css('.blame-commit') + expect(page).not_to have_css('.gl-pagination') + expect(page).not_to have_link _('View entire blame') + end end context 'when blob length is over the blame range limit' do @@ -29,12 +50,15 @@ RSpec.describe 'File blame', :js do 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') + within '[data-testid="blob-content-holder"]' do + expect(page).to have_css('.blame-commit') + expect(page).to have_css('.gl-pagination') + expect(page).to have_link _('View entire blame') - expect(page).to have_css('#L1') - expect(page).not_to have_css('#L3') - expect(find('.page-link.active')).to have_text('1') + expect(page).to have_css('#L1') + expect(page).not_to have_css('#L3') + expect(find('.page-link.active')).to have_text('1') + end end context 'when user clicks on the next button' do @@ -45,15 +69,35 @@ RSpec.describe 'File blame', :js do 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') + within '[data-testid="blob-content-holder"]' 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 it 'correctly redirects to the prior blame page' do - find('.version-link').click + within '[data-testid="blob-content-holder"]' do + find('.version-link').click + + expect(find('.page-link.active')).to have_text('2') + end + end + end + + context 'when user clicks on View entire blame button' do + before do + visit_blob_blame(path) + end + + it 'displays the blame page without pagination' do + within '[data-testid="blob-content-holder"]' do + click_link _('View entire blame') - expect(find('.page-link.active')).to have_text('2') + expect(page).to have_css('#L1') + expect(page).to have_css('#L3') + expect(page).not_to have_css('.gl-pagination') + end end end @@ -65,8 +109,11 @@ RSpec.describe 'File blame', :js do 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') + within '[data-testid="blob-content-holder"]' do + expect(page).to have_css('.blame-commit') + expect(page).not_to have_css('.gl-pagination') + expect(page).not_to have_link _('View entire blame') + end end end end @@ -81,25 +128,29 @@ RSpec.describe 'File blame', :js do it 'displays two hundred 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') + within '[data-testid="blob-content-holder"]' do + 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('#L201') - expect(find('.page-link.active')).to have_text('1') + expect(page).to have_css('#L1') + expect(page).not_to have_css('#L201') + expect(find('.page-link.active')).to have_text('1') + end 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 hundred lines of the file with pagination' do - expect(page).not_to have_css('#L1') - expect(page).to have_css('#L201') - expect(find('.page-link.active')).to have_text('2') + within '[data-testid="blob-content-holder"]' do + find('.js-next-button').click + + expect(page).not_to have_css('#L1') + expect(page).to have_css('#L201') + expect(find('.page-link.active')).to have_text('2') + end end end end diff --git a/spec/features/projects/blobs/user_creates_new_blob_in_new_project_spec.rb b/spec/features/projects/blobs/user_creates_new_blob_in_new_project_spec.rb index 484f740faee..d2774aa74c9 100644 --- a/spec/features/projects/blobs/user_creates_new_blob_in_new_project_spec.rb +++ b/spec/features/projects/blobs/user_creates_new_blob_in_new_project_spec.rb @@ -8,6 +8,10 @@ RSpec.describe 'User creates new blob', :js do let(:user) { create(:user) } let(:project) { create(:project, :empty_repo) } + before do + stub_feature_flags(vscode_web_ide: false) + end + shared_examples 'creating a file' do it 'allows the user to add a new file in Web IDE' do visit project_path(project) diff --git a/spec/features/projects/branches/user_creates_branch_spec.rb b/spec/features/projects/branches/user_creates_branch_spec.rb index 18d083f7d88..be236b7ca7e 100644 --- a/spec/features/projects/branches/user_creates_branch_spec.rb +++ b/spec/features/projects/branches/user_creates_branch_spec.rb @@ -1,48 +1,129 @@ # frozen_string_literal: true -require "spec_helper" +require 'spec_helper' -RSpec.describe "User creates branch", :js do +RSpec.describe 'User creates branch', :js do include Spec::Support::Helpers::Features::BranchesHelpers - let(:user) { create(:user) } - let(:project) { create(:project, :repository) } + let_it_be(:group) { create(:group, :public) } + let_it_be(:user) { create(:user) } - before do - project.add_developer(user) - sign_in(user) + shared_examples 'creates new branch' do + specify do + branch_name = "deploy_keys_#{SecureRandom.hex(4)}" - visit(new_project_branch_path(project)) + create_branch(branch_name) + + expect(page).to have_content(branch_name) + end + end + + shared_examples 'renders not found page' do + specify do + expect(page).to have_title('Not Found') + expect(page).to have_content('Page Not Found') + end end - it "creates new branch" do - branch_name = "deploy_keys" + context 'when project is public with private repository' do + let_it_be(:project) { create(:project, :public, :repository, :repository_private, group: group) } - create_branch(branch_name) + context 'when user is an inherited member from the group' do + context 'and user is a guest' do + before do + group.add_guest(user) + sign_in(user) - expect(page).to have_content(branch_name) - end + visit(new_project_branch_path(project)) + end - context "when branch name is invalid" do - it "does not create new branch" do - invalid_branch_name = "1.0 stable" + it_behaves_like 'renders not found page' + end - fill_in("branch_name", with: invalid_branch_name) - page.find("body").click # defocus the branch_name input + context 'and user is a developer' do + before do + group.add_developer(user) + sign_in(user) - select_branch("master") - click_button("Create branch") + visit(new_project_branch_path(project)) + end - expect(page).to have_content("Branch name is invalid") - expect(page).to have_content("can't contain spaces") + it_behaves_like 'creates new branch' + end end end - context "when branch name already exists" do - it "does not create new branch" do - create_branch("master") + context 'when project is private' do + let_it_be(:project) { create(:project, :private, :repository, group: group) } + + context 'when user is a direct project member' do + context 'and user is a developer' do + before do + project.add_developer(user) + sign_in(user) + + visit(new_project_branch_path(project)) + end + + context 'when on new branch page' do + it 'renders I18n supported text' do + page.within('#new-branch-form') do + expect(page).to have_content(_('Branch name')) + expect(page).to have_content(_('Create from')) + expect(page).to have_content(_('Existing branch name, tag, or commit SHA')) + end + end + end + + it_behaves_like 'creates new branch' + + context 'when branch name is invalid' do + it 'does not create new branch' do + invalid_branch_name = '1.0 stable' + + fill_in('branch_name', with: invalid_branch_name) + page.find('body').click # defocus the branch_name input + + select_branch('master') + click_button('Create branch') + + expect(page).to have_content('Branch name is invalid') + expect(page).to have_content("can't contain spaces") + end + end + + context 'when branch name already exists' do + it 'does not create new branch' do + create_branch('master') + + expect(page).to have_content('Branch already exists') + end + end + end + end + + context 'when user is an inherited member from the group' do + context 'and user is a guest' do + before do + group.add_guest(user) + sign_in(user) + + visit(new_project_branch_path(project)) + end + + it_behaves_like 'renders not found page' + end + + context 'and user is a developer' do + before do + group.add_developer(user) + sign_in(user) + + visit(new_project_branch_path(project)) + end - expect(page).to have_content("Branch already exists") + it_behaves_like 'creates new branch' + end end end end diff --git a/spec/features/projects/commit/mini_pipeline_graph_spec.rb b/spec/features/projects/commit/mini_pipeline_graph_spec.rb index e472cff38ce..417e14e2376 100644 --- a/spec/features/projects/commit/mini_pipeline_graph_spec.rb +++ b/spec/features/projects/commit/mini_pipeline_graph_spec.rb @@ -27,7 +27,7 @@ RSpec.describe 'Mini Pipeline Graph in Commit View', :js do end it 'displays a mini pipeline graph' do - expect(page).to have_selector('[data-testid="commit-box-mini-graph"]') + expect(page).to have_selector('[data-testid="commit-box-pipeline-mini-graph"]') first('[data-testid="mini-pipeline-graph-dropdown"]').click @@ -35,7 +35,7 @@ RSpec.describe 'Mini Pipeline Graph in Commit View', :js do page.within '.js-builds-dropdown-list' do expect(page).to have_selector('.ci-status-icon-running') - expect(page).to have_content(build.stage) + expect(page).to have_content(build.stage_name) end build.drop diff --git a/spec/features/projects/commits/multi_view_diff_spec.rb b/spec/features/projects/commits/multi_view_diff_spec.rb index 5af2e367aed..c0e48b7b86c 100644 --- a/spec/features/projects/commits/multi_view_diff_spec.rb +++ b/spec/features/projects/commits/multi_view_diff_spec.rb @@ -11,8 +11,9 @@ RSpec.shared_examples "no multiple viewers" do |commit_ref| end RSpec.describe 'Multiple view Diffs', :js do - let(:user) { create(:user) } - let(:project) { create(:project, :repository, visibility_level: Gitlab::VisibilityLevel::PUBLIC) } + let_it_be(:user) { create(:user) } + let_it_be(:project) { create(:project, :repository, visibility_level: Gitlab::VisibilityLevel::PUBLIC) } + let(:ref) { '5d6ed1503801ca9dc28e95eeb85a7cf863527aee' } let(:path) { project_commit_path(project, ref) } let(:feature_flag_on) { false } diff --git a/spec/features/projects/environments/environment_metrics_spec.rb b/spec/features/projects/environments/environment_metrics_spec.rb index f5f4d13dd58..bf0949443de 100644 --- a/spec/features/projects/environments/environment_metrics_spec.rb +++ b/spec/features/projects/environments/environment_metrics_spec.rb @@ -30,9 +30,9 @@ RSpec.describe 'Environment > Metrics' do click_link 'Monitoring' expect(page).to have_current_path(project_metrics_dashboard_path(project, environment: environment.id)) - expect(page).to have_css('[data-qa-selector="environments_dropdown"]') # rubocop:disable QA/SelectorUsage + expect(page).to have_css('[data-testid="environments-dropdown"]') - within('[data-qa-selector="environments_dropdown"]') do # rubocop:disable QA/SelectorUsage + within('[data-testid="environments-dropdown"]') do # Click on the dropdown click_on(environment.name) @@ -59,7 +59,7 @@ RSpec.describe 'Environment > Metrics' do visit_environment(environment) click_link 'Monitoring' - expect(page).to have_css('[data-qa-selector="prometheus_graphs"]') # rubocop:disable QA/SelectorUsage + expect(page).to have_css('[data-testid="prometheus-graphs"]') end it_behaves_like 'has environment selector' diff --git a/spec/features/projects/environments/environment_spec.rb b/spec/features/projects/environments/environment_spec.rb index a53e8beb555..be4b21dfff4 100644 --- a/spec/features/projects/environments/environment_spec.rb +++ b/spec/features/projects/environments/environment_spec.rb @@ -264,9 +264,7 @@ RSpec.describe 'Environment' do let(:build) { create(:ci_build, :success, pipeline: pipeline, environment: environment.name) } let(:action) do - create(:ci_build, :manual, pipeline: pipeline, - name: 'close_app', - environment: environment.name) + create(:ci_build, :manual, pipeline: pipeline, name: 'close_app', environment: environment.name) end let(:deployment) do @@ -278,8 +276,7 @@ RSpec.describe 'Environment' do context 'when user has ability to stop environment' do let(:permissions) do - create(:protected_branch, :developers_can_merge, - name: action.ref, project: project) + create(:protected_branch, :developers_can_merge, name: action.ref, project: project) end it 'allows to stop environment', :js do diff --git a/spec/features/projects/feature_flags/user_sees_feature_flag_list_spec.rb b/spec/features/projects/feature_flags/user_sees_feature_flag_list_spec.rb index 221f07a2f75..949e530f86d 100644 --- a/spec/features/projects/feature_flags/user_sees_feature_flag_list_spec.rb +++ b/spec/features/projects/feature_flags/user_sees_feature_flag_list_spec.rb @@ -30,8 +30,7 @@ RSpec.describe 'User sees feature flag list', :js do create(:operations_scope, strategy: strat, environment_scope: 'production') end end - create(:operations_feature_flag, :new_version_flag, project: project, - name: 'my_flag', active: false) + create(:operations_feature_flag, :new_version_flag, project: project, name: 'my_flag', active: false) end it 'shows the user the first flag' do @@ -91,7 +90,7 @@ RSpec.describe 'User sees feature flag list', :js do it 'shows the empty page' do expect(page).to have_text 'Get started with feature flags' expect(page).to have_selector('.btn-confirm', text: 'New feature flag') - expect(page).to have_selector('[data-qa-selector="configure_feature_flags_button"]', text: 'Configure') # rubocop:disable QA/SelectorUsage + expect(page).to have_selector('[data-testid="ff-configure-button"]', text: 'Configure') end end end diff --git a/spec/features/projects/feature_flags/user_updates_feature_flag_spec.rb b/spec/features/projects/feature_flags/user_updates_feature_flag_spec.rb index 71c9d89fbde..eb9ac078662 100644 --- a/spec/features/projects/feature_flags/user_updates_feature_flag_spec.rb +++ b/spec/features/projects/feature_flags/user_updates_feature_flag_spec.rb @@ -18,13 +18,12 @@ RSpec.describe 'User updates feature flag', :js do context 'with a new version feature flag' do let!(:feature_flag) do - create_flag(project, 'test_flag', false, version: Operations::FeatureFlag.versions['new_version_flag'], - description: 'For testing') + create_flag(project, 'test_flag', false, + version: Operations::FeatureFlag.versions['new_version_flag'], description: 'For testing') end let!(:strategy) do - create(:operations_strategy, feature_flag: feature_flag, - name: 'default', parameters: {}) + create(:operations_strategy, feature_flag: feature_flag, name: 'default', parameters: {}) end let!(:scope) do diff --git a/spec/features/projects/files/project_owner_sees_link_to_create_license_file_in_empty_project_spec.rb b/spec/features/projects/files/project_owner_sees_link_to_create_license_file_in_empty_project_spec.rb index 0ad44f31a52..52686469243 100644 --- a/spec/features/projects/files/project_owner_sees_link_to_create_license_file_in_empty_project_spec.rb +++ b/spec/features/projects/files/project_owner_sees_link_to_create_license_file_in_empty_project_spec.rb @@ -9,6 +9,8 @@ RSpec.describe 'Projects > Files > Project owner sees a link to create a license let(:project_maintainer) { project.first_owner } before do + stub_feature_flags(vscode_web_ide: false) + sign_in(project_maintainer) end diff --git a/spec/features/projects/files/user_edits_files_spec.rb b/spec/features/projects/files/user_edits_files_spec.rb index d7460538be9..1a9c5483218 100644 --- a/spec/features/projects/files/user_edits_files_spec.rb +++ b/spec/features/projects/files/user_edits_files_spec.rb @@ -14,6 +14,8 @@ RSpec.describe 'Projects > Files > User edits files', :js do let(:user) { create(:user) } before do + stub_feature_flags(vscode_web_ide: false) + sign_in(user) end @@ -102,6 +104,21 @@ RSpec.describe 'Projects > Files > User edits files', :js do expect(page).to have_content('*.rbca') end + it 'shows loader on commit changes' do + set_default_button('edit') + click_link('.gitignore') + click_link_or_button('Edit') + + # why: We don't want the form to actually submit, so that we can assert the button's changed state + page.execute_script("document.querySelector('.js-edit-blob-form').addEventListener('submit', e => e.preventDefault())") + + find('.file-editor', match: :first) + editor_set_value('*.rbca') + click_button('Commit changes') + + expect(page).to have_button('Commit changes', disabled: true, class: 'js-commit-button-loading') + end + it 'shows the diff of an edited file' do set_default_button('edit') click_link('.gitignore') diff --git a/spec/features/projects/fork_spec.rb b/spec/features/projects/fork_spec.rb index fb27f0961b6..b8c127f0078 100644 --- a/spec/features/projects/fork_spec.rb +++ b/spec/features/projects/fork_spec.rb @@ -126,7 +126,10 @@ RSpec.describe 'Project fork' do let(:user) { create(:group_member, :maintainer, user: create(:user), group: group ).user } def submit_form - select(group.name) + find('[data-testid="select_namespace_dropdown"]').click + find('[data-testid="select_namespace_dropdown_search_field"]').fill_in(with: group.name) + click_button group.name + click_button 'Fork project' end diff --git a/spec/features/projects/jobs/user_browses_jobs_spec.rb b/spec/features/projects/jobs/user_browses_jobs_spec.rb index 289ab8cffa5..995f4a1e3d2 100644 --- a/spec/features/projects/jobs/user_browses_jobs_spec.rb +++ b/spec/features/projects/jobs/user_browses_jobs_spec.rb @@ -58,8 +58,7 @@ RSpec.describe 'User browses jobs' do context 'when a job can be canceled' do let!(:job) do - create(:ci_build, pipeline: pipeline, - stage: 'test') + create(:ci_build, pipeline: pipeline, stage: 'test') end before do @@ -81,7 +80,7 @@ RSpec.describe 'User browses jobs' do context 'when a job can be retried' do let!(:job) do create(:ci_build, pipeline: pipeline, - stage: 'test') + stage: 'test') end before do @@ -190,7 +189,7 @@ RSpec.describe 'User browses jobs' do context 'column links' do let!(:job) do create(:ci_build, pipeline: pipeline, - stage: 'test') + stage: 'test') end before do diff --git a/spec/features/projects/milestones/milestones_sorting_spec.rb b/spec/features/projects/milestones/milestones_sorting_spec.rb index 2ad820e4a06..c47350fb663 100644 --- a/spec/features/projects/milestones/milestones_sorting_spec.rb +++ b/spec/features/projects/milestones/milestones_sorting_spec.rb @@ -8,7 +8,7 @@ RSpec.describe 'Milestones sorting', :js do let(:milestones_for_sort_by) do { 'Due later' => %w[b c a], - 'Name, ascending' => %w[a b c], + 'Name, ascending' => %w[a b c], 'Name, descending' => %w[c b a], 'Start later' => %w[a c b], 'Start soon' => %w[b c a], diff --git a/spec/features/projects/navbar_spec.rb b/spec/features/projects/navbar_spec.rb index e07a5d09405..5b5f7860e43 100644 --- a/spec/features/projects/navbar_spec.rb +++ b/spec/features/projects/navbar_spec.rb @@ -49,7 +49,7 @@ RSpec.describe 'Project navbar' do stub_config(pages: { enabled: true }) insert_after_sub_nav_item( - _('Packages & Registries'), + _('Packages and registries'), within: _('Settings'), new_sub_nav_item_name: _('Pages') ) @@ -83,6 +83,8 @@ RSpec.describe 'Project navbar' do end context 'when harbor registry is available' do + let_it_be(:harbor_integration) { create(:harbor_integration, project: project) } + before do stub_feature_flags(harbor_registry_integration: true) diff --git a/spec/features/projects/new_project_spec.rb b/spec/features/projects/new_project_spec.rb index f45025d079a..7cf05242a23 100644 --- a/spec/features/projects/new_project_spec.rb +++ b/spec/features/projects/new_project_spec.rb @@ -424,9 +424,10 @@ RSpec.describe 'New project', :js do it 'keeps "Import project" tab open after form validation error' do collision_project = create(:project, name: 'test-name-collision', namespace: user.namespace) - stub_request(:get, "http://foo/bar/info/refs?service=git-upload-pack").to_return({ status: 200, - body: '001e# service=git-upload-pack', - headers: { 'Content-Type': 'application/x-git-upload-pack-advertisement' } }) + stub_request(:get, "http://foo/bar/info/refs?service=git-upload-pack").to_return( + { status: 200, + body: '001e# service=git-upload-pack', + headers: { 'Content-Type': 'application/x-git-upload-pack-advertisement' } }) fill_in 'project_import_url', with: 'http://foo/bar' fill_in 'project_name', with: collision_project.name @@ -465,9 +466,10 @@ RSpec.describe 'New project', :js do end it 'initiates import when valid repo url is provided' do - stub_request(:get, "http://foo/bar/info/refs?service=git-upload-pack").to_return({ status: 200, - body: '001e# service=git-upload-pack', - headers: { 'Content-Type': 'application/x-git-upload-pack-advertisement' } }) + stub_request(:get, "http://foo/bar/info/refs?service=git-upload-pack").to_return( + { status: 200, + body: '001e# service=git-upload-pack', + headers: { 'Content-Type': 'application/x-git-upload-pack-advertisement' } }) fill_in 'project_import_url', with: 'http://foo/bar' diff --git a/spec/features/projects/pipeline_schedules_spec.rb b/spec/features/projects/pipeline_schedules_spec.rb index 0711a30e974..dcc46f5d223 100644 --- a/spec/features/projects/pipeline_schedules_spec.rb +++ b/spec/features/projects/pipeline_schedules_spec.rb @@ -95,7 +95,7 @@ RSpec.describe 'Pipeline Schedules', :js do it 'displays the required information description' do page.within('.pipeline-schedule-table-row') do expect(page).to have_content('pipeline schedule') - expect(find(".next-run-cell time")['title']) + expect(find("[data-testid='next-run-cell'] time")['title']) .to include(pipeline_schedule.real_next_run.strftime('%b %-d, %Y')) expect(page).to have_link('master') expect(page).to have_link("##{pipeline.id}") @@ -259,7 +259,7 @@ RSpec.describe 'Pipeline Schedules', :js do click_button 'Save pipeline schedule' page.within('.pipeline-schedule-table-row:nth-child(1)') do - expect(page).to have_css(".next-run-cell time") + expect(page).to have_css("[data-testid='next-run-cell'] time") end end end diff --git a/spec/features/projects/pipelines/legacy_pipeline_spec.rb b/spec/features/projects/pipelines/legacy_pipeline_spec.rb index 14f60dfe061..250a336469c 100644 --- a/spec/features/projects/pipelines/legacy_pipeline_spec.rb +++ b/spec/features/projects/pipelines/legacy_pipeline_spec.rb @@ -73,9 +73,9 @@ RSpec.describe 'Pipeline', :js 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('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 @@ -668,9 +668,9 @@ RSpec.describe 'Pipeline', :js do 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('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 @@ -769,13 +769,17 @@ RSpec.describe 'Pipeline', :js do 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) + 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) + 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 @@ -873,8 +877,14 @@ RSpec.describe 'Pipeline', :js do 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) + 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 @@ -895,8 +905,14 @@ RSpec.describe 'Pipeline', :js do 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) + 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 @@ -1207,7 +1223,7 @@ RSpec.describe 'Pipeline', :js do subject expect(page).to have_content(failed_build.name) - expect(page).to have_content(failed_build.stage) + expect(page).to have_content(failed_build.stage_name) end it 'shows build failure logs' do @@ -1253,7 +1269,7 @@ RSpec.describe 'Pipeline', :js do subject expect(page).to have_content(failed_build.name) - expect(page).to have_content(failed_build.stage) + expect(page).to have_content(failed_build.stage_name) end it 'does not show log' do diff --git a/spec/features/projects/pipelines/legacy_pipelines_spec.rb b/spec/features/projects/pipelines/legacy_pipelines_spec.rb index eb8f2de3aba..2e0ea695ab3 100644 --- a/spec/features/projects/pipelines/legacy_pipelines_spec.rb +++ b/spec/features/projects/pipelines/legacy_pipelines_spec.rb @@ -546,8 +546,8 @@ RSpec.describe 'Pipelines', :js do context 'for a failed pipeline' do let!(:build) do create(:ci_build, :failed, pipeline: pipeline, - stage: 'build', - name: 'build') + stage: 'build', + name: 'build') end it 'displays the failure reason' do @@ -652,10 +652,10 @@ RSpec.describe 'Pipelines', :js do 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') + 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') @@ -674,6 +674,7 @@ RSpec.describe 'Pipelines', :js do let(:project) { create(:project, :repository) } before do + stub_feature_flags(run_pipeline_graphql: false) visit new_project_pipeline_path(project) end diff --git a/spec/features/projects/pipelines/pipeline_spec.rb b/spec/features/projects/pipelines/pipeline_spec.rb index cfdd851cb80..51a6fbc4d36 100644 --- a/spec/features/projects/pipelines/pipeline_spec.rb +++ b/spec/features/projects/pipelines/pipeline_spec.rb @@ -72,9 +72,9 @@ RSpec.describe 'Pipeline', :js 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('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 @@ -793,9 +793,9 @@ RSpec.describe 'Pipeline', :js do 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('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 @@ -895,12 +895,12 @@ RSpec.describe 'Pipeline', :js do let!(:test_job) do create(:ci_build, :pending, stage: 'test', name: 'test', - stage_idx: 1, pipeline: pipeline, project: project) + 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) + stage_idx: 2, pipeline: pipeline, project: project, resource_group: resource_group) end describe 'GET /:project/-/pipelines/:id' do @@ -998,8 +998,14 @@ RSpec.describe 'Pipeline', :js do 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) + 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 @@ -1126,7 +1132,7 @@ RSpec.describe 'Pipeline', :js do subject expect(page).to have_content(failed_build.name) - expect(page).to have_content(failed_build.stage) + expect(page).to have_content(failed_build.stage_name) end it 'shows build failure logs' do @@ -1172,7 +1178,7 @@ RSpec.describe 'Pipeline', :js do subject expect(page).to have_content(failed_build.name) - expect(page).to have_content(failed_build.stage) + expect(page).to have_content(failed_build.stage_name) end it 'does not show log' do diff --git a/spec/features/projects/pipelines/pipelines_spec.rb b/spec/features/projects/pipelines/pipelines_spec.rb index bf521971ae0..404e51048bc 100644 --- a/spec/features/projects/pipelines/pipelines_spec.rb +++ b/spec/features/projects/pipelines/pipelines_spec.rb @@ -536,8 +536,8 @@ RSpec.describe 'Pipelines', :js do context 'for a failed pipeline' do let!(:build) do create(:ci_build, :failed, pipeline: pipeline, - stage: 'build', - name: 'build') + stage: 'build', + name: 'build') end it 'displays the failure reason' do @@ -635,10 +635,10 @@ RSpec.describe 'Pipelines', :js do 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') + 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') @@ -656,19 +656,7 @@ RSpec.describe 'Pipelines', :js do 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 - + shared_examples 'run pipeline form with gitlab-ci.yml' do context 'with gitlab-ci.yml', :js do before do stub_ci_pipeline_to_return_yaml_file @@ -702,7 +690,9 @@ RSpec.describe 'Pipelines', :js do end end end + end + shared_examples 'run pipeline form without gitlab-ci.yml' do context 'without gitlab-ci.yml' do before do click_on 'Run pipeline' @@ -722,6 +712,51 @@ RSpec.describe 'Pipelines', :js do end end end + + # Run Pipeline form with REST endpoints + # TODO: Clean up tests when run_pipeline_graphql is enabled + context 'with feature flag disabled' do + before do + stub_feature_flags(run_pipeline_graphql: false) + 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 + + it_behaves_like 'run pipeline form with gitlab-ci.yml' + + it_behaves_like 'run pipeline form without gitlab-ci.yml' + end + end + + # Run Pipeline form with GraphQL + context 'with feature flag enabled' do + before do + stub_feature_flags(run_pipeline_graphql: true) + 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 + + it_behaves_like 'run pipeline form with gitlab-ci.yml' + + it_behaves_like 'run pipeline form without gitlab-ci.yml' + end + end end describe 'Reset runner caches' do diff --git a/spec/features/projects/releases/user_creates_release_spec.rb b/spec/features/projects/releases/user_creates_release_spec.rb index 10c4395da81..d82c4229b71 100644 --- a/spec/features/projects/releases/user_creates_release_spec.rb +++ b/spec/features/projects/releases/user_creates_release_spec.rb @@ -47,7 +47,7 @@ RSpec.describe 'User creates release', :js do fill_out_form_and_submit end - it 'creates a new release when "Create release" is clicked and redirects to the release\'s dedicated page', :aggregate_failures do + it 'creates a new release when "Create release" is clicked and redirects to the release\'s dedicated page', :aggregate_failures, :sidekiq_inline do release = project.releases.last expect(release.tag).to eq(tag_name) @@ -66,6 +66,11 @@ RSpec.describe 'User creates release', :js do expect(link.url).to eq(link_2[:url]) expect(link.name).to eq(link_2[:title]) + expect(release).not_to be_historical_release + expect(release).not_to be_upcoming_release + + expect(release.evidences.length).to eq(1) + expect(page).to have_current_path(project_release_path(project, release)) end end diff --git a/spec/features/projects/settings/merge_requests_settings_spec.rb b/spec/features/projects/settings/merge_requests_settings_spec.rb new file mode 100644 index 00000000000..ba84d8b6d1a --- /dev/null +++ b/spec/features/projects/settings/merge_requests_settings_spec.rb @@ -0,0 +1,261 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe 'Projects > Settings > Merge requests' do + include ProjectForksHelper + + let(:user) { create(:user) } + let(:project) { create(:project, :public, namespace: user.namespace, path: 'gitlab', name: 'sample') } + + before do + sign_in(user) + + visit(project_settings_merge_requests_path(project)) + end + + it 'shows "Merge commit" strategy' do + page.within '.merge-request-settings-form' do + expect(page).to have_content 'Merge commit' + end + end + + it 'shows "Merge commit with semi-linear history " strategy' do + page.within '.merge-request-settings-form' do + expect(page).to have_content 'Merge commit with semi-linear history' + end + end + + it 'shows "Fast-forward merge" strategy' do + page.within '.merge-request-settings-form' do + expect(page).to have_content 'Fast-forward merge' + end + end + + it 'shows Squash commit options', :aggregate_failures do + page.within '.merge-request-settings-form' do + expect(page).to have_content 'Do not allow' + expect(page).to have_content 'Squashing is never performed and the checkbox is hidden.' + + expect(page).to have_content 'Allow' + expect(page).to have_content 'Checkbox is visible and unselected by default.' + + expect(page).to have_content 'Encourage' + expect(page).to have_content 'Checkbox is visible and selected by default.' + + expect(page).to have_content 'Require' + end + end + + context 'when Merge Request and Pipelines are initially enabled', :js 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 threads must be resolved' + + visit edit_project_path(project) + + within('.sharing-permissions-form') do + within('[data-for="project[project_feature_attributes][merge_requests_access_level]"]') do + find('.gl-toggle').click + end + end + + find('[data-testid="project-features-save-button"]').send_keys(:return) + + visit project_settings_merge_requests_path(project) + + expect(page).to have_content('Not Found') + end + end + + context 'when Pipelines are initially disabled', :js do + before do + project.project_feature.update_attribute('builds_access_level', ProjectFeature::DISABLED) + + visit project_settings_merge_requests_path(project) + end + + 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 threads must be resolved' + + visit edit_project_path(project) + + within('.sharing-permissions-form') do + within('.project-feature-controls[data-for="project[project_feature_attributes][builds_access_level]"]') do + find('.gl-toggle').click + end + end + + find('[data-testid="project-features-save-button"]').send_keys(:return) + + visit project_settings_merge_requests_path(project) + + expect(page).to have_content 'Pipelines must succeed' + expect(page).to have_content 'All threads must be resolved' + end + end + end + + context 'when Merge Request are initially disabled', :js do + before do + project.project_feature.update_attribute('merge_requests_access_level', ProjectFeature::DISABLED) + + visit(project_settings_merge_requests_path(project)) + end + + it 'does not show the Merge Requests settings' do + expect(page).to have_content('Not Found') + + visit edit_project_path(project) + + within('.sharing-permissions-form') do + within('[data-for="project[project_feature_attributes][merge_requests_access_level]"]') do + find('.gl-toggle').click + end + end + + find('[data-testid="project-features-save-button"]').send_keys(:return) + + visit project_settings_merge_requests_path(project) + + expect(page).to have_content 'Pipelines must succeed' + expect(page).to have_content 'All threads must be resolved' + end + end + + describe 'Checkbox to enable merge request link', :js do + it 'is initially checked' do + checkbox = find_field('project_printing_merge_request_link_enabled') + expect(checkbox).to be_checked + end + + it 'when unchecked sets :printing_merge_request_link_enabled to false' do + uncheck('project_printing_merge_request_link_enabled') + within('.merge-request-settings-form') do + find('.rspec-save-merge-request-changes') + click_on('Save changes') + end + + find('.flash-notice') + checkbox = find_field('project_printing_merge_request_link_enabled') + + expect(checkbox).not_to be_checked + + project.reload + expect(project.printing_merge_request_link_enabled).to be(false) + end + end + + describe 'Checkbox to remove source branch after merge', :js do + it 'is initially checked' do + checkbox = find_field('project_remove_source_branch_after_merge') + expect(checkbox).to be_checked + end + + it 'when unchecked sets :remove_source_branch_after_merge to false' do + uncheck('project_remove_source_branch_after_merge') + within('.merge-request-settings-form') do + find('.rspec-save-merge-request-changes') + click_on('Save changes') + end + + find('.flash-notice') + checkbox = find_field('project_remove_source_branch_after_merge') + + expect(checkbox).not_to be_checked + + project.reload + expect(project.remove_source_branch_after_merge).to be(false) + end + end + + describe 'Squash commits when merging', :js do + it 'initially has :squash_option set to :default_off' do + radio = find_field('project_project_setting_attributes_squash_option_default_off') + expect(radio).to be_checked + end + + it 'allows :squash_option to be set to :default_on' do + choose('project_project_setting_attributes_squash_option_default_on') + + within('.merge-request-settings-form') do + find('.rspec-save-merge-request-changes') + click_on('Save changes') + end + + wait_for_requests + + radio = find_field('project_project_setting_attributes_squash_option_default_on') + + expect(radio).to be_checked + expect(project.reload.project_setting.squash_option).to eq('default_on') + end + + it 'allows :squash_option to be set to :always' do + choose('project_project_setting_attributes_squash_option_always') + + within('.merge-request-settings-form') do + find('.rspec-save-merge-request-changes') + click_on('Save changes') + end + + wait_for_requests + + radio = find_field('project_project_setting_attributes_squash_option_always') + + expect(radio).to be_checked + expect(project.reload.project_setting.squash_option).to eq('always') + end + + it 'allows :squash_option to be set to :never' do + choose('project_project_setting_attributes_squash_option_never') + + within('.merge-request-settings-form') do + find('.rspec-save-merge-request-changes') + click_on('Save changes') + end + + wait_for_requests + + radio = find_field('project_project_setting_attributes_squash_option_never') + + expect(radio).to be_checked + 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 + + wait_for_requests + + 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/registry_settings_cleanup_tags_spec.rb b/spec/features/projects/settings/registry_settings_cleanup_tags_spec.rb index 5a50b3de772..477c4c2e1ba 100644 --- a/spec/features/projects/settings/registry_settings_cleanup_tags_spec.rb +++ b/spec/features/projects/settings/registry_settings_cleanup_tags_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe 'Project > Settings > Packages & Registries > Container registry tag expiration policy' do +RSpec.describe 'Project > Settings > Packages and registries > Container registry tag expiration policy' do let_it_be(:user) { create(:user) } let_it_be(:project, reload: true) { create(:project, namespace: user.namespace) } @@ -20,10 +20,89 @@ RSpec.describe 'Project > Settings > Packages & Registries > Container registry end context 'as owner', :js do + it 'shows active tab on sidebar' do + subject + + expect(find('.sidebar-top-level-items > li.active')).to have_content('Settings') + expect(find('.sidebar-sub-level-items > li.active:not(.fly-out-top-item)')) + .to have_content('Packages and registries') + end + it 'shows available section' do subject expect(find('.breadcrumbs')).to have_content('Clean up image tags') + + section = find('[data-testid="container-expiration-policy-project-settings"]') + expect(section).to have_text 'Clean up image tags' + end + + it 'saves cleanup policy submit the form' do + subject + + within '[data-testid="container-expiration-policy-project-settings"]' do + select('Every day', from: 'Run cleanup') + select('50 tags per image name', from: 'Keep the most recent:') + fill_in('Keep tags matching:', with: 'stable') + select('7 days', from: 'Remove tags older than:') + fill_in('Remove tags matching:', with: '.*-production') + + submit_button = find('[data-testid="save-button"') + expect(submit_button).not_to be_disabled + submit_button.click + end + + expect(page).to have_current_path(project_settings_packages_and_registries_path(project)) + expect(find('.gl-alert-body')).to have_content('Cleanup policy successfully saved.') + end + + it 'does not save cleanup policy submit form with invalid regex' do + subject + + within '[data-testid="container-expiration-policy-project-settings"]' do + fill_in('Remove tags matching:', with: '*-production') + + submit_button = find('[data-testid="save-button"') + expect(submit_button).not_to be_disabled + submit_button.click + end + + expect(find('.gl-toast')).to have_content('Something went wrong while updating the cleanup policy.') + end + end + + context 'with a project without expiration policy', :js do + before do + project.container_expiration_policy.destroy! + end + + context 'with container_expiration_policies_enable_historic_entries enabled' do + before do + stub_application_setting(container_expiration_policies_enable_historic_entries: true) + end + + it 'displays the related section' do + subject + + within '[data-testid="container-expiration-policy-project-settings"]' do + expect(find('[data-testid="enable-toggle"]')) + .to have_content('Disabled - Tags will not be automatically deleted.') + end + end + end + + context 'with container_expiration_policies_enable_historic_entries disabled' do + before do + stub_application_setting(container_expiration_policies_enable_historic_entries: false) + end + + it 'does not display the related section' do + subject + + within '[data-testid="container-expiration-policy-project-settings"]' do + expect(find('.gl-alert-title')).to have_content('Cleanup policy for tags is disabled') + end + end end end diff --git a/spec/features/projects/settings/registry_settings_spec.rb b/spec/features/projects/settings/registry_settings_spec.rb index 1fb46c669e7..d64570cd5cc 100644 --- a/spec/features/projects/settings/registry_settings_spec.rb +++ b/spec/features/projects/settings/registry_settings_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe 'Project > Settings > Packages & Registries > Container registry tag expiration policy', :js do +RSpec.describe 'Project > Settings > Packages and registries > Container registry tag expiration policy' do let_it_be(:user) { create(:user) } let_it_be(:project, reload: true) { create(:project, namespace: user.namespace) } @@ -19,48 +19,30 @@ RSpec.describe 'Project > Settings > Packages & Registries > Container registry stub_container_registry_config(enabled: container_registry_enabled) end - context 'as owner' do - it 'shows available section' do + context 'as owner', :js do + it 'shows active tab on sidebar' do subject - settings_block = find('[data-testid="container-expiration-policy-project-settings"]') - expect(settings_block).to have_text 'Clean up image tags' + expect(find('.sidebar-top-level-items > li.active')).to have_content('Settings') + expect(find('.sidebar-sub-level-items > li.active:not(.fly-out-top-item)')) + .to have_content('Packages and registries') end - it 'saves cleanup policy submit the form' do + it 'shows available section' do subject - within '[data-testid="container-expiration-policy-project-settings"]' do - select('Every day', from: 'Run cleanup') - select('50 tags per image name', from: 'Keep the most recent:') - fill_in('Keep tags matching:', with: 'stable') - select('7 days', from: 'Remove tags older than:') - fill_in('Remove tags matching:', with: '.*-production') - - submit_button = find('[data-testid="save-button"') - expect(submit_button).not_to be_disabled - submit_button.click - end - - expect(find('.gl-toast')).to have_content('Cleanup policy successfully saved.') + settings_block = find('[data-testid="container-expiration-policy-project-settings"]') + expect(settings_block).to have_text 'Clean up image tags' end - it 'does not save cleanup policy submit form with invalid regex' do + it 'contains link to clean up image tags page' do subject - within '[data-testid="container-expiration-policy-project-settings"]' do - fill_in('Remove tags matching:', with: '*-production') - - submit_button = find('[data-testid="save-button"') - expect(submit_button).not_to be_disabled - submit_button.click - end - - expect(find('.gl-toast')).to have_content('Something went wrong while updating the cleanup policy.') + expect(page).to have_link('Edit cleanup rules', href: cleanup_image_tags_project_settings_packages_and_registries_path(project)) end end - context 'with a project without expiration policy' do + context 'with a project without expiration policy', :js do before do project.container_expiration_policy.destroy! end @@ -74,7 +56,7 @@ RSpec.describe 'Project > Settings > Packages & Registries > Container registry subject within '[data-testid="container-expiration-policy-project-settings"]' do - expect(find('[data-testid="enable-toggle"]')).to have_content('Disabled - Tags will not be automatically deleted.') + expect(page).to have_link('Set cleanup rules', href: cleanup_image_tags_project_settings_packages_and_registries_path(project)) 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 6aa59f72d2a..c76b4d0af88 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 @@ -9,29 +9,29 @@ RSpec.describe 'Projects > Settings > User manages merge request settings' do before do sign_in(user) - visit edit_project_path(project) + visit project_settings_merge_requests_path(project) end it 'shows "Merge commit" strategy' do - page.within '#js-merge-request-settings' do + page.within '.merge-request-settings-form' do expect(page).to have_content 'Merge commit' end end it 'shows "Merge commit with semi-linear history " strategy' do - page.within '#js-merge-request-settings' do + page.within '.merge-request-settings-form' do expect(page).to have_content 'Merge commit with semi-linear history' end end it 'shows "Fast-forward merge" strategy' do - page.within '#js-merge-request-settings' do + page.within '.merge-request-settings-form' do expect(page).to have_content 'Fast-forward merge' end end it 'shows Squash commit options', :aggregate_failures do - page.within '#js-merge-request-settings' do + page.within '.merge-request-settings-form' do expect(page).to have_content 'Do not allow' expect(page).to have_content 'Squashing is never performed and the checkbox is hidden.' @@ -52,30 +52,33 @@ RSpec.describe 'Projects > Settings > User manages merge request settings' do expect(page).to have_content 'Pipelines must succeed' 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 - find('[data-testid="project-features-save-button"]').send_keys(:return) - end + visit edit_project_path(project) + + find('.project-feature-controls[data-for="project[project_feature_attributes][merge_requests_access_level]"] .gl-toggle').click + find('[data-testid="project-features-save-button"]').send_keys(:return) + + visit project_settings_merge_requests_path(project) - expect(page).not_to have_content 'Pipelines must succeed' - expect(page).not_to have_content 'All threads must be resolved' + expect(page).to have_content "Page Not Found" end end context 'when Pipelines are initially disabled', :js do before do project.project_feature.update_attribute('builds_access_level', ProjectFeature::DISABLED) - visit edit_project_path(project) + visit project_settings_merge_requests_path(project) end 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 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 - find('[data-testid="project-features-save-button"]').send_keys(:return) - end + visit edit_project_path(project) + + find('.project-feature-controls[data-for="project[project_feature_attributes][builds_access_level]"] .gl-toggle').click + find('[data-testid="project-features-save-button"]').send_keys(:return) + + visit project_settings_merge_requests_path(project) expect(page).to have_content 'Pipelines must succeed' expect(page).to have_content 'All threads must be resolved' @@ -86,18 +89,22 @@ RSpec.describe 'Projects > Settings > User manages merge request settings' do context 'when Merge Request are initially disabled', :js do before do project.project_feature.update_attribute('merge_requests_access_level', ProjectFeature::DISABLED) - visit edit_project_path(project) + visit project_settings_merge_requests_path(project) end 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 threads must be resolved' + visit edit_project_path(project) + within('.sharing-permissions-form') do find('.project-feature-controls[data-for="project[project_feature_attributes][merge_requests_access_level]"] .gl-toggle').click find('[data-testid="project-features-save-button"]').send_keys(:return) end + visit project_settings_merge_requests_path(project) + expect(page).to have_content 'Pipelines must succeed' expect(page).to have_content 'All threads must be resolved' end diff --git a/spec/features/projects/settings/visibility_settings_spec.rb b/spec/features/projects/settings/visibility_settings_spec.rb index fc78b5b5769..5cb12544066 100644 --- a/spec/features/projects/settings/visibility_settings_spec.rb +++ b/spec/features/projects/settings/visibility_settings_spec.rb @@ -28,26 +28,12 @@ RSpec.describe 'Projects > Settings > Visibility settings', :js do expect(visibility_select_container).to have_content 'Only accessible by project members. Membership must be explicitly granted to each user.' end - context 'merge requests select' do - it 'hides merge requests section' do - find('.project-feature-controls[data-for="project[project_feature_attributes][merge_requests_access_level]"] .gl-toggle').click - - expect(page).to have_selector('.merge-requests-feature', visible: false) - end - - context 'given project with merge_requests_disabled access level' do - let(:project) { create(:project, :merge_requests_disabled, namespace: user.namespace) } - - it 'hides merge requests section' do - expect(page).to have_selector('.merge-requests-feature', visible: false) - end - end - end - context 'builds select' do it 'hides builds select section' do find('.project-feature-controls[data-for="project[project_feature_attributes][builds_access_level]"] .gl-toggle').click + visit project_settings_merge_requests_path(project) + expect(page).to have_selector('.builds-feature', visible: false) end @@ -55,6 +41,8 @@ RSpec.describe 'Projects > Settings > Visibility settings', :js do let(:project) { create(:project, :builds_disabled, namespace: user.namespace) } it 'hides builds select section' do + visit project_settings_merge_requests_path(project) + expect(page).to have_selector('.builds-feature', visible: false) end end diff --git a/spec/features/projects/settings/webhooks_settings_spec.rb b/spec/features/projects/settings/webhooks_settings_spec.rb index c84de7fc03f..d525544ac15 100644 --- a/spec/features/projects/settings/webhooks_settings_spec.rb +++ b/spec/features/projects/settings/webhooks_settings_spec.rb @@ -139,6 +139,12 @@ RSpec.describe 'Projects > Settings > Webhook Settings' do expect(page).to have_current_path(edit_project_hook_path(project, hook), ignore_query: true) end + + it 'does not show search settings on the hook log details' do + visit project_hook_hook_log_path(project, hook, hook_log) + + expect(page).not_to have_field(placeholder: 'Search settings', disabled: true) + end end end end diff --git a/spec/features/projects/show/user_interacts_with_stars_spec.rb b/spec/features/projects/show/user_interacts_with_stars_spec.rb index aa61b629d92..e0dd4f65010 100644 --- a/spec/features/projects/show/user_interacts_with_stars_spec.rb +++ b/spec/features/projects/show/user_interacts_with_stars_spec.rb @@ -14,14 +14,36 @@ RSpec.describe 'Projects > Show > User interacts with project stars' do end it 'toggles the star' do - find('.star-btn').click + star_project expect(page).to have_css('.star-count', text: 1) - find('.star-btn').click + unstar_project expect(page).to have_css('.star-count', text: 0) end + + it 'validates starring a project' do + project.add_owner(user) + + star_project + + visit(dashboard_projects_path) + + expect(page).to have_css('.stars', text: 1) + end + + it 'validates un-starring a project' do + project.add_owner(user) + + star_project + + unstar_project + + visit(dashboard_projects_path) + + expect(page).to have_css('.stars', text: 0) + end end context 'when user is not signed in' do @@ -38,3 +60,15 @@ RSpec.describe 'Projects > Show > User interacts with project stars' do end end end + +private + +def star_project + click_button(_('Star')) + wait_for_requests +end + +def unstar_project + click_button(_('Unstar')) + wait_for_requests +end diff --git a/spec/features/projects/show/user_sees_collaboration_links_spec.rb b/spec/features/projects/show/user_sees_collaboration_links_spec.rb index fb2f0539558..1440db141a6 100644 --- a/spec/features/projects/show/user_sees_collaboration_links_spec.rb +++ b/spec/features/projects/show/user_sees_collaboration_links_spec.rb @@ -39,7 +39,7 @@ RSpec.describe 'Projects > Show > Collaboration links', :js do # The dropdown above the tree page.within('.repo-breadcrumb') do - find('.qa-add-to-tree').click # rubocop:disable QA/SelectorUsage + find('[data-testid="add-to-tree"]').click aggregate_failures 'dropdown links above the repo tree' do expect(page).to have_link('New file') @@ -71,7 +71,7 @@ RSpec.describe 'Projects > Show > Collaboration links', :js do find_new_menu_toggle.click end - expect(page).not_to have_selector('.qa-add-to-tree') # rubocop:disable QA/SelectorUsage + expect(page).not_to have_selector('[data-testid="add-to-tree"]') expect(page).not_to have_link('Web IDE') end 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 89f6b4237a4..5056e245fed 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 @@ -288,6 +288,17 @@ RSpec.describe 'Projects > Show > User sees setup shortcut buttons' do end end + it 'no Auto DevOps button if builds feature is disabled' do + project.project_feature.update_attribute(:builds_access_level, ProjectFeature::DISABLED) + + visit project_path(project) + + page.within('.project-buttons') do + expect(page).not_to have_link('Enable Auto DevOps') + expect(page).not_to have_link('Auto DevOps enabled') + end + end + it 'no "Enable Auto DevOps" button when .gitlab-ci.yml already exists' do Files::CreateService.new( project, diff --git a/spec/features/projects/tree/create_directory_spec.rb b/spec/features/projects/tree/create_directory_spec.rb index 074469a9b55..9c950cfee6e 100644 --- a/spec/features/projects/tree/create_directory_spec.rb +++ b/spec/features/projects/tree/create_directory_spec.rb @@ -7,6 +7,8 @@ RSpec.describe 'Multi-file editor new directory', :js do let(:project) { create(:project, :repository) } before do + stub_feature_flags(vscode_web_ide: false) + project.add_maintainer(user) sign_in(user) diff --git a/spec/features/projects/tree/create_file_spec.rb b/spec/features/projects/tree/create_file_spec.rb index 85c644fa528..c0567ed4580 100644 --- a/spec/features/projects/tree/create_file_spec.rb +++ b/spec/features/projects/tree/create_file_spec.rb @@ -7,6 +7,8 @@ RSpec.describe 'Multi-file editor new file', :js do let(:project) { create(:project, :repository) } before do + stub_feature_flags(vscode_web_ide: false) + project.add_maintainer(user) sign_in(user) diff --git a/spec/features/projects/tree/tree_show_spec.rb b/spec/features/projects/tree/tree_show_spec.rb index 163e347d03d..eb0ef756b30 100644 --- a/spec/features/projects/tree/tree_show_spec.rb +++ b/spec/features/projects/tree/tree_show_spec.rb @@ -26,7 +26,7 @@ RSpec.describe 'Projects tree', :js do expect(page).to have_selector('.tree-item') expect(page).to have_content('add tests for .gitattributes custom highlighting') expect(page).not_to have_selector('[data-testid="alert-danger"]') - expect(page).not_to have_selector('[data-qa-selector="label-lfs"]', text: 'LFS') # rubocop:disable QA/SelectorUsage + expect(page).not_to have_selector('[data-testid="label-lfs"]', text: 'LFS') end it 'renders tree table for a subtree without errors' do @@ -35,7 +35,7 @@ RSpec.describe 'Projects tree', :js do expect(page).to have_selector('.tree-item') expect(page).to have_content('add spaces in whitespace file') - expect(page).not_to have_selector('[data-qa-selector="label-lfs"]', text: 'LFS') # rubocop:disable QA/SelectorUsage + expect(page).not_to have_selector('[data-testid="label-lfs"]', text: 'LFS') expect(page).not_to have_selector('[data-testid="alert-danger"]') end @@ -112,11 +112,15 @@ RSpec.describe 'Projects tree', :js do it 'renders LFS badge on blob item' do visit project_tree_path(project, File.join('master', 'files/lfs')) - expect(page).to have_selector('[data-qa-selector="label-lfs"]', text: 'LFS') # rubocop:disable QA/SelectorUsage + expect(page).to have_selector('[data-testid="label-lfs"]', text: 'LFS') end end context 'web IDE' do + before do + stub_feature_flags(vscode_web_ide: false) + end + it 'opens folder in IDE' do visit project_tree_path(project, File.join('master', 'bar')) diff --git a/spec/features/projects/tree/upload_file_spec.rb b/spec/features/projects/tree/upload_file_spec.rb index ce00483bc91..f32141d6051 100644 --- a/spec/features/projects/tree/upload_file_spec.rb +++ b/spec/features/projects/tree/upload_file_spec.rb @@ -9,6 +9,8 @@ RSpec.describe 'Multi-file editor upload file', :js do let(:img_file) { File.join(Rails.root, 'spec', 'fixtures', 'dk.png') } before do + stub_feature_flags(vscode_web_ide: false) + project.add_maintainer(user) sign_in(user) diff --git a/spec/features/projects/user_sorts_projects_spec.rb b/spec/features/projects/user_sorts_projects_spec.rb index 7c970f7ee3d..b9b28398279 100644 --- a/spec/features/projects/user_sorts_projects_spec.rb +++ b/spec/features/projects/user_sorts_projects_spec.rb @@ -24,6 +24,7 @@ RSpec.describe 'User sorts projects and order persists' do end it "is set on the group_canonical_path" do + stub_feature_flags(group_overview_tabs_vue: false) visit(group_canonical_path(group)) within '[data-testid=group_sort_by_dropdown]' do @@ -32,6 +33,7 @@ RSpec.describe 'User sorts projects and order persists' do end it "is set on the details_group_path" do + stub_feature_flags(group_overview_tabs_vue: false) visit(details_group_path(group)) within '[data-testid=group_sort_by_dropdown]' do @@ -64,6 +66,7 @@ RSpec.describe 'User sorts projects and order persists' do context 'from group homepage', :js do before do + stub_feature_flags(group_overview_tabs_vue: false) sign_in(user) visit(group_canonical_path(group)) within '[data-testid=group_sort_by_dropdown]' do @@ -77,6 +80,7 @@ RSpec.describe 'User sorts projects and order persists' do context 'from group details', :js do before do + stub_feature_flags(group_overview_tabs_vue: false) sign_in(user) visit(details_group_path(group)) within '[data-testid=group_sort_by_dropdown]' do |