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 {
});
},
[
types
.
SET_RIGHT_PANE
](
state
,
view
)
{
state
.
rightPane
=
state
.
rightPane
===
view
?
null
:
view
;
Object
.
assign
(
state
,
{
rightPane
:
state
.
rightPane
===
view
?
null
:
view
,
});
},
...
projectMutations
,
...
mergeRequestMutation
,
...
...
app/assets/javascripts/vue_shared/components/tabs/tab.vue
View file @
8b1c43bd
...
...
@@ -27,7 +27,9 @@ export default {
this
.
isTab
=
true
;
},
updated
()
{
this
.
$parent
.
$forceUpdate
();
if
(
this
.
$parent
)
{
this
.
$parent
.
$forceUpdate
();
}
},
};
</
script
>
...
...
spec/javascripts/ide/mock_data.js
View file @
8b1c43bd
...
...
@@ -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
=
[
{
id
:
1
,
...
...
spec/javascripts/ide/stores/modules/pipelines/actions_spec.js
View file @
8b1c43bd
...
...
@@ -5,15 +5,15 @@ import actions, {
receiveLatestPipelineError
,
receiveLatestPipelineSuccess
,
fetchLatestPipeline
,
request
Job
s
,
receive
Job
sError
,
receive
Job
sSuccess
,
fetch
Job
s
,
request
Stage
s
,
receive
Stage
sError
,
receive
Stage
sSuccess
,
fetch
Stage
s
,
}
from
'
~/ide/stores/modules/pipelines/actions
'
;
import
state
from
'
~/ide/stores/modules/pipelines/state
'
;
import
*
as
types
from
'
~/ide/stores/modules/pipelines/mutation_types
'
;
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
'
,
()
=>
{
let
mockedState
;
...
...
@@ -141,19 +141,19 @@ describe('IDE pipelines actions', () => {
});
});
describe
(
'
request
Job
s
'
,
()
=>
{
describe
(
'
request
Stage
s
'
,
()
=>
{
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
'
,
()
=>
{
it
(
'
commits error
'
,
done
=>
{
testAction
(
receive
Job
sError
,
receive
Stage
sError
,
null
,
mockedState
,
[{
type
:
types
.
RECEIVE_
JOB
S_ERROR
}],
[{
type
:
types
.
RECEIVE_
STAGE
S_ERROR
}],
[],
done
,
);
...
...
@@ -162,80 +162,53 @@ describe('IDE pipelines actions', () => {
it
(
'
creates flash message
'
,
()
=>
{
const
flashSpy
=
spyOnDependency
(
actions
,
'
flash
'
);
receive
Job
sError
({
commit
()
{}
});
receive
Stage
sError
({
commit
()
{}
});
expect
(
flashSpy
).
toHaveBeenCalled
();
});
});
describe
(
'
receive
Job
sSuccess
'
,
()
=>
{
describe
(
'
receive
Stage
sSuccess
'
,
()
=>
{
it
(
'
commits jobs
'
,
done
=>
{
testAction
(
receive
Job
sSuccess
,
job
s
,
receive
Stage
sSuccess
,
stage
s
,
mockedState
,
[{
type
:
types
.
RECEIVE_
JOBS_SUCCESS
,
payload
:
job
s
}],
[{
type
:
types
.
RECEIVE_
STAGES_SUCCESS
,
payload
:
stage
s
}],
[],
done
,
);
});
});
describe
(
'
fetchJobs
'
,
()
=>
{
let
page
=
''
;
describe
(
'
fetchStages
'
,
()
=>
{
beforeEach
(()
=>
{
mockedState
.
latestPipeline
=
pipelines
[
0
];
});
describe
(
'
success
'
,
()
=>
{
beforeEach
(()
=>
{
mock
.
onGet
(
/
\/
api
\/
v4
\/
projects
\/(
.*
)\/
pipelines
\/(
.*
)\/
jobs/
).
replyOnce
(()
=>
[
200
,
jobs
,
{
'
x-next-page
'
:
page
,
},
]);
mock
.
onGet
(
/
\/(
.*
)\/
pipelines
\/(
.*
)\/
builds.json/
).
replyOnce
(
200
,
stages
);
});
it
(
'
dispatches request
'
,
done
=>
{
testAction
(
fetch
Job
s
,
fetch
Stage
s
,
null
,
mockedState
,
[],
[{
type
:
'
request
Jobs
'
},
{
type
:
'
receiveJob
sSuccess
'
}],
[{
type
:
'
request
Stages
'
},
{
type
:
'
receiveStage
sSuccess
'
}],
done
,
);
});
it
(
'
dispatches success with latest pipeline
'
,
done
=>
{
testAction
(
fetch
Job
s
,
fetch
Stage
s
,
null
,
mockedState
,
[],
[{
type
:
'
requestJobs
'
},
{
type
:
'
receiveJobsSuccess
'
,
payload
:
jobs
}],
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
},
],
[{
type
:
'
requestStages
'
},
{
type
:
'
receiveStagesSuccess
'
,
payload
:
stages
}],
done
,
);
});
...
...
@@ -243,44 +216,27 @@ describe('IDE pipelines actions', () => {
it
(
'
calls axios with correct URL
'
,
()
=>
{
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
'
,
{
params
:
{
page
:
'
1
'
},
});
});
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
'
},
});
expect
(
apiSpy
).
toHaveBeenCalledWith
(
'
/test/project/pipelines/1/builds.json
'
,
jasmine
.
anything
(),
);
});
});
describe
(
'
error
'
,
()
=>
{
beforeEach
(()
=>
{
mock
.
onGet
(
/
\/
api
\/
v4
\/
projects
\/(
.*
)\/
pipelines
(
.*
)
/
).
replyOnce
(
500
);
mock
.
onGet
(
/
\/
(
.*
)\/
pipelines
\/(
.*
)\/
builds.json
/
).
replyOnce
(
500
);
});
it
(
'
dispatches error
'
,
done
=>
{
testAction
(
fetch
Job
s
,
fetch
Stage
s
,
null
,
mockedState
,
[],
[{
type
:
'
request
Jobs
'
},
{
type
:
'
receiveJob
sError
'
}],
[{
type
:
'
request
Stages
'
},
{
type
:
'
receiveStage
sError
'
}],
done
,
);
});
...
...
spec/javascripts/ide/stores/modules/pipelines/getters_spec.js
View file @
8b1c43bd
...
...
@@ -37,35 +37,4 @@ describe('IDE pipeline getters', () => {
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
state
from
'
~/ide/stores/modules/pipelines/state
'
;
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
'
,
()
=>
{
let
mockedState
;
...
...
@@ -49,70 +49,47 @@ describe('IDE pipelines mutations', () => {
});
});
describe
(
types
.
REQUEST_
JOB
S
,
()
=>
{
it
(
'
sets
job
s loading to true
'
,
()
=>
{
mutations
[
types
.
REQUEST_
JOB
S
](
mockedState
);
describe
(
types
.
REQUEST_
STAGE
S
,
()
=>
{
it
(
'
sets
stage
s loading to true
'
,
()
=>
{
mutations
[
types
.
REQUEST_
STAGE
S
](
mockedState
);
expect
(
mockedState
.
isLoadingJobs
).
toBe
(
true
);
});
});
describe
(
types
.
RECEIVE_
JOB
S_ERROR
,
()
=>
{
describe
(
types
.
RECEIVE_
STAGE
S_ERROR
,
()
=>
{
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
);
});
});
describe
(
types
.
RECEIVE_
JOB
S_SUCCESS
,
()
=>
{
describe
(
types
.
RECEIVE_
STAGE
S_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
);
});
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
).
toEqual
([
{
title
:
'
test
'
,
jobs
:
jasmine
.
anything
(),
...
stages
[
0
],
id
:
0
,
isCollapsed
:
false
,
isLoading
:
false
,
jobs
:
[],
},
{
title
:
'
build
'
,
jobs
:
jasmine
.
anything
(),
},
]);
});
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
,
})),
...
stages
[
1
],
id
:
1
,
isCollapsed
:
false
,
isLoading
:
false
,
jobs
:
[],
},
]);
});
...
...
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