Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-05-12 00:09:40 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-05-12 00:09:40 +0300
commit3f45eb27e9586ad87682c2d125770e119a7e9fe0 (patch)
tree533c2906ecf49c1403a2c21211241f21768e139a /spec/frontend
parent636eb69592af287dd76876e6fc3c898ad1af33f6 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend')
-rw-r--r--spec/frontend/monitoring/mock_data.js211
-rw-r--r--spec/frontend/monitoring/store/variable_mapping_spec.js156
-rw-r--r--spec/frontend/registry/explorer/pages/details_spec.js20
-rw-r--r--spec/frontend/reports/accessibility_report/grouped_accessibility_reports_app_spec.js25
-rw-r--r--spec/frontend/reports/accessibility_report/mock_data.js119
-rw-r--r--spec/frontend/reports/accessibility_report/store/actions_spec.js82
-rw-r--r--spec/frontend/reports/accessibility_report/store/getters_spec.js8
-rw-r--r--spec/frontend/reports/accessibility_report/store/mutations_spec.js23
-rw-r--r--spec/frontend/reports/accessibility_report/store/utils_spec.js35
9 files changed, 342 insertions, 337 deletions
diff --git a/spec/frontend/monitoring/mock_data.js b/spec/frontend/monitoring/mock_data.js
index f846d5aaea5..dab560d197d 100644
--- a/spec/frontend/monitoring/mock_data.js
+++ b/spec/frontend/monitoring/mock_data.js
@@ -560,3 +560,214 @@ export const mockNamespacedData = {
export const mockLogsPath = '/mockLogsPath';
export const mockLogsHref = `${mockLogsPath}?duration_seconds=${mockTimeRange.duration.seconds}`;
+
+const templatingVariableTypes = {
+ text: {
+ simple: 'Simple text',
+ advanced: {
+ label: 'Variable 4',
+ type: 'text',
+ options: {
+ default_value: 'default',
+ },
+ },
+ },
+ custom: {
+ simple: ['value1', 'value2', 'value3'],
+ advanced: {
+ normal: {
+ label: 'Advanced Var',
+ type: 'custom',
+ options: {
+ values: [
+ { value: 'value1', text: 'Var 1 Option 1' },
+ {
+ value: 'value2',
+ text: 'Var 1 Option 2',
+ default: true,
+ },
+ ],
+ },
+ },
+ withoutOpts: {
+ type: 'custom',
+ options: {},
+ },
+ withoutLabel: {
+ type: 'custom',
+ options: {
+ values: [
+ { value: 'value1', text: 'Var 1 Option 1' },
+ {
+ value: 'value2',
+ text: 'Var 1 Option 2',
+ default: true,
+ },
+ ],
+ },
+ },
+ withoutType: {
+ label: 'Variable 2',
+ options: {
+ values: [
+ { value: 'value1', text: 'Var 1 Option 1' },
+ {
+ value: 'value2',
+ text: 'Var 1 Option 2',
+ default: true,
+ },
+ ],
+ },
+ },
+ },
+ },
+};
+
+const generateMockTemplatingData = data => {
+ const vars = data
+ ? {
+ variables: {
+ ...data,
+ },
+ }
+ : {};
+ return {
+ dashboard: {
+ templating: vars,
+ },
+ };
+};
+
+const responseForSimpleTextVariable = {
+ simpleText: {
+ label: 'simpleText',
+ type: 'text',
+ value: 'Simple text',
+ },
+};
+
+const responseForAdvTextVariable = {
+ advText: {
+ label: 'Variable 4',
+ type: 'text',
+ value: 'default',
+ },
+};
+
+const responseForSimpleCustomVariable = {
+ simpleCustom: {
+ label: 'simpleCustom',
+ options: [
+ {
+ default: false,
+ text: 'value1',
+ value: 'value1',
+ },
+ {
+ default: false,
+ text: 'value2',
+ value: 'value2',
+ },
+ {
+ default: false,
+ text: 'value3',
+ value: 'value3',
+ },
+ ],
+ type: 'custom',
+ },
+};
+
+const responseForAdvancedCustomVariableWithoutOptions = {
+ advCustomWithoutOpts: {
+ label: 'advCustomWithoutOpts',
+ options: [],
+ type: 'custom',
+ },
+};
+
+const responseForAdvancedCustomVariableWithoutLabel = {
+ advCustomWithoutLabel: {
+ label: 'advCustomWithoutLabel',
+ options: [
+ {
+ default: false,
+ text: 'Var 1 Option 1',
+ value: 'value1',
+ },
+ {
+ default: true,
+ text: 'Var 1 Option 2',
+ value: 'value2',
+ },
+ ],
+ type: 'custom',
+ },
+};
+
+const responseForAdvancedCustomVariable = {
+ ...responseForSimpleCustomVariable,
+ advCustomNormal: {
+ label: 'Advanced Var',
+ options: [
+ {
+ default: false,
+ text: 'Var 1 Option 1',
+ value: 'value1',
+ },
+ {
+ default: true,
+ text: 'Var 1 Option 2',
+ value: 'value2',
+ },
+ ],
+ type: 'custom',
+ },
+};
+
+const responsesForAllVariableTypes = {
+ ...responseForSimpleTextVariable,
+ ...responseForAdvTextVariable,
+ ...responseForSimpleCustomVariable,
+ ...responseForAdvancedCustomVariable,
+};
+
+export const mockTemplatingData = {
+ emptyTemplatingProp: generateMockTemplatingData(),
+ emptyVariablesProp: generateMockTemplatingData({}),
+ simpleText: generateMockTemplatingData({ simpleText: templatingVariableTypes.text.simple }),
+ advText: generateMockTemplatingData({ advText: templatingVariableTypes.text.advanced }),
+ simpleCustom: generateMockTemplatingData({ simpleCustom: templatingVariableTypes.custom.simple }),
+ advCustomWithoutOpts: generateMockTemplatingData({
+ advCustomWithoutOpts: templatingVariableTypes.custom.advanced.withoutOpts,
+ }),
+ advCustomWithoutType: generateMockTemplatingData({
+ advCustomWithoutType: templatingVariableTypes.custom.advanced.withoutType,
+ }),
+ advCustomWithoutLabel: generateMockTemplatingData({
+ advCustomWithoutLabel: templatingVariableTypes.custom.advanced.withoutLabel,
+ }),
+ simpleAndAdv: generateMockTemplatingData({
+ simpleCustom: templatingVariableTypes.custom.simple,
+ advCustomNormal: templatingVariableTypes.custom.advanced.normal,
+ }),
+ allVariableTypes: generateMockTemplatingData({
+ simpleText: templatingVariableTypes.text.simple,
+ advText: templatingVariableTypes.text.advanced,
+ simpleCustom: templatingVariableTypes.custom.simple,
+ advCustomNormal: templatingVariableTypes.custom.advanced.normal,
+ }),
+};
+
+export const mockTemplatingDataResponses = {
+ emptyTemplatingProp: {},
+ emptyVariablesProp: {},
+ simpleText: responseForSimpleTextVariable,
+ advText: responseForAdvTextVariable,
+ simpleCustom: responseForSimpleCustomVariable,
+ advCustomWithoutOpts: responseForAdvancedCustomVariableWithoutOptions,
+ advCustomWithoutType: {},
+ advCustomWithoutLabel: responseForAdvancedCustomVariableWithoutLabel,
+ simpleAndAdv: responseForAdvancedCustomVariable,
+ allVariableTypes: responsesForAllVariableTypes,
+};
diff --git a/spec/frontend/monitoring/store/variable_mapping_spec.js b/spec/frontend/monitoring/store/variable_mapping_spec.js
index 5081092a519..47681ac7c65 100644
--- a/spec/frontend/monitoring/store/variable_mapping_spec.js
+++ b/spec/frontend/monitoring/store/variable_mapping_spec.js
@@ -1,149 +1,21 @@
import { parseTemplatingVariables } from '~/monitoring/stores/variable_mapping';
+import { mockTemplatingData, mockTemplatingDataResponses } from '../mock_data';
describe('parseTemplatingVariables', () => {
- const generateMockTemplatingData = data => {
- const vars = data
- ? {
- variables: {
- ...data,
- },
- }
- : {};
- return {
- dashboard: {
- templating: vars,
- },
- };
- };
-
- const simpleVar = ['value1', 'value2', 'value3'];
- const advVar = {
- label: 'Advanced Var',
- type: 'custom',
- options: {
- values: [
- { value: 'value1', text: 'Var 1 Option 1' },
- {
- value: 'value2',
- text: 'Var 1 Option 2',
- default: true,
- },
- ],
- },
- };
- const advVarWithoutOptions = {
- type: 'custom',
- options: {},
- };
- const advVarWithoutLabel = {
- type: 'custom',
- options: {
- values: [
- { value: 'value1', text: 'Var 1 Option 1' },
- {
- value: 'value2',
- text: 'Var 1 Option 2',
- default: true,
- },
- ],
- },
- };
- const advVarWithoutType = {
- label: 'Variable 2',
- options: {
- values: [
- { value: 'value1', text: 'Var 1 Option 1' },
- {
- value: 'value2',
- text: 'Var 1 Option 2',
- default: true,
- },
- ],
- },
- };
-
- const responseForSimpleCustomVariable = {
- simpleVar: {
- label: 'simpleVar',
- options: [
- {
- default: false,
- text: 'value1',
- value: 'value1',
- },
- {
- default: false,
- text: 'value2',
- value: 'value2',
- },
- {
- default: false,
- text: 'value3',
- value: 'value3',
- },
- ],
- type: 'custom',
- },
- };
-
- const responseForAdvancedCustomVariableWithoutOptions = {
- advVarWithoutOptions: {
- label: 'advVarWithoutOptions',
- options: [],
- type: 'custom',
- },
- };
-
- const responseForAdvancedCustomVariableWithoutLabel = {
- advVarWithoutLabel: {
- label: 'advVarWithoutLabel',
- options: [
- {
- default: false,
- text: 'Var 1 Option 1',
- value: 'value1',
- },
- {
- default: true,
- text: 'Var 1 Option 2',
- value: 'value2',
- },
- ],
- type: 'custom',
- },
- };
-
- const responseForAdvancedCustomVariable = {
- ...responseForSimpleCustomVariable,
- advVar: {
- label: 'Advanced Var',
- options: [
- {
- default: false,
- text: 'Var 1 Option 1',
- value: 'value1',
- },
- {
- default: true,
- text: 'Var 1 Option 2',
- value: 'value2',
- },
- ],
- type: 'custom',
- },
- };
-
it.each`
- case | input | expected
- ${'Returns empty object for no dashboard input'} | ${{}} | ${{}}
- ${'Returns empty object for empty dashboard input'} | ${{ dashboard: {} }} | ${{}}
- ${'Returns empty object for empty templating prop'} | ${generateMockTemplatingData()} | ${{}}
- ${'Returns empty object for empty variables prop'} | ${generateMockTemplatingData({})} | ${{}}
- ${'Returns parsed object for simple variable'} | ${generateMockTemplatingData({ simpleVar })} | ${responseForSimpleCustomVariable}
- ${'Returns parsed object for advanced variable without options'} | ${generateMockTemplatingData({ advVarWithoutOptions })} | ${responseForAdvancedCustomVariableWithoutOptions}
- ${'Returns parsed object for advanced variable without type'} | ${generateMockTemplatingData({ advVarWithoutType })} | ${{}}
- ${'Returns parsed object for advanced variable without label'} | ${generateMockTemplatingData({ advVarWithoutLabel })} | ${responseForAdvancedCustomVariableWithoutLabel}
- ${'Returns parsed object for simple and advanced variables'} | ${generateMockTemplatingData({ simpleVar, advVar })} | ${responseForAdvancedCustomVariable}
+ case | input | expected
+ ${'Returns empty object for no dashboard input'} | ${{}} | ${{}}
+ ${'Returns empty object for empty dashboard input'} | ${{ dashboard: {} }} | ${{}}
+ ${'Returns empty object for empty templating prop'} | ${mockTemplatingData.emptyTemplatingProp} | ${{}}
+ ${'Returns empty object for empty variables prop'} | ${mockTemplatingData.emptyVariablesProp} | ${{}}
+ ${'Returns parsed object for simple text variable'} | ${mockTemplatingData.simpleText} | ${mockTemplatingDataResponses.simpleText}
+ ${'Returns parsed object for advanced text variable'} | ${mockTemplatingData.advText} | ${mockTemplatingDataResponses.advText}
+ ${'Returns parsed object for simple custom variable'} | ${mockTemplatingData.simpleCustom} | ${mockTemplatingDataResponses.simpleCustom}
+ ${'Returns parsed object for advanced custom variable without options'} | ${mockTemplatingData.advCustomWithoutOpts} | ${mockTemplatingDataResponses.advCustomWithoutOpts}
+ ${'Returns parsed object for advanced custom variable without type'} | ${mockTemplatingData.advCustomWithoutType} | ${{}}
+ ${'Returns parsed object for advanced custom variable without label'} | ${mockTemplatingData.advCustomWithoutLabel} | ${mockTemplatingDataResponses.advCustomWithoutLabel}
+ ${'Returns parsed object for simple and advanced custom variables'} | ${mockTemplatingData.simpleAndAdv} | ${mockTemplatingDataResponses.simpleAndAdv}
+ ${'Returns parsed object for all variable types'} | ${mockTemplatingData.allVariableTypes} | ${mockTemplatingDataResponses.allVariableTypes}
`('$case', ({ input, expected }) => {
expect(parseTemplatingVariables(input?.dashboard?.templating)).toEqual(expected);
});
diff --git a/spec/frontend/registry/explorer/pages/details_spec.js b/spec/frontend/registry/explorer/pages/details_spec.js
index 67f6568dc3c..93098403a28 100644
--- a/spec/frontend/registry/explorer/pages/details_spec.js
+++ b/spec/frontend/registry/explorer/pages/details_spec.js
@@ -37,6 +37,7 @@ describe('Details Page', () => {
const findAllCheckboxes = () => wrapper.findAll('.js-row-checkbox');
const findCheckedCheckboxes = () => findAllCheckboxes().filter(c => c.attributes('checked'));
const findFirsTagColumn = () => wrapper.find('.js-tag-column');
+ const findFirstTagNameText = () => wrapper.find('[data-testid="rowNameText"]');
const findAlert = () => wrapper.find(GlAlert);
const routeId = window.btoa(JSON.stringify({ name: 'foo', tags_path: 'bar' }));
@@ -248,15 +249,24 @@ describe('Details Page', () => {
});
});
- describe('tag cell', () => {
+ describe('name cell', () => {
+ it('tag column has a tooltip with the tag name', () => {
+ mountComponent();
+ expect(findFirstTagNameText().attributes('title')).toBe(tagsListResponse.data[0].name);
+ });
+
describe('on desktop viewport', () => {
beforeEach(() => {
mountComponent();
});
- it('has class w-25', () => {
+ it('table header has class w-25', () => {
expect(findFirsTagColumn().classes()).toContain('w-25');
});
+
+ it('tag column has the mw-m class', () => {
+ expect(findFirstRowItem('rowName').classes()).toContain('mw-m');
+ });
});
describe('on mobile viewport', () => {
@@ -268,9 +278,13 @@ describe('Details Page', () => {
});
});
- it('does not has class w-25', () => {
+ it('table header does not have class w-25', () => {
expect(findFirsTagColumn().classes()).not.toContain('w-25');
});
+
+ it('tag column has the gl-justify-content-end class', () => {
+ expect(findFirstRowItem('rowName').classes()).toContain('gl-justify-content-end');
+ });
});
});
diff --git a/spec/frontend/reports/accessibility_report/grouped_accessibility_reports_app_spec.js b/spec/frontend/reports/accessibility_report/grouped_accessibility_reports_app_spec.js
index 3336b696e5a..a036588596a 100644
--- a/spec/frontend/reports/accessibility_report/grouped_accessibility_reports_app_spec.js
+++ b/spec/frontend/reports/accessibility_report/grouped_accessibility_reports_app_spec.js
@@ -3,7 +3,7 @@ import Vuex from 'vuex';
import GroupedAccessibilityReportsApp from '~/reports/accessibility_report/grouped_accessibility_reports_app.vue';
import AccessibilityIssueBody from '~/reports/accessibility_report/components/accessibility_issue_body.vue';
import store from '~/reports/accessibility_report/store';
-import { comparedReportResult } from './mock_data';
+import { mockReport } from './mock_data';
const localVue = createLocalVue();
localVue.use(Vuex);
@@ -18,8 +18,7 @@ describe('Grouped accessibility reports app', () => {
store: mockStore,
localVue,
propsData: {
- baseEndpoint: 'base_endpoint.json',
- headEndpoint: 'head_endpoint.json',
+ endpoint: 'endpoint.json',
},
methods: {
fetchReport: () => {},
@@ -66,8 +65,7 @@ describe('Grouped accessibility reports app', () => {
beforeEach(() => {
mockStore.state.report = {
summary: {
- errors: 0,
- warnings: 0,
+ errored: 0,
},
};
});
@@ -83,8 +81,7 @@ describe('Grouped accessibility reports app', () => {
beforeEach(() => {
mockStore.state.report = {
summary: {
- errors: 0,
- warnings: 1,
+ errored: 1,
},
};
});
@@ -100,8 +97,7 @@ describe('Grouped accessibility reports app', () => {
beforeEach(() => {
mockStore.state.report = {
summary: {
- errors: 1,
- warnings: 1,
+ errored: 2,
},
};
});
@@ -115,18 +111,15 @@ describe('Grouped accessibility reports app', () => {
describe('with issues to show', () => {
beforeEach(() => {
- mockStore.state.report = comparedReportResult;
+ mockStore.state.report = mockReport;
});
it('renders custom accessibility issue body', () => {
const issueBody = wrapper.find(AccessibilityIssueBody);
- expect(issueBody.props('issue').name).toEqual(comparedReportResult.new_errors[0].name);
- expect(issueBody.props('issue').code).toEqual(comparedReportResult.new_errors[0].code);
- expect(issueBody.props('issue').message).toEqual(
- comparedReportResult.new_errors[0].message,
- );
- expect(issueBody.props('isNew')).toEqual(true);
+ expect(issueBody.props('issue').code).toBe(mockReport.new_errors[0].code);
+ expect(issueBody.props('issue').message).toBe(mockReport.new_errors[0].message);
+ expect(issueBody.props('isNew')).toBe(true);
});
});
});
diff --git a/spec/frontend/reports/accessibility_report/mock_data.js b/spec/frontend/reports/accessibility_report/mock_data.js
index 1db2d8db25a..f8e832c1ce5 100644
--- a/spec/frontend/reports/accessibility_report/mock_data.js
+++ b/spec/frontend/reports/accessibility_report/mock_data.js
@@ -1,86 +1,55 @@
-export const baseReport = {
- results: {
- 'http://about.gitlab.com/users/sign_in': [
- {
- code: 'WCAG2AA.Principle1.Guideline1_4.1_4_3.G18.Fail',
- type: 'error',
- typeCode: 1,
- message:
- 'This element has insufficient contrast at this conformance level. Expected a contrast ratio of at least 4.5:1, but text in this element has a contrast ratio of 2.82:1. Recommendation: change background to #d1470c.',
- context:
- '<a class="btn btn-nav-cta btn-nav-link-cta" href="/free-trial">\nGet free trial\n</a>',
- selector: '#main-nav > div:nth-child(2) > ul > div:nth-child(8) > a',
- runner: 'htmlcs',
- runnerExtras: {},
- },
- ],
- 'https://about.gitlab.com': [
- {
- code: 'WCAG2AA.Principle4.Guideline4_1.4_1_2.H91.A.NoContent',
- type: 'error',
- typeCode: 1,
- message:
- 'Anchor element found with a valid href attribute, but no link content has been supplied.',
- context: '<a href="/" class="navbar-brand animated"><svg height="36" viewBox="0 0 1...</a>',
- selector: '#main-nav > div:nth-child(1) > a',
- runner: 'htmlcs',
- runnerExtras: {},
- },
- ],
- },
-};
-
-export const parsedBaseReport = [
- '{"code":"WCAG2AA.Principle1.Guideline1_4.1_4_3.G18.Fail","type":"error","typeCode":1,"message":"This element has insufficient contrast at this conformance level. Expected a contrast ratio of at least 4.5:1, but text in this element has a contrast ratio of 2.82:1. Recommendation: change background to #d1470c.","context":"<a class=\\"btn btn-nav-cta btn-nav-link-cta\\" href=\\"/free-trial\\">\\nGet free trial\\n</a>","selector":"#main-nav > div:nth-child(2) > ul > div:nth-child(8) > a","runner":"htmlcs","runnerExtras":{}}',
- '{"code":"WCAG2AA.Principle4.Guideline4_1.4_1_2.H91.A.NoContent","type":"error","typeCode":1,"message":"Anchor element found with a valid href attribute, but no link content has been supplied.","context":"<a href=\\"/\\" class=\\"navbar-brand animated\\"><svg height=\\"36\\" viewBox=\\"0 0 1...</a>","selector":"#main-nav > div:nth-child(1) > a","runner":"htmlcs","runnerExtras":{}}',
-];
-
-export const headReport = {
- results: {
- 'http://about.gitlab.com/users/sign_in': [
- {
- code: 'WCAG2AA.Principle1.Guideline1_4.1_4_3.G18.Fail',
- type: 'error',
- typeCode: 1,
- message:
- 'This element has insufficient contrast at this conformance level. Expected a contrast ratio of at least 4.5:1, but text in this element has a contrast ratio of 3.84:1. Recommendation: change text colour to #767676.',
- context: '<a href="/stages-devops-lifecycle/" class="main-nav-link">Product</a>',
- selector: '#main-nav > div:nth-child(2) > ul > li:nth-child(1) > a',
- runner: 'htmlcs',
- runnerExtras: {},
- },
- ],
- 'https://about.gitlab.com': [
- {
- code: 'WCAG2AA.Principle4.Guideline4_1.4_1_2.H91.A.NoContent',
- type: 'error',
- typeCode: 1,
- message:
- 'Anchor element found with a valid href attribute, but no link content has been supplied.',
- context: '<a href="/" class="navbar-brand animated"><svg height="36" viewBox="0 0 1...</a>',
- selector: '#main-nav > div:nth-child(1) > a',
- runner: 'htmlcs',
- runnerExtras: {},
- },
- ],
- },
-};
-
-export const comparedReportResult = {
+export const mockReport = {
status: 'failed',
summary: {
total: 2,
- notes: 0,
- errors: 2,
- warnings: 0,
+ resolved: 0,
+ errored: 2,
},
- new_errors: [headReport.results['http://about.gitlab.com/users/sign_in'][0]],
+ new_errors: [
+ {
+ code: 'WCAG2AA.Principle1.Guideline1_4.1_4_3.G18.Fail',
+ type: 'error',
+ typeCode: 1,
+ message:
+ 'This element has insufficient contrast at this conformance level. Expected a contrast ratio of at least 4.5:1, but text in this element has a contrast ratio of 3.84:1. Recommendation: change text colour to #767676.',
+ context: '<a href="/stages-devops-lifecycle/" class="main-nav-link">Product</a>',
+ selector: '#main-nav > div:nth-child(2) > ul > li:nth-child(1) > a',
+ runner: 'htmlcs',
+ runnerExtras: {},
+ },
+ ],
new_notes: [],
new_warnings: [],
- resolved_errors: [baseReport.results['http://about.gitlab.com/users/sign_in'][0]],
+ resolved_errors: [
+ {
+ code: 'WCAG2AA.Principle4.Guideline4_1.4_1_2.H91.A.NoContent',
+ type: 'error',
+ typeCode: 1,
+ message:
+ 'Anchor element found with a valid href attribute, but no link content has been supplied.',
+ context: '<a href="/" class="navbar-brand animated"><svg height="36" viewBox="0 0 1...</a>',
+ selector: '#main-nav > div:nth-child(1) > a',
+ runner: 'htmlcs',
+ runnerExtras: {},
+ },
+ ],
resolved_notes: [],
resolved_warnings: [],
- existing_errors: [headReport.results['https://about.gitlab.com'][0]],
+ existing_errors: [
+ {
+ code: 'WCAG2AA.Principle4.Guideline4_1.4_1_2.H91.A.NoContent',
+ type: 'error',
+ typeCode: 1,
+ message:
+ 'Anchor element found with a valid href attribute, but no link content has been supplied.',
+ context: '<a href="/" class="navbar-brand animated"><svg height="36" viewBox="0 0 1...</a>',
+ selector: '#main-nav > div:nth-child(1) > a',
+ runner: 'htmlcs',
+ runnerExtras: {},
+ },
+ ],
existing_notes: [],
existing_warnings: [],
};
+
+export default () => {};
diff --git a/spec/frontend/reports/accessibility_report/store/actions_spec.js b/spec/frontend/reports/accessibility_report/store/actions_spec.js
index d8fbb030a62..129a5bade86 100644
--- a/spec/frontend/reports/accessibility_report/store/actions_spec.js
+++ b/spec/frontend/reports/accessibility_report/store/actions_spec.js
@@ -5,7 +5,7 @@ import * as types from '~/reports/accessibility_report/store/mutation_types';
import createStore from '~/reports/accessibility_report/store';
import { TEST_HOST } from 'spec/test_constants';
import testAction from 'helpers/vuex_action_helper';
-import { baseReport, headReport, comparedReportResult } from '../mock_data';
+import { mockReport } from '../mock_data';
describe('Accessibility Reports actions', () => {
let localState;
@@ -18,14 +18,13 @@ describe('Accessibility Reports actions', () => {
describe('setEndpoints', () => {
it('should commit SET_ENDPOINTS mutation', done => {
- const baseEndpoint = 'base_endpoint.json';
- const headEndpoint = 'head_endpoint.json';
+ const endpoint = 'endpoint.json';
testAction(
- actions.setEndpoints,
- { baseEndpoint, headEndpoint },
+ actions.setEndpoint,
+ endpoint,
localState,
- [{ type: types.SET_ENDPOINTS, payload: { baseEndpoint, headEndpoint } }],
+ [{ type: types.SET_ENDPOINT, payload: endpoint }],
[],
done,
);
@@ -36,37 +35,14 @@ describe('Accessibility Reports actions', () => {
let mock;
beforeEach(() => {
- localState.baseEndpoint = `${TEST_HOST}/endpoint.json`;
- localState.headEndpoint = `${TEST_HOST}/endpoint.json`;
+ localState.endpoint = `${TEST_HOST}/endpoint.json`;
mock = new MockAdapter(axios);
});
afterEach(() => {
mock.restore();
- });
-
- describe('when no endpoints are given', () => {
- beforeEach(() => {
- localState.baseEndpoint = null;
- localState.headEndpoint = null;
- });
-
- it('should commit REQUEST_REPORT and RECEIVE_REPORT_ERROR mutations', done => {
- testAction(
- actions.fetchReport,
- null,
- localState,
- [
- { type: types.REQUEST_REPORT },
- {
- type: types.RECEIVE_REPORT_ERROR,
- payload: 'Accessibility report artifact not found',
- },
- ],
- [],
- done,
- );
- });
+ actions.stopPolling();
+ actions.clearEtagPoll();
});
describe('success', () => {
@@ -81,7 +57,7 @@ describe('Accessibility Reports actions', () => {
[{ type: types.REQUEST_REPORT }],
[
{
- payload: [{ ...data, isHead: false }, { ...data, isHead: true }],
+ payload: { status: 200, data },
type: 'receiveReportSuccess',
},
],
@@ -98,14 +74,8 @@ describe('Accessibility Reports actions', () => {
actions.fetchReport,
null,
localState,
- [
- { type: types.REQUEST_REPORT },
- {
- type: types.RECEIVE_REPORT_ERROR,
- payload: 'Failed to retrieve accessibility report',
- },
- ],
- [],
+ [{ type: types.REQUEST_REPORT }],
+ [{ type: 'receiveReportError' }],
done,
);
});
@@ -113,13 +83,37 @@ describe('Accessibility Reports actions', () => {
});
describe('receiveReportSuccess', () => {
- it('should commit RECEIVE_REPORT_SUCCESS mutation', done => {
+ it('should commit RECEIVE_REPORT_SUCCESS mutation with 200', done => {
+ testAction(
+ actions.receiveReportSuccess,
+ { status: 200, data: mockReport },
+ localState,
+ [{ type: types.RECEIVE_REPORT_SUCCESS, payload: mockReport }],
+ [{ type: 'stopPolling' }],
+ done,
+ );
+ });
+
+ it('should not commit RECEIVE_REPORTS_SUCCESS mutation with 204', done => {
testAction(
actions.receiveReportSuccess,
- [{ ...baseReport, isHead: false }, { ...headReport, isHead: true }],
+ { status: 204, data: mockReport },
localState,
- [{ type: types.RECEIVE_REPORT_SUCCESS, payload: comparedReportResult }],
[],
+ [],
+ done,
+ );
+ });
+ });
+
+ describe('receiveReportError', () => {
+ it('should commit RECEIVE_REPORT_ERROR mutation', done => {
+ testAction(
+ actions.receiveReportError,
+ null,
+ localState,
+ [{ type: types.RECEIVE_REPORT_ERROR }],
+ [{ type: 'stopPolling' }],
done,
);
});
diff --git a/spec/frontend/reports/accessibility_report/store/getters_spec.js b/spec/frontend/reports/accessibility_report/store/getters_spec.js
index 3f267f73504..db8f48c067a 100644
--- a/spec/frontend/reports/accessibility_report/store/getters_spec.js
+++ b/spec/frontend/reports/accessibility_report/store/getters_spec.js
@@ -67,8 +67,7 @@ describe('Accessibility reports store getters', () => {
it('returns summary message containing number of errors', () => {
localState.report = {
summary: {
- errors: 1,
- warnings: 1,
+ errored: 2,
},
};
const result = 'Accessibility scanning detected 2 issues for the source branch only';
@@ -81,8 +80,7 @@ describe('Accessibility reports store getters', () => {
it('returns summary message containing no errors', () => {
localState.report = {
summary: {
- errors: 0,
- warnings: 0,
+ errored: 0,
},
};
const result = 'Accessibility scanning detected no issues for the source branch only';
@@ -108,7 +106,7 @@ describe('Accessibility reports store getters', () => {
it('returns false', () => {
localState.report = {
status: 'success',
- summary: { errors: 0, warnings: 0 },
+ summary: { errored: 0 },
};
expect(getters.shouldRenderIssuesList(localState)).toEqual(false);
diff --git a/spec/frontend/reports/accessibility_report/store/mutations_spec.js b/spec/frontend/reports/accessibility_report/store/mutations_spec.js
index 13a1ae2f545..a4e9571b721 100644
--- a/spec/frontend/reports/accessibility_report/store/mutations_spec.js
+++ b/spec/frontend/reports/accessibility_report/store/mutations_spec.js
@@ -10,17 +10,12 @@ describe('Accessibility Reports mutations', () => {
localState = localStore.state;
});
- describe('SET_ENDPOINTS', () => {
- it('sets base and head endpoints to give values', () => {
- const baseEndpoint = 'base_endpoint.json';
- const headEndpoint = 'head_endpoint.json';
- mutations.SET_ENDPOINTS(localState, {
- baseEndpoint,
- headEndpoint,
- });
-
- expect(localState.baseEndpoint).toEqual(baseEndpoint);
- expect(localState.headEndpoint).toEqual(headEndpoint);
+ describe('SET_ENDPOINT', () => {
+ it('sets endpoint to given value', () => {
+ const endpoint = 'endpoint.json';
+ mutations.SET_ENDPOINT(localState, endpoint);
+
+ expect(localState.endpoint).toEqual(endpoint);
});
});
@@ -65,11 +60,5 @@ describe('Accessibility Reports mutations', () => {
expect(localState.hasError).toEqual(true);
});
-
- it('sets errorMessage to given message', () => {
- mutations.RECEIVE_REPORT_ERROR(localState, 'message');
-
- expect(localState.errorMessage).toEqual('message');
- });
});
});
diff --git a/spec/frontend/reports/accessibility_report/store/utils_spec.js b/spec/frontend/reports/accessibility_report/store/utils_spec.js
deleted file mode 100644
index a5fa1889503..00000000000
--- a/spec/frontend/reports/accessibility_report/store/utils_spec.js
+++ /dev/null
@@ -1,35 +0,0 @@
-import * as utils from '~/reports/accessibility_report/store/utils';
-import { baseReport, headReport, parsedBaseReport, comparedReportResult } from '../mock_data';
-
-describe('Accessibility Report store utils', () => {
- describe('parseAccessibilityReport', () => {
- it('returns array of stringified issues', () => {
- const result = utils.parseAccessibilityReport(baseReport);
-
- expect(result).toEqual(parsedBaseReport);
- });
- });
-
- describe('compareAccessibilityReports', () => {
- let reports;
-
- beforeEach(() => {
- reports = [
- {
- isHead: false,
- issues: utils.parseAccessibilityReport(baseReport),
- },
- {
- isHead: true,
- issues: utils.parseAccessibilityReport(headReport),
- },
- ];
- });
-
- it('returns the comparison report with a new, resolved, and existing error', () => {
- const result = utils.compareAccessibilityReports(reports);
-
- expect(result).toEqual(comparedReportResult);
- });
- });
-});