summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/pipelines/stores
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-08-20 18:42:06 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-08-20 18:42:06 +0000
commit6e4e1050d9dba2b7b2523fdd1768823ab85feef4 (patch)
tree78be5963ec075d80116a932011d695dd33910b4e /app/assets/javascripts/pipelines/stores
parent1ce776de4ae122aba3f349c02c17cebeaa8ecf07 (diff)
downloadgitlab-ce-6e4e1050d9dba2b7b2523fdd1768823ab85feef4.tar.gz
Add latest changes from gitlab-org/gitlab@13-3-stable-ee
Diffstat (limited to 'app/assets/javascripts/pipelines/stores')
-rw-r--r--app/assets/javascripts/pipelines/stores/test_reports/actions.js45
-rw-r--r--app/assets/javascripts/pipelines/stores/test_reports/getters.js3
-rw-r--r--app/assets/javascripts/pipelines/stores/test_reports/mutation_types.js2
-rw-r--r--app/assets/javascripts/pipelines/stores/test_reports/mutations.js33
-rw-r--r--app/assets/javascripts/pipelines/stores/test_reports/state.js10
5 files changed, 53 insertions, 40 deletions
diff --git a/app/assets/javascripts/pipelines/stores/test_reports/actions.js b/app/assets/javascripts/pipelines/stores/test_reports/actions.js
index ccacb9f7e97..f10bbeec77c 100644
--- a/app/assets/javascripts/pipelines/stores/test_reports/actions.js
+++ b/app/assets/javascripts/pipelines/stores/test_reports/actions.js
@@ -1,46 +1,46 @@
import axios from '~/lib/utils/axios_utils';
import * as types from './mutation_types';
-import createFlash from '~/flash';
+import { deprecatedCreateFlash as createFlash } from '~/flash';
import { s__ } from '~/locale';
export const fetchSummary = ({ state, commit, dispatch }) => {
- // If we do this without the build_report_summary feature flag enabled
- // it causes a race condition for toggleLoading and ruins the loading
- // state in the application
- if (state.useBuildSummaryReport) {
- dispatch('toggleLoading');
- }
+ dispatch('toggleLoading');
return axios
.get(state.summaryEndpoint)
.then(({ data }) => {
commit(types.SET_SUMMARY, data);
-
- if (!state.useBuildSummaryReport) {
- // Set the tab counter badge to total_count
- // This is temporary until we can server-side render that count number
- // (see https://gitlab.com/gitlab-org/gitlab/-/issues/223134)
- document.querySelector('.js-test-report-badge-counter').innerHTML = data.total_count || 0;
- }
})
.catch(() => {
createFlash(s__('TestReports|There was an error fetching the summary.'));
})
.finally(() => {
- if (state.useBuildSummaryReport) {
- dispatch('toggleLoading');
- }
+ dispatch('toggleLoading');
});
};
-export const fetchFullReport = ({ state, commit, dispatch }) => {
+export const fetchTestSuite = ({ state, commit, dispatch }, index) => {
+ const { hasFullSuite } = state.testReports?.test_suites?.[index] || {};
+ // We don't need to fetch the suite if we have the information already
+ if (hasFullSuite) {
+ return Promise.resolve();
+ }
+
dispatch('toggleLoading');
+ const { name = '', build_ids = [] } = state.testReports?.test_suites?.[index] || {};
+ // Replacing `/:suite_name.json` with the name of the suite. Including the extra characters
+ // to ensure that we replace exactly the template part of the URL string
+ const endpoint = state.suiteEndpoint?.replace(
+ '/:suite_name.json',
+ `/${encodeURIComponent(name)}.json`,
+ );
+
return axios
- .get(state.fullReportEndpoint)
- .then(({ data }) => commit(types.SET_REPORTS, data))
+ .get(endpoint, { params: { build_ids } })
+ .then(({ data }) => commit(types.SET_SUITE, { suite: data, index }))
.catch(() => {
- createFlash(s__('TestReports|There was an error fetching the test reports.'));
+ createFlash(s__('TestReports|There was an error fetching the test suite.'));
})
.finally(() => {
dispatch('toggleLoading');
@@ -52,6 +52,3 @@ export const setSelectedSuiteIndex = ({ commit }, data) =>
export const removeSelectedSuiteIndex = ({ commit }) =>
commit(types.SET_SELECTED_SUITE_INDEX, null);
export const toggleLoading = ({ commit }) => commit(types.TOGGLE_LOADING);
-
-// prevent babel-plugin-rewire from generating an invalid default during karma tests
-export default () => {};
diff --git a/app/assets/javascripts/pipelines/stores/test_reports/getters.js b/app/assets/javascripts/pipelines/stores/test_reports/getters.js
index 877762b77c9..6c670806cc4 100644
--- a/app/assets/javascripts/pipelines/stores/test_reports/getters.js
+++ b/app/assets/javascripts/pipelines/stores/test_reports/getters.js
@@ -16,6 +16,3 @@ export const getSuiteTests = state => {
const { test_cases: testCases = [] } = getSelectedSuite(state);
return testCases.sort(sortTestCases).map(addIconStatus);
};
-
-// prevent babel-plugin-rewire from generating an invalid default during karma tests
-export default () => {};
diff --git a/app/assets/javascripts/pipelines/stores/test_reports/mutation_types.js b/app/assets/javascripts/pipelines/stores/test_reports/mutation_types.js
index 76405557b51..52345888cb0 100644
--- a/app/assets/javascripts/pipelines/stores/test_reports/mutation_types.js
+++ b/app/assets/javascripts/pipelines/stores/test_reports/mutation_types.js
@@ -1,4 +1,4 @@
-export const SET_REPORTS = 'SET_REPORTS';
export const SET_SELECTED_SUITE_INDEX = 'SET_SELECTED_SUITE_INDEX';
export const SET_SUMMARY = 'SET_SUMMARY';
+export const SET_SUITE = 'SET_SUITE';
export const TOGGLE_LOADING = 'TOGGLE_LOADING';
diff --git a/app/assets/javascripts/pipelines/stores/test_reports/mutations.js b/app/assets/javascripts/pipelines/stores/test_reports/mutations.js
index 2531ab1e87c..3652a12a6ba 100644
--- a/app/assets/javascripts/pipelines/stores/test_reports/mutations.js
+++ b/app/assets/javascripts/pipelines/stores/test_reports/mutations.js
@@ -1,16 +1,41 @@
import * as types from './mutation_types';
export default {
- [types.SET_REPORTS](state, testReports) {
- Object.assign(state, { testReports, hasFullReport: true });
+ [types.SET_SUITE](state, { suite = {}, index = null }) {
+ state.testReports.test_suites[index] = { ...suite, hasFullSuite: true };
},
[types.SET_SELECTED_SUITE_INDEX](state, selectedSuiteIndex) {
Object.assign(state, { selectedSuiteIndex });
},
- [types.SET_SUMMARY](state, summary) {
- Object.assign(state, { testReports: { ...state.testReports, ...summary } });
+ [types.SET_SUMMARY](state, testReports) {
+ const { total } = testReports;
+ state.testReports = {
+ ...testReports,
+
+ /*
+ TLDR; this is a temporary mapping that will be updated once
+ test suites have the new data schema
+
+ The backend is in the middle of updating the data schema
+ to have a `total` object containing the total data values.
+ The test suites don't have the new schema, but the summary
+ does. Currently the `test_summary.vue` component takes both
+ the summary and a test suite depending on what is being viewed.
+ This is a temporary change to map the new schema to the old until
+ we can update the schema for the test suites also.
+ Since test suites is an array, it is easier to just map the summary
+ to the old schema instead of mapping every test suite to the new.
+ */
+
+ total_time: total.time,
+ total_count: total.count,
+ success_count: total.success,
+ failed_count: total.failed,
+ skipped_count: total.skipped,
+ error_count: total.error,
+ };
},
[types.TOGGLE_LOADING](state) {
diff --git a/app/assets/javascripts/pipelines/stores/test_reports/state.js b/app/assets/javascripts/pipelines/stores/test_reports/state.js
index bcf5c147916..af79521d68a 100644
--- a/app/assets/javascripts/pipelines/stores/test_reports/state.js
+++ b/app/assets/javascripts/pipelines/stores/test_reports/state.js
@@ -1,13 +1,7 @@
-export default ({
- fullReportEndpoint = '',
- summaryEndpoint = '',
- useBuildSummaryReport = false,
-}) => ({
+export default ({ summaryEndpoint = '', suiteEndpoint = '' }) => ({
summaryEndpoint,
- fullReportEndpoint,
+ suiteEndpoint,
testReports: {},
selectedSuiteIndex: null,
- hasFullReport: false,
isLoading: false,
- useBuildSummaryReport,
});