diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-11-17 14:33:21 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-11-17 14:33:21 +0300 |
commit | 7021455bd1ed7b125c55eb1b33c5a01f2bc55ee0 (patch) | |
tree | 5bdc2229f5198d516781f8d24eace62fc7e589e9 /spec/frontend/issuable/related_issues | |
parent | 185b095e93520f96e9cfc31d9c3e69b498cdab7c (diff) |
Add latest changes from gitlab-org/gitlab@15-6-stable-eev15.6.0-rc42
Diffstat (limited to 'spec/frontend/issuable/related_issues')
-rw-r--r-- | spec/frontend/issuable/related_issues/components/related_issues_block_spec.js | 48 | ||||
-rw-r--r-- | spec/frontend/issuable/related_issues/components/related_issues_root_spec.js | 8 |
2 files changed, 35 insertions, 21 deletions
diff --git a/spec/frontend/issuable/related_issues/components/related_issues_block_spec.js b/spec/frontend/issuable/related_issues/components/related_issues_block_spec.js index 1b2935ce5d1..996b2406240 100644 --- a/spec/frontend/issuable/related_issues/components/related_issues_block_spec.js +++ b/spec/frontend/issuable/related_issues/components/related_issues_block_spec.js @@ -40,12 +40,12 @@ describe('RelatedIssuesBlock', () => { }); it.each` - issuableType | pathIdSeparator | titleText | helpLinkText | addButtonText - ${'issue'} | ${PathIdSeparator.Issue} | ${'Linked items'} | ${'Read more about related issues'} | ${'Add a related issue'} - ${'epic'} | ${PathIdSeparator.Epic} | ${'Linked epics'} | ${'Read more about related epics'} | ${'Add a related epic'} + issuableType | pathIdSeparator | titleText | addButtonText + ${'issue'} | ${PathIdSeparator.Issue} | ${'Linked items'} | ${'Add a related issue'} + ${'epic'} | ${PathIdSeparator.Epic} | ${'Linked epics'} | ${'Add a related epic'} `( - 'displays "$titleText" in the header, "$helpLinkText" aria-label for help link, and "$addButtonText" aria-label for add button when issuableType is set to "$issuableType"', - ({ issuableType, pathIdSeparator, titleText, helpLinkText, addButtonText }) => { + 'displays "$titleText" in the header and "$addButtonText" aria-label for add button when issuableType is set to "$issuableType"', + ({ issuableType, pathIdSeparator, titleText, addButtonText }) => { wrapper = mountExtended(RelatedIssuesBlock, { propsData: { pathIdSeparator, @@ -56,9 +56,6 @@ describe('RelatedIssuesBlock', () => { }); expect(wrapper.find('.card-title').text()).toContain(titleText); - expect(wrapper.find('[data-testid="help-link"]').attributes('aria-label')).toBe( - helpLinkText, - ); expect(findIssueCountBadgeAddButton().attributes('aria-label')).toBe(addButtonText); }, ); @@ -100,7 +97,7 @@ describe('RelatedIssuesBlock', () => { slots: { 'header-actions': headerActions }, }); - expect(wrapper.find('[data-testid="custom-button"]').html()).toBe(headerActions); + expect(wrapper.findByTestId('custom-button').html()).toBe(headerActions); }); }); @@ -260,15 +257,30 @@ describe('RelatedIssuesBlock', () => { }); }); - it('toggle button is disabled when issue has no related items', () => { - wrapper = shallowMountExtended(RelatedIssuesBlock, { - propsData: { - pathIdSeparator: PathIdSeparator.Issue, - relatedIssues: [], - issuableType: 'issue', - }, - }); + describe('empty state', () => { + it.each` + issuableType | pathIdSeparator | showCategorizedIssues | emptyText | helpLinkText + ${'issue'} | ${PathIdSeparator.Issue} | ${false} | ${"Link issues together to show that they're related."} | ${'Learn more about linking issues'} + ${'issue'} | ${PathIdSeparator.Issue} | ${true} | ${"Link issues together to show that they're related or that one is blocking others."} | ${'Learn more about linking issues'} + ${'incident'} | ${PathIdSeparator.Issue} | ${false} | ${"Link incidents together to show that they're related."} | ${'Learn more about linking issues and incidents'} + ${'incident'} | ${PathIdSeparator.Issue} | ${true} | ${"Link incidents together to show that they're related or that one is blocking others."} | ${'Learn more about linking issues and incidents'} + ${'epic'} | ${PathIdSeparator.Epic} | ${true} | ${"Link epics together to show that they're related or that one is blocking others."} | ${'Learn more about linking epics'} + `( + 'displays "$emptyText" in the body and "$helpLinkText" aria-label for help link', + ({ issuableType, pathIdSeparator, showCategorizedIssues, emptyText, helpLinkText }) => { + wrapper = mountExtended(RelatedIssuesBlock, { + propsData: { + pathIdSeparator, + issuableType, + canAdmin: true, + helpPath: '/help/user/project/issues/related_issues', + showCategorizedIssues, + }, + }); - expect(findToggleButton().props('disabled')).toBe(true); + expect(wrapper.findByTestId('related-issues-body').text()).toContain(emptyText); + expect(wrapper.findByTestId('help-link').attributes('aria-label')).toBe(helpLinkText); + }, + ); }); }); diff --git a/spec/frontend/issuable/related_issues/components/related_issues_root_spec.js b/spec/frontend/issuable/related_issues/components/related_issues_root_spec.js index 680dbd68493..bedf8bcaf34 100644 --- a/spec/frontend/issuable/related_issues/components/related_issues_root_spec.js +++ b/spec/frontend/issuable/related_issues/components/related_issues_root_spec.js @@ -201,18 +201,20 @@ describe('RelatedIssuesRoot', () => { ]); }); - it('displays a message from the backend upon error', async () => { + it('passes an error message from the backend upon error', async () => { const input = '#123'; const message = 'error'; mock.onPost(defaultProps.endpoint).reply(409, { message }); wrapper.vm.store.setPendingReferences([issuable1.reference, issuable2.reference]); - expect(createAlert).not.toHaveBeenCalled(); + expect(findRelatedIssuesBlock().props('hasError')).toBe(false); + expect(findRelatedIssuesBlock().props('itemAddFailureMessage')).toBe(null); findRelatedIssuesBlock().vm.$emit('addIssuableFormSubmit', input); await waitForPromises(); - expect(createAlert).toHaveBeenCalledWith({ message }); + expect(findRelatedIssuesBlock().props('hasError')).toBe(true); + expect(findRelatedIssuesBlock().props('itemAddFailureMessage')).toBe(message); }); }); |