Commit 8b2532a3 authored by Dan Davison's avatar Dan Davison

Merge branch 'qa-add-click-by-js-to-checkboxes' into 'master'

Fix e2e checkbox workarounds

See merge request gitlab-org/gitlab!58958
parents 99cfad50 e80e136c
...@@ -214,7 +214,7 @@ export default { ...@@ -214,7 +214,7 @@ export default {
<gl-form-checkbox <gl-form-checkbox
v-model="issueTransitionEnabled" v-model="issueTransitionEnabled"
:disabled="isInheriting" :disabled="isInheriting"
data-qa-selector="service_jira_issue_transition_enabled" data-qa-selector="service_jira_issue_transition_enabled_checkbox"
> >
{{ s__('JiraService|Enable Jira transitions') }} {{ s__('JiraService|Enable Jira transitions') }}
</gl-form-checkbox> </gl-form-checkbox>
...@@ -232,7 +232,7 @@ export default { ...@@ -232,7 +232,7 @@ export default {
name="service[jira_issue_transition_automatic]" name="service[jira_issue_transition_automatic]"
:value="issueTransitionOption.value" :value="issueTransitionOption.value"
:disabled="isInheriting" :disabled="isInheriting"
:data-qa-selector="`service_jira_issue_transition_automatic_${issueTransitionOption.value}`" :data-qa-selector="`service_jira_issue_transition_automatic_${issueTransitionOption.value}_radio`"
> >
{{ issueTransitionOption.label }} {{ issueTransitionOption.label }}
......
...@@ -44,7 +44,8 @@ export default { ...@@ -44,7 +44,8 @@ export default {
:checked="value" :checked="value"
:disabled="isDisabled" :disabled="isDisabled"
name="squash" name="squash"
class="qa-squash-checkbox js-squash-checkbox gl-mr-2 gl-display-flex gl-align-items-center" class="js-squash-checkbox gl-mr-2 gl-display-flex gl-align-items-center"
data-qa-selector="squash_checkbox"
:title="tooltipTitle" :title="tooltipTitle"
@change="(checked) => $emit('input', checked)" @change="(checked) => $emit('input', checked)"
> >
......
...@@ -162,14 +162,11 @@ export default { ...@@ -162,14 +162,11 @@ export default {
</template> </template>
</markdown-field> </markdown-field>
</gl-form-group> </gl-form-group>
<gl-form-group <gl-form-group :label="__('Confidentiality')" label-for="epic-confidentiality">
:label="__('Confidentiality')"
label-for="epic-confidentiality"
data-qa-selector="confidential_epic_checkbox"
>
<gl-form-checkbox <gl-form-checkbox
id="epic-confidentiality" id="epic-confidentiality"
v-model="confidential" v-model="confidential"
data-qa-selector="confidential_epic_checkbox"
data-testid="epic-confidentiality" data-testid="epic-confidentiality"
> >
{{ $options.i18n.confidentialityLabel }} {{ $options.i18n.confidentialityLabel }}
......
...@@ -17,8 +17,7 @@ module QA ...@@ -17,8 +17,7 @@ module QA
end end
def enable_confidential_epic def enable_confidential_epic
# TODO: Fix this workaround for checkbox hidden by label check_element(:confidential_epic_checkbox, true)
find_element(:confidential_epic_checkbox, visible: false).click
end end
def set_title(title) def set_title(title)
......
...@@ -132,7 +132,7 @@ module QA ...@@ -132,7 +132,7 @@ module QA
all(element_selector_css(name), **kwargs) all(element_selector_css(name), **kwargs)
end end
def check_element(name) def check_element(name, click_by_js = false)
if find_element(name, visible: false).checked? if find_element(name, visible: false).checked?
QA::Runtime::Logger.debug("#{name} is already checked") QA::Runtime::Logger.debug("#{name} is already checked")
...@@ -140,7 +140,7 @@ module QA ...@@ -140,7 +140,7 @@ module QA
end end
retry_until(sleep_interval: 1) do retry_until(sleep_interval: 1) do
find_element(name, visible: false).click click_checkbox_or_radio(name, click_by_js)
checked = find_element(name, visible: false).checked? checked = find_element(name, visible: false).checked?
QA::Runtime::Logger.debug(checked ? "#{name} was checked" : "#{name} was not checked") QA::Runtime::Logger.debug(checked ? "#{name} was checked" : "#{name} was not checked")
...@@ -149,7 +149,7 @@ module QA ...@@ -149,7 +149,7 @@ module QA
end end
end end
def uncheck_element(name) def uncheck_element(name, click_by_js = false)
unless find_element(name, visible: false).checked? unless find_element(name, visible: false).checked?
QA::Runtime::Logger.debug("#{name} is already unchecked") QA::Runtime::Logger.debug("#{name} is already unchecked")
...@@ -157,7 +157,7 @@ module QA ...@@ -157,7 +157,7 @@ module QA
end end
retry_until(sleep_interval: 1) do retry_until(sleep_interval: 1) do
find_element(name, visible: false).click click_checkbox_or_radio(name, click_by_js)
unchecked = !find_element(name, visible: false).checked? unchecked = !find_element(name, visible: false).checked?
QA::Runtime::Logger.debug(unchecked ? "#{name} was unchecked" : "#{name} was not unchecked") QA::Runtime::Logger.debug(unchecked ? "#{name} was unchecked" : "#{name} was not unchecked")
...@@ -175,9 +175,7 @@ module QA ...@@ -175,9 +175,7 @@ module QA
end end
retry_until(sleep_interval: 1) do retry_until(sleep_interval: 1) do
radio = find_element(name, visible: false) click_checkbox_or_radio(name, click_by_js)
# Some radio buttons are hidden by their labels and cannot be clicked directly
click_by_js ? page.execute_script("arguments[0].click();", radio) : radio.click
selected = find_element(name, visible: false).checked? selected = find_element(name, visible: false).checked?
QA::Runtime::Logger.debug(selected ? "#{name} was selected" : "#{name} was not selected") QA::Runtime::Logger.debug(selected ? "#{name} was selected" : "#{name} was not selected")
...@@ -423,6 +421,14 @@ module QA ...@@ -423,6 +421,14 @@ module QA
end end
end end
end end
private
def click_checkbox_or_radio(name, click_by_js)
box = find_element(name, visible: false)
# Some checkboxes and radio buttons are hidden by their labels and cannot be clicked directly
click_by_js ? page.execute_script("arguments[0].click();", box) : box.click
end
end end
end end
end end
...@@ -238,18 +238,12 @@ module QA ...@@ -238,18 +238,12 @@ module QA
end end
def mark_to_squash def mark_to_squash
# The squash checkbox is disabled on load
wait_until do
has_element?(:squash_checkbox)
end
# The squash checkbox is enabled via JS # The squash checkbox is enabled via JS
wait_until(reload: false) do wait_until(reload: false) do
!find_element(:squash_checkbox).disabled? !find_element(:squash_checkbox, visible: false).disabled?
end end
# TODO: Fix workaround for data-qa-selector failure check_element(:squash_checkbox, true)
click_element(:squash_checkbox)
end end
def merge! def merge!
......
...@@ -13,9 +13,9 @@ module QA ...@@ -13,9 +13,9 @@ module QA
end end
view 'app/assets/javascripts/integrations/edit/components/jira_trigger_fields.vue' do view 'app/assets/javascripts/integrations/edit/components/jira_trigger_fields.vue' do
element :service_jira_issue_transition_enabled element :service_jira_issue_transition_enabled_checkbox
element :service_jira_issue_transition_automatic_true, ':data-qa-selector="`service_jira_issue_transition_automatic_${issueTransitionOption.value}`"' # rubocop:disable QA/ElementWithPattern element :service_jira_issue_transition_automatic_true_radio, ':data-qa-selector="`service_jira_issue_transition_automatic_${issueTransitionOption.value}_radio`"' # rubocop:disable QA/ElementWithPattern
element :service_jira_issue_transition_automatic_false, ':data-qa-selector="`service_jira_issue_transition_automatic_${issueTransitionOption.value}`"' # rubocop:disable QA/ElementWithPattern element :service_jira_issue_transition_automatic_false_radio, ':data-qa-selector="`service_jira_issue_transition_automatic_${issueTransitionOption.value}_radio`"' # rubocop:disable QA/ElementWithPattern
element :service_jira_issue_transition_id_field element :service_jira_issue_transition_id_field
end end
...@@ -55,15 +55,15 @@ module QA ...@@ -55,15 +55,15 @@ module QA
end end
def enable_transitions def enable_transitions
click_element_coordinates(:service_jira_issue_transition_enabled, visible: false) check_element(:service_jira_issue_transition_enabled_checkbox, true)
end end
def use_automatic_transitions def use_automatic_transitions
click_element_coordinates(:service_jira_issue_transition_automatic_true, visible: false) choose_element(:service_jira_issue_transition_automatic_true_radio, true)
end end
def use_custom_transitions def use_custom_transitions
click_element_coordinates(:service_jira_issue_transition_automatic_false, visible: false) choose_element(:service_jira_issue_transition_automatic_false_radio, true)
end end
def set_transition_ids(transition_ids) def set_transition_ids(transition_ids)
......
...@@ -52,13 +52,13 @@ module QA ...@@ -52,13 +52,13 @@ module QA
elements elements
end end
def check_element(name) def check_element(name, click_by_js = nil)
log("checking :#{name}") log("checking :#{name}")
super super
end end
def uncheck_element(name) def uncheck_element(name, click_by_js = nil)
log("unchecking :#{name}") log("unchecking :#{name}")
super super
......
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