Commit 85aa134c authored by Olena Horal-Koretska's avatar Olena Horal-Koretska

Merge branch 'jivanvl-fix-infinitely-collapsible-sections-backwards-compatibility' into 'master'

Add backwards compatibility to nested job log sections

See merge request gitlab-org/gitlab!67793
parents d51d6a27 5601aab4
...@@ -174,7 +174,7 @@ export const logLinesParser = (lines = [], previousTraceState = {}, prevParsedLi ...@@ -174,7 +174,7 @@ export const logLinesParser = (lines = [], previousTraceState = {}, prevParsedLi
parsedLines[currentHeader.index].line.section_duration = line.section_duration; parsedLines[currentHeader.index].line.section_duration = line.section_duration;
isPreviousLineHeader = false; isPreviousLineHeader = false;
currentHeader = null; currentHeader = null;
} else { } else if (currentHeader?.isHeader) {
currentHeader.line.section_duration = line.section_duration; currentHeader.line.section_duration = line.section_duration;
if (previousSection && previousSection?.index) { if (previousSection && previousSection?.index) {
...@@ -185,6 +185,11 @@ export const logLinesParser = (lines = [], previousTraceState = {}, prevParsedLi ...@@ -185,6 +185,11 @@ export const logLinesParser = (lines = [], previousTraceState = {}, prevParsedLi
} }
currentHeader = previousSection; currentHeader = previousSection;
} else {
// On older job logs, there's no `section_header: true` response, it's just an object
// with the `section_duration` and `section` props, so we just parse it
// as a standard line
parsedLines.push(parseLine(line, currentLineCount));
} }
} else { } else {
parsedLines.push(parseLine(line, currentLineCount)); parsedLines.push(parseLine(line, currentLineCount));
......
...@@ -123,6 +123,15 @@ export const multipleCollapsibleSectionsMockData = [ ...@@ -123,6 +123,15 @@ export const multipleCollapsibleSectionsMockData = [
}, },
]; ];
export const backwardsCompatibilityTrace = [
{
offset: 2365,
content: [],
section: 'download-artifacts',
section_duration: '00:01',
},
];
export const originalTrace = [ export const originalTrace = [
{ {
offset: 1, offset: 1,
......
...@@ -19,6 +19,7 @@ import { ...@@ -19,6 +19,7 @@ import {
collapsibleTrace, collapsibleTrace,
collapsibleTraceIncremental, collapsibleTraceIncremental,
multipleCollapsibleSectionsMockData, multipleCollapsibleSectionsMockData,
backwardsCompatibilityTrace,
} from '../components/log/mock_data'; } from '../components/log/mock_data';
describe('Jobs Store Utils', () => { describe('Jobs Store Utils', () => {
...@@ -297,6 +298,21 @@ describe('Jobs Store Utils', () => { ...@@ -297,6 +298,21 @@ describe('Jobs Store Utils', () => {
expect(result.parsedLines[1].lines).toEqual(expect.arrayContaining(innerSection)); expect(result.parsedLines[1].lines).toEqual(expect.arrayContaining(innerSection));
}); });
}); });
describe('backwards compatibility', () => {
beforeEach(() => {
result = logLinesParser(backwardsCompatibilityTrace);
});
it('should return an object with a parsedLines prop', () => {
expect(result).toEqual(
expect.objectContaining({
parsedLines: expect.any(Array),
}),
);
expect(result.parsedLines).toHaveLength(1);
});
});
}); });
describe('findOffsetAndRemove', () => { describe('findOffsetAndRemove', () => {
......
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