2020-06-23 00:09:42 +05:30
|
|
|
import { mount, createLocalVue } from '@vue/test-utils';
|
|
|
|
import Vuex from 'vuex';
|
2021-04-29 21:17:54 +05:30
|
|
|
import Api from '~/api';
|
2021-04-17 20:07:23 +05:30
|
|
|
import GroupedTestReportsApp from '~/reports/grouped_test_report/grouped_test_reports_app.vue';
|
|
|
|
import { getStoreConfig } from '~/reports/grouped_test_report/store';
|
2020-06-23 00:09:42 +05:30
|
|
|
|
2020-05-24 23:13:21 +05:30
|
|
|
import { failedReport } from '../mock_data/mock_data';
|
2021-03-11 19:13:27 +05:30
|
|
|
import mixedResultsTestReports from '../mock_data/new_and_fixed_failures_report.json';
|
|
|
|
import newErrorsTestReports from '../mock_data/new_errors_report.json';
|
2018-11-18 11:00:15 +05:30
|
|
|
import newFailedTestReports from '../mock_data/new_failures_report.json';
|
2021-03-11 19:13:27 +05:30
|
|
|
import successTestReports from '../mock_data/no_failures_report.json';
|
2021-01-29 00:20:46 +05:30
|
|
|
import recentFailuresTestReports from '../mock_data/recent_failures_report.json';
|
2018-11-18 11:00:15 +05:30
|
|
|
import resolvedFailures from '../mock_data/resolved_failures.json';
|
|
|
|
|
2021-04-29 21:17:54 +05:30
|
|
|
jest.mock('~/api.js');
|
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
const localVue = createLocalVue();
|
|
|
|
localVue.use(Vuex);
|
|
|
|
|
|
|
|
describe('Grouped test reports app', () => {
|
|
|
|
const endpoint = 'endpoint.json';
|
2021-04-29 21:17:54 +05:30
|
|
|
const headBlobPath = '/blob/path';
|
2020-07-28 23:09:34 +05:30
|
|
|
const pipelinePath = '/path/to/pipeline';
|
2020-06-23 00:09:42 +05:30
|
|
|
let wrapper;
|
|
|
|
let mockStore;
|
|
|
|
|
2021-11-18 22:05:49 +05:30
|
|
|
const mountComponent = ({ props = { pipelinePath } } = {}) => {
|
2021-03-11 19:13:27 +05:30
|
|
|
wrapper = mount(GroupedTestReportsApp, {
|
2020-06-23 00:09:42 +05:30
|
|
|
store: mockStore,
|
|
|
|
localVue,
|
|
|
|
propsData: {
|
|
|
|
endpoint,
|
2021-04-29 21:17:54 +05:30
|
|
|
headBlobPath,
|
2020-07-28 23:09:34 +05:30
|
|
|
pipelinePath,
|
|
|
|
...props,
|
2020-06-23 00:09:42 +05:30
|
|
|
},
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2021-03-08 18:12:59 +05:30
|
|
|
const setReports = (reports) => {
|
2020-06-23 00:09:42 +05:30
|
|
|
mockStore.state.status = reports.status;
|
|
|
|
mockStore.state.summary = reports.summary;
|
|
|
|
mockStore.state.reports = reports.suites;
|
|
|
|
};
|
|
|
|
|
|
|
|
const findHeader = () => wrapper.find('[data-testid="report-section-code-text"]');
|
2021-01-29 00:20:46 +05:30
|
|
|
const findExpandButton = () => wrapper.find('[data-testid="report-section-expand-button"]');
|
2020-07-28 23:09:34 +05:30
|
|
|
const findFullTestReportLink = () => wrapper.find('[data-testid="group-test-reports-full-link"]');
|
2021-04-17 20:07:23 +05:30
|
|
|
const findSummaryDescription = () => wrapper.find('[data-testid="summary-row-description"]');
|
|
|
|
const findIssueListUnresolvedHeading = () => wrapper.find('[data-testid="unresolvedHeading"]');
|
|
|
|
const findIssueListResolvedHeading = () => wrapper.find('[data-testid="resolvedHeading"]');
|
2020-06-23 00:09:42 +05:30
|
|
|
const findIssueDescription = () => wrapper.find('[data-testid="test-issue-body-description"]');
|
2021-04-17 20:07:23 +05:30
|
|
|
const findIssueRecentFailures = () =>
|
|
|
|
wrapper.find('[data-testid="test-issue-body-recent-failures"]');
|
2020-06-23 00:09:42 +05:30
|
|
|
const findAllIssueDescriptions = () =>
|
|
|
|
wrapper.findAll('[data-testid="test-issue-body-description"]');
|
2018-11-18 11:00:15 +05:30
|
|
|
|
|
|
|
beforeEach(() => {
|
2020-11-24 15:15:51 +05:30
|
|
|
mockStore = new Vuex.Store({
|
|
|
|
...getStoreConfig(),
|
|
|
|
actions: {
|
|
|
|
fetchReports: () => {},
|
2021-04-29 21:17:54 +05:30
|
|
|
setPaths: () => {},
|
2020-11-24 15:15:51 +05:30
|
|
|
},
|
|
|
|
});
|
2020-06-23 00:09:42 +05:30
|
|
|
mountComponent();
|
2018-11-18 11:00:15 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(() => {
|
2020-06-23 00:09:42 +05:30
|
|
|
wrapper.destroy();
|
|
|
|
wrapper = null;
|
2018-11-18 11:00:15 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
describe('with success result', () => {
|
|
|
|
beforeEach(() => {
|
2020-06-23 00:09:42 +05:30
|
|
|
setReports(successTestReports);
|
|
|
|
mountComponent();
|
2018-11-18 11:00:15 +05:30
|
|
|
});
|
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
it('renders success summary text', () => {
|
|
|
|
expect(findHeader().text()).toBe(
|
|
|
|
'Test summary contained no changed test results out of 11 total tests',
|
|
|
|
);
|
2018-11-18 11:00:15 +05:30
|
|
|
});
|
2020-07-28 23:09:34 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
describe('`View full report` button', () => {
|
2020-10-24 23:57:45 +05:30
|
|
|
it('should render the full test report link', () => {
|
|
|
|
const fullTestReportLink = findFullTestReportLink();
|
2020-07-28 23:09:34 +05:30
|
|
|
|
2020-10-24 23:57:45 +05:30
|
|
|
expect(fullTestReportLink.exists()).toBe(true);
|
|
|
|
expect(pipelinePath).not.toBe('');
|
|
|
|
expect(fullTestReportLink.attributes('href')).toBe(`${pipelinePath}/test_report`);
|
2020-07-28 23:09:34 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
describe('Without a pipelinePath', () => {
|
|
|
|
beforeEach(() => {
|
|
|
|
mountComponent({
|
|
|
|
props: { pipelinePath: '' },
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should not render the full test report link', () => {
|
|
|
|
expect(findFullTestReportLink().exists()).toBe(false);
|
|
|
|
});
|
|
|
|
});
|
2018-11-18 11:00:15 +05:30
|
|
|
});
|
|
|
|
|
2021-01-29 00:20:46 +05:30
|
|
|
describe('`Expand` button', () => {
|
|
|
|
beforeEach(() => {
|
|
|
|
setReports(newFailedTestReports);
|
|
|
|
});
|
|
|
|
|
2021-11-18 22:05:49 +05:30
|
|
|
it('tracks service ping metric', () => {
|
|
|
|
mountComponent();
|
2021-01-29 00:20:46 +05:30
|
|
|
findExpandButton().trigger('click');
|
|
|
|
|
2021-04-29 21:17:54 +05:30
|
|
|
expect(Api.trackRedisHllUserEvent).toHaveBeenCalledTimes(1);
|
|
|
|
expect(Api.trackRedisHllUserEvent).toHaveBeenCalledWith(wrapper.vm.$options.expandEvent);
|
2021-01-29 00:20:46 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
it('only tracks the first expansion', () => {
|
2021-11-18 22:05:49 +05:30
|
|
|
mountComponent();
|
2021-04-29 21:17:54 +05:30
|
|
|
const expandButton = findExpandButton();
|
|
|
|
expandButton.trigger('click');
|
|
|
|
expandButton.trigger('click');
|
|
|
|
expandButton.trigger('click');
|
2021-01-29 00:20:46 +05:30
|
|
|
|
2021-04-29 21:17:54 +05:30
|
|
|
expect(Api.trackRedisHllUserEvent).toHaveBeenCalledTimes(1);
|
|
|
|
});
|
2021-01-29 00:20:46 +05:30
|
|
|
});
|
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
describe('with new failed result', () => {
|
2018-11-18 11:00:15 +05:30
|
|
|
beforeEach(() => {
|
2020-06-23 00:09:42 +05:30
|
|
|
setReports(newFailedTestReports);
|
|
|
|
mountComponent();
|
2018-11-18 11:00:15 +05:30
|
|
|
});
|
|
|
|
|
2021-04-17 20:07:23 +05:30
|
|
|
it('renders New heading', () => {
|
|
|
|
expect(findIssueListUnresolvedHeading().text()).toBe('New');
|
|
|
|
});
|
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
it('renders failed summary text', () => {
|
|
|
|
expect(findHeader().text()).toBe('Test summary contained 2 failed out of 11 total tests');
|
2018-11-18 11:00:15 +05:30
|
|
|
});
|
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
it('renders failed test suite', () => {
|
|
|
|
expect(findSummaryDescription().text()).toContain(
|
|
|
|
'rspec:pg found 2 failed out of 8 total tests',
|
|
|
|
);
|
2018-11-18 11:00:15 +05:30
|
|
|
});
|
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
it('renders failed issue in list', () => {
|
|
|
|
expect(findIssueDescription().text()).toContain(
|
|
|
|
'Test#sum when a is 1 and b is 2 returns summary',
|
|
|
|
);
|
2018-11-18 11:00:15 +05:30
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2020-03-13 15:44:24 +05:30
|
|
|
describe('with new error result', () => {
|
|
|
|
beforeEach(() => {
|
2020-06-23 00:09:42 +05:30
|
|
|
setReports(newErrorsTestReports);
|
|
|
|
mountComponent();
|
|
|
|
});
|
|
|
|
|
2021-04-17 20:07:23 +05:30
|
|
|
it('renders New heading', () => {
|
|
|
|
expect(findIssueListUnresolvedHeading().text()).toBe('New');
|
|
|
|
});
|
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
it('renders error summary text', () => {
|
|
|
|
expect(findHeader().text()).toBe('Test summary contained 2 errors out of 11 total tests');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('renders error test suite', () => {
|
|
|
|
expect(findSummaryDescription().text()).toContain(
|
|
|
|
'karma found 2 errors out of 3 total tests',
|
|
|
|
);
|
2020-03-13 15:44:24 +05:30
|
|
|
});
|
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
it('renders error issue in list', () => {
|
|
|
|
expect(findIssueDescription().text()).toContain(
|
|
|
|
'Test#sum when a is 1 and b is 2 returns summary',
|
|
|
|
);
|
2020-03-13 15:44:24 +05:30
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2018-11-18 11:00:15 +05:30
|
|
|
describe('with mixed results', () => {
|
|
|
|
beforeEach(() => {
|
2020-06-23 00:09:42 +05:30
|
|
|
setReports(mixedResultsTestReports);
|
|
|
|
mountComponent();
|
|
|
|
});
|
|
|
|
|
2021-04-17 20:07:23 +05:30
|
|
|
it('renders New and Fixed headings', () => {
|
|
|
|
expect(findIssueListUnresolvedHeading().text()).toBe('New');
|
|
|
|
expect(findIssueListResolvedHeading().text()).toBe('Fixed');
|
|
|
|
});
|
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
it('renders summary text', () => {
|
|
|
|
expect(findHeader().text()).toBe(
|
|
|
|
'Test summary contained 2 failed and 2 fixed test results out of 11 total tests',
|
|
|
|
);
|
2018-11-18 11:00:15 +05:30
|
|
|
});
|
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
it('renders failed test suite', () => {
|
|
|
|
expect(findSummaryDescription().text()).toContain(
|
|
|
|
'rspec:pg found 1 failed and 2 fixed test results out of 8 total tests',
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('renders failed issue in list', () => {
|
|
|
|
expect(findIssueDescription().text()).toContain(
|
|
|
|
'Test#subtract when a is 2 and b is 1 returns correct result',
|
|
|
|
);
|
2018-11-18 11:00:15 +05:30
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2020-03-13 15:44:24 +05:30
|
|
|
describe('with resolved failures and resolved errors', () => {
|
2018-11-18 11:00:15 +05:30
|
|
|
beforeEach(() => {
|
2020-06-23 00:09:42 +05:30
|
|
|
setReports(resolvedFailures);
|
|
|
|
mountComponent();
|
2018-11-18 11:00:15 +05:30
|
|
|
});
|
|
|
|
|
2021-04-17 20:07:23 +05:30
|
|
|
it('renders Fixed heading', () => {
|
|
|
|
expect(findIssueListResolvedHeading().text()).toBe('Fixed');
|
|
|
|
});
|
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
it('renders summary text', () => {
|
|
|
|
expect(findHeader().text()).toBe(
|
|
|
|
'Test summary contained 4 fixed test results out of 11 total tests',
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('renders resolved test suite', () => {
|
|
|
|
expect(findSummaryDescription().text()).toContain(
|
|
|
|
'rspec:pg found 4 fixed test results out of 8 total tests',
|
|
|
|
);
|
2018-11-18 11:00:15 +05:30
|
|
|
});
|
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
it('renders resolved failures', () => {
|
|
|
|
expect(findIssueDescription().text()).toContain(
|
|
|
|
resolvedFailures.suites[0].resolved_failures[0].name,
|
|
|
|
);
|
2018-11-18 11:00:15 +05:30
|
|
|
});
|
2020-03-13 15:44:24 +05:30
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
it('renders resolved errors', () => {
|
2021-03-08 18:12:59 +05:30
|
|
|
expect(findAllIssueDescriptions().at(2).text()).toContain(
|
|
|
|
resolvedFailures.suites[0].resolved_errors[0].name,
|
|
|
|
);
|
2020-05-24 23:13:21 +05:30
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2021-01-29 00:20:46 +05:30
|
|
|
describe('recent failures counts', () => {
|
|
|
|
describe('with recent failures counts', () => {
|
|
|
|
beforeEach(() => {
|
|
|
|
setReports(recentFailuresTestReports);
|
2021-03-08 18:12:59 +05:30
|
|
|
mountComponent();
|
2021-01-29 00:20:46 +05:30
|
|
|
});
|
|
|
|
|
2021-03-08 18:12:59 +05:30
|
|
|
it('renders the recently failed tests summary', () => {
|
|
|
|
expect(findHeader().text()).toContain(
|
|
|
|
'2 out of 3 failed tests have failed more than once in the last 14 days',
|
|
|
|
);
|
2021-01-29 00:20:46 +05:30
|
|
|
});
|
|
|
|
|
2021-03-08 18:12:59 +05:30
|
|
|
it('renders the recently failed count on the test suite', () => {
|
|
|
|
expect(findSummaryDescription().text()).toContain(
|
|
|
|
'1 out of 2 failed tests has failed more than once in the last 14 days',
|
|
|
|
);
|
|
|
|
});
|
2021-01-29 00:20:46 +05:30
|
|
|
|
2021-03-08 18:12:59 +05:30
|
|
|
it('renders the recent failures count on the test case', () => {
|
2021-06-08 01:23:25 +05:30
|
|
|
expect(findIssueRecentFailures().text()).toBe('Failed 8 times in main in the last 14 days');
|
2021-01-29 00:20:46 +05:30
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('without recent failures counts', () => {
|
|
|
|
beforeEach(() => {
|
|
|
|
setReports(mixedResultsTestReports);
|
|
|
|
mountComponent();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('does not render the recently failed tests summary', () => {
|
|
|
|
expect(findHeader().text()).not.toContain('failed more than once in the last 14 days');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('does not render the recently failed count on the test suite', () => {
|
|
|
|
expect(findSummaryDescription().text()).not.toContain(
|
|
|
|
'failed more than once in the last 14 days',
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('does not render the recent failures count on the test case', () => {
|
|
|
|
expect(findIssueDescription().text()).not.toContain('in the last 14 days');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2020-05-24 23:13:21 +05:30
|
|
|
describe('with a report that failed to load', () => {
|
|
|
|
beforeEach(() => {
|
2020-06-23 00:09:42 +05:30
|
|
|
setReports(failedReport);
|
|
|
|
mountComponent();
|
2020-05-24 23:13:21 +05:30
|
|
|
});
|
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
it('renders an error status for the report', () => {
|
|
|
|
const { name } = failedReport.suites[0];
|
2020-05-24 23:13:21 +05:30
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
expect(findSummaryDescription().text()).toContain(
|
|
|
|
`An error occurred while loading ${name} result`,
|
|
|
|
);
|
2020-03-13 15:44:24 +05:30
|
|
|
});
|
2018-11-18 11:00:15 +05:30
|
|
|
});
|
|
|
|
|
2021-04-17 20:07:23 +05:30
|
|
|
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',
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2018-11-18 11:00:15 +05:30
|
|
|
describe('with error', () => {
|
|
|
|
beforeEach(() => {
|
2020-06-23 00:09:42 +05:30
|
|
|
mockStore.state.isLoading = false;
|
|
|
|
mockStore.state.hasError = true;
|
|
|
|
mountComponent();
|
2018-11-18 11:00:15 +05:30
|
|
|
});
|
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
it('renders loading state', () => {
|
|
|
|
expect(findHeader().text()).toBe('Test summary failed loading results');
|
2018-11-18 11:00:15 +05:30
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('while loading', () => {
|
|
|
|
beforeEach(() => {
|
2020-06-23 00:09:42 +05:30
|
|
|
mockStore.state.isLoading = true;
|
|
|
|
mountComponent();
|
2018-11-18 11:00:15 +05:30
|
|
|
});
|
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
it('renders loading state', () => {
|
|
|
|
expect(findHeader().text()).toBe('Test summary results are being parsed');
|
2018-11-18 11:00:15 +05:30
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|