diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-12-17 14:59:07 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-12-17 14:59:07 +0300 |
commit | 8b573c94895dc0ac0e1d9d59cf3e8745e8b539ca (patch) | |
tree | 544930fb309b30317ae9797a9683768705d664c4 /spec/features/projects | |
parent | 4b1de649d0168371549608993deac953eb692019 (diff) |
Add latest changes from gitlab-org/gitlab@13-7-stable-eev13.7.0-rc42
Diffstat (limited to 'spec/features/projects')
34 files changed, 624 insertions, 401 deletions
diff --git a/spec/features/projects/active_tabs_spec.rb b/spec/features/projects/active_tabs_spec.rb index 349e5f5e177..8001ce0f454 100644 --- a/spec/features/projects/active_tabs_spec.rb +++ b/spec/features/projects/active_tabs_spec.rb @@ -124,15 +124,15 @@ RSpec.describe 'Project active tab' do context 'on project Analytics' do before do - visit charts_project_graph_path(project, 'master') + visit project_cycle_analytics_path(project) end - context 'on project Analytics/Repository Analytics' do + context 'on project Analytics/Value Stream Analytics' do it_behaves_like 'page has active tab', _('Analytics') - it_behaves_like 'page has active sub tab', _('Repository') + it_behaves_like 'page has active sub tab', _('Value Stream') end - context 'on project Analytics/Cycle Analytics' do + context 'on project Analytics/"CI / CD"' do before do click_tab(_('CI / CD')) end diff --git a/spec/features/projects/blobs/balsamiq_spec.rb b/spec/features/projects/blobs/balsamiq_spec.rb new file mode 100644 index 00000000000..bce60856544 --- /dev/null +++ b/spec/features/projects/blobs/balsamiq_spec.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe 'Balsamiq file blob', :js do + let(:project) { create(:project, :public, :repository) } + + before do + visit project_blob_path(project, 'add-balsamiq-file/files/images/balsamiq.bmpr') + + wait_for_requests + end + + it 'displays Balsamiq file content' do + expect(page).to have_content("Mobile examples") + 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 6b9fd41059d..484f740faee 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 @@ -9,12 +9,9 @@ RSpec.describe 'User creates new blob', :js do let(:project) { create(:project, :empty_repo) } shared_examples 'creating a file' do - before do - sign_in(user) + it 'allows the user to add a new file in Web IDE' do visit project_path(project) - end - it 'allows the user to add a new file in Web IDE' do click_link 'New file' wait_for_requests @@ -31,6 +28,7 @@ RSpec.describe 'User creates new blob', :js do describe 'as a maintainer' do before do project.add_maintainer(user) + sign_in(user) end it_behaves_like 'creating a file' @@ -39,6 +37,11 @@ RSpec.describe 'User creates new blob', :js do describe 'as an admin' do let(:user) { create(:user, :admin) } + before do + sign_in(user) + gitlab_enable_admin_mode_sign_in(user) + end + it_behaves_like 'creating a file' end diff --git a/spec/features/projects/blobs/user_follows_pipeline_suggest_nudge_spec.rb b/spec/features/projects/blobs/user_follows_pipeline_suggest_nudge_spec.rb index 3069405ba63..1c79b2ddc38 100644 --- a/spec/features/projects/blobs/user_follows_pipeline_suggest_nudge_spec.rb +++ b/spec/features/projects/blobs/user_follows_pipeline_suggest_nudge_spec.rb @@ -5,8 +5,8 @@ require 'spec_helper' RSpec.describe 'User follows pipeline suggest nudge spec when feature is enabled', :js do include CookieHelper - let(:user) { create(:user, :admin) } let(:project) { create(:project, :empty_repo) } + let(:user) { project.owner } describe 'viewing the new blob page' do before do diff --git a/spec/features/projects/clusters/gcp_spec.rb b/spec/features/projects/clusters/gcp_spec.rb index a0519d88532..d34dde6a8f2 100644 --- a/spec/features/projects/clusters/gcp_spec.rb +++ b/spec/features/projects/clusters/gcp_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe 'Gcp Cluster', :js, :do_not_mock_admin_mode do +RSpec.describe 'Gcp Cluster', :js do include GoogleApi::CloudPlatformHelpers let(:project) { create(:project) } diff --git a/spec/features/projects/clusters_spec.rb b/spec/features/projects/clusters_spec.rb index 6c6e65005f6..6da66989b09 100644 --- a/spec/features/projects/clusters_spec.rb +++ b/spec/features/projects/clusters_spec.rb @@ -110,7 +110,7 @@ RSpec.describe 'Clusters', :js do visit project_clusters_path(project) end - it 'user sees a add cluster button ' do + it 'user sees a add cluster button' do expect(page).to have_selector('.js-add-cluster:not(.readonly)') end diff --git a/spec/features/projects/container_registry_spec.rb b/spec/features/projects/container_registry_spec.rb index 45bf35a6aab..ee453aa7bbf 100644 --- a/spec/features/projects/container_registry_spec.rb +++ b/spec/features/projects/container_registry_spec.rb @@ -94,7 +94,8 @@ RSpec.describe 'Container Registry', :js do end it('pagination navigate to the second page') do - visit_second_page + visit_next_page + expect(page).to have_content '20' end end @@ -116,22 +117,23 @@ RSpec.describe 'Container Registry', :js do context 'when there are more than 10 images' do before do - create_list(:container_repository, 12, project: project) project.container_repositories << container_repository + create_list(:container_repository, 12, project: project) + visit_container_registry end it 'shows pagination' do - expect(page).to have_css '.gl-pagination' + expect(page).to have_css '.gl-keyset-pagination' end it 'pagination goes to second page' do - visit_second_page + visit_next_page expect(page).to have_content 'my/image' end it 'pagination is preserved after navigating back from details' do - visit_second_page + visit_next_page click_link 'my/image' breadcrumb = find '.breadcrumbs' breadcrumb.click_link 'Container Registry' @@ -148,8 +150,8 @@ RSpec.describe 'Container Registry', :js do click_link name end - def visit_second_page - pagination = find '.gl-pagination' - pagination.click_link '2' + def visit_next_page + pagination = find '.gl-keyset-pagination' + pagination.click_button 'Next' end end diff --git a/spec/features/projects/diffs/diff_show_spec.rb b/spec/features/projects/diffs/diff_show_spec.rb index 19f111a727b..747277e2562 100644 --- a/spec/features/projects/diffs/diff_show_spec.rb +++ b/spec/features/projects/diffs/diff_show_spec.rb @@ -155,10 +155,6 @@ RSpec.describe 'Diff file viewer', :js do context 'binary file that appears to be text in the first 1024 bytes' do before do - # The file we're visiting is smaller than 10 KB and we want it collapsed - # so we need to disable the size increase feature. - stub_feature_flags(gitlab_git_diff_size_limit_increase: false) - visit_commit('7b1cf4336b528e0f3d1d140ee50cafdbc703597c') end diff --git a/spec/features/projects/environments/environment_metrics_spec.rb b/spec/features/projects/environments/environment_metrics_spec.rb index 8315c821b6d..e8f197b67c2 100644 --- a/spec/features/projects/environments/environment_metrics_spec.rb +++ b/spec/features/projects/environments/environment_metrics_spec.rb @@ -22,7 +22,7 @@ RSpec.describe 'Environment > Metrics' do end around do |example| - Timecop.freeze(current_time) { example.run } + travel_to(current_time) { example.run } end shared_examples 'has environment selector' do diff --git a/spec/features/projects/environments/environments_spec.rb b/spec/features/projects/environments/environments_spec.rb index 8c032660726..27167f95104 100644 --- a/spec/features/projects/environments/environments_spec.rb +++ b/spec/features/projects/environments/environments_spec.rb @@ -12,8 +12,20 @@ RSpec.describe 'Environments page', :js do sign_in(user) end + def actions_button_selector + '[data-testid="environment-actions-button"]' + end + + def action_link_selector + '[data-testid="manual-action-link"]' + end + def stop_button_selector - %q{button[title="Stop environment"]} + 'button[title="Stop environment"]' + end + + def upcoming_deployment_content_selector + '[data-testid="upcoming-deployment-content"]' end describe 'page tabs' do @@ -187,18 +199,17 @@ RSpec.describe 'Environments page', :js do end it 'shows a play button' do - find('.js-environment-actions-dropdown').click - + find(actions_button_selector).click expect(page).to have_content(action.name) end it 'allows to play a manual action', :js do expect(action).to be_manual - find('.js-environment-actions-dropdown').click + find(actions_button_selector).click expect(page).to have_content(action.name) - expect { find('.js-manual-action-link').click } + expect { find(action_link_selector).click } .not_to change { Ci::Pipeline.count } end @@ -301,11 +312,11 @@ RSpec.describe 'Environments page', :js do end it 'has a dropdown for actionable jobs' do - expect(page).to have_selector('.dropdown-new.btn.btn-default [data-testid="play-icon"]') + expect(page).to have_selector("#{actions_button_selector} [data-testid=\"play-icon\"]") end it "has link to the delayed job's action" do - find('.js-environment-actions-dropdown').click + find(actions_button_selector).click expect(page).to have_button('delayed job') expect(page).to have_content(/\d{2}:\d{2}:\d{2}/) @@ -320,7 +331,7 @@ RSpec.describe 'Environments page', :js do end it "shows 00:00:00 as the remaining time" do - find('.js-environment-actions-dropdown').click + find(actions_button_selector).click expect(page).to have_content("00:00:00") end @@ -328,8 +339,8 @@ RSpec.describe 'Environments page', :js do context 'when user played a delayed job immediately' do before do - find('.js-environment-actions-dropdown').click - page.accept_confirm { click_button('delayed job') } + find(actions_button_selector).click + accept_confirm { find(action_link_selector).click } wait_for_requests end @@ -355,6 +366,26 @@ RSpec.describe 'Environments page', :js do expect(page).to have_content('No deployments yet') end end + + context 'when there is an upcoming deployment' do + let_it_be(:project) { create(:project, :repository) } + + let!(:deployment) do + create(:deployment, :running, + environment: environment, + sha: project.commit.id) + end + + it "renders the upcoming deployment", :aggregate_failures do + visit_environments(project) + + within(upcoming_deployment_content_selector) do + expect(page).to have_content("##{deployment.iid}") + expect(page).to have_selector("a[href=\"#{project_job_path(project, deployment.deployable)}\"]") + expect(page).to have_link(href: /#{deployment.user.username}/) + end + end + end end it 'does have a new environment button' do @@ -423,10 +454,10 @@ RSpec.describe 'Environments page', :js do expect(page).to have_content 'review-1' expect(page).to have_content 'review-2' within('.ci-table') do - within('.gl-responsive-table-row:nth-child(3)') do + within('[data-qa-selector="environment_item"]', text: 'review-1') do expect(find('.js-auto-stop').text).not_to be_empty end - within('.gl-responsive-table-row:nth-child(4)') do + within('[data-qa-selector="environment_item"]', text: 'review-2') do expect(find('.js-auto-stop').text).not_to be_empty end end diff --git a/spec/features/projects/feature_flags/user_creates_feature_flag_spec.rb b/spec/features/projects/feature_flags/user_creates_feature_flag_spec.rb index 830dda737b0..eaafc7e607b 100644 --- a/spec/features/projects/feature_flags/user_creates_feature_flag_spec.rb +++ b/spec/features/projects/feature_flags/user_creates_feature_flag_spec.rb @@ -67,118 +67,6 @@ RSpec.describe 'User creates feature flag', :js do end end - context 'with new version flags disabled' do - before do - stub_feature_flags(feature_flags_new_version: false) - end - - context 'when creates without changing scopes' do - before do - visit(new_project_feature_flag_path(project)) - set_feature_flag_info('ci_live_trace', 'For live trace') - click_button 'Create feature flag' - expect(page).to have_current_path(project_feature_flags_path(project)) - end - - it 'shows the created feature flag' do - within_feature_flag_row(1) do - expect(page.find('.feature-flag-name')).to have_content('ci_live_trace') - expect_status_toggle_button_to_be_checked - - within_feature_flag_scopes do - expect(page.find('[data-qa-selector="feature-flag-scope-info-badge"]:nth-child(1)')).to have_content('*') - end - end - end - end - - context 'when creates with disabling the default scope' do - before do - visit(new_project_feature_flag_path(project)) - set_feature_flag_info('ci_live_trace', 'For live trace') - - within_scope_row(1) do - within_status { find('.project-feature-toggle').click } - end - - click_button 'Create feature flag' - end - - it 'shows the created feature flag' do - within_feature_flag_row(1) do - expect(page.find('.feature-flag-name')).to have_content('ci_live_trace') - expect_status_toggle_button_to_be_checked - - within_feature_flag_scopes do - expect(page.find('[data-qa-selector="feature-flag-scope-muted-badge"]:nth-child(1)')).to have_content('*') - end - end - end - end - - context 'when creates with an additional scope' do - before do - visit(new_project_feature_flag_path(project)) - set_feature_flag_info('mr_train', '') - - within_scope_row(2) do - within_environment_spec do - find('.js-env-search > input').set("review/*") - find('.js-create-button').click - end - end - - within_scope_row(2) do - within_status { find('.project-feature-toggle').click } - end - - click_button 'Create feature flag' - end - - it 'shows the created feature flag' do - within_feature_flag_row(1) do - expect(page.find('.feature-flag-name')).to have_content('mr_train') - expect_status_toggle_button_to_be_checked - - within_feature_flag_scopes do - expect(page.find('[data-qa-selector="feature-flag-scope-info-badge"]:nth-child(1)')).to have_content('*') - expect(page.find('[data-qa-selector="feature-flag-scope-info-badge"]:nth-child(2)')).to have_content('review/*') - end - end - end - end - - context 'when searches an environment name for scope creation' do - let!(:environment) { create(:environment, name: 'production', project: project) } - - before do - visit(new_project_feature_flag_path(project)) - set_feature_flag_info('mr_train', '') - - within_scope_row(2) do - within_environment_spec do - find('.js-env-search > input').set('prod') - click_button 'production' - end - end - - click_button 'Create feature flag' - end - - it 'shows the created feature flag' do - within_feature_flag_row(1) do - expect(page.find('.feature-flag-name')).to have_content('mr_train') - expect_status_toggle_button_to_be_checked - - within_feature_flag_scopes do - expect(page.find('[data-qa-selector="feature-flag-scope-info-badge"]:nth-child(1)')).to have_content('*') - expect(page.find('[data-qa-selector="feature-flag-scope-muted-badge"]:nth-child(2)')).to have_content('production') - end - end - end - end - end - private def set_feature_flag_info(name, description) diff --git a/spec/features/projects/features_visibility_spec.rb b/spec/features/projects/features_visibility_spec.rb index 467adb25a17..2f0fbd29cb5 100644 --- a/spec/features/projects/features_visibility_spec.rb +++ b/spec/features/projects/features_visibility_spec.rb @@ -14,7 +14,7 @@ RSpec.describe 'Edit Project Settings' do sign_in(member) end - tools = { builds: "pipelines", issues: "issues", wiki: "wiki", snippets: "snippets", merge_requests: "merge_requests" } + tools = { builds: "pipelines", issues: "issues", wiki: "wiki", snippets: "snippets", merge_requests: "merge_requests", analytics: "analytics" } tools.each do |tool_name, shortcut_name| describe "feature #{tool_name}" do @@ -150,6 +150,7 @@ RSpec.describe 'Edit Project Settings' do before do non_member.update_attribute(:admin, true) sign_in(non_member) + gitlab_enable_admin_mode_sign_in(non_member) end it 'renders 404 if feature is disabled' do diff --git a/spec/features/projects/gfm_autocomplete_load_spec.rb b/spec/features/projects/gfm_autocomplete_load_spec.rb index b02483be489..f4cd65bcba1 100644 --- a/spec/features/projects/gfm_autocomplete_load_spec.rb +++ b/spec/features/projects/gfm_autocomplete_load_spec.rb @@ -6,7 +6,7 @@ RSpec.describe 'GFM autocomplete loading', :js do let(:project) { create(:project) } before do - sign_in(create(:admin)) + sign_in(project.owner) visit project_path(project) end diff --git a/spec/features/projects/import_export/import_file_spec.rb b/spec/features/projects/import_export/import_file_spec.rb index 83ceffa621c..af228764c17 100644 --- a/spec/features/projects/import_export/import_file_spec.rb +++ b/spec/features/projects/import_export/import_file_spec.rb @@ -28,73 +28,40 @@ RSpec.describe 'Import/Export - project import integration test', :js do let(:project_name) { 'Test Project Name' + randomHex } let(:project_path) { 'test-project-name' + randomHex } - context 'prefilled the path' do - it 'user imports an exported project successfully', :sidekiq_might_not_need_inline do - visit new_project_path + it 'user imports an exported project successfully', :sidekiq_might_not_need_inline do + visit new_project_path + click_import_project_tab + click_link 'GitLab export' - fill_in :project_name, with: project_name, visible: true - click_import_project_tab - click_link 'GitLab export' + fill_in :name, with: 'Test Project Name', visible: true + fill_in :path, with: 'test-project-path', visible: true + attach_file('file', file) - expect(page).to have_content('Import an exported GitLab project') - expect(URI.parse(current_url).query).to eq("namespace_id=#{namespace.id}&name=#{ERB::Util.url_encode(project_name)}&path=#{project_path}") + expect { click_on 'Import project' }.to change { Project.count }.by(1) - attach_file('file', file) - click_on 'Import project' - - expect(Project.count).to eq(1) - - project = Project.last - expect(project).not_to be_nil - expect(project.description).to eq("Foo Bar") - expect(project.issues).not_to be_empty - expect(project.merge_requests).not_to be_empty - expect(wiki_exists?(project)).to be true - expect(project.import_state.status).to eq('finished') - end + project = Project.last + expect(project).not_to be_nil + expect(page).to have_content("Project 'test-project-path' is being imported") end - context 'path is not prefilled' do - it 'user imports an exported project successfully', :sidekiq_might_not_need_inline do - visit new_project_path - click_import_project_tab - click_link 'GitLab export' + it 'invalid project' do + project = create(:project, namespace: user.namespace) - fill_in :name, with: 'Test Project Name', visible: true - fill_in :path, with: 'test-project-path', visible: true - attach_file('file', file) + visit new_project_path - expect { click_on 'Import project' }.to change { Project.count }.by(1) + click_import_project_tab + click_link 'GitLab export' + fill_in :name, with: project.name, visible: true + attach_file('file', file) + click_on 'Import project' - project = Project.last - expect(project).not_to be_nil - expect(page).to have_content("Project 'test-project-path' is being imported") + page.within('.flash-container') do + expect(page).to have_content('Project could not be imported') end end end - it 'invalid project' do - project = create(:project, namespace: user.namespace) - - visit new_project_path - - fill_in :project_name, with: project.name, visible: true - click_import_project_tab - click_link 'GitLab export' - attach_file('file', file) - click_on 'Import project' - - page.within('.flash-container') do - expect(page).to have_content('Project could not be imported') - end - end - - def wiki_exists?(project) - wiki = ProjectWiki.new(project) - wiki.repository.exists? && !wiki.repository.empty? - end - def click_import_project_tab - find('#import-project-tab').click + find('[data-qa-selector="import_project_link"]').click end end diff --git a/spec/features/projects/jobs/permissions_spec.rb b/spec/features/projects/jobs/permissions_spec.rb index 7f46a369dd6..b1e8127c54c 100644 --- a/spec/features/projects/jobs/permissions_spec.rb +++ b/spec/features/projects/jobs/permissions_spec.rb @@ -3,11 +3,13 @@ require 'spec_helper' RSpec.describe 'Project Jobs Permissions' do - let(:user) { create(:user) } - let(:group) { create(:group, name: 'some group') } - let(:project) { create(:project, :repository, namespace: group) } - let(:pipeline) { create(:ci_empty_pipeline, project: project, sha: project.commit.sha, ref: 'master') } - let!(:job) { create(:ci_build, :running, :coverage, :trace_artifact, pipeline: pipeline) } + using RSpec::Parameterized::TableSyntax + + let_it_be_with_reload(:group) { create(:group, name: 'some group') } + let_it_be_with_reload(:project) { create(:project, :repository, namespace: group) } + let_it_be_with_reload(:pipeline) { create(:ci_empty_pipeline, project: project, sha: project.commit.sha, ref: 'master') } + let_it_be(:user) { create(:user) } + let_it_be(:job) { create(:ci_build, :running, :coverage, :trace_artifact, pipeline: pipeline) } before do sign_in(user) @@ -34,7 +36,7 @@ RSpec.describe 'Project Jobs Permissions' do context 'when public access for jobs is disabled' do before do - project.update(public_builds: false) + project.update!(public_builds: false) end context 'when user is a guest' do @@ -48,7 +50,7 @@ RSpec.describe 'Project Jobs Permissions' do context 'when project is internal' do before do - project.update(visibility_level: Gitlab::VisibilityLevel::INTERNAL) + project.update!(visibility_level: Gitlab::VisibilityLevel::INTERNAL) end it_behaves_like 'recent job page details responds with status', 404 @@ -58,12 +60,30 @@ RSpec.describe 'Project Jobs Permissions' do context 'when public access for jobs is enabled' do before do - project.update(public_builds: true) + project.update!(public_builds: true) + end + + context 'when user is a guest' do + before do + project.add_guest(user) + end + + it_behaves_like 'recent job page details responds with status', 200 + it_behaves_like 'project jobs page responds with status', 200 + end + + context 'when user is a developer' do + before do + project.add_developer(user) + end + + it_behaves_like 'recent job page details responds with status', 200 + it_behaves_like 'project jobs page responds with status', 200 end context 'when project is internal' do before do - project.update(visibility_level: Gitlab::VisibilityLevel::INTERNAL) + project.update!(visibility_level: Gitlab::VisibilityLevel::INTERNAL) end it_behaves_like 'recent job page details responds with status', 200 do @@ -89,7 +109,7 @@ RSpec.describe 'Project Jobs Permissions' do describe 'artifacts page' do context 'when recent job has artifacts available' do - before do + before_all do archive = fixture_file_upload('spec/fixtures/ci_build_artifacts.zip') create(:ci_job_artifact, :archive, file: archive, job: job) @@ -97,7 +117,7 @@ RSpec.describe 'Project Jobs Permissions' do context 'when public access for jobs is disabled' do before do - project.update(public_builds: false) + project.update!(public_builds: false) end context 'when user with guest role' do @@ -128,4 +148,124 @@ RSpec.describe 'Project Jobs Permissions' do end end end + + context 'with CI_DEBUG_TRACE' do + let_it_be(:ci_instance_variable) { create(:ci_instance_variable, key: 'CI_DEBUG_TRACE') } + + describe 'trace endpoint' do + let_it_be(:job) { create(:ci_build, :trace_artifact, pipeline: pipeline) } + + where(:public_builds, :user_project_role, :ci_debug_trace, :expected_status_code) do + true | 'developer' | true | 200 + true | 'guest' | true | 403 + true | 'developer' | false | 200 + true | 'guest' | false | 200 + false | 'developer' | true | 200 + false | 'guest' | true | 403 + false | 'developer' | false | 200 + false | 'guest' | false | 403 + end + + with_them do + before do + ci_instance_variable.update!(value: ci_debug_trace) + project.update!(public_builds: public_builds) + project.add_role(user, user_project_role) + end + + it 'renders trace to authorized users' do + visit trace_project_job_path(project, job) + + expect(status_code).to eq(expected_status_code) + end + end + + context 'when restrict_access_to_build_debug_mode feature not enabled' do + where(:public_builds, :user_project_role, :ci_debug_trace, :expected_status_code) do + true | 'developer' | true | 200 + true | 'guest' | true | 200 + true | 'developer' | false | 200 + true | 'guest' | false | 200 + false | 'developer' | true | 200 + false | 'guest' | true | 403 + false | 'developer' | false | 200 + false | 'guest' | false | 403 + end + + with_them do + before do + stub_feature_flags(restrict_access_to_build_debug_mode: false) + ci_instance_variable.update!(value: ci_debug_trace) + project.update!(public_builds: public_builds) + project.add_role(user, user_project_role) + end + + it 'renders trace to authorized users' do + visit trace_project_job_path(project, job) + + expect(status_code).to eq(expected_status_code) + end + end + end + end + + describe 'raw page' do + let_it_be(:job) { create(:ci_build, :running, :coverage, :trace_artifact, pipeline: pipeline) } + + where(:public_builds, :user_project_role, :ci_debug_trace, :expected_status_code, :expected_msg) do + true | 'developer' | true | 200 | nil + true | 'guest' | true | 403 | 'You must have developer or higher permissions' + true | 'developer' | false | 200 | nil + true | 'guest' | false | 200 | nil + false | 'developer' | true | 200 | nil + false | 'guest' | true | 403 | 'You must have developer or higher permissions' + false | 'developer' | false | 200 | nil + false | 'guest' | false | 403 | 'The current user is not authorized to access the job log' + end + + with_them do + before do + ci_instance_variable.update!(value: ci_debug_trace) + project.update!(public_builds: public_builds) + project.add_role(user, user_project_role) + end + + it 'renders raw trace to authorized users' do + visit raw_project_job_path(project, job) + + expect(status_code).to eq(expected_status_code) + expect(page).to have_content(expected_msg) + end + end + + context 'when restrict_access_to_build_debug_mode feature not enabled' do + where(:public_builds, :user_project_role, :ci_debug_trace, :expected_status_code, :expected_msg) do + true | 'developer' | true | 200 | nil + true | 'guest' | true | 200 | nil + true | 'developer' | false | 200 | nil + true | 'guest' | false | 200 | nil + false | 'developer' | true | 200 | nil + false | 'guest' | true | 403 | 'The current user is not authorized to access the job log' + false | 'developer' | false | 200 | nil + false | 'guest' | false | 403 | 'The current user is not authorized to access the job log' + end + + with_them do + before do + stub_feature_flags(restrict_access_to_build_debug_mode: false) + ci_instance_variable.update!(value: ci_debug_trace) + project.update!(public_builds: public_builds) + project.add_role(user, user_project_role) + end + + it 'renders raw trace to authorized users' do + visit raw_project_job_path(project, job) + + expect(status_code).to eq(expected_status_code) + expect(page).to have_content(expected_msg) + end + end + end + end + end end diff --git a/spec/features/projects/jobs_spec.rb b/spec/features/projects/jobs_spec.rb index e19337e1ff5..4edda9febbe 100644 --- a/spec/features/projects/jobs_spec.rb +++ b/spec/features/projects/jobs_spec.rb @@ -25,72 +25,113 @@ RSpec.describe 'Jobs', :clean_gitlab_redis_shared_state do end describe "GET /:project/jobs" do - let!(:job) { create(:ci_build, pipeline: pipeline) } - - context "Pending scope" do + context 'with no jobs' do before do - visit project_jobs_path(project, scope: :pending) - end + stub_experiment(jobs_empty_state: experiment_active) + stub_experiment_for_subject(jobs_empty_state: in_experiment_group) - it "shows Pending tab jobs" do - expect(page).to have_selector('.nav-links li.active', text: 'Pending') - expect(page).to have_content job.short_sha - expect(page).to have_content job.ref - expect(page).to have_content job.name + visit project_jobs_path(project) end - end - context "Running scope" do - before do - job.run! - visit project_jobs_path(project, scope: :running) - end + context 'when experiment not active' do + let(:experiment_active) { false } + let(:in_experiment_group) { false } - it "shows Running tab jobs" do - expect(page).to have_selector('.nav-links li.active', text: 'Running') - expect(page).to have_content job.short_sha - expect(page).to have_content job.ref - expect(page).to have_content job.name + it 'shows the empty state control page' do + expect(page).to have_content('No jobs to show') + expect(page).to have_link('Get started with Pipelines') + end end - end - context "Finished scope" do - before do - job.run! - visit project_jobs_path(project, scope: :finished) + context 'when experiment active and user in control group' do + let(:experiment_active) { true } + let(:in_experiment_group) { false } + + it 'shows the empty state control page' do + expect(page).to have_content('No jobs to show') + expect(page).to have_link('Get started with Pipelines') + end end - it "shows Finished tab jobs" do - expect(page).to have_selector('.nav-links li.active', text: 'Finished') - expect(page).to have_content 'No jobs to show' + context 'when experiment active and user in experimental group' do + let(:experiment_active) { true } + let(:in_experiment_group) { true } + + it 'shows the empty state experiment page' do + expect(page).to have_content('Use jobs to automate your tasks') + expect(page).to have_link('Create CI/CD configuration file') + end end end - context "All jobs" do - before do - project.builds.running_or_pending.each(&:success) - visit project_jobs_path(project) + context 'with a job' do + let!(:job) { create(:ci_build, pipeline: pipeline) } + + context "Pending scope" do + before do + visit project_jobs_path(project, scope: :pending) + end + + it "shows Pending tab jobs" do + expect(page).to have_selector('.nav-links li.active', text: 'Pending') + expect(page).to have_content job.short_sha + expect(page).to have_content job.ref + expect(page).to have_content job.name + end end - it "shows All tab jobs" do - expect(page).to have_selector('.nav-links li.active', text: 'All') - expect(page).to have_content job.short_sha - expect(page).to have_content job.ref - expect(page).to have_content job.name + context "Running scope" do + before do + job.run! + visit project_jobs_path(project, scope: :running) + end + + it "shows Running tab jobs" do + expect(page).to have_selector('.nav-links li.active', text: 'Running') + expect(page).to have_content job.short_sha + expect(page).to have_content job.ref + expect(page).to have_content job.name + end end - end - context "when visiting old URL" do - let(:jobs_url) do - project_jobs_path(project) + context "Finished scope" do + before do + job.run! + visit project_jobs_path(project, scope: :finished) + end + + it "shows Finished tab jobs" do + expect(page).to have_selector('.nav-links li.active', text: 'Finished') + expect(page).to have_content 'No jobs to show' + end end - before do - visit jobs_url.sub('/-/jobs', '/builds') + context "All jobs" do + before do + project.builds.running_or_pending.each(&:success) + visit project_jobs_path(project) + end + + it "shows All tab jobs" do + expect(page).to have_selector('.nav-links li.active', text: 'All') + expect(page).to have_content job.short_sha + expect(page).to have_content job.ref + expect(page).to have_content job.name + end end - it "redirects to new URL" do - expect(page.current_path).to eq(jobs_url) + context "when visiting old URL" do + let(:jobs_url) do + project_jobs_path(project) + end + + before do + visit jobs_url.sub('/-/jobs', '/builds') + end + + it "redirects to new URL" do + expect(page.current_path).to eq(jobs_url) + end end end end diff --git a/spec/features/projects/labels/issues_sorted_by_priority_spec.rb b/spec/features/projects/labels/issues_sorted_by_priority_spec.rb index 85a08c441ca..0a373b0d51a 100644 --- a/spec/features/projects/labels/issues_sorted_by_priority_spec.rb +++ b/spec/features/projects/labels/issues_sorted_by_priority_spec.rb @@ -15,7 +15,7 @@ RSpec.describe 'Issue prioritization' do # According to https://gitlab.com/gitlab-org/gitlab-foss/issues/14189#note_4360653 context 'when issues have one label', :js do - it 'Are sorted properly' do + it 'are sorted properly' do # Issues issue_1 = create(:issue, title: 'issue_1', project: project) issue_2 = create(:issue, title: 'issue_2', project: project) @@ -45,7 +45,7 @@ RSpec.describe 'Issue prioritization' do end context 'when issues have multiple labels', :js do - it 'Are sorted properly' do + it 'are sorted properly' do # Issues issue_1 = create(:issue, title: 'issue_1', project: project) issue_2 = create(:issue, title: 'issue_2', project: project) diff --git a/spec/features/projects/new_project_spec.rb b/spec/features/projects/new_project_spec.rb index 6a2ec9aa4a8..4aabf040655 100644 --- a/spec/features/projects/new_project_spec.rb +++ b/spec/features/projects/new_project_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe 'New project' do +RSpec.describe 'New project', :js do include Select2Helper context 'as a user' do @@ -18,6 +18,7 @@ RSpec.describe 'New project' do ) visit new_project_path + find('[data-qa-selector="blank_project_link"]').click expect(page).to have_content 'Other visibility settings have been disabled by the administrator.' end @@ -28,6 +29,7 @@ RSpec.describe 'New project' do ) visit new_project_path + find('[data-qa-selector="blank_project_link"]').click expect(page).to have_content 'Visibility settings have been disabled by the administrator.' end @@ -42,17 +44,18 @@ RSpec.describe 'New project' do it 'shows "New project" page', :js do visit new_project_path + find('[data-qa-selector="blank_project_link"]').click expect(page).to have_content('Project name') expect(page).to have_content('Project URL') expect(page).to have_content('Project slug') - find('#import-project-tab').click + click_link('New project') + find('[data-qa-selector="import_project_link"]').click expect(page).to have_link('GitHub') expect(page).to have_link('Bitbucket') expect(page).to have_link('GitLab.com') - expect(page).to have_link('Google Code') expect(page).to have_button('Repo by URL') expect(page).to have_link('GitLab export') end @@ -61,7 +64,7 @@ RSpec.describe 'New project' do before do visit new_project_path - find('#import-project-tab').click + find('[data-qa-selector="import_project_link"]').click end it { expect(page).to have_link('Manifest file') } @@ -73,6 +76,7 @@ RSpec.describe 'New project' do stub_application_setting(default_project_visibility: level) visit new_project_path + find('[data-qa-selector="blank_project_link"]').click page.within('#blank-project-pane') do expect(find_field("project_visibility_level_#{level}")).to be_checked end @@ -80,6 +84,7 @@ RSpec.describe 'New project' do it "saves visibility level #{level} on validation error" do visit new_project_path + find('[data-qa-selector="blank_project_link"]').click choose(s_(key)) click_button('Create project') @@ -97,6 +102,7 @@ RSpec.describe 'New project' do it 'has private selected' do group = create(:group, visibility_level: Gitlab::VisibilityLevel::PRIVATE) visit new_project_path(namespace_id: group.id) + find('[data-qa-selector="blank_project_link"]').click page.within('#blank-project-pane') do expect(find_field("project_visibility_level_#{Gitlab::VisibilityLevel::PRIVATE}")).to be_checked @@ -112,6 +118,7 @@ RSpec.describe 'New project' do it 'has private selected' do group = create(:group, visibility_level: Gitlab::VisibilityLevel::PUBLIC) visit new_project_path(namespace_id: group.id, project: { visibility_level: Gitlab::VisibilityLevel::PRIVATE }) + find('[data-qa-selector="blank_project_link"]').click page.within('#blank-project-pane') do expect(find_field("project_visibility_level_#{Gitlab::VisibilityLevel::PRIVATE}")).to be_checked @@ -123,6 +130,7 @@ RSpec.describe 'New project' do context 'Readme selector' do it 'shows the initialize with Readme checkbox on "Blank project" tab' do visit new_project_path + find('[data-qa-selector="blank_project_link"]').click expect(page).to have_css('input#project_initialize_with_readme') expect(page).to have_content('Initialize repository with a README') @@ -130,7 +138,7 @@ RSpec.describe 'New project' do it 'does not show the initialize with Readme checkbox on "Create from template" tab' do visit new_project_path - find('#create-from-template-pane').click + find('[data-qa-selector="create_from_template_link"]').click first('.choose-template').click page.within '.project-fields-form' do @@ -141,7 +149,7 @@ RSpec.describe 'New project' do it 'does not show the initialize with Readme checkbox on "Import project" tab' do visit new_project_path - find('#import-project-tab').click + find('[data-qa-selector="import_project_link"]').click first('.js-import-git-toggle-button').click page.within '.toggle-import-form' do @@ -155,13 +163,12 @@ RSpec.describe 'New project' do context 'with user namespace' do before do visit new_project_path + find('[data-qa-selector="blank_project_link"]').click end it 'selects the user namespace' do page.within('#blank-project-pane') do - namespace = find('#project_namespace_id') - - expect(namespace.text).to eq user.username + expect(page).to have_select('project[namespace_id]', visible: false, selected: user.username) end end end @@ -172,13 +179,12 @@ RSpec.describe 'New project' do before do group.add_owner(user) visit new_project_path(namespace_id: group.id) + find('[data-qa-selector="blank_project_link"]').click end it 'selects the group namespace' do page.within('#blank-project-pane') do - namespace = find('#project_namespace_id option[selected]') - - expect(namespace.text).to eq group.name + expect(page).to have_select('project[namespace_id]', visible: false, selected: group.name) end end end @@ -190,13 +196,12 @@ RSpec.describe 'New project' do before do group.add_maintainer(user) visit new_project_path(namespace_id: subgroup.id) + find('[data-qa-selector="blank_project_link"]').click end it 'selects the group namespace' do page.within('#blank-project-pane') do - namespace = find('#project_namespace_id option[selected]') - - expect(namespace.text).to eq subgroup.full_path + expect(page).to have_select('project[namespace_id]', visible: false, selected: subgroup.full_path) end end end @@ -211,6 +216,7 @@ RSpec.describe 'New project' do internal_group.add_owner(user) private_group.add_owner(user) visit new_project_path(namespace_id: public_group.id) + find('[data-qa-selector="blank_project_link"]').click end it 'enables the correct visibility options' do @@ -240,7 +246,7 @@ RSpec.describe 'New project' do context 'Import project options', :js do before do visit new_project_path - find('#import-project-tab').click + find('[data-qa-selector="import_project_link"]').click end context 'from git repository url, "Repo by URL"' do @@ -285,17 +291,6 @@ RSpec.describe 'New project' do end end - context 'from Google Code' do - before do - first('.import_google_code').click - end - - it 'shows import instructions' do - expect(page).to have_content('Import projects from Google Code') - expect(current_path).to eq new_import_google_code_path - end - end - context 'from manifest file' do before do first('.import_manifest').click @@ -315,13 +310,12 @@ RSpec.describe 'New project' do before do group.add_developer(user) visit new_project_path(namespace_id: group.id) + find('[data-qa-selector="blank_project_link"]').click end it 'selects the group namespace' do page.within('#blank-project-pane') do - namespace = find('#project_namespace_id option[selected]') - - expect(namespace.text).to eq group.full_path + expect(page).to have_select('project[namespace_id]', visible: false, selected: group.full_path) end end end diff --git a/spec/features/projects/settings/operations_settings_spec.rb b/spec/features/projects/settings/operations_settings_spec.rb index de7251db5c9..1d9f256a819 100644 --- a/spec/features/projects/settings/operations_settings_spec.rb +++ b/spec/features/projects/settings/operations_settings_spec.rb @@ -23,7 +23,7 @@ RSpec.describe 'Projects > Settings > For a forked project', :js do describe 'Settings > Operations' do describe 'Incidents' do - let(:create_issue) { 'Create an issue. Issues are created for each alert triggered.' } + let(:create_issue) { 'Create an incident. Incidents are created for each alert triggered.' } let(:send_email) { 'Send a separate email notification to Developers.' } before do diff --git a/spec/features/projects/settings/registry_settings_spec.rb b/spec/features/projects/settings/registry_settings_spec.rb index cb333bdb428..2b03ecf5af1 100644 --- a/spec/features/projects/settings/registry_settings_spec.rb +++ b/spec/features/projects/settings/registry_settings_spec.rb @@ -26,20 +26,20 @@ RSpec.describe 'Project > Settings > CI/CD > Container registry tag expiration p subject settings_block = find('#js-registry-policies') - expect(settings_block).to have_text 'Cleanup policy for tags' + expect(settings_block).to have_text 'Clean up image tags' end it 'saves cleanup policy submit the form' do subject within '#js-registry-policies' do - within '.gl-card-body' do - select('7 days until tags are automatically removed', from: 'Expiration interval:') - select('Every day', from: 'Expiration schedule:') - select('50 tags per image name', from: 'Number of tags to retain:') - fill_in('Tags with names matching this regex pattern will expire:', with: '.*-production') - end - submit_button = find('.gl-card-footer .btn.btn-success') + 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('.btn.btn-success') expect(submit_button).not_to be_disabled submit_button.click end @@ -51,10 +51,9 @@ RSpec.describe 'Project > Settings > CI/CD > Container registry tag expiration p subject within '#js-registry-policies' do - within '.gl-card-body' do - fill_in('Tags with names matching this regex pattern will expire:', with: '*-production') - end - submit_button = find('.gl-card-footer .btn.btn-success') + fill_in('Remove tags matching:', with: '*-production') + + submit_button = find('.btn.btn-success') expect(submit_button).not_to be_disabled submit_button.click end @@ -85,7 +84,7 @@ RSpec.describe 'Project > Settings > CI/CD > Container registry tag expiration p within '#js-registry-policies' do case result when :available_section - expect(find('.gl-card-header')).to have_content('Tag expiration policy') + expect(find('[data-testid="enable-toggle"]')).to have_content('Disabled - Tags will not be automatically deleted.') when :disabled_message expect(find('.gl-alert-title')).to have_content('Cleanup policy for tags is disabled') end diff --git a/spec/features/projects/settings/repository_settings_spec.rb b/spec/features/projects/settings/repository_settings_spec.rb index 8c7b7bc70a2..3e520142117 100644 --- a/spec/features/projects/settings/repository_settings_spec.rb +++ b/spec/features/projects/settings/repository_settings_spec.rb @@ -289,13 +289,13 @@ RSpec.describe 'Projects > Settings > Repository settings' do visit project_settings_repository_path(project) end - context 'when project mirroring is enabled' do + context 'when project mirroring is enabled', :enable_admin_mode do let(:mirror_available) { true } include_examples 'shows mirror settings' end - context 'when project mirroring is disabled' do + context 'when project mirroring is disabled', :enable_admin_mode do let(:mirror_available) { false } include_examples 'shows mirror settings' diff --git a/spec/features/projects/settings/service_desk_setting_spec.rb b/spec/features/projects/settings/service_desk_setting_spec.rb index 59e6f54da2f..d31913d2dcf 100644 --- a/spec/features/projects/settings/service_desk_setting_spec.rb +++ b/spec/features/projects/settings/service_desk_setting_spec.rb @@ -14,20 +14,57 @@ RSpec.describe 'Service Desk Setting', :js do allow_any_instance_of(Project).to receive(:present).with(current_user: user).and_return(presenter) allow(::Gitlab::IncomingEmail).to receive(:enabled?) { true } allow(::Gitlab::IncomingEmail).to receive(:supports_wildcard?) { true } - - visit edit_project_path(project) end it 'shows activation checkbox' do + visit edit_project_path(project) + expect(page).to have_selector("#service-desk-checkbox") end - it 'shows incoming email after activating' do - find("#service-desk-checkbox").click - wait_for_requests - project.reload - expect(project.service_desk_enabled).to be_truthy - expect(project.service_desk_address).to be_present - expect(find('[data-testid="incoming-email"]').value).to eq(project.service_desk_address) + context 'when service_desk_email is disabled' do + before do + allow(::Gitlab::ServiceDeskEmail).to receive(:enabled?).and_return(false) + + visit edit_project_path(project) + end + + it 'shows incoming email but not project name suffix after activating' do + find("#service-desk-checkbox").click + + wait_for_requests + + project.reload + expect(project.service_desk_enabled).to be_truthy + expect(project.service_desk_address).to be_present + expect(find('[data-testid="incoming-email"]').value).to eq(project.service_desk_incoming_address) + expect(page).not_to have_selector('#service-desk-project-suffix') + end + end + + context 'when service_desk_email is enabled' do + before do + allow(::Gitlab::ServiceDeskEmail).to receive(:enabled?) { true } + allow(::Gitlab::ServiceDeskEmail).to receive(:address_for_key) { 'address-suffix@example.com' } + + visit edit_project_path(project) + end + + it 'allows setting of custom address suffix' do + find("#service-desk-checkbox").click + wait_for_requests + + project.reload + expect(find('[data-testid="incoming-email"]').value).to eq(project.service_desk_incoming_address) + + page.within '#js-service-desk' do + fill_in('service-desk-project-suffix', with: 'foo') + click_button 'Save changes' + end + + wait_for_requests + + expect(find('[data-testid="incoming-email"]').value).to eq('address-suffix@example.com') + end end end diff --git a/spec/features/projects/settings/user_interacts_with_deploy_keys_spec.rb b/spec/features/projects/settings/user_interacts_with_deploy_keys_spec.rb index ba504624823..91a7753fe6d 100644 --- a/spec/features/projects/settings/user_interacts_with_deploy_keys_spec.rb +++ b/spec/features/projects/settings/user_interacts_with_deploy_keys_spec.rb @@ -19,7 +19,7 @@ RSpec.describe "User interacts with deploy keys", :js do click_button("Enable") - expect(page).not_to have_selector(".fa-spinner") + expect(page).not_to have_selector(".gl-spinner") expect(current_path).to eq(project_settings_repository_path(project)) find(".js-deployKeys-tab-enabled_keys").click diff --git a/spec/features/projects/show/developer_views_empty_project_instructions_spec.rb b/spec/features/projects/show/developer_views_empty_project_instructions_spec.rb deleted file mode 100644 index 8d239cb2cbf..00000000000 --- a/spec/features/projects/show/developer_views_empty_project_instructions_spec.rb +++ /dev/null @@ -1,20 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -RSpec.describe 'Projects > Show > Developer views empty project instructions' do - let(:project) { create(:project, :empty_repo) } - let(:developer) { create(:user) } - - before do - project.add_developer(developer) - - sign_in(developer) - end - - it 'displays "git clone" instructions' do - visit project_path(project) - - expect(page).to have_content("git clone") - end -end diff --git a/spec/features/projects/show/no_password_spec.rb b/spec/features/projects/show/no_password_spec.rb index 79cd65e5406..d18ff75b324 100644 --- a/spec/features/projects/show/no_password_spec.rb +++ b/spec/features/projects/show/no_password_spec.rb @@ -15,7 +15,7 @@ RSpec.describe 'No Password Alert' do let(:user) { create(:user) } it 'shows no alert' do - expect(page).not_to have_content "You won't be able to pull or push project code via HTTP until you set a password on your account" + expect(page).not_to have_content "You won't be able to pull or push repositories via HTTP until you set a password on your account" end end @@ -23,7 +23,7 @@ RSpec.describe 'No Password Alert' do let(:user) { create(:user, password_automatically_set: true) } it 'shows a password alert' do - expect(page).to have_content "You won't be able to pull or push project code via HTTP until you set a password on your account" + expect(page).to have_content "You won't be able to pull or push repositories via HTTP until you set a password on your account" end end end @@ -41,7 +41,7 @@ RSpec.describe 'No Password Alert' do gitlab_sign_in_via('saml', user, 'my-uid') visit project_path(project) - expect(page).to have_content "You won't be able to pull or push project code via HTTP until you create a personal access token on your account" + expect(page).to have_content "You won't be able to pull or push repositories via HTTP until you create a personal access token on your account" end end @@ -51,7 +51,7 @@ RSpec.describe 'No Password Alert' do gitlab_sign_in_via('saml', user, 'my-uid') visit project_path(project) - expect(page).not_to have_content "You won't be able to pull or push project code via HTTP until you create a personal access token on your account" + expect(page).not_to have_content "You won't be able to pull or push repositories via HTTP until you create a personal access token on your account" end end end @@ -65,7 +65,7 @@ RSpec.describe 'No Password Alert' do end it 'shows no alert' do - expect(page).not_to have_content "You won't be able to pull or push project code via HTTP until you" + expect(page).not_to have_content "You won't be able to pull or push repositories via HTTP until you" end end end diff --git a/spec/features/projects/show/schema_markup_spec.rb b/spec/features/projects/show/schema_markup_spec.rb index e651798af23..1777b72cbf5 100644 --- a/spec/features/projects/show/schema_markup_spec.rb +++ b/spec/features/projects/show/schema_markup_spec.rb @@ -14,7 +14,7 @@ RSpec.describe 'Projects > Show > Schema Markup' do expect(page).to have_selector('img[itemprop="image"]') expect(page).to have_selector('[itemprop="name"]', text: project.name) expect(page).to have_selector('[itemprop="identifier"]', text: "Project ID: #{project.id}") - expect(page).to have_selector('[itemprop="abstract"]', text: project.description) + expect(page).to have_selector('[itemprop="description"]', text: project.description) expect(page).to have_selector('[itemprop="license"]', text: project.repository.license.name) expect(find_all('[itemprop="keywords"]').map(&:text)).to match_array(project.tag_list.map(&:capitalize)) expect(page).to have_selector('[itemprop="about"]') diff --git a/spec/features/projects/show/user_sees_git_instructions_spec.rb b/spec/features/projects/show/user_sees_git_instructions_spec.rb index 3b77fd7eebf..febdb70de86 100644 --- a/spec/features/projects/show/user_sees_git_instructions_spec.rb +++ b/spec/features/projects/show/user_sees_git_instructions_spec.rb @@ -122,13 +122,11 @@ RSpec.describe 'Projects > Show > User sees Git instructions' do context 'when project is not empty' do let_it_be(:project) { create(:project, :public, :repository) } - before do - visit(project_path(project)) - end - context 'when not signed in' do before do allow(Gitlab.config.gitlab).to receive(:host).and_return('www.example.com') + + visit(project_path(project)) end include_examples 'shows details of non empty 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 189aa45ff75..9b51e867156 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 @@ -22,7 +22,7 @@ RSpec.describe 'Projects > Show > User sees setup shortcut buttons' do visit project_path(project) end - it 'Project buttons are not visible' do + it 'project buttons are not visible' do visit project_path(project) page.within('.project-buttons') do @@ -165,7 +165,7 @@ RSpec.describe 'Projects > Show > User sees setup shortcut buttons' do context 'when the project does not have a README' do it 'shows the single file editor "Add README" button' do - allow(project.repository).to receive(:readme).and_return(nil) + allow(project.repository).to receive(:readme_path).and_return(nil) visit project_path(project) diff --git a/spec/features/projects/terraform_spec.rb b/spec/features/projects/terraform_spec.rb index 2680dfb2b13..dfa4dad8490 100644 --- a/spec/features/projects/terraform_spec.rb +++ b/spec/features/projects/terraform_spec.rb @@ -4,44 +4,94 @@ require 'spec_helper' RSpec.describe 'Terraform', :js do let_it_be(:project) { create(:project) } + let_it_be(:terraform_state) { create(:terraform_state, :locked, :with_version, project: project) } - let(:user) { project.creator } + context 'when user is a terraform administrator' do + let(:admin) { project.creator } - before do - gitlab_sign_in(user) - end - - context 'when user does not have any terraform states and visits index page' do before do - visit project_terraform_index_path(project) + gitlab_sign_in(admin) end - it 'sees an empty state' do - expect(page).to have_content('Get started with Terraform') + context 'when user does not have any terraform states and visits the index page' do + let(:empty_project) { create(:project) } + + before do + empty_project.add_maintainer(admin) + visit project_terraform_index_path(empty_project) + end + + it 'sees an empty state' do + expect(page).to have_content('Get started with Terraform') + end end - end - context 'when user has a terraform state' do - let_it_be(:terraform_state) { create(:terraform_state, :locked, project: project) } + context 'when user has a terraform state' do + context 'when user visits the index page' do + before do + visit project_terraform_index_path(project) + end - context 'when user visits the index page' do - before do - visit project_terraform_index_path(project) + it 'displays a tab with states count' do + expect(page).to have_content("States #{project.terraform_states.size}") + end + + it 'displays a table with terraform states' do + expect(page).to have_selector( + '[data-testid="terraform-states-table-name"]', + count: project.terraform_states.size + ) + end + + it 'displays terraform actions dropdown' do + expect(page).to have_selector( + '[data-testid*="terraform-state-actions"]', + count: project.terraform_states.size + ) + end + + it 'displays terraform information' do + expect(page).to have_content(terraform_state.name) + end end - it 'displays a tab with states count' do - expect(page).to have_content("States #{project.terraform_states.size}") + context 'when clicking on the delete button' do + let(:additional_state) { create(:terraform_state, project: project) } + + it 'removes the state', :aggregate_failures do + visit project_terraform_index_path(project) + + expect(page).to have_content(additional_state.name) + + find("[data-testid='terraform-state-actions-#{additional_state.name}']").click + find('[data-testid="terraform-state-remove"]').click + fill_in "terraform-state-remove-input-#{additional_state.name}", with: additional_state.name + click_button 'Remove' + + expect(page).not_to have_content(additional_state.name) + expect { additional_state.reload }.to raise_error ActiveRecord::RecordNotFound + end end + end + end + + context 'when user is a terraform developer' do + let_it_be(:developer) { create(:user) } - it 'displays a table with terraform states' do + before do + project.add_developer(developer) + gitlab_sign_in(developer) + visit project_terraform_index_path(project) + end + + context 'when user visits the index page' do + it 'displays a table without an action dropdown', :aggregate_failures do expect(page).to have_selector( - '[data-testid="terraform-states-table"] tbody tr', + '[data-testid="terraform-states-table-name"]', count: project.terraform_states.size ) - end - it 'displays terraform information' do - expect(page).to have_content(terraform_state.name) + expect(page).not_to have_selector('[data-testid*="terraform-state-actions"]') end end end diff --git a/spec/features/projects/user_creates_project_spec.rb b/spec/features/projects/user_creates_project_spec.rb index b204ae76e07..feb5f348256 100644 --- a/spec/features/projects/user_creates_project_spec.rb +++ b/spec/features/projects/user_creates_project_spec.rb @@ -13,6 +13,7 @@ RSpec.describe 'User creates a project', :js do it 'creates a new project' do visit(new_project_path) + find('[data-qa-selector="blank_project_link"]').click fill_in(:project_name, with: 'Empty') page.within('#content-body') do @@ -39,6 +40,7 @@ RSpec.describe 'User creates a project', :js do it 'creates a new project' do visit(new_project_path) + find('[data-qa-selector="blank_project_link"]').click fill_in :project_name, with: 'A Subgroup Project' fill_in :project_path, with: 'a-subgroup-project' @@ -67,6 +69,7 @@ RSpec.describe 'User creates a project', :js do it 'creates a new project' do visit(new_project_path) + find('[data-qa-selector="blank_project_link"]').click fill_in :project_name, with: 'a-new-project' fill_in :project_path, with: 'a-new-project' diff --git a/spec/features/projects/user_sorts_projects_spec.rb b/spec/features/projects/user_sorts_projects_spec.rb new file mode 100644 index 00000000000..6a5ed49f1a6 --- /dev/null +++ b/spec/features/projects/user_sorts_projects_spec.rb @@ -0,0 +1,82 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe 'User sorts projects and order persists' do + include CookieHelper + + let_it_be(:user) { create(:user) } + let_it_be(:group) { create(:group) } + let_it_be(:group_member) { create(:group_member, :maintainer, user: user, group: group) } + let_it_be(:project) { create(:project, :public, group: group) } + + shared_examples_for "sort order persists across all views" do |project_paths_label, group_paths_label| + it "is set on the dashboard_projects_path" do + visit(dashboard_projects_path) + + expect(find('.dropdown-menu a.is-active', text: project_paths_label)).to have_content(project_paths_label) + end + + it "is set on the explore_projects_path" do + visit(explore_projects_path) + + expect(find('.dropdown-menu a.is-active', text: project_paths_label)).to have_content(project_paths_label) + end + + it "is set on the group_canonical_path" do + visit(group_canonical_path(group)) + + expect(find('.dropdown-menu a.is-active', text: group_paths_label)).to have_content(group_paths_label) + end + + it "is set on the details_group_path" do + visit(details_group_path(group)) + + expect(find('.dropdown-menu a.is-active', text: group_paths_label)).to have_content(group_paths_label) + end + end + + context "from explore projects" do + before do + sign_in(user) + visit(explore_projects_path) + find('#sort-projects-dropdown').click + first(:link, 'Last updated').click + end + + it_behaves_like "sort order persists across all views", "Last updated", "Last updated" + end + + context 'from dashboard projects' do + before do + sign_in(user) + visit(dashboard_projects_path) + find('#sort-projects-dropdown').click + first(:link, 'Name').click + end + + it_behaves_like "sort order persists across all views", "Name", "Name" + end + + context 'from group homepage' do + before do + sign_in(user) + visit(group_canonical_path(group)) + find('button.dropdown-menu-toggle').click + first(:link, 'Last created').click + end + + it_behaves_like "sort order persists across all views", "Created date", "Last created" + end + + context 'from group details' do + before do + sign_in(user) + visit(details_group_path(group)) + find('button.dropdown-menu-toggle').click + first(:link, 'Most stars').click + end + + it_behaves_like "sort order persists across all views", "Stars", "Most stars" + end +end diff --git a/spec/features/projects/user_views_empty_project_spec.rb b/spec/features/projects/user_views_empty_project_spec.rb index 9202d18b86f..3d4d9a7ea96 100644 --- a/spec/features/projects/user_views_empty_project_spec.rb +++ b/spec/features/projects/user_views_empty_project_spec.rb @@ -7,12 +7,9 @@ RSpec.describe 'User views an empty project' do let(:user) { create(:user) } shared_examples 'allowing push to default branch' do - before do - sign_in(user) + it 'shows push-to-master instructions' do visit project_path(project) - end - it 'shows push-to-master instructions' do expect(page).to have_content('git push -u origin master') end end @@ -20,6 +17,7 @@ RSpec.describe 'User views an empty project' do describe 'as a maintainer' do before do project.add_maintainer(user) + sign_in(user) end it_behaves_like 'allowing push to default branch' @@ -28,17 +26,33 @@ RSpec.describe 'User views an empty project' do describe 'as an admin' do let(:user) { create(:user, :admin) } - it_behaves_like 'allowing push to default branch' + context 'when admin mode is enabled' do + before do + sign_in(user) + gitlab_enable_admin_mode_sign_in(user) + end + + it_behaves_like 'allowing push to default branch' + end + + context 'when admin mode is disabled' do + it 'does not show push-to-master instructions' do + visit project_path(project) + + expect(page).not_to have_content('git push -u origin master') + end + end end describe 'as a developer' do before do project.add_developer(user) sign_in(user) - visit project_path(project) end it 'does not show push-to-master instructions' do + visit project_path(project) + expect(page).not_to have_content('git push -u origin master') end end diff --git a/spec/features/projects/wiki/user_git_access_wiki_page_spec.rb b/spec/features/projects/wiki/user_git_access_wiki_page_spec.rb deleted file mode 100644 index 83679c6bd1d..00000000000 --- a/spec/features/projects/wiki/user_git_access_wiki_page_spec.rb +++ /dev/null @@ -1,21 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -RSpec.describe 'Projects > Wiki > User views Git access wiki page' do - let(:user) { create(:user) } - let(:project) { create(:project, :wiki_repo, :public) } - let(:wiki_page) { create(:wiki_page, wiki: project.wiki, title: 'home', content: '[some link](other-page)') } - - before do - sign_in(user) - end - - it 'Visit Wiki Page Current Commit' do - visit project_wiki_path(project, wiki_page) - - click_link 'Clone repository' - expect(page).to have_text("Clone repository #{project.wiki.full_path}") - expect(page).to have_text(project.wiki.http_url_to_repo) - end -end diff --git a/spec/features/projects/wikis_spec.rb b/spec/features/projects/wikis_spec.rb index 1c66ad81145..621f8c71b20 100644 --- a/spec/features/projects/wikis_spec.rb +++ b/spec/features/projects/wikis_spec.rb @@ -17,4 +17,5 @@ RSpec.describe 'Project wikis' do it_behaves_like 'User views a wiki page' it_behaves_like 'User views wiki pages' it_behaves_like 'User views wiki sidebar' + it_behaves_like 'User views Git access wiki page' end |