Commit 45f5f340 authored by Ezekiel Kigbo's avatar Ezekiel Kigbo

Update metrics feature spec

With the new metrics UI elements we need
to update the selectors used in feature specs
parent f33d91ab
...@@ -49,11 +49,15 @@ export const METRICS_POPOVER_CONTENT = { ...@@ -49,11 +49,15 @@ export const METRICS_POPOVER_CONTENT = {
'ValueStreamAnalytics|Median time from issue first merge request created to issue closed.', 'ValueStreamAnalytics|Median time from issue first merge request created to issue closed.',
), ),
}, },
'new-issue': { description: s__('ValueStreamAnalytics|Number of new issues created.') },
'new-issues': { description: s__('ValueStreamAnalytics|Number of new issues created.') }, 'new-issues': { description: s__('ValueStreamAnalytics|Number of new issues created.') },
deploys: { description: s__('ValueStreamAnalytics|Total number of deploys to production.') }, deploys: { description: s__('ValueStreamAnalytics|Total number of deploys to production.') },
'deployment-frequency': { 'deployment-frequency': {
description: s__('ValueStreamAnalytics|Average number of deployments to production per day.'), description: s__('ValueStreamAnalytics|Average number of deployments to production per day.'),
}, },
commits: {
description: s__('ValueStreamAnalytics|Number of commits pushed to the default branch'),
},
}; };
export const projectMetricsRequests = (cycleAnalyticsForGroups = false) => { export const projectMetricsRequests = (cycleAnalyticsForGroups = false) => {
......
...@@ -36549,6 +36549,9 @@ msgstr "" ...@@ -36549,6 +36549,9 @@ msgstr ""
msgid "ValueStreamAnalytics|Median time from issue first merge request created to issue closed." msgid "ValueStreamAnalytics|Median time from issue first merge request created to issue closed."
msgstr "" msgstr ""
msgid "ValueStreamAnalytics|Number of commits pushed to the default branch"
msgstr ""
msgid "ValueStreamAnalytics|Number of new issues created." msgid "ValueStreamAnalytics|Number of new issues created."
msgstr "" msgstr ""
......
...@@ -7,6 +7,7 @@ RSpec.describe 'Value Stream Analytics', :js do ...@@ -7,6 +7,7 @@ RSpec.describe 'Value Stream Analytics', :js do
let_it_be(:guest) { create(:user) } let_it_be(:guest) { create(:user) }
let_it_be(:project) { create(:project, :repository) } let_it_be(:project) { create(:project, :repository) }
let_it_be(:stage_table_selector) { '[data-testid="vsa-stage-table"]' } let_it_be(:stage_table_selector) { '[data-testid="vsa-stage-table"]' }
let_it_be(:metrics_selector) { "[data-testid='vsa-time-metrics']" }
let(:issue) { create(:issue, project: project, created_at: 2.days.ago) } let(:issue) { create(:issue, project: project, created_at: 2.days.ago) }
let(:milestone) { create(:milestone, project: project) } let(:milestone) { create(:milestone, project: project) }
...@@ -61,10 +62,10 @@ RSpec.describe 'Value Stream Analytics', :js do ...@@ -61,10 +62,10 @@ RSpec.describe 'Value Stream Analytics', :js do
end end
it 'shows pipeline summary' do it 'shows pipeline summary' do
expect(new_issues_counter).to have_content('1') expect(new_issue_counter).to have_content('1')
expect(commits_counter).to have_content('2') expect(commits_counter).to have_content('-')
expect(deploys_counter).to have_content('1') expect(deploys_counter).to have_content('-')
expect(deployment_frequency_counter).to have_content('0') expect(deployment_frequency_counter).to have_content('-')
end end
it 'shows data on each stage', :sidekiq_might_not_need_inline do it 'shows data on each stage', :sidekiq_might_not_need_inline do
...@@ -96,7 +97,7 @@ RSpec.describe 'Value Stream Analytics', :js do ...@@ -96,7 +97,7 @@ RSpec.describe 'Value Stream Analytics', :js do
end end
it 'shows only relevant data' do it 'shows only relevant data' do
expect(new_issues_counter).to have_content('1') expect(new_issue_counter).to have_content('1')
end end
end end
end end
...@@ -116,7 +117,7 @@ RSpec.describe 'Value Stream Analytics', :js do ...@@ -116,7 +117,7 @@ RSpec.describe 'Value Stream Analytics', :js do
end end
it 'does not show the commit stats' do it 'does not show the commit stats' do
expect(page).to have_no_selector(:xpath, commits_counter_selector) expect(page.find(metrics_selector)).not_to have_selector("#commits")
end end
it 'needs permissions to see restricted stages' do it 'needs permissions to see restricted stages' do
...@@ -130,28 +131,29 @@ RSpec.describe 'Value Stream Analytics', :js do ...@@ -130,28 +131,29 @@ RSpec.describe 'Value Stream Analytics', :js do
end end
end end
def new_issues_counter def find_metric_tile(sel)
find(:xpath, "//p[contains(text(),'New Issue')]/preceding-sibling::h3") page.find("#{metrics_selector} #{sel}")
end end
def commits_counter_selector # When now use proper pluralization for the metric names, which affects the id
"//p[contains(text(),'Commits')]/preceding-sibling::h3" def new_issue_counter
find_metric_tile("#new-issue")
end end
def commits_counter def new_issues_counter
find(:xpath, commits_counter_selector) find_metric_tile("#new-issues")
end end
def deploys_counter def commits_counter
find(:xpath, "//p[contains(text(),'Deploy')]/preceding-sibling::h3", match: :first) find_metric_tile("#commits")
end end
def deployment_frequency_counter_selector def deploys_counter
"//p[contains(text(),'Deployment Frequency')]/preceding-sibling::h3" find_metric_tile("#deploys")
end end
def deployment_frequency_counter def deployment_frequency_counter
find(:xpath, deployment_frequency_counter_selector) find_metric_tile("#deployment-frequency")
end end
def expect_issue_to_be_present def expect_issue_to_be_present
......
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