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
8b1c43bd
Commit
8b1c43bd
authored
May 24, 2018
by
Phil Hughes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
spec fixes
parent
1e48b7ee
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
74 additions
and
147 deletions
+74
-147
app/assets/javascripts/ide/stores/mutations.js
app/assets/javascripts/ide/stores/mutations.js
+3
-1
app/assets/javascripts/vue_shared/components/tabs/tab.vue
app/assets/javascripts/vue_shared/components/tabs/tab.vue
+3
-1
spec/javascripts/ide/mock_data.js
spec/javascripts/ide/mock_data.js
+21
-0
spec/javascripts/ide/stores/modules/pipelines/actions_spec.js
.../javascripts/ide/stores/modules/pipelines/actions_spec.js
+28
-72
spec/javascripts/ide/stores/modules/pipelines/getters_spec.js
.../javascripts/ide/stores/modules/pipelines/getters_spec.js
+0
-31
spec/javascripts/ide/stores/modules/pipelines/mutations_spec.js
...avascripts/ide/stores/modules/pipelines/mutations_spec.js
+19
-42
No files found.
app/assets/javascripts/ide/stores/mutations.js
View file @
8b1c43bd
...
@@ -149,7 +149,9 @@ export default {
...
@@ -149,7 +149,9 @@ export default {
});
});
},
},
[
types
.
SET_RIGHT_PANE
](
state
,
view
)
{
[
types
.
SET_RIGHT_PANE
](
state
,
view
)
{
state
.
rightPane
=
state
.
rightPane
===
view
?
null
:
view
;
Object
.
assign
(
state
,
{
rightPane
:
state
.
rightPane
===
view
?
null
:
view
,
});
},
},
...
projectMutations
,
...
projectMutations
,
...
mergeRequestMutation
,
...
mergeRequestMutation
,
...
...
app/assets/javascripts/vue_shared/components/tabs/tab.vue
View file @
8b1c43bd
...
@@ -27,7 +27,9 @@ export default {
...
@@ -27,7 +27,9 @@ export default {
this
.
isTab
=
true
;
this
.
isTab
=
true
;
},
},
updated
()
{
updated
()
{
this
.
$parent
.
$forceUpdate
();
if
(
this
.
$parent
)
{
this
.
$parent
.
$forceUpdate
();
}
},
},
};
};
</
script
>
</
script
>
...
...
spec/javascripts/ide/mock_data.js
View file @
8b1c43bd
...
@@ -29,6 +29,27 @@ export const pipelines = [
...
@@ -29,6 +29,27 @@ export const pipelines = [
},
},
];
];
export
const
stages
=
[
{
dropdown_path
:
'
testing
'
,
name
:
'
build
'
,
status
:
{
icon
:
'
status_failed
'
,
group
:
'
failed
'
,
text
:
'
Failed
'
,
},
},
{
dropdown_path
:
'
testing
'
,
name
:
'
test
'
,
status
:
{
icon
:
'
status_failed
'
,
group
:
'
failed
'
,
text
:
'
Failed
'
,
},
},
];
export
const
jobs
=
[
export
const
jobs
=
[
{
{
id
:
1
,
id
:
1
,
...
...
spec/javascripts/ide/stores/modules/pipelines/actions_spec.js
View file @
8b1c43bd
...
@@ -5,15 +5,15 @@ import actions, {
...
@@ -5,15 +5,15 @@ import actions, {
receiveLatestPipelineError
,
receiveLatestPipelineError
,
receiveLatestPipelineSuccess
,
receiveLatestPipelineSuccess
,
fetchLatestPipeline
,
fetchLatestPipeline
,
request
Job
s
,
request
Stage
s
,
receive
Job
sError
,
receive
Stage
sError
,
receive
Job
sSuccess
,
receive
Stage
sSuccess
,
fetch
Job
s
,
fetch
Stage
s
,
}
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
testAction
from
'
../../../../helpers/vuex_action_helper
'
;
import
testAction
from
'
../../../../helpers/vuex_action_helper
'
;
import
{
pipelines
,
job
s
}
from
'
../../../mock_data
'
;
import
{
pipelines
,
stage
s
}
from
'
../../../mock_data
'
;
describe
(
'
IDE pipelines actions
'
,
()
=>
{
describe
(
'
IDE pipelines actions
'
,
()
=>
{
let
mockedState
;
let
mockedState
;
...
@@ -141,19 +141,19 @@ describe('IDE pipelines actions', () => {
...
@@ -141,19 +141,19 @@ describe('IDE pipelines actions', () => {
});
});
});
});
describe
(
'
request
Job
s
'
,
()
=>
{
describe
(
'
request
Stage
s
'
,
()
=>
{
it
(
'
commits request
'
,
done
=>
{
it
(
'
commits request
'
,
done
=>
{
testAction
(
request
Jobs
,
null
,
mockedState
,
[{
type
:
types
.
REQUEST_JOB
S
}],
[],
done
);
testAction
(
request
Stages
,
null
,
mockedState
,
[{
type
:
types
.
REQUEST_STAGE
S
}],
[],
done
);
});
});
});
});
describe
(
'
receiveJobsError
'
,
()
=>
{
describe
(
'
receiveJobsError
'
,
()
=>
{
it
(
'
commits error
'
,
done
=>
{
it
(
'
commits error
'
,
done
=>
{
testAction
(
testAction
(
receive
Job
sError
,
receive
Stage
sError
,
null
,
null
,
mockedState
,
mockedState
,
[{
type
:
types
.
RECEIVE_
JOB
S_ERROR
}],
[{
type
:
types
.
RECEIVE_
STAGE
S_ERROR
}],
[],
[],
done
,
done
,
);
);
...
@@ -162,80 +162,53 @@ describe('IDE pipelines actions', () => {
...
@@ -162,80 +162,53 @@ describe('IDE pipelines actions', () => {
it
(
'
creates flash message
'
,
()
=>
{
it
(
'
creates flash message
'
,
()
=>
{
const
flashSpy
=
spyOnDependency
(
actions
,
'
flash
'
);
const
flashSpy
=
spyOnDependency
(
actions
,
'
flash
'
);
receive
Job
sError
({
commit
()
{}
});
receive
Stage
sError
({
commit
()
{}
});
expect
(
flashSpy
).
toHaveBeenCalled
();
expect
(
flashSpy
).
toHaveBeenCalled
();
});
});
});
});
describe
(
'
receive
Job
sSuccess
'
,
()
=>
{
describe
(
'
receive
Stage
sSuccess
'
,
()
=>
{
it
(
'
commits jobs
'
,
done
=>
{
it
(
'
commits jobs
'
,
done
=>
{
testAction
(
testAction
(
receive
Job
sSuccess
,
receive
Stage
sSuccess
,
job
s
,
stage
s
,
mockedState
,
mockedState
,
[{
type
:
types
.
RECEIVE_
JOBS_SUCCESS
,
payload
:
job
s
}],
[{
type
:
types
.
RECEIVE_
STAGES_SUCCESS
,
payload
:
stage
s
}],
[],
[],
done
,
done
,
);
);
});
});
});
});
describe
(
'
fetchJobs
'
,
()
=>
{
describe
(
'
fetchStages
'
,
()
=>
{
let
page
=
''
;
beforeEach
(()
=>
{
beforeEach
(()
=>
{
mockedState
.
latestPipeline
=
pipelines
[
0
];
mockedState
.
latestPipeline
=
pipelines
[
0
];
});
});
describe
(
'
success
'
,
()
=>
{
describe
(
'
success
'
,
()
=>
{
beforeEach
(()
=>
{
beforeEach
(()
=>
{
mock
.
onGet
(
/
\/
api
\/
v4
\/
projects
\/(
.*
)\/
pipelines
\/(
.*
)\/
jobs/
).
replyOnce
(()
=>
[
mock
.
onGet
(
/
\/(
.*
)\/
pipelines
\/(
.*
)\/
builds.json/
).
replyOnce
(
200
,
stages
);
200
,
jobs
,
{
'
x-next-page
'
:
page
,
},
]);
});
});
it
(
'
dispatches request
'
,
done
=>
{
it
(
'
dispatches request
'
,
done
=>
{
testAction
(
testAction
(
fetch
Job
s
,
fetch
Stage
s
,
null
,
null
,
mockedState
,
mockedState
,
[],
[],
[{
type
:
'
request
Jobs
'
},
{
type
:
'
receiveJob
sSuccess
'
}],
[{
type
:
'
request
Stages
'
},
{
type
:
'
receiveStage
sSuccess
'
}],
done
,
done
,
);
);
});
});
it
(
'
dispatches success with latest pipeline
'
,
done
=>
{
it
(
'
dispatches success with latest pipeline
'
,
done
=>
{
testAction
(
testAction
(
fetch
Job
s
,
fetch
Stage
s
,
null
,
null
,
mockedState
,
mockedState
,
[],
[],
[{
type
:
'
requestJobs
'
},
{
type
:
'
receiveJobsSuccess
'
,
payload
:
jobs
}],
[{
type
:
'
requestStages
'
},
{
type
:
'
receiveStagesSuccess
'
,
payload
:
stages
}],
done
,
);
});
it
(
'
dispatches twice for both pages
'
,
done
=>
{
page
=
'
2
'
;
testAction
(
fetchJobs
,
null
,
mockedState
,
[],
[
{
type
:
'
requestJobs
'
},
{
type
:
'
receiveJobsSuccess
'
,
payload
:
jobs
},
{
type
:
'
fetchJobs
'
,
payload
:
'
2
'
},
{
type
:
'
requestJobs
'
},
{
type
:
'
receiveJobsSuccess
'
,
payload
:
jobs
},
],
done
,
done
,
);
);
});
});
...
@@ -243,44 +216,27 @@ describe('IDE pipelines actions', () => {
...
@@ -243,44 +216,27 @@ describe('IDE pipelines actions', () => {
it
(
'
calls axios with correct URL
'
,
()
=>
{
it
(
'
calls axios with correct URL
'
,
()
=>
{
const
apiSpy
=
spyOn
(
axios
,
'
get
'
).
and
.
callThrough
();
const
apiSpy
=
spyOn
(
axios
,
'
get
'
).
and
.
callThrough
();
fetch
Job
s
({
dispatch
()
{},
state
:
mockedState
,
rootState
:
mockedState
});
fetch
Stage
s
({
dispatch
()
{},
state
:
mockedState
,
rootState
:
mockedState
});
expect
(
apiSpy
).
toHaveBeenCalledWith
(
'
/api/v4/projects/test%2Fproject/pipelines/1/jobs
'
,
{
expect
(
apiSpy
).
toHaveBeenCalledWith
(
params
:
{
page
:
'
1
'
},
'
/test/project/pipelines/1/builds.json
'
,
});
jasmine
.
anything
(),
});
);
it
(
'
calls axios with page next page
'
,
()
=>
{
const
apiSpy
=
spyOn
(
axios
,
'
get
'
).
and
.
callThrough
();
fetchJobs
({
dispatch
()
{},
state
:
mockedState
,
rootState
:
mockedState
});
expect
(
apiSpy
).
toHaveBeenCalledWith
(
'
/api/v4/projects/test%2Fproject/pipelines/1/jobs
'
,
{
params
:
{
page
:
'
1
'
},
});
page
=
'
2
'
;
fetchJobs
({
dispatch
()
{},
state
:
mockedState
,
rootState
:
mockedState
},
page
);
expect
(
apiSpy
).
toHaveBeenCalledWith
(
'
/api/v4/projects/test%2Fproject/pipelines/1/jobs
'
,
{
params
:
{
page
:
'
2
'
},
});
});
});
});
});
describe
(
'
error
'
,
()
=>
{
describe
(
'
error
'
,
()
=>
{
beforeEach
(()
=>
{
beforeEach
(()
=>
{
mock
.
onGet
(
/
\/
api
\/
v4
\/
projects
\/(
.*
)\/
pipelines
(
.*
)
/
).
replyOnce
(
500
);
mock
.
onGet
(
/
\/
(
.*
)\/
pipelines
\/(
.*
)\/
builds.json
/
).
replyOnce
(
500
);
});
});
it
(
'
dispatches error
'
,
done
=>
{
it
(
'
dispatches error
'
,
done
=>
{
testAction
(
testAction
(
fetch
Job
s
,
fetch
Stage
s
,
null
,
null
,
mockedState
,
mockedState
,
[],
[],
[{
type
:
'
request
Jobs
'
},
{
type
:
'
receiveJob
sError
'
}],
[{
type
:
'
request
Stages
'
},
{
type
:
'
receiveStage
sError
'
}],
done
,
done
,
);
);
});
});
...
...
spec/javascripts/ide/stores/modules/pipelines/getters_spec.js
View file @
8b1c43bd
...
@@ -37,35 +37,4 @@ describe('IDE pipeline getters', () => {
...
@@ -37,35 +37,4 @@ describe('IDE pipeline getters', () => {
expect
(
getters
.
hasLatestPipeline
(
mockedState
)).
toBe
(
true
);
expect
(
getters
.
hasLatestPipeline
(
mockedState
)).
toBe
(
true
);
});
});
});
});
describe
(
'
failedJobs
'
,
()
=>
{
it
(
'
returns array of failed jobs
'
,
()
=>
{
mockedState
.
stages
=
[
{
title
:
'
test
'
,
jobs
:
[{
id
:
1
,
status
:
'
failed
'
},
{
id
:
2
,
status
:
'
success
'
}],
},
{
title
:
'
build
'
,
jobs
:
[{
id
:
3
,
status
:
'
failed
'
},
{
id
:
4
,
status
:
'
failed
'
}],
},
];
expect
(
getters
.
failedJobs
(
mockedState
).
length
).
toBe
(
3
);
expect
(
getters
.
failedJobs
(
mockedState
)).
toEqual
([
{
id
:
1
,
status
:
jasmine
.
anything
(),
},
{
id
:
3
,
status
:
jasmine
.
anything
(),
},
{
id
:
4
,
status
:
jasmine
.
anything
(),
},
]);
});
});
});
});
spec/javascripts/ide/stores/modules/pipelines/mutations_spec.js
View file @
8b1c43bd
import
mutations
from
'
~/ide/stores/modules/pipelines/mutations
'
;
import
mutations
from
'
~/ide/stores/modules/pipelines/mutations
'
;
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
{
pipelines
,
job
s
}
from
'
../../../mock_data
'
;
import
{
pipelines
,
stage
s
}
from
'
../../../mock_data
'
;
describe
(
'
IDE pipelines mutations
'
,
()
=>
{
describe
(
'
IDE pipelines mutations
'
,
()
=>
{
let
mockedState
;
let
mockedState
;
...
@@ -49,70 +49,47 @@ describe('IDE pipelines mutations', () => {
...
@@ -49,70 +49,47 @@ describe('IDE pipelines mutations', () => {
});
});
});
});
describe
(
types
.
REQUEST_
JOB
S
,
()
=>
{
describe
(
types
.
REQUEST_
STAGE
S
,
()
=>
{
it
(
'
sets
job
s loading to true
'
,
()
=>
{
it
(
'
sets
stage
s loading to true
'
,
()
=>
{
mutations
[
types
.
REQUEST_
JOB
S
](
mockedState
);
mutations
[
types
.
REQUEST_
STAGE
S
](
mockedState
);
expect
(
mockedState
.
isLoadingJobs
).
toBe
(
true
);
expect
(
mockedState
.
isLoadingJobs
).
toBe
(
true
);
});
});
});
});
describe
(
types
.
RECEIVE_
JOB
S_ERROR
,
()
=>
{
describe
(
types
.
RECEIVE_
STAGE
S_ERROR
,
()
=>
{
it
(
'
sets jobs loading to false
'
,
()
=>
{
it
(
'
sets jobs loading to false
'
,
()
=>
{
mutations
[
types
.
RECEIVE_
JOB
S_ERROR
](
mockedState
);
mutations
[
types
.
RECEIVE_
STAGE
S_ERROR
](
mockedState
);
expect
(
mockedState
.
isLoadingJobs
).
toBe
(
false
);
expect
(
mockedState
.
isLoadingJobs
).
toBe
(
false
);
});
});
});
});
describe
(
types
.
RECEIVE_
JOB
S_SUCCESS
,
()
=>
{
describe
(
types
.
RECEIVE_
STAGE
S_SUCCESS
,
()
=>
{
it
(
'
sets jobs loading to false on success
'
,
()
=>
{
it
(
'
sets jobs loading to false on success
'
,
()
=>
{
mutations
[
types
.
RECEIVE_
JOBS_SUCCESS
](
mockedState
,
job
s
);
mutations
[
types
.
RECEIVE_
STAGES_SUCCESS
](
mockedState
,
stage
s
);
expect
(
mockedState
.
isLoadingJobs
).
toBe
(
false
);
expect
(
mockedState
.
isLoadingJobs
).
toBe
(
false
);
});
});
it
(
'
sets stages
'
,
()
=>
{
it
(
'
sets stages
'
,
()
=>
{
mutations
[
types
.
RECEIVE_
JOBS_SUCCESS
](
mockedState
,
job
s
);
mutations
[
types
.
RECEIVE_
STAGES_SUCCESS
](
mockedState
,
stage
s
);
expect
(
mockedState
.
stages
.
length
).
toBe
(
2
);
expect
(
mockedState
.
stages
.
length
).
toBe
(
2
);
expect
(
mockedState
.
stages
).
toEqual
([
expect
(
mockedState
.
stages
).
toEqual
([
{
{
title
:
'
test
'
,
...
stages
[
0
],
jobs
:
jasmine
.
anything
(),
id
:
0
,
isCollapsed
:
false
,
isLoading
:
false
,
jobs
:
[],
},
},
{
{
title
:
'
build
'
,
...
stages
[
1
],
jobs
:
jasmine
.
anything
(),
id
:
1
,
},
isCollapsed
:
false
,
]);
isLoading
:
false
,
});
jobs
:
[],
it
(
'
sets jobs in stages
'
,
()
=>
{
mutations
[
types
.
RECEIVE_JOBS_SUCCESS
](
mockedState
,
jobs
);
expect
(
mockedState
.
stages
[
0
].
jobs
.
length
).
toBe
(
3
);
expect
(
mockedState
.
stages
[
1
].
jobs
.
length
).
toBe
(
1
);
expect
(
mockedState
.
stages
).
toEqual
([
{
title
:
jasmine
.
anything
(),
jobs
:
jobs
.
filter
(
job
=>
job
.
stage
===
'
test
'
).
map
(
job
=>
({
id
:
job
.
id
,
name
:
job
.
name
,
status
:
job
.
status
,
stage
:
job
.
stage
,
duration
:
job
.
duration
,
})),
},
{
title
:
jasmine
.
anything
(),
jobs
:
jobs
.
filter
(
job
=>
job
.
stage
===
'
build
'
).
map
(
job
=>
({
id
:
job
.
id
,
name
:
job
.
name
,
status
:
job
.
status
,
stage
:
job
.
stage
,
duration
:
job
.
duration
,
})),
},
},
]);
]);
});
});
...
...
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