Commit 21530ae8 authored by Jose Ivan Vargas's avatar Jose Ivan Vargas

Merge branch '301236-fix-test-report-not-rendering' into 'master'

Fix missing pipeline test report bug

See merge request gitlab-org/gitlab!54363
parents ae2965c1 fcb0c2f9
...@@ -18,8 +18,6 @@ export default { ...@@ -18,8 +18,6 @@ export default {
testCase: { testCase: {
type: Object, type: Object,
required: true, required: true,
validator: ({ classname, formattedTime, name }) =>
Boolean(classname) && Boolean(formattedTime) && Boolean(name),
}, },
}, },
computed: { computed: {
......
...@@ -20,6 +20,8 @@ export const getSuiteTests = (state) => { ...@@ -20,6 +20,8 @@ export const getSuiteTests = (state) => {
return testCases return testCases
.map((testCase) => ({ .map((testCase) => ({
...testCase, ...testCase,
classname: testCase.classname || '',
name: testCase.name || '',
filePath: testCase.file ? `${state.blobPath}/${formatFilePath(testCase.file)}` : null, filePath: testCase.file ? `${state.blobPath}/${formatFilePath(testCase.file)}` : null,
})) }))
.map(addIconStatus) .map(addIconStatus)
......
---
title: Fix pipeline test report not rendering when missing properties
merge_request: 54363
author:
type: fixed
...@@ -94,6 +94,70 @@ describe('Getters TestReports Store', () => { ...@@ -94,6 +94,70 @@ describe('Getters TestReports Store', () => {
expect(getters.getSuiteTests(state)).toEqual([]); expect(getters.getSuiteTests(state)).toEqual([]);
}); });
describe('when a test case classname property is null', () => {
it('should return an empty string value for the classname property', () => {
const testCases = testReports.test_suites[0].test_cases;
setupState({
...defaultState,
testReports: {
...testReports,
test_suites: [
{
test_cases: testCases.map((testCase) => ({
...testCase,
classname: null,
})),
},
],
},
});
const expected = testCases
.map((x) => ({
...x,
classname: '',
filePath: `${state.blobPath}/${formatFilePath(x.file)}`,
formattedTime: formattedTime(x.execution_time),
icon: iconForTestStatus(x.status),
}))
.slice(0, state.pageInfo.perPage);
expect(getters.getSuiteTests(state)).toEqual(expected);
});
});
describe('when a test case name property is null', () => {
it('should return an empty string value for the name property', () => {
const testCases = testReports.test_suites[0].test_cases;
setupState({
...defaultState,
testReports: {
...testReports,
test_suites: [
{
test_cases: testCases.map((testCase) => ({
...testCase,
name: null,
})),
},
],
},
});
const expected = testCases
.map((x) => ({
...x,
name: '',
filePath: `${state.blobPath}/${formatFilePath(x.file)}`,
formattedTime: formattedTime(x.execution_time),
icon: iconForTestStatus(x.status),
}))
.slice(0, state.pageInfo.perPage);
expect(getters.getSuiteTests(state)).toEqual(expected);
});
});
}); });
describe('getSuiteTestCount', () => { describe('getSuiteTestCount', () => {
......
...@@ -68,7 +68,7 @@ describe('Test reports suite table', () => { ...@@ -68,7 +68,7 @@ describe('Test reports suite table', () => {
beforeEach(() => createComponent()); beforeEach(() => createComponent());
it('renders the correct number of rows', () => { it('renders the correct number of rows', () => {
expect(allCaseRows().length).toBe(testCases.length); expect(allCaseRows()).toHaveLength(testCases.length);
}); });
it.each([ it.each([
...@@ -114,4 +114,32 @@ describe('Test reports suite table', () => { ...@@ -114,4 +114,32 @@ describe('Test reports suite table', () => {
expect(wrapper.find(GlPagination).exists()).toBe(true); expect(wrapper.find(GlPagination).exists()).toBe(true);
}); });
}); });
describe('when a test case classname property is null', () => {
it('still renders all test cases', () => {
createComponent({
...testSuite,
test_cases: testSuite.test_cases.map((testCase) => ({
...testCase,
classname: null,
})),
});
expect(allCaseRows()).toHaveLength(testCases.length);
});
});
describe('when a test case name property is null', () => {
it('still renders all test cases', () => {
createComponent({
...testSuite,
test_cases: testSuite.test_cases.map((testCase) => ({
...testCase,
name: null,
})),
});
expect(allCaseRows()).toHaveLength(testCases.length);
});
});
}); });
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