Commit 9eafffb9 authored by Ramya Authappan's avatar Ramya Authappan

Merge branch 'egb-add-test-fix-branch-switcher-fetch-policy' into 'master'

End to end test for branch switcher fetch policy

See merge request gitlab-org/gitlab!63811
parents da16dc67 8cb2f6c5
......@@ -103,6 +103,7 @@ export default {
v-model="targetBranch"
class="gl-font-monospace!"
required
data-qa-selector="target_branch_field"
/>
<gl-form-checkbox
v-if="!isCurrentBranchTarget"
......
......@@ -211,6 +211,7 @@ export default {
:header-text="$options.i18n.dropdownHeader"
:text="currentBranch"
icon="branch"
data-qa-selector="branch_selector_button"
>
<gl-search-box-by-type :debounce="$options.inputDebounce" @input="setSearchTerm" />
<gl-dropdown-section-header>
......@@ -228,6 +229,7 @@ export default {
:key="branch"
:is-checked="currentBranch === branch"
:is-check-item="true"
data-qa-selector="menu_branch_button"
@click="selectBranch(branch)"
>
{{ branch }}
......
......@@ -297,6 +297,10 @@ module QA
autoload :New, 'qa/page/project/pipeline/new'
end
module PipelineEditor
autoload :Show, 'qa/page/project/pipeline_editor/show'
end
module Tag
autoload :Index, 'qa/page/project/tag/index'
autoload :New, 'qa/page/project/tag/new'
......
# frozen_string_literal: true
module QA
module Page
module Project
module PipelineEditor
class Show < QA::Page::Base
view 'app/assets/javascripts/pipeline_editor/components/file_nav/branch_switcher.vue' do
element :branch_selector_button
element :menu_branch_button
end
view 'app/assets/javascripts/pipeline_editor/components/commit/commit_form.vue' do
element :target_branch_field
end
def has_branch_selector_button?
has_element? :branch_selector_button
end
def click_branch_selector_button
wait_until(reload: false) do
has_element?(:branch_selector_button)
end
click_element(:branch_selector_button, skip_finished_loading_check: true)
end
def select_branch_from_dropdown(branch_to_switch_to)
wait_until(reload: false) do
has_element?(:menu_branch_button)
end
click_element(:menu_branch_button, text: branch_to_switch_to, skip_finished_loading_check: true)
end
def target_branch_name
wait_until(reload: false) do
has_element?(:target_branch_field)
end
find_element(:target_branch_field, skip_finished_loading_check: true).value
end
end
end
end
end
end
......@@ -20,6 +20,24 @@ module QA
click_element(:sidebar_menu_link, menu_item: 'CI/CD')
end
end
def go_to_pipeline_editor
hover_ci_cd_pipelines do
within_submenu do
click_element(:sidebar_menu_item_link, menu_item: 'Editor')
end
end
end
private
def hover_ci_cd_pipelines
within_sidebar do
find_element(:sidebar_menu_link, menu_item: 'CI/CD').hover
yield
end
end
end
end
end
......
# frozen_string_literal: true
module QA
RSpec.describe 'Verify' do
describe 'Pipeline editor', :requires_admin do
let(:project) do
Resource::Project.fabricate_via_api! do |project|
project.name = 'pipeline-editor-project'
end
end
let!(:commit) do
Resource::Repository::Commit.fabricate_via_api! do |commit|
commit.project = project
commit.commit_message = 'Add .gitlab-ci.yml'
commit.add_files(
[
{
file_path: '.gitlab-ci.yml',
content: default_file_content
}
]
)
end
end
let!(:production_push) do
Resource::Repository::Push.fabricate! do |push|
push.repository_http_uri = project.repository_http_location.uri
push.branch_name = 'production'
push.file_name = '.gitlab-ci.yml'
push.file_content = production_file_content
end
end
let(:default_file_content) do
<<~YAML
stages:
- test
initialize:
stage: test
script:
- echo "initialized in #{project.default_branch}"
YAML
end
let(:production_file_content) do
<<~YAML
stages:
- test
initialize:
stage: test
script:
- echo "initialized in production"
YAML
end
before do
Runtime::Feature.enable(:pipeline_editor_branch_switcher)
Flow::Login.sign_in
project.visit!
Page::Project::Menu.perform(&:go_to_pipeline_editor)
end
after do
Runtime::Feature.disable(:pipeline_editor_branch_switcher)
project.remove_via_api!
Page::Main::Menu.perform(&:sign_out)
end
it 'can switch branches and target branch field updates accordingly', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/1856' do
Page::Project::PipelineEditor::Show.perform do |show|
expect(show).to have_branch_selector_button
show.click_branch_selector_button
show.select_branch_from_dropdown(production_push.branch_name)
expect(show.target_branch_name).to eq(production_push.branch_name)
show.click_branch_selector_button
show.select_branch_from_dropdown(project.default_branch)
expect(show.target_branch_name).to eq(project.default_branch)
end
end
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment