Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
eaec5360
Commit
eaec5360
authored
Oct 15, 2019
by
Filipa Lacerda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adds checks for null
Backend sends data as null, frontend code was not prepared and failed silently
parent
ed52aa0f
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
95 additions
and
11 deletions
+95
-11
app/assets/javascripts/jobs/store/mutations.js
app/assets/javascripts/jobs/store/mutations.js
+3
-3
app/assets/javascripts/jobs/store/utils.js
app/assets/javascripts/jobs/store/utils.js
+10
-8
spec/frontend/jobs/store/mutations_spec.js
spec/frontend/jobs/store/mutations_spec.js
+75
-0
spec/frontend/jobs/store/utils_spec.js
spec/frontend/jobs/store/utils_spec.js
+7
-0
No files found.
app/assets/javascripts/jobs/store/mutations.js
View file @
eaec5360
...
@@ -26,7 +26,7 @@ export default {
...
@@ -26,7 +26,7 @@ export default {
if
(
log
.
append
)
{
if
(
log
.
append
)
{
if
(
isNewJobLogActive
())
{
if
(
isNewJobLogActive
())
{
state
.
trace
=
updateIncrementalTrace
(
log
.
lines
,
state
.
trace
)
;
state
.
trace
=
log
.
lines
?
updateIncrementalTrace
(
log
.
lines
,
state
.
trace
)
:
state
.
trace
;
}
else
{
}
else
{
state
.
trace
+=
log
.
html
;
state
.
trace
+=
log
.
html
;
}
}
...
@@ -35,9 +35,9 @@ export default {
...
@@ -35,9 +35,9 @@ export default {
// When the job still does not have a trace
// When the job still does not have a trace
// the trace response will not have a defined
// the trace response will not have a defined
// html or size. We keep the old value otherwise these
// html or size. We keep the old value otherwise these
// will be set to `
undefined
`
// will be set to `
null
`
if
(
isNewJobLogActive
())
{
if
(
isNewJobLogActive
())
{
state
.
trace
=
log
LinesParser
(
log
.
lines
)
||
state
.
trace
;
state
.
trace
=
log
.
lines
?
logLinesParser
(
log
.
lines
)
:
state
.
trace
;
}
else
{
}
else
{
state
.
trace
=
log
.
html
||
state
.
trace
;
state
.
trace
=
log
.
html
||
state
.
trace
;
}
}
...
...
app/assets/javascripts/jobs/store/utils.js
View file @
eaec5360
...
@@ -147,13 +147,15 @@ export const findOffsetAndRemove = (newLog = [], oldParsed = []) => {
...
@@ -147,13 +147,15 @@ export const findOffsetAndRemove = (newLog = [], oldParsed = []) => {
const
firstNew
=
newLog
[
0
];
const
firstNew
=
newLog
[
0
];
if
(
last
.
offset
===
firstNew
.
offset
||
(
last
.
line
&&
last
.
line
.
offset
===
firstNew
.
offset
))
{
if
(
last
&&
firstNew
)
{
cloneOldLog
.
splice
(
lastIndex
);
if
(
last
.
offset
===
firstNew
.
offset
||
(
last
.
line
&&
last
.
line
.
offset
===
firstNew
.
offset
))
{
}
else
if
(
last
.
lines
&&
last
.
lines
.
length
)
{
cloneOldLog
.
splice
(
lastIndex
);
const
lastNestedIndex
=
last
.
lines
.
length
-
1
;
}
else
if
(
last
.
lines
&&
last
.
lines
.
length
)
{
const
lastNested
=
last
.
lines
[
lastNestedIndex
];
const
lastNestedIndex
=
last
.
lines
.
length
-
1
;
if
(
lastNested
.
offset
===
firstNew
.
offset
)
{
const
lastNested
=
last
.
lines
[
lastNestedIndex
];
last
.
lines
.
splice
(
lastNestedIndex
);
if
(
lastNested
.
offset
===
firstNew
.
offset
)
{
last
.
lines
.
splice
(
lastNestedIndex
);
}
}
}
}
}
...
@@ -170,7 +172,7 @@ export const findOffsetAndRemove = (newLog = [], oldParsed = []) => {
...
@@ -170,7 +172,7 @@ export const findOffsetAndRemove = (newLog = [], oldParsed = []) => {
* @param array oldLog
* @param array oldLog
* @param array newLog
* @param array newLog
*/
*/
export
const
updateIncrementalTrace
=
(
newLog
,
oldParsed
=
[])
=>
{
export
const
updateIncrementalTrace
=
(
newLog
=
[]
,
oldParsed
=
[])
=>
{
const
parsedLog
=
findOffsetAndRemove
(
newLog
,
oldParsed
);
const
parsedLog
=
findOffsetAndRemove
(
newLog
,
oldParsed
);
return
logLinesParser
(
newLog
,
parsedLog
);
return
logLinesParser
(
newLog
,
parsedLog
);
...
...
spec/frontend/jobs/store/mutations_spec.js
View file @
eaec5360
...
@@ -80,6 +80,81 @@ describe('Jobs Store Mutations', () => {
...
@@ -80,6 +80,81 @@ describe('Jobs Store Mutations', () => {
expect
(
stateCopy
.
traceSize
).
toEqual
(
511846
);
expect
(
stateCopy
.
traceSize
).
toEqual
(
511846
);
expect
(
stateCopy
.
isTraceComplete
).
toEqual
(
true
);
expect
(
stateCopy
.
isTraceComplete
).
toEqual
(
true
);
});
});
describe
(
'
with new job log
'
,
()
=>
{
let
stateWithNewLog
;
beforeEach
(()
=>
{
gon
.
features
=
gon
.
features
||
{};
gon
.
features
.
jobLogJson
=
true
;
stateWithNewLog
=
state
();
});
afterEach
(()
=>
{
gon
.
features
.
jobLogJson
=
false
;
});
describe
(
'
log.lines
'
,
()
=>
{
describe
(
'
when append is true
'
,
()
=>
{
it
(
'
sets the parsed log
'
,
()
=>
{
mutations
[
types
.
RECEIVE_TRACE_SUCCESS
](
stateWithNewLog
,
{
append
:
true
,
size
:
511846
,
complete
:
true
,
lines
:
[
{
offset
:
1
,
content
:
[{
text
:
'
Running with gitlab-runner 11.12.1 (5a147c92)
'
}],
},
],
});
expect
(
stateWithNewLog
.
trace
).
toEqual
([
{
offset
:
1
,
content
:
[{
text
:
'
Running with gitlab-runner 11.12.1 (5a147c92)
'
}],
lineNumber
:
0
,
},
]);
});
});
describe
(
'
when it is defined
'
,
()
=>
{
it
(
'
sets the parsed log
'
,
()
=>
{
mutations
[
types
.
RECEIVE_TRACE_SUCCESS
](
stateWithNewLog
,
{
append
:
false
,
size
:
511846
,
complete
:
true
,
lines
:
[
{
offset
:
0
,
content
:
[{
text
:
'
Running with gitlab-runner 11.11.1 (5a147c92)
'
}]
},
],
});
expect
(
stateWithNewLog
.
trace
).
toEqual
([
{
offset
:
0
,
content
:
[{
text
:
'
Running with gitlab-runner 11.11.1 (5a147c92)
'
}],
lineNumber
:
0
,
},
]);
});
});
describe
(
'
when it is null
'
,
()
=>
{
it
(
'
sets the default value
'
,
()
=>
{
mutations
[
types
.
RECEIVE_TRACE_SUCCESS
](
stateWithNewLog
,
{
append
:
true
,
html
,
size
:
511846
,
complete
:
false
,
lines
:
null
,
});
expect
(
stateWithNewLog
.
trace
).
toEqual
([]);
});
});
});
});
});
});
describe
(
'
STOP_POLLING_TRACE
'
,
()
=>
{
describe
(
'
STOP_POLLING_TRACE
'
,
()
=>
{
...
...
spec/frontend/jobs/store/utils_spec.js
View file @
eaec5360
...
@@ -291,6 +291,13 @@ describe('Jobs Store Utils', () => {
...
@@ -291,6 +291,13 @@ describe('Jobs Store Utils', () => {
});
});
});
});
});
});
describe
(
'
when no data is provided
'
,
()
=>
{
it
(
'
returns an empty array
'
,
()
=>
{
const
result
=
findOffsetAndRemove
();
expect
(
result
).
toEqual
([]);
});
});
});
});
describe
(
'
getIncrementalLineNumber
'
,
()
=>
{
describe
(
'
getIncrementalLineNumber
'
,
()
=>
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment