diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-03-30 15:08:15 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-03-30 15:08:15 +0300 |
commit | bfa1adf9773ba7ea7cde546ea545b72721d36faa (patch) | |
tree | 79155d8617972eaccf3f97be90a511f5fddf1672 /qa | |
parent | e820415ceab5819ea8a29174543f9246b608b5fd (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'qa')
6 files changed, 157 insertions, 0 deletions
diff --git a/qa/qa/page/project/settings/branch_rules.rb b/qa/qa/page/project/settings/branch_rules.rb new file mode 100644 index 00000000000..b01f493addf --- /dev/null +++ b/qa/qa/page/project/settings/branch_rules.rb @@ -0,0 +1,33 @@ +# frozen_string_literal: true + +module QA + module Page + module Project + module Settings + class BranchRules < Page::Base + view 'app/assets/javascripts/projects/settings/repository/branch_rules/app.vue' do + element :add_branch_rule_button + end + + view 'app/assets/javascripts/projects/settings/repository/branch_rules/components/branch_rule.vue' do + element :branch_content + element :details_button + end + + def click_add_branch_rule + click_element(:add_branch_rule_button) + click_button('Create protected branch') + end + + def navigate_to_branch_rules_details(branch_name) + within_element(:branch_content, branch_name: branch_name) do + click_element(:details_button) + end + end + end + end + end + end +end + +QA::Page::Project::Settings::BranchRules.prepend_mod_with('Page::Project::Settings::BranchRules', namespace: QA) diff --git a/qa/qa/page/project/settings/branch_rules_details.rb b/qa/qa/page/project/settings/branch_rules_details.rb new file mode 100644 index 00000000000..f6806a30efa --- /dev/null +++ b/qa/qa/page/project/settings/branch_rules_details.rb @@ -0,0 +1,35 @@ +# frozen_string_literal: true + +module QA + module Page + module Project + module Settings + class BranchRulesDetails < Page::Base + view 'app/assets/javascripts/projects/settings/branch_rules/components/view/index.vue' do + element :allowed_to_push_content + element :allowed_to_merge_content + end + + view 'app/assets/javascripts/projects/settings/branch_rules/components/view/protection_row.vue' do + element :access_level_content + end + + def has_allowed_to_push?(role) + within_element(:allowed_to_push_content) do + has_element?(:access_level_content, role: role) + end + end + + def has_allowed_to_merge?(role) + within_element(:allowed_to_merge_content) do + has_element?(:access_level_content, role: role) + end + end + end + end + end + end +end + +QA::Page::Project::Settings::BranchRulesDetails.prepend_mod_with( # rubocop:disable Cop/InjectEnterpriseEditionModule + 'Page::Project::Settings::BranchRulesDetails', namespace: QA) diff --git a/qa/qa/page/project/settings/repository.rb b/qa/qa/page/project/settings/repository.rb index 6931d26b259..d9aaacbde32 100644 --- a/qa/qa/page/project/settings/repository.rb +++ b/qa/qa/page/project/settings/repository.rb @@ -27,6 +27,10 @@ module QA element :protected_tag_settings_content end + view 'app/views/projects/branch_rules/_show.html.haml' do + element :branch_rules_content + end + def expand_deploy_tokens(&block) expand_content(:deploy_tokens_settings_content) do Settings::DeployTokens.perform(&block) @@ -57,6 +61,10 @@ module QA end end + def expand_branch_rules + expand_content(:branch_rules_content) + end + def expand_default_branch(&block) within('#branch-defaults-settings') do find('.btn-default').click do diff --git a/qa/qa/specs/features/api/1_manage/group_access_token_spec.rb b/qa/qa/specs/features/api/1_manage/group_access_token_spec.rb index e0db758dde3..fc400fbb9c7 100644 --- a/qa/qa/specs/features/api/1_manage/group_access_token_spec.rb +++ b/qa/qa/specs/features/api/1_manage/group_access_token_spec.rb @@ -26,6 +26,9 @@ module QA file.name = "text-#{SecureRandom.hex(8)}.txt" file.content = 'New file' end + rescue StandardError => e + QA::Runtime::Logger.error("Full failure message: #{e.message}") + raise end.not_to raise_error end @@ -42,6 +45,9 @@ module QA commit.commit_message = 'Add new file' commit.add_files([{ file_path: "text-#{SecureRandom.hex(8)}.txt", content: 'new file' }]) end + rescue StandardError => e + QA::Runtime::Logger.error("Full failure message: #{e.message}") + raise end.not_to raise_error end end diff --git a/qa/qa/specs/features/api/1_manage/project_access_token_spec.rb b/qa/qa/specs/features/api/1_manage/project_access_token_spec.rb index d693bbd43ff..eeeb78e17d7 100644 --- a/qa/qa/specs/features/api/1_manage/project_access_token_spec.rb +++ b/qa/qa/specs/features/api/1_manage/project_access_token_spec.rb @@ -24,6 +24,9 @@ module QA file.name = "text-#{SecureRandom.hex(8)}.txt" file.content = 'New file' end + rescue StandardError => e + QA::Runtime::Logger.error("Full failure message: #{e.message}") + raise end.not_to raise_error end @@ -37,6 +40,9 @@ module QA commit.commit_message = 'Add new file' commit.add_files([{ file_path: "text-#{SecureRandom.hex(8)}.txt", content: 'new file' }]) end + rescue StandardError => e + QA::Runtime::Logger.error("Full failure message: #{e.message}") + raise end.not_to raise_error end end diff --git a/qa/qa/specs/features/browser_ui/3_create/repository/add_new_branch_rule_spec.rb b/qa/qa/specs/features/browser_ui/3_create/repository/add_new_branch_rule_spec.rb new file mode 100644 index 00000000000..de6723e5579 --- /dev/null +++ b/qa/qa/specs/features/browser_ui/3_create/repository/add_new_branch_rule_spec.rb @@ -0,0 +1,69 @@ +# frozen_string_literal: true + +module QA + RSpec.describe 'Create' do + describe 'Branch Rules Overview', product_group: :source_code, feature_flag: { + name: 'branch_rules', + scope: :project + } do + let(:branch_name) { 'new-branch' } + let(:allowed_to_push_role) { Resource::ProtectedBranch::Roles::NO_ONE } + let(:allowed_to_merge_role) { Resource::ProtectedBranch::Roles::MAINTAINERS } + let(:project) do + Resource::Project.fabricate_via_api! do |project| + project.name = 'branch-rule-project' + project.initialize_with_readme = true + end + end + + before do + Runtime::Feature.enable(:branch_rules, project: project) + + Flow::Login.sign_in + + Resource::Repository::Commit.fabricate_via_api! do |commit| + commit.project = project + commit.branch = branch_name + commit.start_branch = project.default_branch + commit.commit_message = 'First commit' + commit.add_files([{ file_path: 'new_file.rb', content: '# new content' }]) + end + end + + after do + Runtime::Feature.disable(:branch_rules, project: project) + end + + it 'adds a new branch rule', testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/397587' do + project.visit! + + Page::Project::Menu.perform(&:go_to_repository_settings) + + Page::Project::Settings::Repository.perform(&:expand_branch_rules) + + Page::Project::Settings::BranchRules.perform(&:click_add_branch_rule) + + Page::Project::Settings::ProtectedBranches.perform do |settings| + settings.select_branch(branch_name) + settings.select_allowed_to_push(roles: allowed_to_push_role) + settings.select_allowed_to_merge(roles: allowed_to_merge_role) + settings.protect_branch + end + + Page::Project::Settings::Repository.perform(&:expand_branch_rules) + + Page::Project::Settings::BranchRules.perform do |rules| + expect(rules).to have_content(branch_name) + rules.navigate_to_branch_rules_details(branch_name) + end + + Page::Project::Settings::BranchRulesDetails.perform do |details| + aggregate_failures 'branch rules details' do + expect(details).to have_allowed_to_push(allowed_to_push_role[:description]) + expect(details).to have_allowed_to_merge(allowed_to_merge_role[:description]) + end + end + end + end + end +end |