Commit 0e66c4e2 authored by Peter Leitzen's avatar Peter Leitzen

Merge branch '214449-fix-hardcoded-vsa-string-in-tests' into 'master'

Remove hardcoded I18n string assertions

Closes #214449

See merge request gitlab-org/gitlab!31064
parents 79499705 b5a82d5b
...@@ -5,10 +5,10 @@ describe 'Group Value Stream Analytics', :js do ...@@ -5,10 +5,10 @@ describe 'Group Value Stream Analytics', :js do
include DragTo include DragTo
let_it_be(:user) { create(:user) } let_it_be(:user) { create(:user) }
let_it_be(:group) { create(:group, name: "CA-test-group") } let_it_be(:group) { create(:group, name: 'CA-test-group') }
let_it_be(:sub_group) { create(:group, name: "CA-sub-group", parent: group) } let_it_be(:sub_group) { create(:group, name: 'CA-sub-group', parent: group) }
let_it_be(:group2) { create(:group, name: "CA-bad-test-group") } let_it_be(:group2) { create(:group, name: 'CA-bad-test-group') }
let_it_be(:project) { create(:project, :repository, namespace: group, group: group, name: "Cool fun project") } let_it_be(:project) { create(:project, :repository, namespace: group, group: group, name: 'Cool fun project') }
let_it_be(:group_label1) { create(:group_label, group: group) } let_it_be(:group_label1) { create(:group_label, group: group) }
let_it_be(:group_label2) { create(:group_label, group: group) } let_it_be(:group_label2) { create(:group_label, group: group) }
let_it_be(:label) { create(:group_label, group: group2) } let_it_be(:label) { create(:group_label, group: group2) }
...@@ -29,7 +29,7 @@ describe 'Group Value Stream Analytics', :js do ...@@ -29,7 +29,7 @@ describe 'Group Value Stream Analytics', :js do
it 'displays an empty state before a group is selected' do it 'displays an empty state before a group is selected' do
element = page.find('.row.empty-state') element = page.find('.row.empty-state')
expect(element).to have_content(_("Value Stream Analytics can help you determine your team’s velocity")) expect(element).to have_content(_('Value Stream Analytics can help you determine your team’s velocity'))
expect(element.find('.svg-content img')['src']).to have_content('illustrations/analytics/cycle-analytics-empty-chart') expect(element.find('.svg-content img')['src']).to have_content('illustrations/analytics/cycle-analytics-empty-chart')
end end
end end
...@@ -45,7 +45,7 @@ describe 'Group Value Stream Analytics', :js do ...@@ -45,7 +45,7 @@ describe 'Group Value Stream Analytics', :js do
visit analytics_cycle_analytics_path visit analytics_cycle_analytics_path
end end
it_behaves_like "empty state" it_behaves_like 'empty state'
context 'deep linked url parameters' do context 'deep linked url parameters' do
group_dropdown = '.js-groups-dropdown-filter' group_dropdown = '.js-groups-dropdown-filter'
...@@ -59,8 +59,8 @@ describe 'Group Value Stream Analytics', :js do ...@@ -59,8 +59,8 @@ describe 'Group Value Stream Analytics', :js do
sign_in(user) sign_in(user)
end end
shared_examples "group dropdown set" do shared_examples 'group dropdown set' do
it "has the group dropdown prepopulated" do it 'has the group dropdown prepopulated' do
element = page.find(group_dropdown) element = page.find(group_dropdown)
expect(element).to have_content group.name expect(element).to have_content group.name
...@@ -73,7 +73,7 @@ describe 'Group Value Stream Analytics', :js do ...@@ -73,7 +73,7 @@ describe 'Group Value Stream Analytics', :js do
visit analytics_cycle_analytics_path visit analytics_cycle_analytics_path
end end
it_behaves_like "empty state" it_behaves_like 'empty state'
end end
context 'with created_after date > created_before date' do context 'with created_after date > created_before date' do
...@@ -81,7 +81,7 @@ describe 'Group Value Stream Analytics', :js do ...@@ -81,7 +81,7 @@ describe 'Group Value Stream Analytics', :js do
visit "#{analytics_cycle_analytics_path}?created_after=2019-12-31&created_before=2019-11-01" visit "#{analytics_cycle_analytics_path}?created_after=2019-12-31&created_before=2019-11-01"
end end
it_behaves_like "empty state" it_behaves_like 'empty state'
end end
context 'with fake parameters' do context 'with fake parameters' do
...@@ -89,7 +89,7 @@ describe 'Group Value Stream Analytics', :js do ...@@ -89,7 +89,7 @@ describe 'Group Value Stream Analytics', :js do
visit "#{analytics_cycle_analytics_path}?beans=not-cool" visit "#{analytics_cycle_analytics_path}?beans=not-cool"
end end
it_behaves_like "empty state" it_behaves_like 'empty state'
end end
end end
...@@ -99,7 +99,7 @@ describe 'Group Value Stream Analytics', :js do ...@@ -99,7 +99,7 @@ describe 'Group Value Stream Analytics', :js do
visit "#{analytics_cycle_analytics_path}?group_id=#{group.full_path}" visit "#{analytics_cycle_analytics_path}?group_id=#{group.full_path}"
end end
it_behaves_like "group dropdown set" it_behaves_like 'group dropdown set'
end end
context 'with project_ids set' do context 'with project_ids set' do
...@@ -107,13 +107,13 @@ describe 'Group Value Stream Analytics', :js do ...@@ -107,13 +107,13 @@ describe 'Group Value Stream Analytics', :js do
visit "#{analytics_cycle_analytics_path}?group_id=#{group.full_path}&project_ids[]=#{project.id}" visit "#{analytics_cycle_analytics_path}?group_id=#{group.full_path}&project_ids[]=#{project.id}"
end end
it "has the projects dropdown prepopulated" do it 'has the projects dropdown prepopulated' do
element = page.find(projects_dropdown) element = page.find(projects_dropdown)
expect(element).to have_content project.name expect(element).to have_content project.name
end end
it_behaves_like "group dropdown set" it_behaves_like 'group dropdown set'
end end
context 'with created_before and created_after set' do context 'with created_before and created_after set' do
...@@ -123,14 +123,14 @@ describe 'Group Value Stream Analytics', :js do ...@@ -123,14 +123,14 @@ describe 'Group Value Stream Analytics', :js do
visit "#{analytics_cycle_analytics_path}?group_id=#{group.full_path}&created_before=2019-12-31&created_after=2019-11-01" visit "#{analytics_cycle_analytics_path}?group_id=#{group.full_path}&created_before=2019-12-31&created_after=2019-11-01"
end end
it "has the date range prepopulated" do it 'has the date range prepopulated' do
element = page.find(date_range) element = page.find(date_range)
expect(element.find('.js-daterange-picker-from input').value).to eq "2019-11-01" expect(element.find('.js-daterange-picker-from input').value).to eq '2019-11-01'
expect(element.find('.js-daterange-picker-to input').value).to eq "2019-12-31" expect(element.find('.js-daterange-picker-to input').value).to eq '2019-12-31'
end end
it_behaves_like "group dropdown set" it_behaves_like 'group dropdown set'
end end
end end
end end
...@@ -188,7 +188,7 @@ describe 'Group Value Stream Analytics', :js do ...@@ -188,7 +188,7 @@ describe 'Group Value Stream Analytics', :js do
it 'will display recent activity' do it 'will display recent activity' do
page.within(find('.js-recent-activity')) do page.within(find('.js-recent-activity')) do
expect(page).to have_selector('.card-header') expect(page).to have_selector('.card-header')
expect(page).to have_content('Recent Activity') expect(page).to have_content(_('Recent Activity'))
end end
end end
end end
...@@ -211,14 +211,15 @@ describe 'Group Value Stream Analytics', :js do ...@@ -211,14 +211,15 @@ describe 'Group Value Stream Analytics', :js do
stage_nav = page.find(stage_nav_selector) stage_nav = page.find(stage_nav_selector)
%w[Issue Plan Code Test Review Staging Total].each do |item| %w[Issue Plan Code Test Review Staging Total].each do |item|
expect(stage_nav).to have_content(item) string_id = "CycleAnalytics|#{item}"
expect(stage_nav).to have_content(s_(string_id))
end end
end end
end end
end end
context 'with a group selected' do context 'with a group selected' do
card_metric_selector = ".js-recent-activity .js-metric-card-item" card_metric_selector = '.js-recent-activity .js-metric-card-item'
before do before do
select_group select_group
...@@ -231,14 +232,14 @@ describe 'Group Value Stream Analytics', :js do ...@@ -231,14 +232,14 @@ describe 'Group Value Stream Analytics', :js do
it 'displays the number of issues' do it 'displays the number of issues' do
issue_count = page.all(card_metric_selector).first issue_count = page.all(card_metric_selector).first
expect(issue_count).to have_content('New Issues') expect(issue_count).to have_content(n_('New Issue', 'New Issues', 3))
expect(issue_count).to have_content('3') expect(issue_count).to have_content('3')
end end
it 'displays the number of deploys' do it 'displays the number of deploys' do
deploys_count = page.all(card_metric_selector)[1] deploys_count = page.all(card_metric_selector)[1]
expect(deploys_count).to have_content('Deploys') expect(deploys_count).to have_content(n_('Deploy', 'Deploys', 0))
expect(deploys_count).to have_content('-') expect(deploys_count).to have_content('-')
end end
...@@ -259,7 +260,8 @@ describe 'Group Value Stream Analytics', :js do ...@@ -259,7 +260,8 @@ describe 'Group Value Stream Analytics', :js do
end end
def select_stage(name) def select_stage(name)
page.find('.stage-nav .stage-nav-item .stage-name', text: name, match: :prefer_exact).click string_id = "CycleAnalyticsStage|#{name}"
page.find('.stage-nav .stage-nav-item .stage-name', text: s_(string_id), match: :prefer_exact).click
wait_for_requests wait_for_requests
end end
...@@ -297,17 +299,17 @@ describe 'Group Value Stream Analytics', :js do ...@@ -297,17 +299,17 @@ describe 'Group Value Stream Analytics', :js do
end end
dummy_stages = [ dummy_stages = [
{ title: "Issue", description: "Time before an issue gets scheduled", events_count: 1, median: "5 days" }, { title: 'Issue', description: 'Time before an issue gets scheduled', events_count: 1, median: '5 days' },
{ title: "Plan", description: "Time before an issue starts implementation", events_count: 0, median: "Not enough data" }, { title: 'Plan', description: 'Time before an issue starts implementation', events_count: 0, median: 'Not enough data' },
{ title: "Code", description: "Time until first merge request", events_count: 1, median: "about 5 hours" }, { title: 'Code', description: 'Time until first merge request', events_count: 1, median: 'about 5 hours' },
{ title: "Test", description: "Total test time for all commits/merges", events_count: 0, median: "Not enough data" }, { title: 'Test', description: 'Total test time for all commits/merges', events_count: 0, median: 'Not enough data' },
{ title: "Review", description: "Time between merge request creation and merge/close", events_count: 1, median: "about 1 hour" }, { title: 'Review', description: 'Time between merge request creation and merge/close', events_count: 1, median: 'about 1 hour' },
{ title: "Staging", description: "From merge request merge until deploy to production", events_count: 1, median: "about 1 hour" }, { title: 'Staging', description: 'From merge request merge until deploy to production', events_count: 1, median: 'about 1 hour' },
{ title: "Total", description: "From issue creation until deploy to production", events_count: 1, median: "5 days" } { title: 'Total', description: 'From issue creation until deploy to production', events_count: 1, median: '5 days' }
] ]
it 'each stage will have median values', :sidekiq_might_not_need_inline do it 'each stage will have median values', :sidekiq_might_not_need_inline do
stages = page.all(".stage-nav .stage-median").collect(&:text) stages = page.all('.stage-nav .stage-median').collect(&:text)
stages.each_with_index do |median, index| stages.each_with_index do |median, index|
expect(median).to eq(dummy_stages[index][:median]) expect(median).to eq(dummy_stages[index][:median])
...@@ -321,7 +323,7 @@ describe 'Group Value Stream Analytics', :js do ...@@ -321,7 +323,7 @@ describe 'Group Value Stream Analytics', :js do
if stage[:events_count] == 0 if stage[:events_count] == 0
expect(page).not_to have_selector('.stage-events .events-description') expect(page).not_to have_selector('.stage-events .events-description')
else else
expect(page.find('.stage-events .events-description').text).to have_text(stage[:description]) expect(page.find('.stage-events .events-description').text).to have_text(_(stage[:description]))
end end
end end
end end
...@@ -368,9 +370,9 @@ describe 'Group Value Stream Analytics', :js do ...@@ -368,9 +370,9 @@ describe 'Group Value Stream Analytics', :js do
end end
it 'displays the chart' do it 'displays the chart' do
expect(page).to have_text('Type of work') expect(page).to have_text(s_('CycleAnalytics|Type of work'))
expect(page).to have_text('Tasks by type') expect(page).to have_text(s_('CycleAnalytics|Tasks by type'))
end end
it 'has 2 labels selected' do it 'has 2 labels selected' do
...@@ -390,17 +392,17 @@ describe 'Group Value Stream Analytics', :js do ...@@ -390,17 +392,17 @@ describe 'Group Value Stream Analytics', :js do
end end
it 'shows the no data available message' do it 'shows the no data available message' do
expect(page).to have_text('Type of work') expect(page).to have_text(s_('CycleAnalytics|Type of work'))
expect(page).to have_text('There is no data available. Please change your selection.') expect(page).to have_text(_('There is no data available. Please change your selection.'))
end end
end end
end end
end end
describe 'Customizable cycle analytics', :js do describe 'Customizable cycle analytics', :js do
custom_stage_name = "Cool beans" custom_stage_name = 'Cool beans'
custom_stage_with_labels_name = "Cool beans - now with labels" custom_stage_with_labels_name = 'Cool beans - now with labels'
start_event_identifier = :merge_request_created start_event_identifier = :merge_request_created
end_event_identifier = :merge_request_merged end_event_identifier = :merge_request_merged
start_label_event = :issue_label_added start_label_event = :issue_label_added
...@@ -408,8 +410,8 @@ describe 'Group Value Stream Analytics', :js do ...@@ -408,8 +410,8 @@ describe 'Group Value Stream Analytics', :js do
let(:add_stage_button) { '.js-add-stage-button' } let(:add_stage_button) { '.js-add-stage-button' }
let(:params) { { name: custom_stage_name, start_event_identifier: start_event_identifier, end_event_identifier: end_event_identifier } } let(:params) { { name: custom_stage_name, start_event_identifier: start_event_identifier, end_event_identifier: end_event_identifier } }
let(:first_default_stage) { page.find('.stage-nav-item-cell', text: "Issue").ancestor(".stage-nav-item") } let(:first_default_stage) { page.find('.stage-nav-item-cell', text: 'Issue').ancestor('.stage-nav-item') }
let(:first_custom_stage) { page.find('.stage-nav-item-cell', text: custom_stage_name).ancestor(".stage-nav-item") } let(:first_custom_stage) { page.find('.stage-nav-item-cell', text: custom_stage_name).ancestor('.stage-nav-item') }
let(:nav) { page.find(stage_nav_selector) } let(:nav) { page.find(stage_nav_selector) }
def create_custom_stage(parent_group = group) def create_custom_stage(parent_group = group)
...@@ -419,14 +421,14 @@ describe 'Group Value Stream Analytics', :js do ...@@ -419,14 +421,14 @@ describe 'Group Value Stream Analytics', :js do
def toggle_more_options(stage) def toggle_more_options(stage)
stage.hover stage.hover
stage.find(".more-actions-toggle").click stage.find('.more-actions-toggle').click
end end
def select_dropdown_option(name, value = start_event_identifier) def select_dropdown_option(name, value = start_event_identifier)
page.find("select[name='#{name}']").all('option').find { |item| item.value == value.to_s }.select_option page.find("select[name='#{name}']").all('option').find { |item| item.value == value.to_s }.select_option
end end
def select_dropdown_option_by_value(name, value, elem = "option") def select_dropdown_option_by_value(name, value, elem = 'option')
page.find("select[name='#{name}']").find("#{elem}[value=#{value}]").select_option page.find("select[name='#{name}']").find("#{elem}[value=#{value}]").select_option
end end
...@@ -531,7 +533,7 @@ describe 'Group Value Stream Analytics', :js do ...@@ -531,7 +533,7 @@ describe 'Group Value Stream Analytics', :js do
it 'is visible' do it 'is visible' do
expect(page).to have_selector(add_stage_button, visible: true) expect(page).to have_selector(add_stage_button, visible: true)
expect(page).to have_text('Add a stage') expect(page).to have_text(s_('CustomCycleAnalytics|Add a stage'))
end end
it 'becomes active when clicked' do it 'becomes active when clicked' do
...@@ -543,11 +545,11 @@ describe 'Group Value Stream Analytics', :js do ...@@ -543,11 +545,11 @@ describe 'Group Value Stream Analytics', :js do
end end
it 'displays the custom stage form when clicked' do it 'displays the custom stage form when clicked' do
expect(page).not_to have_text('New stage') expect(page).not_to have_text(s_('CustomCycleAnalytics|New stage'))
page.find(add_stage_button).click page.find(add_stage_button).click
expect(page).to have_text('New stage') expect(page).to have_text(s_('CustomCycleAnalytics|New stage'))
end end
end end
...@@ -562,39 +564,39 @@ describe 'Group Value Stream Analytics', :js do ...@@ -562,39 +564,39 @@ describe 'Group Value Stream Analytics', :js do
context 'with empty fields' do context 'with empty fields' do
it 'submit button is disabled by default' do it 'submit button is disabled by default' do
expect(page).to have_button('Add stage', disabled: true) expect(page).to have_button(s_('CustomCycleAnalytics|Add stage'), disabled: true)
end end
end end
shared_examples 'submits the form successfully' do |stage_name| shared_examples 'submits the form successfully' do |stage_name|
it 'submit button is enabled' do it 'submit button is enabled' do
expect(page).to have_button('Add stage', disabled: false) expect(page).to have_button(s_('CustomCycleAnalytics|Add stage'), disabled: false)
end end
it 'submit button is disabled if the start event changes' do it 'submit button is disabled if the start event changes' do
select_dropdown_option 'custom-stage-start-event', 'issue_created' select_dropdown_option 'custom-stage-start-event', 'issue_created'
expect(page).to have_button('Add stage', disabled: true) expect(page).to have_button(s_('CustomCycleAnalytics|Add stage'), disabled: true)
end end
it 'the custom stage is saved' do it 'the custom stage is saved' do
click_button 'Add stage' click_button(s_('CustomCycleAnalytics|Add stage'))
expect(page).to have_selector('.stage-nav-item', text: stage_name) expect(page).to have_selector('.stage-nav-item', text: stage_name)
end end
it 'a confirmation message is displayed' do it 'a confirmation message is displayed' do
fill_in 'custom-stage-name', with: stage_name fill_in 'custom-stage-name', with: stage_name
click_button 'Add stage' click_button(s_('CustomCycleAnalytics|Add stage'))
expect(page.find('.flash-notice')).to have_text("Your custom stage '#{stage_name}' was created") expect(page.find('.flash-notice')).to have_text(_("Your custom stage '%{title}' was created") % { title: stage_name })
end end
it 'with a default name' do it 'with a default name' do
fill_in 'custom-stage-name', with: 'issue' fill_in 'custom-stage-name', with: 'issue'
click_button 'Add stage' click_button(s_('CustomCycleAnalytics|Add stage'))
expect(page).to have_button('Add stage', disabled: true) expect(page).to have_button(s_('CustomCycleAnalytics|Add stage'), disabled: true)
end end
end end
...@@ -606,8 +608,8 @@ describe 'Group Value Stream Analytics', :js do ...@@ -606,8 +608,8 @@ describe 'Group Value Stream Analytics', :js do
end end
it 'does not have label dropdowns' do it 'does not have label dropdowns' do
expect(page).not_to have_content('Start event label') expect(page).not_to have_content(s_('CustomCycleAnalytics|Start event label'))
expect(page).not_to have_content('Stop event label') expect(page).not_to have_content(s_('CustomCycleAnalytics|Stop event label'))
end end
it_behaves_like 'submits the form successfully', custom_stage_name it_behaves_like 'submits the form successfully', custom_stage_name
...@@ -621,17 +623,17 @@ describe 'Group Value Stream Analytics', :js do ...@@ -621,17 +623,17 @@ describe 'Group Value Stream Analytics', :js do
end end
it 'has label dropdowns' do it 'has label dropdowns' do
expect(page).to have_content('Start event label') expect(page).to have_content(s_('CustomCycleAnalytics|Start event label'))
expect(page).to have_content('Stop event label') expect(page).to have_content(s_('CustomCycleAnalytics|Stop event label'))
end end
it 'submit button is disabled' do it 'submit button is disabled' do
expect(page).to have_button('Add stage', disabled: true) expect(page).to have_button(s_('CustomCycleAnalytics|Add stage'), disabled: true)
end end
context 'with labels available' do context 'with labels available' do
start_field = "custom-stage-start-event-label" start_field = 'custom-stage-start-event-label'
end_field = "custom-stage-stop-event-label" end_field = 'custom-stage-stop-event-label'
it 'does not contain labels from outside the group' do it 'does not contain labels from outside the group' do
wait_for_labels(start_field) wait_for_labels(start_field)
...@@ -662,14 +664,14 @@ describe 'Group Value Stream Analytics', :js do ...@@ -662,14 +664,14 @@ describe 'Group Value Stream Analytics', :js do
context 'Edit stage form' do context 'Edit stage form' do
stage_form_class = '.custom-stage-form' stage_form_class = '.custom-stage-form'
stage_save_button = '.js-save-stage' stage_save_button = '.js-save-stage'
name_field = "custom-stage-name" name_field = 'custom-stage-name'
start_event_field = "custom-stage-start-event" start_event_field = 'custom-stage-start-event'
end_event_field = "custom-stage-stop-event" end_event_field = 'custom-stage-stop-event'
updated_custom_stage_name = 'Extra uber cool stage' updated_custom_stage_name = 'Extra uber cool stage'
def select_edit_stage def select_edit_stage
toggle_more_options(first_custom_stage) toggle_more_options(first_custom_stage)
click_button "Edit stage" click_button(_('Edit stage'))
end end
context 'with no changes to the data' do context 'with no changes to the data' do
...@@ -678,7 +680,7 @@ describe 'Group Value Stream Analytics', :js do ...@@ -678,7 +680,7 @@ describe 'Group Value Stream Analytics', :js do
end end
it 'displays the editing stage form' do it 'displays the editing stage form' do
expect(page.find(stage_form_class)).to have_text 'Editing stage' expect(page.find(stage_form_class)).to have_text(s_('CustomCycleAnalytics|Editing stage'))
end end
it 'prepoulates the stage data' do it 'prepoulates the stage data' do
...@@ -688,7 +690,7 @@ describe 'Group Value Stream Analytics', :js do ...@@ -688,7 +690,7 @@ describe 'Group Value Stream Analytics', :js do
end end
it 'disables the submit form button' do it 'disables the submit form button' do
expect(page.find(stage_save_button)[:disabled]).to eq "true" expect(page.find(stage_save_button)[:disabled]).to eq 'true'
end end
end end
...@@ -707,22 +709,22 @@ describe 'Group Value Stream Analytics', :js do ...@@ -707,22 +709,22 @@ describe 'Group Value Stream Analytics', :js do
fill_in name_field, with: updated_custom_stage_name fill_in name_field, with: updated_custom_stage_name
page.find(stage_save_button).click page.find(stage_save_button).click
expect(page.find('.flash-notice')).to have_text 'Stage data updated' expect(page.find('.flash-notice')).to have_text(_('Stage data updated'))
expect(page.find(stage_nav_selector)).not_to have_text custom_stage_name expect(page.find(stage_nav_selector)).not_to have_text custom_stage_name
expect(page.find(stage_nav_selector)).to have_text updated_custom_stage_name expect(page.find(stage_nav_selector)).to have_text updated_custom_stage_name
end end
it 'disables the submit form button if incomplete' do it 'disables the submit form button if incomplete' do
fill_in name_field, with: "" fill_in name_field, with: ''
expect(page.find(stage_save_button)[:disabled]).to eq "true" expect(page.find(stage_save_button)[:disabled]).to eq 'true'
end end
it 'with a default name' do it 'with a default name' do
fill_in name_field, with: 'issue' fill_in name_field, with: 'issue'
page.find(stage_save_button).click page.find(stage_save_button).click
expect(page.find(stage_form_class)).to have_text("Stage name already exists") expect(page.find(stage_form_class)).to have_text(s_('CustomCycleAnalytics|Stage name already exists'))
end end
end end
end end
...@@ -783,18 +785,18 @@ describe 'Group Value Stream Analytics', :js do ...@@ -783,18 +785,18 @@ describe 'Group Value Stream Analytics', :js do
def open_recover_stage_dropdown def open_recover_stage_dropdown
find(add_stage_button).click find(add_stage_button).click
expect(page).to have_content('New stage') expect(page).to have_content(s_('CustomCycleAnalytics|New stage'))
expect(page).to have_content('Recover hidden stage') expect(page).to have_content(_('Recover hidden stage'))
click_button "Recover hidden stage" click_button(_('Recover hidden stage'))
within(:css, '.js-recover-hidden-stage-dropdown') do within(:css, '.js-recover-hidden-stage-dropdown') do
expect(find(".dropdown-menu")).to have_content('Default stages') expect(find('.dropdown-menu')).to have_content(_('Default stages'))
end end
end end
def active_stages def active_stages
page.all(".stage-nav .stage-name").collect(&:text) page.all('.stage-nav .stage-name').collect(&:text)
end end
before do before do
...@@ -804,53 +806,53 @@ describe 'Group Value Stream Analytics', :js do ...@@ -804,53 +806,53 @@ describe 'Group Value Stream Analytics', :js do
end end
it 'can be hidden' do it 'can be hidden' do
expect(first_default_stage.find('.more-actions-dropdown')).to have_text "Hide stage" expect(first_default_stage.find('.more-actions-dropdown')).to have_text(_('Hide stage'))
end end
it 'can not be edited' do it 'can not be edited' do
expect(first_default_stage.find('.more-actions-dropdown')).not_to have_text "Edit stage" expect(first_default_stage.find('.more-actions-dropdown')).not_to have_text(_('Edit stage'))
end end
it 'can not be removed' do it 'can not be removed' do
expect(first_default_stage.find('.more-actions-dropdown')).not_to have_text "Remove stage" expect(first_default_stage.find('.more-actions-dropdown')).not_to have_text(_('Remove stage'))
end end
context 'hidden' do context 'hidden' do
before do before do
click_button "Hide stage" click_button(_('Hide stage'))
# wait for the stage list to laod # wait for the stage list to laod
expect(nav).to have_content("Plan") expect(nav).to have_content(s_('CycleAnalyticsStage|Plan'))
end end
it 'will not appear in the stage table' do it 'will not appear in the stage table' do
expect(active_stages).not_to include("Issue") expect(active_stages).not_to include(s_('CycleAnalyticsStage|Issue'))
end end
it 'can be recovered' do it 'can be recovered' do
open_recover_stage_dropdown open_recover_stage_dropdown
expect(page.find('.js-recover-hidden-stage-dropdown')).to have_text('Issue') expect(page.find('.js-recover-hidden-stage-dropdown')).to have_text(s_('CycleAnalyticsStage|Issue'))
end end
end end
context 'recovered' do context 'recovered' do
before do before do
click_button "Hide stage" click_button(_('Hide stage'))
# wait for the stage list to laod # wait for the stage list to laod
expect(nav).to have_content("Plan") expect(nav).to have_content(s_('CycleAnalyticsStage|Plan'))
end end
it 'will appear in the stage table' do it 'will appear in the stage table' do
open_recover_stage_dropdown open_recover_stage_dropdown
click_button("Issue") click_button(s_('CycleAnalyticsStage|Issue'))
# wait for the stage list to laod # wait for the stage list to laod
expect(nav).to have_content("Plan") expect(nav).to have_content(s_('CycleAnalyticsStage|Plan'))
expect(page.find('.flash-notice')).to have_content 'Stage data updated' expect(page.find('.flash-notice')).to have_content(_('Stage data updated'))
expect(active_stages).to include("Issue") expect(active_stages).to include(s_('CycleAnalyticsStage|Issue'))
end end
end end
end end
...@@ -866,24 +868,24 @@ describe 'Group Value Stream Analytics', :js do ...@@ -866,24 +868,24 @@ describe 'Group Value Stream Analytics', :js do
end end
it 'can not be hidden' do it 'can not be hidden' do
expect(first_custom_stage.find('.more-actions-dropdown')).not_to have_text "Hide stage" expect(first_custom_stage.find('.more-actions-dropdown')).not_to have_text(_('Hide stage'))
end end
it 'can be edited' do it 'can be edited' do
expect(first_custom_stage.find('.more-actions-dropdown')).to have_text "Edit stage" expect(first_custom_stage.find('.more-actions-dropdown')).to have_text(_('Edit stage'))
end end
it 'can be removed' do it 'can be removed' do
expect(first_custom_stage.find('.more-actions-dropdown')).to have_text "Remove stage" expect(first_custom_stage.find('.more-actions-dropdown')).to have_text(_('Remove stage'))
end end
it 'will not appear in the stage table after being removed' do it 'will not appear in the stage table after being removed' do
nav = page.find(stage_nav_selector) nav = page.find(stage_nav_selector)
expect(nav).to have_text(custom_stage_name) expect(nav).to have_text(custom_stage_name)
click_button "Remove stage" click_button(_('Remove stage'))
expect(page.find('.flash-notice')).to have_text 'Stage removed' expect(page.find('.flash-notice')).to have_text(_('Stage removed'))
expect(nav).not_to have_text(custom_stage_name) expect(nav).not_to have_text(custom_stage_name)
end end
end end
...@@ -892,7 +894,10 @@ describe 'Group Value Stream Analytics', :js do ...@@ -892,7 +894,10 @@ describe 'Group Value Stream Analytics', :js do
context 'Duration chart' do context 'Duration chart' do
let(:duration_chart_dropdown) { page.find('.dropdown-stages') } let(:duration_chart_dropdown) { page.find('.dropdown-stages') }
default_stages = %w[Issue Plan Code Test Review Staging Total].freeze default_stages = Analytics::CycleAnalytics::StagePresenter::DEFAULT_STAGE_ATTRIBUTES
.each_value
.map { |value| value[:title].call }
.freeze
def duration_chart_stages def duration_chart_stages
duration_chart_dropdown.all('.dropdown-menu-link').collect(&:text) duration_chart_dropdown.all('.dropdown-menu-link').collect(&:text)
...@@ -916,16 +921,16 @@ describe 'Group Value Stream Analytics', :js do ...@@ -916,16 +921,16 @@ describe 'Group Value Stream Analytics', :js do
before do before do
toggle_more_options(first_default_stage) toggle_more_options(first_default_stage)
click_button "Hide stage" click_button(_('Hide stage'))
# wait for the stage list to laod # wait for the stage list to laod
expect(nav).to have_content("Plan") expect(nav).to have_content(s_('CycleAnalyticsStage|Plan'))
end end
it 'will not appear in the duration chart dropdown' do it 'will not appear in the duration chart dropdown' do
toggle_duration_chart_dropdown toggle_duration_chart_dropdown
expect(duration_chart_stages).not_to include("Issue") expect(duration_chart_stages).not_to include(s_('CycleAnalyticsStage|Issue'))
end 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