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
4fb45144
Commit
4fb45144
authored
Aug 01, 2019
by
Paul Slaughter
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clean up job_app_spec
- Remove setTimeout calls - Add helper function to encapsulate setup
parent
3077c356
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
287 additions
and
396 deletions
+287
-396
spec/javascripts/jobs/components/job_app_spec.js
spec/javascripts/jobs/components/job_app_spec.js
+287
-396
No files found.
spec/javascripts/jobs/components/job_app_spec.js
View file @
4fb45144
...
@@ -3,7 +3,9 @@ import MockAdapter from 'axios-mock-adapter';
...
@@ -3,7 +3,9 @@ import MockAdapter from 'axios-mock-adapter';
import
axios
from
'
~/lib/utils/axios_utils
'
;
import
axios
from
'
~/lib/utils/axios_utils
'
;
import
jobApp
from
'
~/jobs/components/job_app.vue
'
;
import
jobApp
from
'
~/jobs/components/job_app.vue
'
;
import
createStore
from
'
~/jobs/store
'
;
import
createStore
from
'
~/jobs/store
'
;
import
*
as
types
from
'
~/jobs/store/mutation_types
'
;
import
{
mountComponentWithStore
}
from
'
spec/helpers/vue_mount_component_helper
'
;
import
{
mountComponentWithStore
}
from
'
spec/helpers/vue_mount_component_helper
'
;
import
{
waitForMutation
}
from
'
spec/helpers/vue_test_utils_helper
'
;
import
{
resetStore
}
from
'
../store/helpers
'
;
import
{
resetStore
}
from
'
../store/helpers
'
;
import
job
from
'
../mock_data
'
;
import
job
from
'
../mock_data
'
;
...
@@ -26,6 +28,16 @@ describe('Job App ', () => {
...
@@ -26,6 +28,16 @@ describe('Job App ', () => {
'
eyJvZmZzZXQiOjE3NDUxLCJuX29wZW5fdGFncyI6MCwiZmdfY29sb3IiOm51bGwsImJnX2NvbG9yIjpudWxsLCJzdHlsZV9tYXNrIjowfQ%3D%3D
'
,
'
eyJvZmZzZXQiOjE3NDUxLCJuX29wZW5fdGFncyI6MCwiZmdfY29sb3IiOm51bGwsImJnX2NvbG9yIjpudWxsLCJzdHlsZV9tYXNrIjowfQ%3D%3D
'
,
};
};
const
waitForJobReceived
=
()
=>
waitForMutation
(
store
,
types
.
RECEIVE_JOB_SUCCESS
);
const
setupAndMount
=
({
jobData
=
{},
traceData
=
{}
}
=
{})
=>
{
mock
.
onGet
(
props
.
endpoint
).
replyOnce
(
200
,
{
...
job
,
...
jobData
});
mock
.
onGet
(
`
${
props
.
pagePath
}
/trace.json`
).
reply
(
200
,
traceData
);
vm
=
mountComponentWithStore
(
Component
,
{
props
,
store
});
return
waitForJobReceived
();
};
beforeEach
(()
=>
{
beforeEach
(()
=>
{
mock
=
new
MockAdapter
(
axios
);
mock
=
new
MockAdapter
(
axios
);
store
=
createStore
();
store
=
createStore
();
...
@@ -39,103 +51,81 @@ describe('Job App ', () => {
...
@@ -39,103 +51,81 @@ describe('Job App ', () => {
describe
(
'
while loading
'
,
()
=>
{
describe
(
'
while loading
'
,
()
=>
{
beforeEach
(()
=>
{
beforeEach
(()
=>
{
mock
.
onGet
(
props
.
endpoint
).
reply
(
200
,
job
,
{});
setupAndMount
();
mock
.
onGet
(
`
${
props
.
pagePath
}
/trace.json`
).
reply
(
200
,
{});
vm
=
mountComponentWithStore
(
Component
,
{
props
,
store
});
});
});
it
(
'
renders loading icon
'
,
done
=>
{
it
(
'
renders loading icon
'
,
()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.js-job-loading
'
)).
not
.
toBeNull
();
expect
(
vm
.
$el
.
querySelector
(
'
.js-job-loading
'
)).
not
.
toBeNull
();
expect
(
vm
.
$el
.
querySelector
(
'
.js-job-sidebar
'
)).
toBeNull
();
expect
(
vm
.
$el
.
querySelector
(
'
.js-job-sidebar
'
)).
toBeNull
();
expect
(
vm
.
$el
.
querySelector
(
'
.js-job-content
'
)).
toBeNull
();
expect
(
vm
.
$el
.
querySelector
(
'
.js-job-content
'
)).
toBeNull
();
setTimeout
(()
=>
{
done
();
},
0
);
});
});
});
});
describe
(
'
with successful request
'
,
()
=>
{
describe
(
'
with successful request
'
,
()
=>
{
beforeEach
(()
=>
{
mock
.
onGet
(
`
${
props
.
pagePath
}
/trace.json`
).
replyOnce
(
200
,
{});
});
describe
(
'
Header section
'
,
()
=>
{
describe
(
'
Header section
'
,
()
=>
{
describe
(
'
job callout message
'
,
()
=>
{
describe
(
'
job callout message
'
,
()
=>
{
it
(
'
should not render the reason when reason is absent
'
,
done
=>
{
it
(
'
should not render the reason when reason is absent
'
,
done
=>
{
mock
.
onGet
(
props
.
endpoint
).
replyOnce
(
200
,
job
);
setupAndMount
()
vm
=
mountComponentWithStore
(
Component
,
{
props
,
store
});
.
then
(()
=>
{
setTimeout
(()
=>
{
expect
(
vm
.
shouldRenderCalloutMessage
).
toBe
(
false
);
expect
(
vm
.
shouldRenderCalloutMessage
).
toBe
(
false
);
})
done
();
.
then
(
done
)
},
0
);
.
catch
(
done
.
fail
);
});
});
it
(
'
should render the reason when reason is present
'
,
done
=>
{
it
(
'
should render the reason when reason is present
'
,
done
=>
{
mock
.
onGet
(
props
.
endpoint
).
replyOnce
(
setupAndMount
({
200
,
jobData
:
{
Object
.
assign
({},
job
,
{
callout_message
:
'
There is an unkown failure, please try again
'
,
callout_message
:
'
There is an unknown failure, please try again
'
,
},
}),
})
);
.
then
(()
=>
{
vm
=
mountComponentWithStore
(
Component
,
{
props
,
store
});
setTimeout
(()
=>
{
expect
(
vm
.
shouldRenderCalloutMessage
).
toBe
(
true
);
expect
(
vm
.
shouldRenderCalloutMessage
).
toBe
(
true
);
done
();
})
},
0
);
.
then
(
done
)
.
catch
(
done
.
fail
);
});
});
});
});
describe
(
'
triggered job
'
,
()
=>
{
describe
(
'
triggered job
'
,
()
=>
{
beforeEach
(
()
=>
{
beforeEach
(
done
=>
{
const
aYearAgo
=
new
Date
();
const
aYearAgo
=
new
Date
();
aYearAgo
.
setFullYear
(
aYearAgo
.
getFullYear
()
-
1
);
aYearAgo
.
setFullYear
(
aYearAgo
.
getFullYear
()
-
1
);
mock
setupAndMount
({
jobData
:
{
started
:
aYearAgo
.
toISOString
()
}
})
.
onGet
(
props
.
endpoint
)
.
then
(
done
)
.
replyOnce
(
200
,
Object
.
assign
({},
job
,
{
started
:
aYearAgo
.
toISOString
()
}));
.
catch
(
done
.
fail
);
vm
=
mountComponentWithStore
(
Component
,
{
props
,
store
});
});
});
it
(
'
should render provided job information
'
,
done
=>
{
it
(
'
should render provided job information
'
,
()
=>
{
setTimeout
(()
=>
{
expect
(
expect
(
vm
.
$el
vm
.
$el
.
querySelector
(
'
.header-main-content
'
)
.
querySelector
(
'
.header-main-content
'
)
.
textContent
.
replace
(
/
\s
+/g
,
'
'
)
.
textContent
.
replace
(
/
\s
+/g
,
'
'
)
.
trim
(),
.
trim
(),
).
toContain
(
'
passed Job #4757 triggered 1 year ago by Root
'
);
).
toContain
(
'
passed Job #4757 triggered 1 year ago by Root
'
);
done
();
},
0
);
});
});
it
(
'
should render new issue link
'
,
done
=>
{
it
(
'
should render new issue link
'
,
()
=>
{
setTimeout
(()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.js-new-issue
'
).
getAttribute
(
'
href
'
)).
toEqual
(
expect
(
vm
.
$el
.
querySelector
(
'
.js-new-issue
'
).
getAttribute
(
'
href
'
)).
toEqual
(
job
.
new_issue_path
,
job
.
new_issue_path
,
);
);
done
();
},
0
);
});
});
});
});
describe
(
'
created job
'
,
()
=>
{
describe
(
'
created job
'
,
()
=>
{
it
(
'
should render created key
'
,
done
=>
{
it
(
'
should render created key
'
,
done
=>
{
mock
.
onGet
(
props
.
endpoint
).
replyOnce
(
200
,
job
);
setupAndMount
()
vm
=
mountComponentWithStore
(
Component
,
{
props
,
store
});
.
then
(()
=>
{
setTimeout
(()
=>
{
expect
(
expect
(
vm
.
$el
vm
.
$el
.
querySelector
(
'
.header-main-content
'
)
.
querySelector
(
'
.header-main-content
'
)
.
textContent
.
replace
(
/
\s
+/g
,
'
'
)
.
textContent
.
replace
(
/
\s
+/g
,
'
'
)
.
trim
(),
.
trim
(),
).
toContain
(
'
passed Job #4757 created 3 weeks ago by Root
'
);
).
toContain
(
'
passed Job #4757 created 3 weeks ago by Root
'
);
done
();
})
},
0
);
.
then
(
done
)
.
catch
(
done
.
fail
);
});
});
});
});
});
});
...
@@ -143,9 +133,8 @@ describe('Job App ', () => {
...
@@ -143,9 +133,8 @@ describe('Job App ', () => {
describe
(
'
stuck block
'
,
()
=>
{
describe
(
'
stuck block
'
,
()
=>
{
describe
(
'
without active runners availabl
'
,
()
=>
{
describe
(
'
without active runners availabl
'
,
()
=>
{
it
(
'
renders stuck block when there are no runners
'
,
done
=>
{
it
(
'
renders stuck block when there are no runners
'
,
done
=>
{
mock
.
onGet
(
props
.
endpoint
).
replyOnce
(
setupAndMount
({
200
,
jobData
:
{
Object
.
assign
({},
job
,
{
status
:
{
status
:
{
group
:
'
pending
'
,
group
:
'
pending
'
,
icon
:
'
status_pending
'
,
icon
:
'
status_pending
'
,
...
@@ -159,23 +148,23 @@ describe('Job App ', () => {
...
@@ -159,23 +148,23 @@ describe('Job App ', () => {
online
:
false
,
online
:
false
,
},
},
tags
:
[],
tags
:
[],
}),
},
);
})
vm
=
mountComponentWithStore
(
Component
,
{
props
,
store
});
.
then
(()
=>
{
setTimeout
(()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.js-job-stuck
'
)).
not
.
toBeNull
();
expect
(
vm
.
$el
.
querySelector
(
'
.js-job-stuck
'
)).
not
.
toBeNull
();
expect
(
vm
.
$el
.
querySelector
(
'
.js-job-stuck .js-stuck-no-active-runner
'
)).
not
.
toBeNull
();
expect
(
done
();
vm
.
$el
.
querySelector
(
'
.js-job-stuck .js-stuck-no-active-runner
'
),
},
0
);
).
not
.
toBeNull
();
})
.
then
(
done
)
.
catch
(
done
.
fail
);
});
});
});
});
describe
(
'
when available runners can not run specified tag
'
,
()
=>
{
describe
(
'
when available runners can not run specified tag
'
,
()
=>
{
it
(
'
renders tags in stuck block when there are no runners
'
,
done
=>
{
it
(
'
renders tags in stuck block when there are no runners
'
,
done
=>
{
mock
.
onGet
(
props
.
endpoint
).
replyOnce
(
setupAndMount
({
200
,
jobData
:
{
Object
.
assign
({},
job
,
{
status
:
{
status
:
{
group
:
'
pending
'
,
group
:
'
pending
'
,
icon
:
'
status_pending
'
,
icon
:
'
status_pending
'
,
...
@@ -188,27 +177,21 @@ describe('Job App ', () => {
...
@@ -188,27 +177,21 @@ describe('Job App ', () => {
available
:
false
,
available
:
false
,
online
:
false
,
online
:
false
,
},
},
}),
},
);
})
.
then
(()
=>
{
vm
=
mountComponentWithStore
(
Component
,
{
props
,
store
,
});
setTimeout
(()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.js-job-stuck
'
).
textContent
).
toContain
(
job
.
tags
[
0
]);
expect
(
vm
.
$el
.
querySelector
(
'
.js-job-stuck
'
).
textContent
).
toContain
(
job
.
tags
[
0
]);
expect
(
vm
.
$el
.
querySelector
(
'
.js-job-stuck .js-stuck-with-tags
'
)).
not
.
toBeNull
();
expect
(
vm
.
$el
.
querySelector
(
'
.js-job-stuck .js-stuck-with-tags
'
)).
not
.
toBeNull
();
done
();
})
},
0
);
.
then
(
done
)
.
catch
(
done
.
fail
);
});
});
});
});
describe
(
'
when runners are offline and build has tags
'
,
()
=>
{
describe
(
'
when runners are offline and build has tags
'
,
()
=>
{
it
(
'
renders message about job being stuck because of no runners with the specified tags
'
,
done
=>
{
it
(
'
renders message about job being stuck because of no runners with the specified tags
'
,
done
=>
{
mock
.
onGet
(
props
.
endpoint
).
replyOnce
(
setupAndMount
({
200
,
jobData
:
{
Object
.
assign
({},
job
,
{
status
:
{
status
:
{
group
:
'
pending
'
,
group
:
'
pending
'
,
icon
:
'
status_pending
'
,
icon
:
'
status_pending
'
,
...
@@ -221,48 +204,35 @@ describe('Job App ', () => {
...
@@ -221,48 +204,35 @@ describe('Job App ', () => {
available
:
true
,
available
:
true
,
online
:
true
,
online
:
true
,
},
},
}),
},
);
})
.
then
(()
=>
{
vm
=
mountComponentWithStore
(
Component
,
{
props
,
store
,
});
setTimeout
(()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.js-job-stuck
'
).
textContent
).
toContain
(
job
.
tags
[
0
]);
expect
(
vm
.
$el
.
querySelector
(
'
.js-job-stuck
'
).
textContent
).
toContain
(
job
.
tags
[
0
]);
expect
(
vm
.
$el
.
querySelector
(
'
.js-job-stuck .js-stuck-with-tags
'
)).
not
.
toBeNull
();
expect
(
vm
.
$el
.
querySelector
(
'
.js-job-stuck .js-stuck-with-tags
'
)).
not
.
toBeNull
();
done
();
})
},
0
);
.
then
(
done
)
.
catch
(
done
.
fail
);
});
});
});
});
it
(
'
does not renders stuck block when there are no runners
'
,
done
=>
{
it
(
'
does not renders stuck block when there are no runners
'
,
done
=>
{
mock
.
onGet
(
props
.
endpoint
).
replyOnce
(
setupAndMount
({
200
,
jobData
:
{
Object
.
assign
({},
job
,
{
runners
:
{
available
:
true
},
runners
:
{
available
:
true
},
}),
},
);
})
.
then
(()
=>
{
vm
=
mountComponentWithStore
(
Component
,
{
props
,
store
,
});
setTimeout
(()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.js-job-stuck
'
)).
toBeNull
();
expect
(
vm
.
$el
.
querySelector
(
'
.js-job-stuck
'
)).
toBeNull
();
})
done
();
.
then
(
done
)
},
0
);
.
catch
(
done
.
fail
);
});
});
});
});
describe
(
'
unmet prerequisites block
'
,
()
=>
{
describe
(
'
unmet prerequisites block
'
,
()
=>
{
it
(
'
renders unmet prerequisites block when there is an unmet prerequisites failure
'
,
done
=>
{
it
(
'
renders unmet prerequisites block when there is an unmet prerequisites failure
'
,
done
=>
{
mock
.
onGet
(
props
.
endpoint
).
replyOnce
(
setupAndMount
({
200
,
jobData
:
{
Object
.
assign
({},
job
,
{
status
:
{
status
:
{
group
:
'
failed
'
,
group
:
'
failed
'
,
icon
:
'
status_failed
'
,
icon
:
'
status_failed
'
,
...
@@ -282,104 +252,81 @@ describe('Job App ', () => {
...
@@ -282,104 +252,81 @@ describe('Job App ', () => {
available
:
true
,
available
:
true
,
},
},
tags
:
[],
tags
:
[],
}),
},
);
})
vm
=
mountComponentWithStore
(
Component
,
{
props
,
store
});
.
then
(()
=>
{
setTimeout
(()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.js-job-failed
'
)).
not
.
toBeNull
();
expect
(
vm
.
$el
.
querySelector
(
'
.js-job-failed
'
)).
not
.
toBeNull
();
done
();
})
},
0
);
.
then
(
done
)
.
catch
(
done
.
fail
);
});
});
});
});
describe
(
'
environments block
'
,
()
=>
{
describe
(
'
environments block
'
,
()
=>
{
it
(
'
renders environment block when job has environment
'
,
done
=>
{
it
(
'
renders environment block when job has environment
'
,
done
=>
{
mock
.
onGet
(
props
.
endpoint
).
replyOnce
(
setupAndMount
({
200
,
jobData
:
{
Object
.
assign
({},
job
,
{
deployment_status
:
{
deployment_status
:
{
environment
:
{
environment
:
{
environment_path
:
'
/path
'
,
environment_path
:
'
/path
'
,
name
:
'
foo
'
,
name
:
'
foo
'
,
},
},
},
},
}),
},
);
})
.
then
(()
=>
{
vm
=
mountComponentWithStore
(
Component
,
{
props
,
store
,
});
setTimeout
(()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.js-job-environment
'
)).
not
.
toBeNull
();
expect
(
vm
.
$el
.
querySelector
(
'
.js-job-environment
'
)).
not
.
toBeNull
();
})
done
();
.
then
(
done
)
},
0
);
.
catch
(
done
.
fail
);
});
});
it
(
'
does not render environment block when job has environment
'
,
done
=>
{
it
(
'
does not render environment block when job has environment
'
,
done
=>
{
mock
.
onGet
(
props
.
endpoint
).
replyOnce
(
200
,
job
);
setupAndMount
()
.
then
(()
=>
{
vm
=
mountComponentWithStore
(
Component
,
{
props
,
store
,
});
setTimeout
(()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.js-job-environment
'
)).
toBeNull
();
expect
(
vm
.
$el
.
querySelector
(
'
.js-job-environment
'
)).
toBeNull
();
done
();
})
},
0
);
.
then
(
done
)
.
catch
(
done
.
fail
);
});
});
});
});
describe
(
'
erased block
'
,
()
=>
{
describe
(
'
erased block
'
,
()
=>
{
it
(
'
renders erased block when `erased` is true
'
,
done
=>
{
it
(
'
renders erased block when `erased` is true
'
,
done
=>
{
mock
.
onGet
(
props
.
endpoint
).
replyOnce
(
setupAndMount
({
200
,
jobData
:
{
Object
.
assign
({},
job
,
{
erased_by
:
{
erased_by
:
{
username
:
'
root
'
,
username
:
'
root
'
,
web_url
:
'
gitlab.com/root
'
,
web_url
:
'
gitlab.com/root
'
,
},
},
erased_at
:
'
2016-11-07T11:11:16.525Z
'
,
erased_at
:
'
2016-11-07T11:11:16.525Z
'
,
}),
},
);
})
.
then
(()
=>
{
vm
=
mountComponentWithStore
(
Component
,
{
props
,
store
,
});
setTimeout
(()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.js-job-erased-block
'
)).
not
.
toBeNull
();
expect
(
vm
.
$el
.
querySelector
(
'
.js-job-erased-block
'
)).
not
.
toBeNull
();
})
done
();
.
then
(
done
)
},
0
);
.
catch
(
done
.
fail
);
});
});
it
(
'
does not render erased block when `erased` is false
'
,
done
=>
{
it
(
'
does not render erased block when `erased` is false
'
,
done
=>
{
mock
.
onGet
(
props
.
endpoint
).
replyOnce
(
200
,
Object
.
assign
({},
job
,
{
erased_at
:
null
}));
setupAndMount
({
jobData
:
{
vm
=
mountComponentWithStore
(
Component
,
{
erased_at
:
null
,
props
,
},
store
,
})
});
.
then
(()
=>
{
setTimeout
(()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.js-job-erased-block
'
)).
toBeNull
();
expect
(
vm
.
$el
.
querySelector
(
'
.js-job-erased-block
'
)).
toBeNull
();
})
done
();
.
then
(
done
)
},
0
);
.
catch
(
done
.
fail
);
});
});
});
});
describe
(
'
empty states block
'
,
()
=>
{
describe
(
'
empty states block
'
,
()
=>
{
it
(
'
renders empty state when job does not have trace and is not running
'
,
done
=>
{
it
(
'
renders empty state when job does not have trace and is not running
'
,
done
=>
{
mock
.
onGet
(
props
.
endpoint
).
replyOnce
(
setupAndMount
({
200
,
jobData
:
{
Object
.
assign
({},
job
,
{
has_trace
:
false
,
has_trace
:
false
,
status
:
{
status
:
{
group
:
'
pending
'
,
group
:
'
pending
'
,
...
@@ -399,25 +346,18 @@ describe('Job App ', () => {
...
@@ -399,25 +346,18 @@ describe('Job App ', () => {
path
:
'
/path
'
,
path
:
'
/path
'
,
},
},
},
},
}),
},
);
})
.
then
(()
=>
{
vm
=
mountComponentWithStore
(
Component
,
{
props
,
store
,
});
setTimeout
(()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.js-job-empty-state
'
)).
not
.
toBeNull
();
expect
(
vm
.
$el
.
querySelector
(
'
.js-job-empty-state
'
)).
not
.
toBeNull
();
})
done
();
.
then
(
done
)
},
0
);
.
catch
(
done
.
fail
);
});
});
it
(
'
does not render empty state when job does not have trace but it is running
'
,
done
=>
{
it
(
'
does not render empty state when job does not have trace but it is running
'
,
done
=>
{
mock
.
onGet
(
props
.
endpoint
).
replyOnce
(
setupAndMount
({
200
,
jobData
:
{
Object
.
assign
({},
job
,
{
has_trace
:
false
,
has_trace
:
false
,
status
:
{
status
:
{
group
:
'
running
'
,
group
:
'
running
'
,
...
@@ -426,34 +366,23 @@ describe('Job App ', () => {
...
@@ -426,34 +366,23 @@ describe('Job App ', () => {
text
:
'
running
'
,
text
:
'
running
'
,
details_path
:
'
path
'
,
details_path
:
'
path
'
,
},
},
}),
},
);
})
.
then
(()
=>
{
vm
=
mountComponentWithStore
(
Component
,
{
props
,
store
,
});
setTimeout
(()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.js-job-empty-state
'
)).
toBeNull
();
expect
(
vm
.
$el
.
querySelector
(
'
.js-job-empty-state
'
)).
toBeNull
();
})
done
();
.
then
(
done
)
},
0
);
.
catch
(
done
.
fail
);
});
});
it
(
'
does not render empty state when job has trace but it is not running
'
,
done
=>
{
it
(
'
does not render empty state when job has trace but it is not running
'
,
done
=>
{
mock
.
onGet
(
props
.
endpoint
).
replyOnce
(
200
,
Object
.
assign
({},
job
,
{
has_trace
:
true
}));
setupAndMount
({
jobData
:
{
has_trace
:
true
}
})
.
then
(()
=>
{
vm
=
mountComponentWithStore
(
Component
,
{
props
,
store
,
});
setTimeout
(()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.js-job-empty-state
'
)).
toBeNull
();
expect
(
vm
.
$el
.
querySelector
(
'
.js-job-empty-state
'
)).
toBeNull
();
})
.
then
(
done
)
.
catch
(
done
.
fail
);
done
();
done
();
},
0
);
});
});
it
(
'
displays remaining time for a delayed job
'
,
done
=>
{
it
(
'
displays remaining time for a delayed job
'
,
done
=>
{
...
@@ -461,37 +390,23 @@ describe('Job App ', () => {
...
@@ -461,37 +390,23 @@ describe('Job App ', () => {
spyOn
(
Date
,
'
now
'
).
and
.
callFake
(
spyOn
(
Date
,
'
now
'
).
and
.
callFake
(
()
=>
new
Date
(
delayedJobFixture
.
scheduled_at
).
getTime
()
-
oneHourInMilliseconds
,
()
=>
new
Date
(
delayedJobFixture
.
scheduled_at
).
getTime
()
-
oneHourInMilliseconds
,
);
);
mock
.
onGet
(
props
.
endpoint
).
replyOnce
(
200
,
{
...
delayedJobFixture
});
setupAndMount
({
jobData
:
delayedJobFixture
})
vm
=
mountComponentWithStore
(
Component
,
{
props
,
store
,
});
store
.
subscribeAction
(
action
=>
{
if
(
action
.
type
!==
'
receiveJobSuccess
'
)
{
return
;
}
Vue
.
nextTick
()
.
then
(()
=>
{
.
then
(()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.js-job-empty-state
'
)).
not
.
toBeNull
();
expect
(
vm
.
$el
.
querySelector
(
'
.js-job-empty-state
'
)).
not
.
toBeNull
();
const
title
=
vm
.
$el
.
querySelector
(
'
.js-job-empty-state-title
'
);
const
title
=
vm
.
$el
.
querySelector
(
'
.js-job-empty-state-title
'
);
expect
(
title
).
toContainText
(
'
01:00:00
'
);
expect
(
title
).
toContainText
(
'
01:00:00
'
);
done
();
})
})
.
then
(
done
)
.
catch
(
done
.
fail
);
.
catch
(
done
.
fail
);
});
});
});
});
});
describe
(
'
sidebar
'
,
()
=>
{
describe
(
'
sidebar
'
,
()
=>
{
it
(
'
has no blank blocks
'
,
done
=>
{
it
(
'
has no blank blocks
'
,
done
=>
{
mock
.
onGet
(
props
.
endpoint
).
replyOnce
(
setupAndMount
({
200
,
jobData
:
{
Object
.
assign
({},
job
,
{
duration
:
null
,
duration
:
null
,
finished_at
:
null
,
finished_at
:
null
,
erased_at
:
null
,
erased_at
:
null
,
...
@@ -500,106 +415,89 @@ describe('Job App ', () => {
...
@@ -500,106 +415,89 @@ describe('Job App ', () => {
coverage
:
null
,
coverage
:
null
,
tags
:
[],
tags
:
[],
cancel_path
:
null
,
cancel_path
:
null
,
}),
},
);
})
.
then
(()
=>
{
vm
.
$nextTick
(()
=>
{
vm
.
$el
.
querySelectorAll
(
'
.blocks-container > *
'
).
forEach
(
block
=>
{
vm
.
$el
.
querySelectorAll
(
'
.blocks-container > *
'
).
forEach
(
block
=>
{
expect
(
block
.
textContent
.
trim
()).
not
.
toBe
(
''
);
expect
(
block
.
textContent
.
trim
()).
not
.
toBe
(
''
);
});
});
done
();
})
});
.
then
(
done
)
.
catch
(
done
.
fail
);
});
});
});
});
});
});
describe
(
'
archived job
'
,
()
=>
{
describe
(
'
archived job
'
,
()
=>
{
beforeEach
(()
=>
{
beforeEach
(
done
=>
{
mock
.
onGet
(
props
.
endpoint
).
reply
(
200
,
Object
.
assign
({},
job
,
{
archived
:
true
}),
{});
setupAndMount
({
jobData
:
{
archived
:
true
}
})
vm
=
mountComponentWithStore
(
Component
,
{
.
then
(
done
)
props
,
.
catch
(
done
.
fail
);
store
,
});
});
});
it
(
'
renders warning about job being archived
'
,
done
=>
{
it
(
'
renders warning about job being archived
'
,
()
=>
{
setTimeout
(()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.js-archived-job
'
)).
not
.
toBeNull
();
expect
(
vm
.
$el
.
querySelector
(
'
.js-archived-job
'
)).
not
.
toBeNull
();
done
();
},
0
);
});
});
});
});
describe
(
'
non-archived job
'
,
()
=>
{
describe
(
'
non-archived job
'
,
()
=>
{
beforeEach
(()
=>
{
beforeEach
(
done
=>
{
mock
.
onGet
(
props
.
endpoint
).
reply
(
200
,
job
,
{});
setupAndMount
()
vm
=
mountComponentWithStore
(
Component
,
{
.
then
(
done
)
props
,
.
catch
(
done
.
fail
);
store
,
});
});
});
it
(
'
does not warning about job being archived
'
,
done
=>
{
it
(
'
does not warning about job being archived
'
,
()
=>
{
setTimeout
(()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.js-archived-job
'
)).
toBeNull
();
expect
(
vm
.
$el
.
querySelector
(
'
.js-archived-job
'
)).
toBeNull
();
done
();
},
0
);
});
});
});
});
describe
(
'
trace output
'
,
()
=>
{
describe
(
'
trace output
'
,
()
=>
{
beforeEach
(()
=>
{
mock
.
onGet
(
props
.
endpoint
).
reply
(
200
,
job
,
{});
});
describe
(
'
with append flag
'
,
()
=>
{
describe
(
'
with append flag
'
,
()
=>
{
it
(
'
appends the log content to the existing one
'
,
done
=>
{
it
(
'
appends the log content to the existing one
'
,
done
=>
{
mock
.
onGet
(
`
${
props
.
pagePath
}
/trace.json`
).
reply
(
200
,
{
setupAndMount
({
traceData
:
{
html
:
'
<span>More<span>
'
,
html
:
'
<span>More<span>
'
,
status
:
'
running
'
,
status
:
'
running
'
,
state
:
'
newstate
'
,
state
:
'
newstate
'
,
append
:
true
,
append
:
true
,
complete
:
true
,
complete
:
true
,
});
},
})
vm
=
mountComponentWithStore
(
Component
,
{
.
then
(()
=>
{
props
,
store
,
});
vm
.
$store
.
state
.
trace
=
'
Update
'
;
vm
.
$store
.
state
.
trace
=
'
Update
'
;
setTimeout
(()
=>
{
return
vm
.
$nextTick
();
})
.
then
(()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.js-build-trace
'
).
textContent
.
trim
()).
toContain
(
'
Update
'
);
expect
(
vm
.
$el
.
querySelector
(
'
.js-build-trace
'
).
textContent
.
trim
()).
toContain
(
'
Update
'
);
})
done
();
.
then
(
done
)
},
0
);
.
catch
(
done
.
fail
);
});
});
});
});
describe
(
'
without append flag
'
,
()
=>
{
describe
(
'
without append flag
'
,
()
=>
{
it
(
'
replaces the trace
'
,
done
=>
{
it
(
'
replaces the trace
'
,
done
=>
{
mock
.
onGet
(
`
${
props
.
pagePath
}
/trace.json`
).
reply
(
200
,
{
setupAndMount
({
traceData
:
{
html
:
'
<span>Different<span>
'
,
html
:
'
<span>Different<span>
'
,
status
:
'
running
'
,
status
:
'
running
'
,
append
:
false
,
append
:
false
,
complete
:
true
,
complete
:
true
,
});
},
})
vm
=
mountComponentWithStore
(
Component
,
{
.
then
(()
=>
{
props
,
store
,
});
vm
.
$store
.
state
.
trace
=
'
Update
'
;
setTimeout
(()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.js-build-trace
'
).
textContent
.
trim
()).
not
.
toContain
(
expect
(
vm
.
$el
.
querySelector
(
'
.js-build-trace
'
).
textContent
.
trim
()).
not
.
toContain
(
'
Update
'
,
'
Update
'
,
);
);
expect
(
vm
.
$el
.
querySelector
(
'
.js-build-trace
'
).
textContent
.
trim
()).
toContain
(
'
Different
'
);
expect
(
vm
.
$el
.
querySelector
(
'
.js-build-trace
'
).
textContent
.
trim
()).
toContain
(
done
();
'
Different
'
,
},
0
);
);
})
.
then
(
done
)
.
catch
(
done
.
fail
);
});
});
});
});
...
@@ -615,83 +513,76 @@ describe('Job App ', () => {
...
@@ -615,83 +513,76 @@ describe('Job App ', () => {
complete
:
true
,
complete
:
true
,
});
});
vm
=
mountComponentWithStore
(
Component
,
{
setupAndMount
({
props
,
traceData
:
{
store
,
html
:
'
<span>Update</span>
'
,
});
status
:
'
success
'
,
append
:
false
,
setTimeout
(()
=>
{
size
:
50
,
total
:
100
,
complete
:
true
,
},
})
.
then
(()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.js-truncated-info
'
).
textContent
.
trim
()).
toContain
(
expect
(
vm
.
$el
.
querySelector
(
'
.js-truncated-info
'
).
textContent
.
trim
()).
toContain
(
'
50 bytes
'
,
'
50 bytes
'
,
);
);
done
();
})
},
0
);
.
then
(
done
)
.
catch
(
done
.
fail
);
});
});
});
});
describe
(
'
when size is equal than total
'
,
()
=>
{
describe
(
'
when size is equal than total
'
,
()
=>
{
it
(
'
does not show the truncated information
'
,
done
=>
{
it
(
'
does not show the truncated information
'
,
done
=>
{
mock
.
onGet
(
`
${
props
.
pagePath
}
/trace.json`
).
reply
(
200
,
{
setupAndMount
({
traceData
:
{
html
:
'
<span>Update</span>
'
,
html
:
'
<span>Update</span>
'
,
status
:
'
success
'
,
status
:
'
success
'
,
append
:
false
,
append
:
false
,
size
:
100
,
size
:
100
,
total
:
100
,
total
:
100
,
complete
:
true
,
complete
:
true
,
});
},
})
vm
=
mountComponentWithStore
(
Component
,
{
.
then
(()
=>
{
props
,
store
,
});
setTimeout
(()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.js-truncated-info
'
).
textContent
.
trim
()).
not
.
toContain
(
expect
(
vm
.
$el
.
querySelector
(
'
.js-truncated-info
'
).
textContent
.
trim
()).
not
.
toContain
(
'
50 bytes
'
,
'
50 bytes
'
,
);
);
done
();
})
},
0
);
.
then
(
done
)
.
catch
(
done
.
fail
);
});
});
});
});
});
});
describe
(
'
trace controls
'
,
()
=>
{
describe
(
'
trace controls
'
,
()
=>
{
beforeEach
(()
=>
{
beforeEach
(
done
=>
{
mock
.
onGet
(
`
${
props
.
pagePath
}
/trace.json`
).
reply
(
200
,
{
setupAndMount
({
traceData
:
{
html
:
'
<span>Update</span>
'
,
html
:
'
<span>Update</span>
'
,
status
:
'
success
'
,
status
:
'
success
'
,
append
:
false
,
append
:
false
,
size
:
50
,
size
:
50
,
total
:
100
,
total
:
100
,
complete
:
true
,
complete
:
true
,
},
})
.
then
(
done
)
.
catch
(
done
.
fail
);
});
});
vm
=
mountComponentWithStore
(
Component
,
{
it
(
'
should render scroll buttons
'
,
()
=>
{
props
,
store
,
});
});
it
(
'
should render scroll buttons
'
,
done
=>
{
setTimeout
(()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.js-scroll-top
'
)).
not
.
toBeNull
();
expect
(
vm
.
$el
.
querySelector
(
'
.js-scroll-top
'
)).
not
.
toBeNull
();
expect
(
vm
.
$el
.
querySelector
(
'
.js-scroll-bottom
'
)).
not
.
toBeNull
();
expect
(
vm
.
$el
.
querySelector
(
'
.js-scroll-bottom
'
)).
not
.
toBeNull
();
done
();
},
0
);
});
});
it
(
'
should render link to raw ouput
'
,
done
=>
{
it
(
'
should render link to raw ouput
'
,
()
=>
{
setTimeout
(()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.js-raw-link-controller
'
)).
not
.
toBeNull
();
expect
(
vm
.
$el
.
querySelector
(
'
.js-raw-link-controller
'
)).
not
.
toBeNull
();
done
();
},
0
);
});
});
it
(
'
should render link to erase job
'
,
done
=>
{
it
(
'
should render link to erase job
'
,
()
=>
{
setTimeout
(()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.js-erase-link
'
)).
not
.
toBeNull
();
expect
(
vm
.
$el
.
querySelector
(
'
.js-erase-link
'
)).
not
.
toBeNull
();
done
();
},
0
);
});
});
});
});
});
});
...
...
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