diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-12-14 18:08:42 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-12-14 18:08:42 +0000 |
commit | 870dfaa9127e114a6ea2066220760815063fb3de (patch) | |
tree | 687cdcdc75e56796a8711511d9d0e4a56ff4822f /spec/frontend/vue_merge_request_widget | |
parent | 8c4225a66b12683bcf1bba9bb9328fcf65395b6d (diff) | |
download | gitlab-ce-870dfaa9127e114a6ea2066220760815063fb3de.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/vue_merge_request_widget')
-rw-r--r-- | spec/frontend/vue_merge_request_widget/extentions/code_quality/index_spec.js | 43 | ||||
-rw-r--r-- | spec/frontend/vue_merge_request_widget/extentions/code_quality/mock_data.js | 25 |
2 files changed, 26 insertions, 42 deletions
diff --git a/spec/frontend/vue_merge_request_widget/extentions/code_quality/index_spec.js b/spec/frontend/vue_merge_request_widget/extentions/code_quality/index_spec.js index 097cab4db06..a86fbc1500e 100644 --- a/spec/frontend/vue_merge_request_widget/extentions/code_quality/index_spec.js +++ b/spec/frontend/vue_merge_request_widget/extentions/code_quality/index_spec.js @@ -8,9 +8,9 @@ import extensionsContainer from '~/vue_merge_request_widget/components/extension import { registerExtension } from '~/vue_merge_request_widget/components/extensions'; import codeQualityExtension from '~/vue_merge_request_widget/extensions/code_quality'; import httpStatusCodes from '~/lib/utils/http_status'; +import { i18n } from '~/vue_merge_request_widget/extensions/code_quality/constants'; import { codeQualityResponseNewErrors, - codeQualityResponseResolvedErrors, codeQualityResponseResolvedAndNewErrors, codeQualityResponseNoErrors, } from './mock_data'; @@ -59,46 +59,55 @@ describe('Code Quality extension', () => { createComponent(); - expect(wrapper.text()).toBe('Code Quality test metrics results are being parsed'); + expect(wrapper.text()).toBe(i18n.loading); }); - it('displays failed loading text', async () => { - mockApi(httpStatusCodes.INTERNAL_SERVER_ERROR); - + it('with a 204 response, continues to display loading state', async () => { + mockApi(httpStatusCodes.NO_CONTENT, ''); createComponent(); await waitForPromises(); - expect(wrapper.text()).toBe('Code Quality failed loading results'); + + expect(wrapper.text()).toBe(i18n.loading); }); - it('displays quality degradation', async () => { - mockApi(httpStatusCodes.OK, codeQualityResponseNewErrors); + it('displays failed loading text', async () => { + mockApi(httpStatusCodes.INTERNAL_SERVER_ERROR); createComponent(); await waitForPromises(); - - expect(wrapper.text()).toBe('Code Quality degraded on 2 points.'); + expect(wrapper.text()).toBe(i18n.error); }); - it('displays quality improvement', async () => { - mockApi(httpStatusCodes.OK, codeQualityResponseResolvedErrors); + it('displays correct single Report', async () => { + mockApi(httpStatusCodes.OK, codeQualityResponseNewErrors); createComponent(); await waitForPromises(); - expect(wrapper.text()).toBe('Code Quality improved on 2 points.'); + expect(wrapper.text()).toBe( + i18n.degradedCopy(i18n.singularReport(codeQualityResponseNewErrors.new_errors)), + ); }); it('displays quality improvement and degradation', async () => { mockApi(httpStatusCodes.OK, codeQualityResponseResolvedAndNewErrors); createComponent(); - await waitForPromises(); - expect(wrapper.text()).toBe('Code Quality improved on 1 point and degraded on 1 point.'); + // replacing strong tags because they will not be found in the rendered text + expect(wrapper.text()).toBe( + i18n + .improvementAndDegradationCopy( + i18n.pluralReport(codeQualityResponseResolvedAndNewErrors.resolved_errors), + i18n.pluralReport(codeQualityResponseResolvedAndNewErrors.new_errors), + ) + .replace(/%{strong_start}/g, '') + .replace(/%{strong_end}/g, ''), + ); }); it('displays no detected errors', async () => { @@ -108,7 +117,7 @@ describe('Code Quality extension', () => { await waitForPromises(); - expect(wrapper.text()).toBe('No changes to Code Quality.'); + expect(wrapper.text()).toBe(i18n.noChanges); }); }); @@ -145,7 +154,7 @@ describe('Code Quality extension', () => { it('adds fixed indicator (badge) when error is resolved', () => { expect(findAllExtensionListItems().at(1).findComponent(GlBadge).exists()).toBe(true); - expect(findAllExtensionListItems().at(1).findComponent(GlBadge).text()).toEqual('Fixed'); + expect(findAllExtensionListItems().at(1).findComponent(GlBadge).text()).toEqual(i18n.fixed); }); it('should not add fixed indicator (badge) when error is new', () => { diff --git a/spec/frontend/vue_merge_request_widget/extentions/code_quality/mock_data.js b/spec/frontend/vue_merge_request_widget/extentions/code_quality/mock_data.js index f5ad0ce7377..2e8e70f25db 100644 --- a/spec/frontend/vue_merge_request_widget/extentions/code_quality/mock_data.js +++ b/spec/frontend/vue_merge_request_widget/extentions/code_quality/mock_data.js @@ -23,31 +23,6 @@ export const codeQualityResponseNewErrors = { }, }; -export const codeQualityResponseResolvedErrors = { - status: 'failed', - new_errors: [], - resolved_errors: [ - { - description: "Parsing error: 'return' outside of function", - severity: 'minor', - file_path: 'index.js', - line: 12, - }, - { - description: 'TODO found', - severity: 'minor', - file_path: '.gitlab-ci.yml', - line: 73, - }, - ], - existing_errors: [], - summary: { - total: 2, - resolved: 2, - errored: 0, - }, -}; - export const codeQualityResponseResolvedAndNewErrors = { status: 'failed', new_errors: [ |