Commit d017f59e authored by mgandres's avatar mgandres

Add tests for checking displayed current branch in the pipeline editor

parent a482a9f4
...@@ -212,6 +212,7 @@ export default { ...@@ -212,6 +212,7 @@ export default {
:text="currentBranch" :text="currentBranch"
icon="branch" icon="branch"
data-qa-selector="branch_selector_button" data-qa-selector="branch_selector_button"
data-testid="branch-selector"
> >
<gl-search-box-by-type :debounce="$options.inputDebounce" @input="setSearchTerm" /> <gl-search-box-by-type :debounce="$options.inputDebounce" @input="setSearchTerm" />
<gl-dropdown-section-header> <gl-dropdown-section-header>
......
...@@ -5,17 +5,55 @@ require 'spec_helper' ...@@ -5,17 +5,55 @@ require 'spec_helper'
RSpec.describe 'Pipeline Editor', :js do RSpec.describe 'Pipeline Editor', :js do
include Spec::Support::Helpers::Features::SourceEditorSpecHelpers include Spec::Support::Helpers::Features::SourceEditorSpecHelpers
let(:project) { create(:project, :repository) } let(:project) { create(:project_empty_repo, :public) }
let(:user) { create(:user) } let(:user) { create(:user) }
let(:default_branch) { 'main' }
let(:other_branch) { 'test' }
before do before do
sign_in(user) sign_in(user)
project.add_developer(user) project.add_developer(user)
project.repository.create_file(user, project.ci_config_path_or_default, 'Default Content', message: 'Create CI file for main', branch_name: default_branch)
project.repository.create_file(user, project.ci_config_path_or_default, 'Other Content', message: 'Create CI file for test', branch_name: other_branch)
visit project_ci_pipeline_editor_path(project) visit project_ci_pipeline_editor_path(project)
wait_for_requests
end end
it 'user sees the Pipeline Editor page' do it 'user sees the Pipeline Editor page' do
expect(page).to have_content('Pipeline Editor') expect(page).to have_content('Pipeline Editor')
end end
context 'branch switcher' do
before do
stub_feature_flags(pipeline_editor_branch_switcher: true)
end
def switch_to_branch(branch)
find('[data-testid="branch-selector"]').click
page.within '[data-testid="branch-selector"]' do
click_button branch
wait_for_requests
end
end
it 'displays current branch' do
page.within('[data-testid="branch-selector"]') do
expect(page).to have_content(default_branch)
expect(page).not_to have_content(other_branch)
end
end
it 'displays updated current branch after switching branches' do
switch_to_branch(other_branch)
page.within('[data-testid="branch-selector"]') do
expect(page).to have_content(other_branch)
expect(page).not_to have_content(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