diff --git a/qa/qa/specs/features/browser_ui/4_verify/ci_variable/custom_variable_spec.rb b/qa/qa/specs/features/browser_ui/4_verify/ci_variable/custom_variable_spec.rb index 1db6f48a404ba87a4c4e0c36ca6f2e51a8a1db05..4a0a8be3659e79ae01cf2344fb8fc0ee5979110b 100644 --- a/qa/qa/specs/features/browser_ui/4_verify/ci_variable/custom_variable_spec.rb +++ b/qa/qa/specs/features/browser_ui/4_verify/ci_variable/custom_variable_spec.rb @@ -1,8 +1,11 @@ # frozen_string_literal: true module QA - RSpec.describe 'Verify', :runner, product_group: :pipeline_authoring do - describe 'Pipeline with customizable variable' do + RSpec.describe 'Verify', :runner do + describe 'Pipeline with customizable variable', feature_flag: { + name: :run_pipeline_graphql, + scope: :project + } do let(:executor) { "qa-runner-#{Time.now.to_i}" } let(:pipeline_job_name) { 'customizable-variable' } let(:variable_custom_value) { 'Custom Foo' } @@ -45,43 +48,74 @@ module QA end end - before do - Flow::Login.sign_in - project.visit! - Page::Project::Menu.perform(&:click_ci_cd_pipelines) - Page::Project::Pipeline::Index.perform do |index| - index.click_run_pipeline_button + shared_examples 'pipeline with custom variable' do + before do + Flow::Login.sign_in + + project.visit! + Page::Project::Menu.perform(&:click_ci_cd_pipelines) + Page::Project::Pipeline::Index.perform(&:click_run_pipeline_button) + + # Sometimes the variables will not be prefilled because of reactive cache so we revisit the page again. + # TODO: Investigate alternatives to deal with cache implementation + # Issue https://gitlab.com/gitlab-org/gitlab/-/issues/381233 + page.refresh end - end - after do - [runner, project].each(&:remove_via_api!) + after do + runner&.remove_via_api! + end + + it 'manually creates a pipeline and uses the defined custom variable value' do + Page::Project::Pipeline::New.perform do |new| + new.configure_variable(value: variable_custom_value) + new.click_run_pipeline_button + end + + Page::Project::Pipeline::Show.perform do |show| + Support::Waiter.wait_until { show.passed? } + end + + job = Resource::Job.fabricate_via_api! do |job| + job.id = project.job_by_name(pipeline_job_name)[:id] + job.name = pipeline_job_name + job.project = project + end + + job.visit! + + Page::Project::Job::Show.perform do |show| + expect(show.output).to have_content(variable_custom_value) + end + end end - it( - 'manually creates a pipeline and uses the defined custom variable value', + # TODO: Clean up tests when run_pipeline_graphql is enabled + # Issue https://gitlab.com/gitlab-org/gitlab/-/issues/372310 + context( + 'with feature flag disabled', testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/361814' ) do - Page::Project::Pipeline::New.perform do |new| - new.configure_variable(value: variable_custom_value) - new.click_run_pipeline_button + before do + Runtime::Feature.disable(:run_pipeline_graphql, project: project) end - Page::Project::Pipeline::Show.perform do |show| - Support::Waiter.wait_until { show.passed? } - end + it_behaves_like 'pipeline with custom variable' + end - job = Resource::Job.fabricate_via_api! do |job| - job.id = project.job_by_name(pipeline_job_name)[:id] - job.name = pipeline_job_name - job.project = project + context( + 'with feature flag enabled', + testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/378975' + ) do + before do + Runtime::Feature.enable(:run_pipeline_graphql, project: project) end - job.visit! - - Page::Project::Job::Show.perform do |show| - expect(show.output).to have_content(variable_custom_value) + after do + Runtime::Feature.disable(:run_pipeline_graphql, project: project) end + + it_behaves_like 'pipeline with custom variable' end end end diff --git a/qa/qa/specs/features/browser_ui/4_verify/ci_variable/prefill_variables_spec.rb b/qa/qa/specs/features/browser_ui/4_verify/ci_variable/prefill_variables_spec.rb index 7eec0f8870a0c5ee51a847117b509c352d3f1646..c4ce916d47da9c952c5116b8d51dfbc1c87af5a4 100644 --- a/qa/qa/specs/features/browser_ui/4_verify/ci_variable/prefill_variables_spec.rb +++ b/qa/qa/specs/features/browser_ui/4_verify/ci_variable/prefill_variables_spec.rb @@ -2,7 +2,10 @@ module QA RSpec.describe 'Verify' do - describe 'Pipeline with prefill variables', product_group: :pipeline_authoring do + describe 'Pipeline with prefill variables', feature_flag: { + name: :run_pipeline_graphql, + scope: :project + } do let(:prefill_variable_description1) { Faker::Lorem.sentence } let(:prefill_variable_value1) { Faker::Lorem.word } let(:prefill_variable_description2) { Faker::Lorem.sentence } @@ -40,32 +43,62 @@ module QA end end - before do - Flow::Login.sign_in - project.visit! + shared_examples 'pre-filled variables form' do + before do + Flow::Login.sign_in - # Navigate to Run Pipeline page - Page::Project::Menu.perform(&:click_ci_cd_pipelines) - Page::Project::Pipeline::Index.perform(&:click_run_pipeline_button) + project.visit! + # Navigate to Run Pipeline page + Page::Project::Menu.perform(&:click_ci_cd_pipelines) + Page::Project::Pipeline::Index.perform(&:click_run_pipeline_button) + + # Sometimes the variables will not be prefilled because of reactive cache so we revisit the page again. + # TODO: Investigate alternatives to deal with cache implementation + # Issue https://gitlab.com/gitlab-org/gitlab/-/issues/381233 + page.refresh + end + + it 'shows only variables with description as prefill variables on the run pipeline page' do + Page::Project::Pipeline::New.perform do |new| + aggregate_failures do + expect(new).to have_field('Input variable key', with: 'TEST1') + expect(new).to have_field('Input variable value', with: prefill_variable_value1) + expect(new).to have_content(prefill_variable_description1) + + expect(new).to have_field('Input variable key', with: 'TEST2') + expect(new).to have_content(prefill_variable_description2) + + expect(new).not_to have_field('Input variable key', with: 'TEST3') + expect(new).not_to have_field('Input variable key', with: 'TEST4') + end + end + end end - it( - 'shows only variables with description as prefill variables on the run pipeline page', + # TODO: Clean up tests when run_pipeline_graphql is enabled + # Issue https://gitlab.com/gitlab-org/gitlab/-/issues/372310 + context( + 'with feature flag disabled', testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/371204' ) do - Page::Project::Pipeline::New.perform do |new| - aggregate_failures do - expect(new).to have_field('Input variable key', with: 'TEST1') - expect(new).to have_field('Input variable value', with: prefill_variable_value1) - expect(new).to have_content(prefill_variable_description1) + before do + Runtime::Feature.disable(:run_pipeline_graphql, project: project) + end - expect(new).to have_field('Input variable key', with: 'TEST2') - expect(new).to have_content(prefill_variable_description2) + it_behaves_like 'pre-filled variables form' + end - expect(new).not_to have_field('Input variable key', with: 'TEST3') - expect(new).not_to have_field('Input variable key', with: 'TEST4') - end + context 'with feature flag enabled', + testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/378977' do + before do + Runtime::Feature.enable(:run_pipeline_graphql, project: project) end + + after do + Runtime::Feature.disable(:run_pipeline_graphql, project: project) + end + + it_behaves_like 'pre-filled variables form' end end end diff --git a/spec/features/projects/pipelines/pipelines_spec.rb b/spec/features/projects/pipelines/pipelines_spec.rb index eabbcd5e38ec7c9ed23db1c08a758a39a7f2890a..b7b715cb6db8cb9fc56dd726c025f25fbf04432b 100644 --- a/spec/features/projects/pipelines/pipelines_spec.rb +++ b/spec/features/projects/pipelines/pipelines_spec.rb @@ -680,7 +680,7 @@ def create_build(stage, stage_idx, name, status) end context 'when variables are specified' do - it 'creates a new pipeline with variables', quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/375552' do + it 'creates a new pipeline with variables' do page.within(find("[data-testid='ci-variable-row']")) do find("[data-testid='pipeline-form-ci-variable-key']").set('key_name') find("[data-testid='pipeline-form-ci-variable-value']").set('value') @@ -708,7 +708,7 @@ def create_build(stage, stage_idx, name, status) it { expect(page).to have_content('Missing CI config file') } - it 'creates a pipeline after first request failed and a valid gitlab-ci.yml file is available when trying again', quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/375552' do + it 'creates a pipeline after first request failed and a valid gitlab-ci.yml file is available when trying again' do stub_ci_pipeline_to_return_yaml_file expect do @@ -722,6 +722,7 @@ def create_build(stage, stage_idx, name, status) # Run Pipeline form with REST endpoints # TODO: Clean up tests when run_pipeline_graphql is enabled + # Issue https://gitlab.com/gitlab-org/gitlab/-/issues/372310 context 'with feature flag disabled' do before do stub_feature_flags(run_pipeline_graphql: false)