summaryrefslogtreecommitdiff
path: root/spec/frontend/releases/components/release_block_milestone_info_spec.js
diff options
context:
space:
mode:
Diffstat (limited to 'spec/frontend/releases/components/release_block_milestone_info_spec.js')
-rw-r--r--spec/frontend/releases/components/release_block_milestone_info_spec.js77
1 files changed, 22 insertions, 55 deletions
diff --git a/spec/frontend/releases/components/release_block_milestone_info_spec.js b/spec/frontend/releases/components/release_block_milestone_info_spec.js
index 45f4eaa01a9..bb34693c757 100644
--- a/spec/frontend/releases/components/release_block_milestone_info_spec.js
+++ b/spec/frontend/releases/components/release_block_milestone_info_spec.js
@@ -31,7 +31,8 @@ describe('Release block milestone info', () => {
const milestoneProgressBarContainer = () => wrapper.find('.js-milestone-progress-bar-container');
const milestoneListContainer = () => wrapper.find('.js-milestone-list-container');
- const issuesContainer = () => wrapper.find('.js-issues-container');
+ const issuesContainer = () => wrapper.find('[data-testid="issue-stats"]');
+ const mergeRequestsContainer = () => wrapper.find('[data-testid="merge-request-stats"]');
describe('with default props', () => {
beforeEach(() => factory({ milestones }));
@@ -188,66 +189,32 @@ describe('Release block milestone info', () => {
expectAllZeros();
});
- describe('Issue links', () => {
- const findOpenIssuesLink = () => wrapper.find({ ref: 'openIssuesLink' });
- const findOpenIssuesText = () => wrapper.find({ ref: 'openIssuesText' });
- const findClosedIssuesLink = () => wrapper.find({ ref: 'closedIssuesLink' });
- const findClosedIssuesText = () => wrapper.find({ ref: 'closedIssuesText' });
-
- describe('when openIssuePath is provided', () => {
- const openIssuesPath = '/path/to/open/issues';
-
- beforeEach(() => {
- return factory({ milestones, openIssuesPath });
- });
-
- it('renders the open issues as a link', () => {
- expect(findOpenIssuesLink().exists()).toBe(true);
- expect(findOpenIssuesText().exists()).toBe(false);
- });
-
- it('renders the open issues link with the correct href', () => {
- expect(findOpenIssuesLink().attributes().href).toBe(openIssuesPath);
- });
- });
-
- describe('when openIssuePath is not provided', () => {
- beforeEach(() => {
- return factory({ milestones });
- });
+ describe('if the API response is missing the "mr_stats" property', () => {
+ beforeEach(() => factory({ milestones }));
- it('renders the open issues as plain text', () => {
- expect(findOpenIssuesLink().exists()).toBe(false);
- expect(findOpenIssuesText().exists()).toBe(true);
- });
+ it('does not render merge request stats', () => {
+ expect(mergeRequestsContainer().exists()).toBe(false);
});
+ });
- describe('when closedIssuePath is provided', () => {
- const closedIssuesPath = '/path/to/closed/issues';
-
- beforeEach(() => {
- return factory({ milestones, closedIssuesPath });
- });
-
- it('renders the closed issues as a link', () => {
- expect(findClosedIssuesLink().exists()).toBe(true);
- expect(findClosedIssuesText().exists()).toBe(false);
- });
+ describe('if the API response includes the "mr_stats" property', () => {
+ beforeEach(() => {
+ milestones = milestones.map(m => ({
+ ...m,
+ mrStats: {
+ total: 15,
+ merged: 12,
+ closed: 1,
+ },
+ }));
- it('renders the closed issues link with the correct href', () => {
- expect(findClosedIssuesLink().attributes().href).toBe(closedIssuesPath);
- });
+ return factory({ milestones });
});
- describe('when closedIssuePath is not provided', () => {
- beforeEach(() => {
- return factory({ milestones });
- });
-
- it('renders the closed issues as plain text', () => {
- expect(findClosedIssuesLink().exists()).toBe(false);
- expect(findClosedIssuesText().exists()).toBe(true);
- });
+ it('renders merge request stats', () => {
+ expect(trimText(mergeRequestsContainer().text())).toBe(
+ 'Merge Requests 30 Open: 4 • Merged: 24 • Closed: 2',
+ );
});
});
});