Skip to content
代码片段 群组 项目
提交 96f54e72 编辑于 作者: Will Meek's avatar Will Meek 提交者: Dan Davison
浏览文件

Migrate Secure specs to use testid

上级 7f91c621
No related branches found
No related tags found
无相关合并请求
...@@ -95,6 +95,9 @@ export default { ...@@ -95,6 +95,9 @@ export default {
showSecondaryConfigurationHelpPath() { showSecondaryConfigurationHelpPath() {
return Boolean(this.available && this.feature.secondary?.configurationHelpPath); return Boolean(this.available && this.feature.secondary?.configurationHelpPath);
}, },
hyphenatedFeature() {
return this.feature.type.replace(/_/g, '-');
},
}, },
methods: { methods: {
onError(message) { onError(message) {
...@@ -167,7 +170,7 @@ export default { ...@@ -167,7 +170,7 @@ export default {
:href="feature.configurationPath" :href="feature.configurationPath"
variant="confirm" variant="confirm"
:category="configurationButton.category" :category="configurationButton.category"
:data-testid="`${feature.type}_enable_button`" :data-testid="`${hyphenatedFeature}-enable-button`"
class="gl-mt-5" class="gl-mt-5"
> >
{{ configurationButton.text }} {{ configurationButton.text }}
...@@ -179,7 +182,7 @@ export default { ...@@ -179,7 +182,7 @@ export default {
variant="confirm" variant="confirm"
:category="manageViaMrButtonCategory" :category="manageViaMrButtonCategory"
class="gl-mt-5" class="gl-mt-5"
:data-testid="`${feature.type}_mr_button`" :data-testid="`${hyphenatedFeature}-mr-button`"
@error="onError" @error="onError"
/> />
......
...@@ -634,7 +634,6 @@ export default { ...@@ -634,7 +634,6 @@ export default {
variant="confirm" variant="confirm"
:disabled="isMergeButtonDisabled" :disabled="isMergeButtonDisabled"
:loading="isMakingRequest" :loading="isMakingRequest"
data-qa-selector="merge_button"
@click="handleMergeButtonClick(isAutoMergeAvailable)" @click="handleMergeButtonClick(isAutoMergeAvailable)"
>{{ mergeButtonText }}</gl-button >{{ mergeButtonText }}</gl-button
> >
...@@ -644,7 +643,6 @@ export default { ...@@ -644,7 +643,6 @@ export default {
:disabled="isMergeButtonDisabled" :disabled="isMergeButtonDisabled"
variant="confirm" variant="confirm"
data-testid="merge-immediately-dropdown" data-testid="merge-immediately-dropdown"
data-qa-selector="merge_moment_dropdown"
toggle-class="btn-icon js-merge-moment" toggle-class="btn-icon js-merge-moment"
> >
<template #button-content> <template #button-content>
...@@ -655,7 +653,6 @@ export default { ...@@ -655,7 +653,6 @@ export default {
icon-name="warning" icon-name="warning"
button-class="accept-merge-request" button-class="accept-merge-request"
data-testid="merge-immediately-button" data-testid="merge-immediately-button"
data-qa-selector="merge_immediately_menu_item"
@click="handleMergeImmediatelyButtonClick" @click="handleMergeImmediatelyButtonClick"
> >
{{ __('Merge immediately') }} {{ __('Merge immediately') }}
...@@ -692,7 +689,7 @@ export default { ...@@ -692,7 +689,7 @@ export default {
<div <div
v-else v-else
class="gl-w-full gl-order-n1 mr-widget-merge-details" class="gl-w-full gl-order-n1 mr-widget-merge-details"
data-qa-selector="merged_status_content" data-testid="merged-status-content"
> >
<p v-if="showMergeDetailsHeader" class="gl-mb-2 gl-text-gray-900"> <p v-if="showMergeDetailsHeader" class="gl-mb-2 gl-text-gray-900">
{{ __('Merge details') }} {{ __('Merge details') }}
......
...@@ -62,7 +62,7 @@ export default { ...@@ -62,7 +62,7 @@ export default {
<gl-button ref="cancelButton" @click="cancel">{{ __('Cancel') }}</gl-button> <gl-button ref="cancelButton" @click="cancel">{{ __('Cancel') }}</gl-button>
<gl-button <gl-button
variant="danger" variant="danger"
data-qa-selector="merge_immediately_button" data-testid="merge-immediately-confirmation-button"
@click="mergeImmediately" @click="mergeImmediately"
>{{ __('Merge immediately') }}</gl-button >{{ __('Merge immediately') }}</gl-button
> >
......
...@@ -44,7 +44,7 @@ def self.prepended(base) ...@@ -44,7 +44,7 @@ def self.prepended(base)
end end
view 'ee/app/assets/javascripts/vue_merge_request_widget/components/merge_immediately_confirmation_dialog.vue' do view 'ee/app/assets/javascripts/vue_merge_request_widget/components/merge_immediately_confirmation_dialog.vue' do
element :merge_immediately_button element 'merge-immediately-confirmation-button'
end end
view 'ee/app/assets/javascripts/security_dashboard/components/pipeline/vulnerability_finding_modal.vue' do view 'ee/app/assets/javascripts/security_dashboard/components/pipeline/vulnerability_finding_modal.vue' do
...@@ -234,13 +234,13 @@ def num_approvals_required ...@@ -234,13 +234,13 @@ def num_approvals_required
end end
def skip_merge_train_and_merge_immediately def skip_merge_train_and_merge_immediately
click_element :merge_moment_dropdown click_element 'merge-immediately-dropdown'
click_element :merge_immediately_menu_item click_element 'merge-immediately-button'
# Wait for the warning modal dialog to appear # Wait for the warning modal dialog to appear
wait_for_animated_element :merge_immediately_button wait_for_animated_element 'merge-immediately-confirmation-button'
click_element :merge_immediately_button click_element 'merge-immediately-confirmation-button'
finished_loading? finished_loading?
end end
......
...@@ -36,18 +36,6 @@ def has_license?(name) ...@@ -36,18 +36,6 @@ def has_license?(name)
has_element?('report-item-row', text: name) has_element?('report-item-row', text: name)
end end
def has_approved_license?(name)
within_element('report-item-row', text: name) do
has_element?(:status_success_icon, wait: 1)
end
end
def has_denied_license?(name)
within_element('report-item-row', text: name) do
has_element?(:status_failed_icon, wait: 1)
end
end
def wait_for_pipeline_job_replication(name) def wait_for_pipeline_job_replication(name)
QA::Runtime::Logger.debug(%(#{self.class.name} - wait_for_pipeline_job_replication)) QA::Runtime::Logger.debug(%(#{self.class.name} - wait_for_pipeline_job_replication))
wait_until(max_duration: Runtime::Geo.max_file_replication_time) do wait_until(max_duration: Runtime::Geo.max_file_replication_time) do
......
...@@ -9,7 +9,7 @@ class Show < Page::Base ...@@ -9,7 +9,7 @@ class Show < Page::Base
end end
view 'app/views/projects/blame/show.html.haml' do view 'app/views/projects/blame/show.html.haml' do
element :blame_file_content element 'blob-content-holder'
end end
def has_file?(file_name) def has_file?(file_name)
...@@ -23,11 +23,11 @@ def has_no_file?(file_name) ...@@ -23,11 +23,11 @@ def has_no_file?(file_name)
end end
def has_file_content?(file_content) def has_file_content?(file_content)
within_element(:blame_file_content) { has_text?(file_content) } within_element('blob-content-holder') { has_text?(file_content) }
end end
def has_no_file_content?(file_content) def has_no_file_content?(file_content)
within_element(:blame_file_content) do within_element('blob-content-holder') do
has_no_text?(file_content) has_no_text?(file_content)
end end
end end
......
...@@ -81,10 +81,10 @@ class Show < Page::Base ...@@ -81,10 +81,10 @@ class Show < Page::Base
end end
view 'app/assets/javascripts/vue_merge_request_widget/components/states/ready_to_merge.vue' do view 'app/assets/javascripts/vue_merge_request_widget/components/states/ready_to_merge.vue' do
element :merge_button element 'merge-button'
element :merge_moment_dropdown element 'merge-immediately-dropdown'
element :merge_immediately_menu_item element 'merge-immediately-button'
element :merged_status_content element 'merged-status-content'
end end
view 'app/assets/javascripts/vue_merge_request_widget/components/states/sha_mismatch.vue' do view 'app/assets/javascripts/vue_merge_request_widget/components/states/sha_mismatch.vue' do
...@@ -253,13 +253,13 @@ def open_file_tree ...@@ -253,13 +253,13 @@ def open_file_tree
def has_merge_button? def has_merge_button?
refresh refresh
has_element?(:merge_button) has_element?('merge-button')
end end
def has_no_merge_button? def has_no_merge_button?
refresh refresh
has_no_element?(:merge_button) has_no_element?('merge-button')
end end
RSpec::Matchers.define :have_merge_button do RSpec::Matchers.define :have_merge_button do
...@@ -306,7 +306,7 @@ def merge! ...@@ -306,7 +306,7 @@ def merge!
def merge_when_pipeline_succeeds! def merge_when_pipeline_succeeds!
wait_until_ready_to_merge wait_until_ready_to_merge
click_element(:merge_button, text: 'Merge when pipeline succeeds') click_element('merge-button', text: 'Merge when pipeline succeeds')
end end
def merged? def merged?
...@@ -317,17 +317,17 @@ def merged? ...@@ -317,17 +317,17 @@ def merged?
# To remove page refresh logic if possible # To remove page refresh logic if possible
# We don't raise on failure because this method is used as a predicate matcher # We don't raise on failure because this method is used as a predicate matcher
retry_until(max_attempts: 3, reload: true, raise_on_failure: false) do retry_until(max_attempts: 3, reload: true, raise_on_failure: false) do
has_element?(:merged_status_content, text: /The changes were merged into|Changes merged into/, wait: 20) has_element?('merged-status-content', text: /The changes were merged into|Changes merged into/, wait: 20)
end end
end end
RSpec::Matchers.define :be_mergeable do RSpec::Matchers.define :be_mergeable do
match do |page| match do |page|
page.has_element?(:merge_button, disabled: false) page.has_element?('merge-button', disabled: false)
end end
match_when_negated do |page| match_when_negated do |page|
page.has_no_element?(:merge_button, disabled: false) page.has_no_element?('merge-button', disabled: false)
end end
end end
...@@ -347,9 +347,9 @@ def wait_until_ready_to_merge(transient_test: false) ...@@ -347,9 +347,9 @@ def wait_until_ready_to_merge(transient_test: false)
wait_until(message: "Waiting for ready to merge", sleep_interval: 1) do wait_until(message: "Waiting for ready to merge", sleep_interval: 1) do
# changes in mr are rendered async, because of that mr can sometimes show no changes and there will be no # changes in mr are rendered async, because of that mr can sometimes show no changes and there will be no
# merge button, in such case we must retry loop otherwise find_element will raise ElementNotFound error # merge button, in such case we must retry loop otherwise find_element will raise ElementNotFound error
next false unless has_element?(:merge_button, wait: 1) next false unless has_element?('merge-button', wait: 1)
break true unless find_element(:merge_button).disabled? break true unless find_element('merge-button').disabled?
# If the widget shows "Merge blocked: new changes were just added" we can refresh the page and check again # If the widget shows "Merge blocked: new changes were just added" we can refresh the page and check again
next false if has_element?(:head_mismatch_content, wait: 1) next false if has_element?(:head_mismatch_content, wait: 1)
...@@ -380,11 +380,11 @@ def rebase! ...@@ -380,11 +380,11 @@ def rebase!
def merge_immediately! def merge_immediately!
retry_until(reload: true, sleep_interval: 1, max_attempts: 12) do retry_until(reload: true, sleep_interval: 1, max_attempts: 12) do
if has_element?(:merge_moment_dropdown) if has_element?('merge-immediately-dropdown')
click_element(:merge_moment_dropdown, skip_finished_loading_check: true) click_element('merge-immediately-dropdown', skip_finished_loading_check: true)
click_element(:merge_immediately_menu_item, skip_finished_loading_check: true) click_element('merge-immediately-button', skip_finished_loading_check: true)
else else
click_element(:merge_button, skip_finished_loading_check: true) click_element('merge-button', skip_finished_loading_check: true)
end end
merged? merged?
...@@ -395,9 +395,9 @@ def try_to_merge! ...@@ -395,9 +395,9 @@ def try_to_merge!
# Revisit after merge page re-architect is done https://gitlab.com/gitlab-org/gitlab/-/issues/300042 # Revisit after merge page re-architect is done https://gitlab.com/gitlab-org/gitlab/-/issues/300042
# To remove page refresh logic if possible # To remove page refresh logic if possible
wait_until_ready_to_merge wait_until_ready_to_merge
wait_until { !find_element(:merge_button).text.include?('when pipeline succeeds') } # rubocop:disable Rails/NegateInclude wait_until { !find_element('merge-button').text.include?('when pipeline succeeds') } # rubocop:disable Rails/NegateInclude
click_element(:merge_button) click_element('merge-button')
end end
def view_email_patches def view_email_patches
......
...@@ -14,8 +14,8 @@ class ConfigurationForm < QA::Page::Base ...@@ -14,8 +14,8 @@ class ConfigurationForm < QA::Page::Base
view 'app/assets/javascripts/security_configuration/components/feature_card.vue' do view 'app/assets/javascripts/security_configuration/components/feature_card.vue' do
element 'feature-status' element 'feature-status'
element :sast_enable_button, "`${feature.type}_enable_button`" # rubocop:disable QA/ElementWithPattern element 'sast-enable-button', "`${hyphenatedFeature}-enable-button`" # rubocop:disable QA/ElementWithPattern
element :dependency_scanning_mr_button, "`${feature.type}_mr_button`" # rubocop:disable QA/ElementWithPattern element 'dependency-scanning-mr-button', "`${hyphenatedFeature}-mr-button`" # rubocop:disable QA/ElementWithPattern
end end
view 'app/assets/javascripts/security_configuration/components/auto_dev_ops_alert.vue' do view 'app/assets/javascripts/security_configuration/components/auto_dev_ops_alert.vue' do
...@@ -35,11 +35,11 @@ def click_security_configuration_history_link ...@@ -35,11 +35,11 @@ def click_security_configuration_history_link
end end
def click_sast_enable_button def click_sast_enable_button
click_element(:sast_enable_button) click_element('sast-enable-button')
end end
def click_dependency_scanning_mr_button def click_dependency_scanning_mr_button
click_element(:dependency_scanning_mr_button) click_element('dependency-scanning-mr-button')
end end
def has_true_sast_status? def has_true_sast_status?
......
...@@ -75,7 +75,7 @@ module QA ...@@ -75,7 +75,7 @@ module QA
mr.retry_until(reload: true, message: 'Wait until ready to click MWPS') do mr.retry_until(reload: true, message: 'Wait until ready to click MWPS') do
# Click the MWPS button if we can # Click the MWPS button if we can
break mr.merge_when_pipeline_succeeds! if mr.has_element?(:merge_button, text: 'Merge when pipeline succeeds') break mr.merge_when_pipeline_succeeds! if mr.has_element?('merge-button', text: 'Merge when pipeline succeeds')
# But fail if the button is missing because the pipeline is complete # But fail if the button is missing because the pipeline is complete
raise "The pipeline already finished before we could click MWPS" if mr.wait_until { project.pipelines.first }[:status] == 'success' raise "The pipeline already finished before we could click MWPS" if mr.wait_until { project.pipelines.first }[:status] == 'success'
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册