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
0
Merge Requests
0
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
Léo-Paul Géneau
gitlab-ce
Commits
2d6022e0
Commit
2d6022e0
authored
Jun 01, 2018
by
Phil Hughes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
store specs
parent
8c3a2c55
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
189 additions
and
1 deletion
+189
-1
app/assets/javascripts/ide/stores/modules/pipelines/actions.js
...ssets/javascripts/ide/stores/modules/pipelines/actions.js
+1
-1
spec/javascripts/ide/mock_data.js
spec/javascripts/ide/mock_data.js
+4
-0
spec/javascripts/ide/stores/modules/pipelines/actions_spec.js
.../javascripts/ide/stores/modules/pipelines/actions_spec.js
+135
-0
spec/javascripts/ide/stores/modules/pipelines/mutations_spec.js
...avascripts/ide/stores/modules/pipelines/mutations_spec.js
+49
-0
No files found.
app/assets/javascripts/ide/stores/modules/pipelines/actions.js
View file @
2d6022e0
...
@@ -99,7 +99,7 @@ export const fetchJobTrace = ({ dispatch, state }) => {
...
@@ -99,7 +99,7 @@ export const fetchJobTrace = ({ dispatch, state }) => {
return
axios
return
axios
.
get
(
`
${
state
.
detailJob
.
path
}
/trace`
,
{
params
:
{
format
:
'
json
'
}
})
.
get
(
`
${
state
.
detailJob
.
path
}
/trace`
,
{
params
:
{
format
:
'
json
'
}
})
.
then
(({
data
})
=>
dispatch
(
'
receiveJobTraceSuccess
'
,
data
))
.
then
(({
data
})
=>
dispatch
(
'
receiveJobTraceSuccess
'
,
data
))
.
catch
(()
=>
dispatch
(
'
re
quest
JobTraceError
'
));
.
catch
(()
=>
dispatch
(
'
re
ceive
JobTraceError
'
));
};
};
export
default
()
=>
{};
export
default
()
=>
{};
spec/javascripts/ide/mock_data.js
View file @
2d6022e0
...
@@ -75,6 +75,7 @@ export const jobs = [
...
@@ -75,6 +75,7 @@ export const jobs = [
},
},
stage
:
'
test
'
,
stage
:
'
test
'
,
duration
:
1
,
duration
:
1
,
started
:
new
Date
(),
},
},
{
{
id
:
2
,
id
:
2
,
...
@@ -86,6 +87,7 @@ export const jobs = [
...
@@ -86,6 +87,7 @@ export const jobs = [
},
},
stage
:
'
test
'
,
stage
:
'
test
'
,
duration
:
1
,
duration
:
1
,
started
:
new
Date
(),
},
},
{
{
id
:
3
,
id
:
3
,
...
@@ -97,6 +99,7 @@ export const jobs = [
...
@@ -97,6 +99,7 @@ export const jobs = [
},
},
stage
:
'
test
'
,
stage
:
'
test
'
,
duration
:
1
,
duration
:
1
,
started
:
new
Date
(),
},
},
{
{
id
:
4
,
id
:
4
,
...
@@ -108,6 +111,7 @@ export const jobs = [
...
@@ -108,6 +111,7 @@ export const jobs = [
},
},
stage
:
'
build
'
,
stage
:
'
build
'
,
duration
:
1
,
duration
:
1
,
started
:
new
Date
(),
},
},
];
];
...
...
spec/javascripts/ide/stores/modules/pipelines/actions_spec.js
View file @
2d6022e0
...
@@ -13,9 +13,15 @@ import actions, {
...
@@ -13,9 +13,15 @@ import actions, {
receiveJobsSuccess
,
receiveJobsSuccess
,
fetchJobs
,
fetchJobs
,
toggleStageCollapsed
,
toggleStageCollapsed
,
setDetailJob
,
requestJobTrace
,
receiveJobTraceError
,
receiveJobTraceSuccess
,
fetchJobTrace
,
}
from
'
~/ide/stores/modules/pipelines/actions
'
;
}
from
'
~/ide/stores/modules/pipelines/actions
'
;
import
state
from
'
~/ide/stores/modules/pipelines/state
'
;
import
state
from
'
~/ide/stores/modules/pipelines/state
'
;
import
*
as
types
from
'
~/ide/stores/modules/pipelines/mutation_types
'
;
import
*
as
types
from
'
~/ide/stores/modules/pipelines/mutation_types
'
;
import
{
rightSidebarViews
}
from
'
~/ide/constants
'
;
import
testAction
from
'
../../../../helpers/vuex_action_helper
'
;
import
testAction
from
'
../../../../helpers/vuex_action_helper
'
;
import
{
pipelines
,
jobs
}
from
'
../../../mock_data
'
;
import
{
pipelines
,
jobs
}
from
'
../../../mock_data
'
;
...
@@ -281,4 +287,133 @@ describe('IDE pipelines actions', () => {
...
@@ -281,4 +287,133 @@ describe('IDE pipelines actions', () => {
);
);
});
});
});
});
describe
(
'
setDetailJob
'
,
()
=>
{
it
(
'
commits job
'
,
done
=>
{
testAction
(
setDetailJob
,
'
job
'
,
mockedState
,
[{
type
:
types
.
SET_DETAIL_JOB
,
payload
:
'
job
'
}],
[{
type
:
'
setRightPane
'
}],
done
,
);
});
it
(
'
dispatches setRightPane as pipeline when job is null
'
,
done
=>
{
testAction
(
setDetailJob
,
null
,
mockedState
,
[{
type
:
types
.
SET_DETAIL_JOB
}],
[{
type
:
'
setRightPane
'
,
payload
:
rightSidebarViews
.
pipelines
}],
done
,
);
});
it
(
'
dispatches setRightPane as job
'
,
done
=>
{
testAction
(
setDetailJob
,
'
job
'
,
mockedState
,
[{
type
:
types
.
SET_DETAIL_JOB
}],
[{
type
:
'
setRightPane
'
,
payload
:
rightSidebarViews
.
jobsDetail
}],
done
,
);
});
});
describe
(
'
requestJobTrace
'
,
()
=>
{
it
(
'
commits request
'
,
done
=>
{
testAction
(
requestJobTrace
,
null
,
mockedState
,
[{
type
:
types
.
REQUEST_JOB_TRACE
}],
[],
done
);
});
});
describe
(
'
receiveJobTraceError
'
,
()
=>
{
it
(
'
commits error
'
,
done
=>
{
testAction
(
receiveJobTraceError
,
null
,
mockedState
,
[{
type
:
types
.
RECEIVE_JOB_TRACE_ERROR
}],
[],
done
,
);
});
it
(
'
creates flash message
'
,
()
=>
{
const
flashSpy
=
spyOnDependency
(
actions
,
'
flash
'
);
receiveJobTraceError
({
commit
()
{}
});
expect
(
flashSpy
).
toHaveBeenCalled
();
});
});
describe
(
'
receiveJobTraceSuccess
'
,
()
=>
{
it
(
'
commits data
'
,
done
=>
{
testAction
(
receiveJobTraceSuccess
,
'
data
'
,
mockedState
,
[{
type
:
types
.
RECEIVE_JOB_TRACE_SUCCESS
,
payload
:
'
data
'
}],
[],
done
,
);
});
});
describe
(
'
fetchJobTrace
'
,
()
=>
{
beforeEach
(()
=>
{
mockedState
.
detailJob
=
{
path
:
`
${
gl
.
TEST_HOST
}
/project/builds`
,
};
});
describe
(
'
success
'
,
()
=>
{
beforeEach
(()
=>
{
spyOn
(
axios
,
'
get
'
).
and
.
callThrough
();
mock
.
onGet
(
`
${
gl
.
TEST_HOST
}
/project/builds/trace`
).
replyOnce
(
200
,
{
html
:
'
html
'
});
});
it
(
'
dispatches request
'
,
done
=>
{
testAction
(
fetchJobTrace
,
null
,
mockedState
,
[],
[
{
type
:
'
requestJobTrace
'
},
{
type
:
'
receiveJobTraceSuccess
'
,
payload
:
{
html
:
'
html
'
}
},
],
done
,
);
});
it
(
'
sends get request to correct URL
'
,
()
=>
{
fetchJobTrace
({
state
:
mockedState
,
dispatch
()
{}
});
expect
(
axios
.
get
).
toHaveBeenCalledWith
(
`
${
gl
.
TEST_HOST
}
/project/builds/trace`
,
{
params
:
{
format
:
'
json
'
},
});
});
});
describe
(
'
error
'
,
()
=>
{
beforeEach
(()
=>
{
mock
.
onGet
(
`
${
gl
.
TEST_HOST
}
/project/builds/trace`
).
replyOnce
(
500
);
});
it
(
'
dispatches error
'
,
done
=>
{
testAction
(
fetchJobTrace
,
null
,
mockedState
,
[],
[{
type
:
'
requestJobTrace
'
},
{
type
:
'
receiveJobTraceError
'
}],
done
,
);
});
});
});
});
});
spec/javascripts/ide/stores/modules/pipelines/mutations_spec.js
View file @
2d6022e0
...
@@ -147,6 +147,10 @@ describe('IDE pipelines mutations', () => {
...
@@ -147,6 +147,10 @@ describe('IDE pipelines mutations', () => {
name
:
job
.
name
,
name
:
job
.
name
,
status
:
job
.
status
,
status
:
job
.
status
,
path
:
job
.
build_path
,
path
:
job
.
build_path
,
rawPath
:
`
${
job
.
build_path
}
/raw`
,
started
:
job
.
started
,
isLoading
:
false
,
output
:
''
,
})),
})),
);
);
});
});
...
@@ -171,4 +175,49 @@ describe('IDE pipelines mutations', () => {
...
@@ -171,4 +175,49 @@ describe('IDE pipelines mutations', () => {
expect
(
mockedState
.
stages
[
0
].
isCollapsed
).
toBe
(
false
);
expect
(
mockedState
.
stages
[
0
].
isCollapsed
).
toBe
(
false
);
});
});
});
});
describe
(
types
.
SET_DETAIL_JOB
,
()
=>
{
it
(
'
sets detail job
'
,
()
=>
{
mutations
[
types
.
SET_DETAIL_JOB
](
mockedState
,
jobs
[
0
]);
expect
(
mockedState
.
detailJob
).
toEqual
(
jobs
[
0
]);
});
});
describe
(
types
.
REQUEST_JOB_TRACE
,
()
=>
{
beforeEach
(()
=>
{
mockedState
.
detailJob
=
{
...
jobs
[
0
]
};
});
it
(
'
sets loading on detail job
'
,
()
=>
{
mutations
[
types
.
REQUEST_JOB_TRACE
](
mockedState
);
expect
(
mockedState
.
detailJob
.
isLoading
).
toBe
(
true
);
});
});
describe
(
types
.
RECEIVE_JOB_TRACE_ERROR
,
()
=>
{
beforeEach
(()
=>
{
mockedState
.
detailJob
=
{
...
jobs
[
0
],
isLoading
:
true
};
});
it
(
'
sets loading to false on detail job
'
,
()
=>
{
mutations
[
types
.
RECEIVE_JOB_TRACE_ERROR
](
mockedState
);
expect
(
mockedState
.
detailJob
.
isLoading
).
toBe
(
false
);
});
});
describe
(
types
.
RECEIVE_JOB_TRACE_SUCCESS
,
()
=>
{
beforeEach
(()
=>
{
mockedState
.
detailJob
=
{
...
jobs
[
0
],
isLoading
:
true
};
});
it
(
'
sets output on detail job
'
,
()
=>
{
mutations
[
types
.
RECEIVE_JOB_TRACE_SUCCESS
](
mockedState
,
{
html
:
'
html
'
});
expect
(
mockedState
.
detailJob
.
output
).
toBe
(
'
html
'
);
expect
(
mockedState
.
detailJob
.
isLoading
).
toBe
(
false
);
});
});
});
});
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