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>2021-03-16 21:18:33 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-03-16 21:18:33 +0300
commitf64a639bcfa1fc2bc89ca7db268f594306edfd7c (patch)
treea2c3c2ebcc3b45e596949db485d6ed18ffaacfa1 /spec/frontend/reports
parentbfbc3e0d6583ea1a91f627528bedc3d65ba4b10f (diff)
Add latest changes from gitlab-org/gitlab@13-10-stable-eev13.10.0-rc40
Diffstat (limited to 'spec/frontend/reports')
-rw-r--r--spec/frontend/reports/components/summary_row_spec.js24
-rw-r--r--spec/frontend/reports/components/test_issue_body_spec.js72
-rw-r--r--spec/frontend/reports/grouped_test_report/components/modal_spec.js (renamed from spec/frontend/reports/components/modal_spec.js)4
-rw-r--r--spec/frontend/reports/grouped_test_report/components/test_issue_body_spec.js97
-rw-r--r--spec/frontend/reports/grouped_test_report/grouped_test_reports_app_spec.js (renamed from spec/frontend/reports/components/grouped_test_reports_app_spec.js)53
-rw-r--r--spec/frontend/reports/grouped_test_report/store/actions_spec.js (renamed from spec/frontend/reports/store/actions_spec.js)6
-rw-r--r--spec/frontend/reports/grouped_test_report/store/mutations_spec.js (renamed from spec/frontend/reports/store/mutations_spec.js)18
-rw-r--r--spec/frontend/reports/grouped_test_report/store/utils_spec.js (renamed from spec/frontend/reports/store/utils_spec.js)2
-rw-r--r--spec/frontend/reports/mock_data/mock_data.js16
9 files changed, 186 insertions, 106 deletions
diff --git a/spec/frontend/reports/components/summary_row_spec.js b/spec/frontend/reports/components/summary_row_spec.js
index bdd6de1e0be..04d9d10dcd2 100644
--- a/spec/frontend/reports/components/summary_row_spec.js
+++ b/spec/frontend/reports/components/summary_row_spec.js
@@ -1,4 +1,5 @@
import { mount } from '@vue/test-utils';
+import { extendedWrapper } from 'helpers/vue_test_utils_helper';
import SummaryRow from '~/reports/components/summary_row.vue';
describe('Summary row', () => {
@@ -14,16 +15,19 @@ describe('Summary row', () => {
};
const createComponent = ({ propsData = {}, slots = {} } = {}) => {
- wrapper = mount(SummaryRow, {
- propsData: {
- ...props,
- ...propsData,
- },
- slots,
- });
+ wrapper = extendedWrapper(
+ mount(SummaryRow, {
+ propsData: {
+ ...props,
+ ...propsData,
+ },
+ slots,
+ }),
+ );
};
- const findSummary = () => wrapper.find('.report-block-list-issue-description-text');
+ const findSummary = () => wrapper.findByTestId('summary-row-description');
+ const findStatusIcon = () => wrapper.findByTestId('summary-row-icon');
afterEach(() => {
wrapper.destroy();
@@ -37,9 +41,7 @@ describe('Summary row', () => {
it('renders provided icon', () => {
createComponent();
- expect(wrapper.find('.report-block-list-icon span').classes()).toContain(
- 'js-ci-status-icon-warning',
- );
+ expect(findStatusIcon().classes()).toContain('js-ci-status-icon-warning');
});
describe('summary slot', () => {
diff --git a/spec/frontend/reports/components/test_issue_body_spec.js b/spec/frontend/reports/components/test_issue_body_spec.js
deleted file mode 100644
index 2843620a18d..00000000000
--- a/spec/frontend/reports/components/test_issue_body_spec.js
+++ /dev/null
@@ -1,72 +0,0 @@
-import Vue from 'vue';
-import { trimText } from 'helpers/text_helper';
-import { mountComponentWithStore } from 'helpers/vue_mount_component_helper';
-import component from '~/reports/components/test_issue_body.vue';
-import createStore from '~/reports/store';
-import { issue } from '../mock_data/mock_data';
-
-describe('Test Issue body', () => {
- let vm;
- const Component = Vue.extend(component);
- const store = createStore();
-
- const commonProps = {
- issue,
- status: 'failed',
- };
-
- afterEach(() => {
- vm.$destroy();
- });
-
- describe('on click', () => {
- it('calls openModal action', () => {
- vm = mountComponentWithStore(Component, {
- store,
- props: commonProps,
- });
-
- jest.spyOn(vm, 'openModal').mockImplementation(() => {});
-
- vm.$el.querySelector('button').click();
-
- expect(vm.openModal).toHaveBeenCalledWith({
- issue: commonProps.issue,
- });
- });
- });
-
- describe('is new', () => {
- beforeEach(() => {
- vm = mountComponentWithStore(Component, {
- store,
- props: { ...commonProps, isNew: true },
- });
- });
-
- it('renders issue name', () => {
- expect(vm.$el.textContent).toContain(commonProps.issue.name);
- });
-
- it('renders new badge', () => {
- expect(trimText(vm.$el.querySelector('.badge').textContent)).toEqual('New');
- });
- });
-
- describe('not new', () => {
- beforeEach(() => {
- vm = mountComponentWithStore(Component, {
- store,
- props: commonProps,
- });
- });
-
- it('renders issue name', () => {
- expect(vm.$el.textContent).toContain(commonProps.issue.name);
- });
-
- it('does not renders new badge', () => {
- expect(vm.$el.querySelector('.badge')).toEqual(null);
- });
- });
-});
diff --git a/spec/frontend/reports/components/modal_spec.js b/spec/frontend/reports/grouped_test_report/components/modal_spec.js
index d47bb964e8a..303009bab3a 100644
--- a/spec/frontend/reports/components/modal_spec.js
+++ b/spec/frontend/reports/grouped_test_report/components/modal_spec.js
@@ -2,8 +2,8 @@ import { GlLink, GlSprintf } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils';
import { extendedWrapper } from 'helpers/vue_test_utils_helper';
-import ReportsModal from '~/reports/components/modal.vue';
-import state from '~/reports/store/state';
+import ReportsModal from '~/reports/grouped_test_report/components/modal.vue';
+import state from '~/reports/grouped_test_report/store/state';
import CodeBlock from '~/vue_shared/components/code_block.vue';
const StubbedGlModal = { template: '<div><slot></slot></div>', name: 'GlModal', props: ['title'] };
diff --git a/spec/frontend/reports/grouped_test_report/components/test_issue_body_spec.js b/spec/frontend/reports/grouped_test_report/components/test_issue_body_spec.js
new file mode 100644
index 00000000000..e03a52aad8d
--- /dev/null
+++ b/spec/frontend/reports/grouped_test_report/components/test_issue_body_spec.js
@@ -0,0 +1,97 @@
+import { GlBadge, GlButton } from '@gitlab/ui';
+import { shallowMount, createLocalVue } from '@vue/test-utils';
+import Vuex from 'vuex';
+import { extendedWrapper } from 'helpers/vue_test_utils_helper';
+import IssueStatusIcon from '~/reports/components/issue_status_icon.vue';
+import TestIssueBody from '~/reports/grouped_test_report/components/test_issue_body.vue';
+import { failedIssue, successIssue } from '../../mock_data/mock_data';
+
+const localVue = createLocalVue();
+localVue.use(Vuex);
+
+describe('Test issue body', () => {
+ let wrapper;
+ let store;
+
+ const findDescription = () => wrapper.findByTestId('test-issue-body-description');
+ const findStatusIcon = () => wrapper.findComponent(IssueStatusIcon);
+ const findBadge = () => wrapper.findComponent(GlBadge);
+
+ const actionSpies = {
+ openModal: jest.fn(),
+ };
+
+ const createComponent = ({ issue = failedIssue } = {}) => {
+ store = new Vuex.Store({
+ actions: actionSpies,
+ });
+
+ wrapper = extendedWrapper(
+ shallowMount(TestIssueBody, {
+ store,
+ localVue,
+ propsData: {
+ issue,
+ },
+ stubs: {
+ GlBadge,
+ GlButton,
+ IssueStatusIcon,
+ },
+ }),
+ );
+ };
+
+ afterEach(() => {
+ wrapper.destroy();
+ });
+
+ describe('when issue has failed status', () => {
+ beforeEach(() => {
+ createComponent();
+ });
+
+ it('renders issue name', () => {
+ expect(findDescription().text()).toBe(failedIssue.name);
+ });
+
+ it('renders failed status icon', () => {
+ expect(findStatusIcon().props('status')).toBe('failed');
+ });
+
+ describe('when issue has recent failures', () => {
+ it('renders recent failures badge', () => {
+ expect(findBadge().exists()).toBe(true);
+ });
+ });
+ });
+
+ describe('when issue has success status', () => {
+ beforeEach(() => {
+ createComponent({ issue: successIssue });
+ });
+
+ it('does not render recent failures', () => {
+ expect(findBadge().exists()).toBe(false);
+ });
+
+ it('renders issue name', () => {
+ expect(findDescription().text()).toBe(successIssue.name);
+ });
+
+ it('renders success status icon', () => {
+ expect(findStatusIcon().props('status')).toBe('success');
+ });
+ });
+
+ describe('when clicking on an issue', () => {
+ it('calls openModal action', () => {
+ createComponent();
+ wrapper.findComponent(GlButton).trigger('click');
+
+ expect(actionSpies.openModal).toHaveBeenCalledWith(expect.any(Object), {
+ issue: failedIssue,
+ });
+ });
+ });
+});
diff --git a/spec/frontend/reports/components/grouped_test_reports_app_spec.js b/spec/frontend/reports/grouped_test_report/grouped_test_reports_app_spec.js
index ed261ed12c0..49332157691 100644
--- a/spec/frontend/reports/components/grouped_test_reports_app_spec.js
+++ b/spec/frontend/reports/grouped_test_report/grouped_test_reports_app_spec.js
@@ -1,8 +1,8 @@
import { mount, createLocalVue } from '@vue/test-utils';
import Vuex from 'vuex';
import { mockTracking } from 'helpers/tracking_helper';
-import GroupedTestReportsApp from '~/reports/components/grouped_test_reports_app.vue';
-import { getStoreConfig } from '~/reports/store';
+import GroupedTestReportsApp from '~/reports/grouped_test_report/grouped_test_reports_app.vue';
+import { getStoreConfig } from '~/reports/grouped_test_report/store';
import { failedReport } from '../mock_data/mock_data';
import mixedResultsTestReports from '../mock_data/new_and_fixed_failures_report.json';
@@ -42,8 +42,12 @@ describe('Grouped test reports app', () => {
const findHeader = () => wrapper.find('[data-testid="report-section-code-text"]');
const findExpandButton = () => wrapper.find('[data-testid="report-section-expand-button"]');
const findFullTestReportLink = () => wrapper.find('[data-testid="group-test-reports-full-link"]');
- const findSummaryDescription = () => wrapper.find('[data-testid="test-summary-row-description"]');
+ const findSummaryDescription = () => wrapper.find('[data-testid="summary-row-description"]');
+ const findIssueListUnresolvedHeading = () => wrapper.find('[data-testid="unresolvedHeading"]');
+ const findIssueListResolvedHeading = () => wrapper.find('[data-testid="resolvedHeading"]');
const findIssueDescription = () => wrapper.find('[data-testid="test-issue-body-description"]');
+ const findIssueRecentFailures = () =>
+ wrapper.find('[data-testid="test-issue-body-recent-failures"]');
const findAllIssueDescriptions = () =>
wrapper.findAll('[data-testid="test-issue-body-description"]');
@@ -133,6 +137,10 @@ describe('Grouped test reports app', () => {
mountComponent();
});
+ it('renders New heading', () => {
+ expect(findIssueListUnresolvedHeading().text()).toBe('New');
+ });
+
it('renders failed summary text', () => {
expect(findHeader().text()).toBe('Test summary contained 2 failed out of 11 total tests');
});
@@ -144,7 +152,6 @@ describe('Grouped test reports app', () => {
});
it('renders failed issue in list', () => {
- expect(findIssueDescription().text()).toContain('New');
expect(findIssueDescription().text()).toContain(
'Test#sum when a is 1 and b is 2 returns summary',
);
@@ -157,6 +164,10 @@ describe('Grouped test reports app', () => {
mountComponent();
});
+ it('renders New heading', () => {
+ expect(findIssueListUnresolvedHeading().text()).toBe('New');
+ });
+
it('renders error summary text', () => {
expect(findHeader().text()).toBe('Test summary contained 2 errors out of 11 total tests');
});
@@ -168,7 +179,6 @@ describe('Grouped test reports app', () => {
});
it('renders error issue in list', () => {
- expect(findIssueDescription().text()).toContain('New');
expect(findIssueDescription().text()).toContain(
'Test#sum when a is 1 and b is 2 returns summary',
);
@@ -181,6 +191,11 @@ describe('Grouped test reports app', () => {
mountComponent();
});
+ it('renders New and Fixed headings', () => {
+ expect(findIssueListUnresolvedHeading().text()).toBe('New');
+ expect(findIssueListResolvedHeading().text()).toBe('Fixed');
+ });
+
it('renders summary text', () => {
expect(findHeader().text()).toBe(
'Test summary contained 2 failed and 2 fixed test results out of 11 total tests',
@@ -194,7 +209,6 @@ describe('Grouped test reports app', () => {
});
it('renders failed issue in list', () => {
- expect(findIssueDescription().text()).toContain('New');
expect(findIssueDescription().text()).toContain(
'Test#subtract when a is 2 and b is 1 returns correct result',
);
@@ -207,6 +221,10 @@ describe('Grouped test reports app', () => {
mountComponent();
});
+ it('renders Fixed heading', () => {
+ expect(findIssueListResolvedHeading().text()).toBe('Fixed');
+ });
+
it('renders summary text', () => {
expect(findHeader().text()).toBe(
'Test summary contained 4 fixed test results out of 11 total tests',
@@ -252,7 +270,7 @@ describe('Grouped test reports app', () => {
});
it('renders the recent failures count on the test case', () => {
- expect(findIssueDescription().text()).toContain(
+ expect(findIssueRecentFailures().text()).toBe(
'Failed 8 times in master in the last 14 days',
);
});
@@ -295,6 +313,27 @@ describe('Grouped test reports app', () => {
});
});
+ describe('with a report parsing errors', () => {
+ beforeEach(() => {
+ const reports = failedReport;
+ reports.suites[0].suite_errors = {
+ head: 'JUnit XML parsing failed: 2:24: FATAL: attributes construct error',
+ base: 'JUnit data parsing failed: string not matched',
+ };
+ setReports(reports);
+ mountComponent();
+ });
+
+ it('renders the error messages', () => {
+ expect(findSummaryDescription().text()).toContain(
+ 'JUnit XML parsing failed: 2:24: FATAL: attributes construct error',
+ );
+ expect(findSummaryDescription().text()).toContain(
+ 'JUnit data parsing failed: string not matched',
+ );
+ });
+ });
+
describe('with error', () => {
beforeEach(() => {
mockStore.state.isLoading = false;
diff --git a/spec/frontend/reports/store/actions_spec.js b/spec/frontend/reports/grouped_test_report/store/actions_spec.js
index 25c3105466f..28633f7ba16 100644
--- a/spec/frontend/reports/store/actions_spec.js
+++ b/spec/frontend/reports/grouped_test_report/store/actions_spec.js
@@ -12,9 +12,9 @@ import {
receiveReportsError,
openModal,
closeModal,
-} from '~/reports/store/actions';
-import * as types from '~/reports/store/mutation_types';
-import state from '~/reports/store/state';
+} from '~/reports/grouped_test_report/store/actions';
+import * as types from '~/reports/grouped_test_report/store/mutation_types';
+import state from '~/reports/grouped_test_report/store/state';
describe('Reports Store Actions', () => {
let mockedState;
diff --git a/spec/frontend/reports/store/mutations_spec.js b/spec/frontend/reports/grouped_test_report/store/mutations_spec.js
index 652b3b0ec45..60d5016a11b 100644
--- a/spec/frontend/reports/store/mutations_spec.js
+++ b/spec/frontend/reports/grouped_test_report/store/mutations_spec.js
@@ -1,7 +1,7 @@
-import * as types from '~/reports/store/mutation_types';
-import mutations from '~/reports/store/mutations';
-import state from '~/reports/store/state';
-import { issue } from '../mock_data/mock_data';
+import * as types from '~/reports/grouped_test_report/store/mutation_types';
+import mutations from '~/reports/grouped_test_report/store/mutations';
+import state from '~/reports/grouped_test_report/store/state';
+import { failedIssue } from '../../mock_data/mock_data';
describe('Reports Store Mutations', () => {
let stateCopy;
@@ -115,17 +115,17 @@ describe('Reports Store Mutations', () => {
describe('SET_ISSUE_MODAL_DATA', () => {
beforeEach(() => {
mutations[types.SET_ISSUE_MODAL_DATA](stateCopy, {
- issue,
+ issue: failedIssue,
});
});
it('should set modal title', () => {
- expect(stateCopy.modal.title).toEqual(issue.name);
+ expect(stateCopy.modal.title).toEqual(failedIssue.name);
});
it('should set modal data', () => {
- expect(stateCopy.modal.data.execution_time.value).toEqual(issue.execution_time);
- expect(stateCopy.modal.data.system_output.value).toEqual(issue.system_output);
+ expect(stateCopy.modal.data.execution_time.value).toEqual(failedIssue.execution_time);
+ expect(stateCopy.modal.data.system_output.value).toEqual(failedIssue.system_output);
});
it('should open modal', () => {
@@ -136,7 +136,7 @@ describe('Reports Store Mutations', () => {
describe('RESET_ISSUE_MODAL_DATA', () => {
beforeEach(() => {
mutations[types.SET_ISSUE_MODAL_DATA](stateCopy, {
- issue,
+ issue: failedIssue,
});
mutations[types.RESET_ISSUE_MODAL_DATA](stateCopy);
diff --git a/spec/frontend/reports/store/utils_spec.js b/spec/frontend/reports/grouped_test_report/store/utils_spec.js
index cbc87bbb5ec..63320744796 100644
--- a/spec/frontend/reports/store/utils_spec.js
+++ b/spec/frontend/reports/grouped_test_report/store/utils_spec.js
@@ -5,7 +5,7 @@ import {
ICON_SUCCESS,
ICON_NOTFOUND,
} from '~/reports/constants';
-import * as utils from '~/reports/store/utils';
+import * as utils from '~/reports/grouped_test_report/store/utils';
describe('Reports store utils', () => {
describe('summaryTextbuilder', () => {
diff --git a/spec/frontend/reports/mock_data/mock_data.js b/spec/frontend/reports/mock_data/mock_data.js
index 3caaab2fd79..68c7439df47 100644
--- a/spec/frontend/reports/mock_data/mock_data.js
+++ b/spec/frontend/reports/mock_data/mock_data.js
@@ -1,9 +1,23 @@
-export const issue = {
+export const failedIssue = {
result: 'failure',
name: 'Test#sum when a is 1 and b is 2 returns summary',
execution_time: 0.009411,
+ status: 'failed',
system_output:
"Failure/Error: is_expected.to eq(3)\n\n expected: 3\n got: -1\n\n (compared using ==)\n./spec/test_spec.rb:12:in `block (4 levels) in \u003ctop (required)\u003e'",
+ recent_failures: {
+ count: 3,
+ base_branch: 'master',
+ },
+};
+
+export const successIssue = {
+ result: 'success',
+ name: 'Test#sum when a is 1 and b is 2 returns summary',
+ execution_time: 0.009411,
+ status: 'success',
+ system_output: null,
+ recent_failures: null,
};
export const failedReport = {