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/reports/codequality_report/grouped_codequality_reports_app_spec.js | |
parent | 185b095e93520f96e9cfc31d9c3e69b498cdab7c (diff) |
Add latest changes from gitlab-org/gitlab@15-6-stable-eev15.6.0-rc42
Diffstat (limited to 'spec/frontend/reports/codequality_report/grouped_codequality_reports_app_spec.js')
-rw-r--r-- | spec/frontend/reports/codequality_report/grouped_codequality_reports_app_spec.js | 151 |
1 files changed, 0 insertions, 151 deletions
diff --git a/spec/frontend/reports/codequality_report/grouped_codequality_reports_app_spec.js b/spec/frontend/reports/codequality_report/grouped_codequality_reports_app_spec.js deleted file mode 100644 index 962ff068b92..00000000000 --- a/spec/frontend/reports/codequality_report/grouped_codequality_reports_app_spec.js +++ /dev/null @@ -1,151 +0,0 @@ -import { mount } from '@vue/test-utils'; -import Vue from 'vue'; -import Vuex from 'vuex'; -import CodequalityIssueBody from '~/reports/codequality_report/components/codequality_issue_body.vue'; -import GroupedCodequalityReportsApp from '~/reports/codequality_report/grouped_codequality_reports_app.vue'; -import { getStoreConfig } from '~/reports/codequality_report/store'; -import { STATUS_NOT_FOUND } from '~/reports/constants'; -import { parsedReportIssues } from './mock_data'; - -Vue.use(Vuex); - -describe('Grouped code quality reports app', () => { - let wrapper; - let mockStore; - - const PATHS = { - codequalityHelpPath: 'codequality_help.html', - baseBlobPath: 'base/blob/path/', - headBlobPath: 'head/blob/path/', - }; - - const mountComponent = (props = {}) => { - wrapper = mount(GroupedCodequalityReportsApp, { - store: mockStore, - propsData: { - ...PATHS, - ...props, - }, - }); - }; - - const findWidget = () => wrapper.find('.js-codequality-widget'); - const findIssueBody = () => wrapper.findComponent(CodequalityIssueBody); - - beforeEach(() => { - const { state, ...storeConfig } = getStoreConfig(); - mockStore = new Vuex.Store({ - ...storeConfig, - actions: { - setPaths: () => {}, - fetchReports: () => {}, - }, - state: { - ...state, - ...PATHS, - }, - }); - - mountComponent(); - }); - - afterEach(() => { - wrapper.destroy(); - }); - - describe('when it is loading reports', () => { - beforeEach(() => { - mockStore.state.isLoading = true; - }); - - it('should render loading text', () => { - expect(findWidget().text()).toEqual('Loading Code quality report'); - }); - }); - - describe('when base and head reports are loaded and compared', () => { - describe('with no issues', () => { - beforeEach(() => { - mockStore.state.newIssues = []; - mockStore.state.resolvedIssues = []; - }); - - it('renders no changes text', () => { - expect(findWidget().text()).toEqual('No changes to code quality'); - }); - }); - - describe('with issues', () => { - describe('with new issues', () => { - beforeEach(() => { - mockStore.state.newIssues = parsedReportIssues.newIssues; - mockStore.state.resolvedIssues = []; - }); - - it('renders summary text', () => { - expect(findWidget().text()).toContain('Code quality degraded'); - }); - - it('renders custom codequality issue body', () => { - expect(findIssueBody().props('issue')).toEqual(parsedReportIssues.newIssues[0]); - }); - }); - - describe('with resolved issues', () => { - beforeEach(() => { - mockStore.state.newIssues = []; - mockStore.state.resolvedIssues = parsedReportIssues.resolvedIssues; - }); - - it('renders summary text', () => { - expect(findWidget().text()).toContain('Code quality improved'); - }); - - it('renders custom codequality issue body', () => { - expect(findIssueBody().props('issue')).toEqual(parsedReportIssues.resolvedIssues[0]); - }); - }); - - describe('with new and resolved issues', () => { - beforeEach(() => { - mockStore.state.newIssues = parsedReportIssues.newIssues; - mockStore.state.resolvedIssues = parsedReportIssues.resolvedIssues; - }); - - it('renders summary text', () => { - expect(findWidget().text()).toContain( - 'Code quality scanning detected 2 changes in merged results', - ); - }); - - it('renders custom codequality issue body', () => { - expect(findIssueBody().props('issue')).toEqual(parsedReportIssues.newIssues[0]); - }); - }); - }); - }); - - describe('on error', () => { - beforeEach(() => { - mockStore.state.hasError = true; - }); - - it('renders error text', () => { - expect(findWidget().text()).toContain('Failed to load Code quality report'); - }); - - it('does not render a help icon', () => { - expect(findWidget().find('[data-testid="question-o-icon"]').exists()).toBe(false); - }); - - describe('when base report was not found', () => { - beforeEach(() => { - mockStore.state.status = STATUS_NOT_FOUND; - }); - - it('renders a help icon with more information', () => { - expect(findWidget().find('[data-testid="question-o-icon"]').exists()).toBe(true); - }); - }); - }); -}); |