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
239d6138
Commit
239d6138
authored
Feb 07, 2018
by
Phil Hughes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clear the timeout in Jobs class after each test
parent
a55cfc1e
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
19 deletions
+28
-19
app/assets/javascripts/job.js
app/assets/javascripts/job.js
+1
-1
spec/javascripts/job_spec.js
spec/javascripts/job_spec.js
+27
-18
No files found.
app/assets/javascripts/job.js
View file @
239d6138
...
@@ -217,7 +217,7 @@ export default class Job {
...
@@ -217,7 +217,7 @@ export default class Job {
}
}
this
.
isLogComplete
=
log
.
complete
;
this
.
isLogComplete
=
log
.
complete
;
if
(
!
log
.
complet
e
)
{
if
(
log
.
complete
===
fals
e
)
{
this
.
timeout
=
setTimeout
(()
=>
{
this
.
timeout
=
setTimeout
(()
=>
{
this
.
getBuildTrace
();
this
.
getBuildTrace
();
},
4000
);
},
4000
);
...
...
spec/javascripts/job_spec.js
View file @
239d6138
...
@@ -10,6 +10,7 @@ describe('Job', () => {
...
@@ -10,6 +10,7 @@ describe('Job', () => {
const
JOB_URL
=
`
${
gl
.
TEST_HOST
}
/frontend-fixtures/builds-project/-/jobs/1`
;
const
JOB_URL
=
`
${
gl
.
TEST_HOST
}
/frontend-fixtures/builds-project/-/jobs/1`
;
let
mock
;
let
mock
;
let
response
;
let
response
;
let
job
;
function
waitForPromise
()
{
function
waitForPromise
()
{
return
new
Promise
(
resolve
=>
requestAnimationFrame
(
resolve
));
return
new
Promise
(
resolve
=>
requestAnimationFrame
(
resolve
));
...
@@ -22,6 +23,8 @@ describe('Job', () => {
...
@@ -22,6 +23,8 @@ describe('Job', () => {
spyOn
(
urlUtils
,
'
visitUrl
'
);
spyOn
(
urlUtils
,
'
visitUrl
'
);
response
=
{};
mock
=
new
MockAdapter
(
axios
);
mock
=
new
MockAdapter
(
axios
);
mock
.
onGet
(
new
RegExp
(
`
${
JOB_URL
}
/trace.json?(.*)`
)).
reply
(()
=>
[
200
,
response
]);
mock
.
onGet
(
new
RegExp
(
`
${
JOB_URL
}
/trace.json?(.*)`
)).
reply
(()
=>
[
200
,
response
]);
...
@@ -30,7 +33,7 @@ describe('Job', () => {
...
@@ -30,7 +33,7 @@ describe('Job', () => {
afterEach
(()
=>
{
afterEach
(()
=>
{
mock
.
restore
();
mock
.
restore
();
response
=
{}
;
clearTimeout
(
job
.
timeout
)
;
});
});
describe
(
'
class constructor
'
,
()
=>
{
describe
(
'
class constructor
'
,
()
=>
{
...
@@ -43,15 +46,19 @@ describe('Job', () => {
...
@@ -43,15 +46,19 @@ describe('Job', () => {
});
});
describe
(
'
setup
'
,
()
=>
{
describe
(
'
setup
'
,
()
=>
{
beforeEach
(
function
()
{
beforeEach
(
function
(
done
)
{
this
.
job
=
new
Job
();
job
=
new
Job
();
waitForPromise
()
.
then
(
done
)
.
catch
(
done
.
fail
);
});
});
it
(
'
copies build options
'
,
function
()
{
it
(
'
copies build options
'
,
function
()
{
expect
(
this
.
job
.
pagePath
).
toBe
(
JOB_URL
);
expect
(
job
.
pagePath
).
toBe
(
JOB_URL
);
expect
(
this
.
job
.
buildStatus
).
toBe
(
'
success
'
);
expect
(
job
.
buildStatus
).
toBe
(
'
success
'
);
expect
(
this
.
job
.
buildStage
).
toBe
(
'
test
'
);
expect
(
job
.
buildStage
).
toBe
(
'
test
'
);
expect
(
this
.
job
.
state
).
toBe
(
''
);
expect
(
job
.
state
).
toBe
(
''
);
});
});
it
(
'
only shows the jobs matching the current stage
'
,
()
=>
{
it
(
'
only shows the jobs matching the current stage
'
,
()
=>
{
...
@@ -84,12 +91,12 @@ describe('Job', () => {
...
@@ -84,12 +91,12 @@ describe('Job', () => {
complete
:
false
,
complete
:
false
,
};
};
this
.
job
=
new
Job
();
job
=
new
Job
();
waitForPromise
()
waitForPromise
()
.
then
(()
=>
{
.
then
(()
=>
{
expect
(
$
(
'
#build-trace .js-build-output
'
).
text
()).
toMatch
(
/Update/
);
expect
(
$
(
'
#build-trace .js-build-output
'
).
text
()).
toMatch
(
/Update/
);
expect
(
this
.
job
.
state
).
toBe
(
'
newstate
'
);
expect
(
job
.
state
).
toBe
(
'
newstate
'
);
response
=
{
response
=
{
html
:
'
<span>More</span>
'
,
html
:
'
<span>More</span>
'
,
...
@@ -103,7 +110,7 @@ describe('Job', () => {
...
@@ -103,7 +110,7 @@ describe('Job', () => {
.
then
(
waitForPromise
)
.
then
(
waitForPromise
)
.
then
(()
=>
{
.
then
(()
=>
{
expect
(
$
(
'
#build-trace .js-build-output
'
).
text
()).
toMatch
(
/UpdateMore/
);
expect
(
$
(
'
#build-trace .js-build-output
'
).
text
()).
toMatch
(
/UpdateMore/
);
expect
(
this
.
job
.
state
).
toBe
(
'
finalstate
'
);
expect
(
job
.
state
).
toBe
(
'
finalstate
'
);
})
})
.
then
(
done
)
.
then
(
done
)
.
catch
(
done
.
fail
);
.
catch
(
done
.
fail
);
...
@@ -117,7 +124,7 @@ describe('Job', () => {
...
@@ -117,7 +124,7 @@ describe('Job', () => {
complete
:
false
,
complete
:
false
,
};
};
this
.
job
=
new
Job
();
job
=
new
Job
();
waitForPromise
()
waitForPromise
()
.
then
(()
=>
{
.
then
(()
=>
{
...
@@ -151,7 +158,7 @@ describe('Job', () => {
...
@@ -151,7 +158,7 @@ describe('Job', () => {
total
:
100
,
total
:
100
,
};
};
this
.
job
=
new
Job
();
job
=
new
Job
();
waitForPromise
()
waitForPromise
()
.
then
(()
=>
{
.
then
(()
=>
{
...
@@ -172,7 +179,7 @@ describe('Job', () => {
...
@@ -172,7 +179,7 @@ describe('Job', () => {
total
:
100
,
total
:
100
,
};
};
this
.
job
=
new
Job
();
job
=
new
Job
();
waitForPromise
()
waitForPromise
()
.
then
(()
=>
{
.
then
(()
=>
{
...
@@ -191,9 +198,10 @@ describe('Job', () => {
...
@@ -191,9 +198,10 @@ describe('Job', () => {
append
:
false
,
append
:
false
,
size
:
50
,
size
:
50
,
total
:
100
,
total
:
100
,
complete
:
false
,
};
};
this
.
job
=
new
Job
();
job
=
new
Job
();
waitForPromise
()
waitForPromise
()
.
then
(()
=>
{
.
then
(()
=>
{
...
@@ -207,6 +215,7 @@ describe('Job', () => {
...
@@ -207,6 +215,7 @@ describe('Job', () => {
append
:
true
,
append
:
true
,
size
:
10
,
size
:
10
,
total
:
100
,
total
:
100
,
complete
:
true
,
};
};
})
})
.
then
(()
=>
jasmine
.
clock
().
tick
(
4001
))
.
then
(()
=>
jasmine
.
clock
().
tick
(
4001
))
...
@@ -229,7 +238,7 @@ describe('Job', () => {
...
@@ -229,7 +238,7 @@ describe('Job', () => {
total
:
100
,
total
:
100
,
};
};
this
.
job
=
new
Job
();
job
=
new
Job
();
expect
(
expect
(
document
.
querySelector
(
'
.js-raw-link
'
).
textContent
.
trim
(),
document
.
querySelector
(
'
.js-raw-link
'
).
textContent
.
trim
(),
...
@@ -247,7 +256,7 @@ describe('Job', () => {
...
@@ -247,7 +256,7 @@ describe('Job', () => {
total
:
100
,
total
:
100
,
};
};
this
.
job
=
new
Job
();
job
=
new
Job
();
waitForPromise
()
waitForPromise
()
.
then
(()
=>
{
.
then
(()
=>
{
...
@@ -269,7 +278,7 @@ describe('Job', () => {
...
@@ -269,7 +278,7 @@ describe('Job', () => {
total
:
100
,
total
:
100
,
};
};
this
.
job
=
new
Job
();
job
=
new
Job
();
waitForPromise
()
waitForPromise
()
.
then
(
done
)
.
then
(
done
)
...
@@ -296,7 +305,7 @@ describe('Job', () => {
...
@@ -296,7 +305,7 @@ describe('Job', () => {
it
(
'
should request build trace with state parameter
'
,
(
done
)
=>
{
it
(
'
should request build trace with state parameter
'
,
(
done
)
=>
{
spyOn
(
axios
,
'
get
'
).
and
.
callThrough
();
spyOn
(
axios
,
'
get
'
).
and
.
callThrough
();
// eslint-disable-next-line no-new
// eslint-disable-next-line no-new
new
Job
();
job
=
new
Job
();
setTimeout
(()
=>
{
setTimeout
(()
=>
{
expect
(
axios
.
get
).
toHaveBeenCalledWith
(
expect
(
axios
.
get
).
toHaveBeenCalledWith
(
...
...
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