Commit 3e28f1f8 authored by Michael Aigner's avatar Michael Aigner Committed by Jose Ivan Vargas

Fix broken testsuite link if the suite contains a dot

parent 67b05485
...@@ -28,16 +28,12 @@ export const fetchTestSuite = ({ state, commit, dispatch }, index) => { ...@@ -28,16 +28,12 @@ export const fetchTestSuite = ({ state, commit, dispatch }, index) => {
dispatch('toggleLoading'); dispatch('toggleLoading');
const { name = '', build_ids = [] } = state.testReports?.test_suites?.[index] || {}; const { build_ids = [] } = state.testReports?.test_suites?.[index] || {};
// Replacing `/:suite_name.json` with the name of the suite. Including the extra characters // 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 // 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 return axios
.get(endpoint, { params: { build_ids } }) .get(state.suiteEndpoint, { params: { build_ids } })
.then(({ data }) => commit(types.SET_SUITE, { suite: data, index })) .then(({ data }) => commit(types.SET_SUITE, { suite: data, index }))
.catch(() => { .catch(() => {
createFlash(s__('TestReports|There was an error fetching the test suite.')); createFlash(s__('TestReports|There was an error fetching the test suite.'));
......
...@@ -85,5 +85,5 @@ ...@@ -85,5 +85,5 @@
#js-tab-tests.tab-pane #js-tab-tests.tab-pane
#js-pipeline-tests-detail{ data: { summary_endpoint: summary_project_pipeline_tests_path(@project, @pipeline, format: :json), #js-pipeline-tests-detail{ data: { summary_endpoint: summary_project_pipeline_tests_path(@project, @pipeline, format: :json),
suite_endpoint: project_pipeline_test_path(@project, @pipeline, suite_name: ':suite_name', format: :json) } } suite_endpoint: project_pipeline_test_path(@project, @pipeline, suite_name: 'suite', format: :json) } }
= render_if_exists "projects/pipelines/tabs_content", pipeline: @pipeline, project: @project = render_if_exists "projects/pipelines/tabs_content", pipeline: @pipeline, project: @project
---
title: Fix broken testsuite link if the suite contains a dot
merge_request: 51828
author: Michael Aigner @tonka3000
type: fixed
...@@ -16,7 +16,7 @@ describe('Actions TestReports Store', () => { ...@@ -16,7 +16,7 @@ describe('Actions TestReports Store', () => {
const testReports = getJSONFixture('pipelines/test_report.json'); const testReports = getJSONFixture('pipelines/test_report.json');
const summary = { total_count: 1 }; const summary = { total_count: 1 };
const suiteEndpoint = `${TEST_HOST}/tests/:suite_name.json`; const suiteEndpoint = `${TEST_HOST}/tests/suite.json`;
const summaryEndpoint = `${TEST_HOST}/test_reports/summary.json`; const summaryEndpoint = `${TEST_HOST}/test_reports/summary.json`;
const defaultState = { const defaultState = {
suiteEndpoint, suiteEndpoint,
...@@ -69,9 +69,8 @@ describe('Actions TestReports Store', () => { ...@@ -69,9 +69,8 @@ describe('Actions TestReports Store', () => {
beforeEach(() => { beforeEach(() => {
const buildIds = [1]; const buildIds = [1];
testReports.test_suites[0].build_ids = buildIds; testReports.test_suites[0].build_ids = buildIds;
const endpoint = suiteEndpoint.replace(':suite_name', testReports.test_suites[0].name);
mock mock
.onGet(endpoint, { params: { build_ids: buildIds } }) .onGet(suiteEndpoint, { params: { build_ids: buildIds } })
.replyOnce(200, testReports.test_suites[0], {}); .replyOnce(200, testReports.test_suites[0], {});
}); });
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment