Commit 359a9319 authored by Ezekiel Kigbo's avatar Ezekiel Kigbo

Minor refactor test helpers

Adds a data-testid to the stage divs to
ease selection
parent 8bff67db
......@@ -89,7 +89,7 @@ export default {
};
</script>
<template>
<div>
<div data-testid="value-stream-stage-fields">
<div class="gl-display-flex">
<gl-form-group
class="gl-flex-grow-1"
......
......@@ -59,7 +59,7 @@ export default {
};
</script>
<template>
<div class="gl-mb-4">
<div class="gl-mb-4" data-testid="value-stream-stage-fields">
<div class="gl-display-flex">
<gl-form-group
class="gl-flex-grow-1 gl-mb-0"
......
......@@ -40,11 +40,17 @@ RSpec.describe 'Multiple value streams', :js do
wait_for_requests
end
def add_custom_stage_to_form(index = 6)
def add_custom_stage_to_form
page.find_button(s_('CreateValueStreamForm|Add another stage')).click
fill_in "custom-stage-name-#{index}", with: "Cool custom stage - name #{index}"
select_dropdown_option_by_value "custom-stage-start-event-#{index}", :merge_request_created
select_dropdown_option_by_value "custom-stage-end-event-#{index}", :merge_request_merged
index = page.all('[data-testid="value-stream-stage-fields"]').length
last_stage = page.all('[data-testid="value-stream-stage-fields"]').last
within last_stage do
find('[name*="custom-stage-name-"]').fill_in with: "Cool custom stage - name #{index}"
select_dropdown_option_by_value "custom-stage-start-event-", :merge_request_created
select_dropdown_option_by_value "custom-stage-end-event-", :merge_request_merged
end
end
def create_value_stream
......@@ -120,7 +126,7 @@ RSpec.describe 'Multiple value streams', :js do
end
it 'can add a custom stage' do
add_custom_stage_to_form(7)
add_custom_stage_to_form
page.find_button(_('Save Value Stream')).click
wait_for_requests
......
......@@ -15,7 +15,7 @@ module CycleAnalyticsHelpers
end
def toggle_dropdown(field)
page.within("[data-testid='#{field}']") do
page.within("[data-testid*='#{field}']") do
find('.dropdown-toggle').click
wait_for_requests
......@@ -26,7 +26,7 @@ module CycleAnalyticsHelpers
def select_dropdown_option_by_value(name, value, elem = '.dropdown-item')
toggle_dropdown name
page.find("[data-testid='#{name}'] .dropdown-menu").find("#{elem}[value='#{value}']").click
page.find("[data-testid*='#{name}'] .dropdown-menu").find("#{elem}[value='#{value}']").click
end
def create_commit_referencing_issue(issue, branch_name: generate(:branch))
......
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