diff options
Diffstat (limited to 'qa')
-rw-r--r-- | qa/Gemfile | 2 | ||||
-rw-r--r-- | qa/Gemfile.lock | 6 | ||||
-rw-r--r-- | qa/qa/page/project/pipeline/new.rb | 35 | ||||
-rw-r--r-- | qa/qa/specs/features/browser_ui/4_verify/ci_variable/prefill_variables_spec.rb | 98 |
4 files changed, 107 insertions, 34 deletions
diff --git a/qa/Gemfile b/qa/Gemfile index 53a5e0d510e..2a515d6c8e7 100644 --- a/qa/Gemfile +++ b/qa/Gemfile @@ -9,7 +9,7 @@ gem 'capybara', '~> 3.38.0' gem 'capybara-screenshot', '~> 1.0.26' gem 'rake', '~> 13', '>= 13.0.6' gem 'rspec', '~> 3.12' -gem 'selenium-webdriver', '~> 4.6', '>= 4.6.1' +gem 'selenium-webdriver', '~> 4.7', '>= 4.7.1' gem 'airborne', '~> 0.3.7', require: false # airborne is messing with rspec sandboxed mode so not requiring by default gem 'rest-client', '~> 2.1.0' gem 'rspec-retry', '~> 0.6.2', require: 'rspec/retry' diff --git a/qa/Gemfile.lock b/qa/Gemfile.lock index c6ce57cfff5..6920ffe250e 100644 --- a/qa/Gemfile.lock +++ b/qa/Gemfile.lock @@ -48,7 +48,6 @@ GEM watir (>= 6, < 8) chemlab-library-www-gitlab-com (0.1.1) chemlab (~> 0.4) - childprocess (4.1.0) coderay (1.1.2) colorize (0.8.1) concurrent-ruby (1.1.10) @@ -253,8 +252,7 @@ GEM sawyer (0.9.2) addressable (>= 2.3.5) faraday (>= 0.17.3, < 3) - selenium-webdriver (4.6.1) - childprocess (>= 0.5, < 5.0) + selenium-webdriver (4.7.1) rexml (~> 3.2, >= 3.2.5) rubyzip (>= 1.2.2, < 3.0) websocket (~> 1.0) @@ -329,7 +327,7 @@ DEPENDENCIES rspec-retry (~> 0.6.2) rspec_junit_formatter (~> 0.6.0) ruby-debug-ide (~> 0.7.3) - selenium-webdriver (~> 4.6, >= 4.6.1) + selenium-webdriver (~> 4.7, >= 4.7.1) slack-notifier (~> 2.4) terminal-table (~> 3.0.2) warning (~> 1.3) diff --git a/qa/qa/page/project/pipeline/new.rb b/qa/qa/page/project/pipeline/new.rb index 742fcad5c07..f56f69fc077 100644 --- a/qa/qa/page/project/pipeline/new.rb +++ b/qa/qa/page/project/pipeline/new.rb @@ -5,6 +5,8 @@ module QA module Project module Pipeline class New < QA::Page::Base + # TODO: Replace legacy form with the new form when run_pipeline_graphql is enabled by default + # Issue https://gitlab.com/gitlab-org/gitlab/-/issues/372310 view 'app/assets/javascripts/pipeline_new/components/legacy_pipeline_new_form.vue' do element :run_pipeline_button, required: true element :ci_variable_row_container @@ -12,16 +14,49 @@ module QA element :ci_variable_value_field end + view 'app/assets/javascripts/pipeline_new/components/pipeline_new_form.vue' do + element :run_pipeline_button, required: true + element :ci_variable_row_container + element :ci_variable_key_field + element :ci_variable_value_field + element :ci_variable_value_dropdown + element :ci_variable_value_dropdown_item + end + def click_run_pipeline_button click_element(:run_pipeline_button, Page::Project::Pipeline::Show) end + def click_variable_dropdown + return unless has_variable_dropdown? + + click_element(:ci_variable_value_dropdown) + end + def configure_variable(key: nil, value: 'foo', row_index: 0) within_element_by_index(:ci_variable_row_container, row_index) do fill_element(:ci_variable_key_field, key) unless key.nil? fill_element(:ci_variable_value_field, value) end end + + def has_variable_dropdown? + has_element?(:ci_variable_value_dropdown) + end + + def variable_dropdown + return unless has_variable_dropdown? + + find_element(:ci_variable_value_dropdown) + end + + def variable_dropdown_item_with_index(index) + return unless has_variable_dropdown? + + within_element_by_index(:ci_variable_value_dropdown_item, index) do + find('p') + end + end 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 c4ce916d47d..4ae278418a9 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 @@ -4,11 +4,13 @@ module QA RSpec.describe 'Verify' do describe 'Pipeline with prefill variables', feature_flag: { name: :run_pipeline_graphql, - scope: :project + scope: :global } do let(:prefill_variable_description1) { Faker::Lorem.sentence } let(:prefill_variable_value1) { Faker::Lorem.word } + let(:prefill_variable_value5) { Faker::Lorem.word } let(:prefill_variable_description2) { Faker::Lorem.sentence } + let(:prefill_variable_description5) { Faker::Lorem.sentence } let(:project) do Resource::Project.fabricate_via_api! do |project| project.name = 'project-with-prefill-variables' @@ -33,7 +35,12 @@ module QA TEST3: value: test 3 value TEST4: test 4 value - + TEST5: + value: "FOO" + options: + - #{prefill_variable_value5} + - "FOO" + description: #{prefill_variable_description5} test: script: echo "$FOO" YAML @@ -43,22 +50,8 @@ module QA end end - shared_examples 'pre-filled variables form' do - before do - Flow::Login.sign_in - - 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 + shared_examples 'pre-filled variables form' do |testcase| + it 'shows only variables with description as prefill variables on the run pipeline page', testcase: testcase do Page::Project::Pipeline::New.perform do |new| aggregate_failures do expect(new).to have_field('Input variable key', with: 'TEST1') @@ -66,10 +59,15 @@ module QA expect(new).to have_content(prefill_variable_description1) expect(new).to have_field('Input variable key', with: 'TEST2') + expect(new).to have_field('Input variable value', with: '') 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') + + # Legacy and GQL app will render the variable field differently + expect(new).to have_field('Input variable key', with: 'TEST5') + expect(new).to have_content(prefill_variable_description5) end end end @@ -77,28 +75,70 @@ module QA # 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 + context 'with feature flag disabled' do before do - Runtime::Feature.disable(:run_pipeline_graphql, project: project) + Flow::Login.sign_in + 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_behaves_like 'pre-filled variables form' + it_behaves_like 'pre-filled variables form', 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/371204' + + it 'does not prefill dropdown variables but renders them as input fields', + testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/383819' do + Page::Project::Pipeline::New.perform do |new| + expect(new.has_variable_dropdown?).to be(false) + expect(new).to have_field('Input variable value', with: 'FOO') + end + end end - context 'with feature flag enabled', - testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/378977' do + context 'with feature flag enabled' do before do - Runtime::Feature.enable(:run_pipeline_graphql, project: project) + Runtime::Feature.enable(:run_pipeline_graphql) + sleep 30 + + Flow::Login.sign_in + 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 after do - Runtime::Feature.disable(:run_pipeline_graphql, project: project) + Runtime::Feature.disable(:run_pipeline_graphql) + sleep 30 end - it_behaves_like 'pre-filled variables form' + it_behaves_like 'pre-filled variables form', 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/378977' + + it 'shows dropdown for variables with description, value, and options defined', + testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/383820' do + Page::Project::Pipeline::New.perform do |new| + aggregate_failures do + expect(new.variable_dropdown).to have_text('FOO') + + new.click_variable_dropdown + + expect(new.variable_dropdown_item_with_index(0)).to have_text(prefill_variable_value5) + expect(new.variable_dropdown_item_with_index(1)).to have_text('FOO') + end + end + end end end end |