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
cdc92d94
Commit
cdc92d94
authored
May 25, 2018
by
Phil Hughes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed pipeline actions spec
parent
a83dd664
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
73 additions
and
296 deletions
+73
-296
app/assets/javascripts/ide/stores/modules/pipelines/actions.js
...ssets/javascripts/ide/stores/modules/pipelines/actions.js
+1
-0
spec/javascripts/ide/stores/actions/project_spec.js
spec/javascripts/ide/stores/actions/project_spec.js
+1
-110
spec/javascripts/ide/stores/modules/pipelines/actions_spec.js
.../javascripts/ide/stores/modules/pipelines/actions_spec.js
+71
-150
spec/javascripts/ide/stores/mutations/branch_spec.js
spec/javascripts/ide/stores/mutations/branch_spec.js
+0
-36
No files found.
app/assets/javascripts/ide/stores/modules/pipelines/actions.js
View file @
cdc92d94
...
...
@@ -8,6 +8,7 @@ import * as types from './mutation_types';
let
eTagPoll
;
export
const
clearEtagPoll
=
()
=>
(
eTagPoll
=
null
);
export
const
stopPipelinePolling
=
()
=>
eTagPoll
.
stop
();
export
const
restartPipelinePolling
=
()
=>
eTagPoll
.
restart
();
...
...
spec/javascripts/ide/stores/actions/project_spec.js
View file @
cdc92d94
import
Visibility
from
'
visibilityjs
'
;
import
MockAdapter
from
'
axios-mock-adapter
'
;
import
{
refreshLastCommitData
,
pollSuccessCallBack
}
from
'
~/ide/stores/actions
'
;
import
{
refreshLastCommitData
}
from
'
~/ide/stores/actions
'
;
import
store
from
'
~/ide/stores
'
;
import
service
from
'
~/ide/services
'
;
import
axios
from
'
~/lib/utils/axios_utils
'
;
import
{
fullPipelinesResponse
}
from
'
../../mock_data
'
;
import
{
resetStore
}
from
'
../../helpers
'
;
import
testAction
from
'
../../../helpers/vuex_action_helper
'
;
describe
(
'
IDE store project actions
'
,
()
=>
{
const
setProjectState
=
()
=>
{
store
.
state
.
currentProjectId
=
'
abc/def
'
;
store
.
state
.
currentBranchId
=
'
master
'
;
store
.
state
.
projects
[
'
abc/def
'
]
=
{
id
:
4
,
path_with_namespace
:
'
abc/def
'
,
branches
:
{
master
:
{
commit
:
{
id
:
'
abc123def456ghi789jkl
'
,
title
:
'
example
'
,
},
},
},
};
};
beforeEach
(()
=>
{
store
.
state
.
projects
[
'
abc/def
'
]
=
{};
});
...
...
@@ -101,92 +80,4 @@ describe('IDE store project actions', () => {
);
});
});
describe
(
'
pipelinePoll
'
,
()
=>
{
let
mock
;
beforeEach
(()
=>
{
setProjectState
();
jasmine
.
clock
().
install
();
mock
=
new
MockAdapter
(
axios
);
mock
.
onGet
(
'
/abc/def/commit/abc123def456ghi789jkl/pipelines
'
)
.
reply
(
200
,
{
data
:
{
foo
:
'
bar
'
}
},
{
'
poll-interval
'
:
'
10000
'
});
});
afterEach
(()
=>
{
jasmine
.
clock
().
uninstall
();
mock
.
restore
();
store
.
dispatch
(
'
stopPipelinePolling
'
);
});
it
(
'
calls service periodically
'
,
done
=>
{
spyOn
(
axios
,
'
get
'
).
and
.
callThrough
();
spyOn
(
Visibility
,
'
hidden
'
).
and
.
returnValue
(
false
);
store
.
dispatch
(
'
pipelinePoll
'
)
.
then
(()
=>
{
jasmine
.
clock
().
tick
(
1000
);
expect
(
axios
.
get
).
toHaveBeenCalled
();
expect
(
axios
.
get
.
calls
.
count
()).
toBe
(
1
);
})
.
then
(()
=>
new
Promise
(
resolve
=>
requestAnimationFrame
(
resolve
)))
.
then
(()
=>
{
jasmine
.
clock
().
tick
(
10000
);
expect
(
axios
.
get
.
calls
.
count
()).
toBe
(
2
);
})
.
then
(()
=>
new
Promise
(
resolve
=>
requestAnimationFrame
(
resolve
)))
.
then
(()
=>
{
jasmine
.
clock
().
tick
(
10000
);
expect
(
axios
.
get
.
calls
.
count
()).
toBe
(
3
);
})
.
then
(()
=>
new
Promise
(
resolve
=>
requestAnimationFrame
(
resolve
)))
.
then
(()
=>
{
jasmine
.
clock
().
tick
(
10000
);
expect
(
axios
.
get
.
calls
.
count
()).
toBe
(
4
);
})
.
then
(
done
)
.
catch
(
done
.
fail
);
});
});
describe
(
'
pollSuccessCallBack
'
,
()
=>
{
beforeEach
(()
=>
{
setProjectState
();
});
it
(
'
commits correct pipeline
'
,
done
=>
{
testAction
(
pollSuccessCallBack
,
fullPipelinesResponse
,
store
.
state
,
[
{
type
:
'
SET_LAST_COMMIT_PIPELINE
'
,
payload
:
{
projectId
:
'
abc/def
'
,
branchId
:
'
master
'
,
pipeline
:
{
id
:
'
50
'
,
commit
:
{
id
:
'
abc123def456ghi789jkl
'
,
},
details
:
{
status
:
{
icon
:
'
status_passed
'
,
text
:
'
passed
'
,
},
},
},
},
},
],
// mutations
[],
// action
done
,
);
});
});
});
spec/javascripts/ide/stores/modules/pipelines/actions_spec.js
View file @
cdc92d94
import
Visibility
from
'
visibilityjs
'
;
import
MockAdapter
from
'
axios-mock-adapter
'
;
import
axios
from
'
~/lib/utils/axios_utils
'
;
import
actions
,
{
...
...
@@ -5,15 +6,13 @@ import actions, {
receiveLatestPipelineError
,
receiveLatestPipelineSuccess
,
fetchLatestPipeline
,
requestStages
,
receiveStagesError
,
receiveStagesSuccess
,
fetchStages
,
stopPipelinePolling
,
clearEtagPoll
,
}
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
,
stages
}
from
'
../../../mock_data
'
;
import
{
pipelines
}
from
'
../../../mock_data
'
;
describe
(
'
IDE pipelines actions
'
,
()
=>
{
let
mockedState
;
...
...
@@ -51,7 +50,7 @@ describe('IDE pipelines actions', () => {
null
,
mockedState
,
[{
type
:
types
.
RECEIVE_LASTEST_PIPELINE_ERROR
}],
[],
[
{
type
:
'
stopPipelinePolling
'
}
],
done
,
);
});
...
...
@@ -59,7 +58,7 @@ describe('IDE pipelines actions', () => {
it
(
'
creates flash message
'
,
()
=>
{
const
flashSpy
=
spyOnDependency
(
actions
,
'
flash
'
);
receiveLatestPipelineError
({
commit
()
{}
});
receiveLatestPipelineError
({
commit
()
{}
,
dispatch
()
{}
});
expect
(
flashSpy
).
toHaveBeenCalled
();
});
...
...
@@ -79,166 +78,88 @@ describe('IDE pipelines actions', () => {
});
describe
(
'
fetchLatestPipeline
'
,
()
=>
{
describe
(
'
success
'
,
()
=>
{
beforeEach
(()
=>
{
mock
.
onGet
(
/
\/
api
\/
v4
\/
projects
\/(
.*
)\/
pipelines
(
.*
)
/
).
replyOnce
(
200
,
pipelines
);
});
it
(
'
dispatches request
'
,
done
=>
{
testAction
(
fetchLatestPipeline
,
'
123
'
,
mockedState
,
[],
[{
type
:
'
requestLatestPipeline
'
},
{
type
:
'
receiveLatestPipelineSuccess
'
}],
done
,
);
});
it
(
'
dispatches success with latest pipeline
'
,
done
=>
{
testAction
(
fetchLatestPipeline
,
'
123
'
,
mockedState
,
[],
[
{
type
:
'
requestLatestPipeline
'
},
{
type
:
'
receiveLatestPipelineSuccess
'
,
payload
:
pipelines
[
0
]
},
],
done
,
);
});
it
(
'
calls axios with correct params
'
,
()
=>
{
const
apiSpy
=
spyOn
(
axios
,
'
get
'
).
and
.
callThrough
();
fetchLatestPipeline
({
dispatch
()
{},
rootState
:
state
},
'
123
'
);
expect
(
apiSpy
).
toHaveBeenCalledWith
(
jasmine
.
anything
(),
{
params
:
{
sha
:
'
123
'
,
per_page
:
'
1
'
,
},
});
});
});
describe
(
'
error
'
,
()
=>
{
beforeEach
(()
=>
{
mock
.
onGet
(
/
\/
api
\/
v4
\/
projects
\/(
.*
)\/
pipelines
(
.*
)
/
).
replyOnce
(
500
);
});
it
(
'
dispatches error
'
,
done
=>
{
testAction
(
fetchLatestPipeline
,
'
123
'
,
mockedState
,
[],
[{
type
:
'
requestLatestPipeline
'
},
{
type
:
'
receiveLatestPipelineError
'
}],
done
,
);
});
});
});
describe
(
'
requestStages
'
,
()
=>
{
it
(
'
commits request
'
,
done
=>
{
testAction
(
requestStages
,
null
,
mockedState
,
[{
type
:
types
.
REQUEST_STAGES
}],
[],
done
);
});
});
describe
(
'
receiveJobsError
'
,
()
=>
{
it
(
'
commits error
'
,
done
=>
{
testAction
(
receiveStagesError
,
null
,
mockedState
,
[{
type
:
types
.
RECEIVE_STAGES_ERROR
}],
[],
done
,
);
});
it
(
'
creates flash message
'
,
()
=>
{
const
flashSpy
=
spyOnDependency
(
actions
,
'
flash
'
);
receiveStagesError
({
commit
()
{}
});
expect
(
flashSpy
).
toHaveBeenCalled
();
});
});
describe
(
'
receiveStagesSuccess
'
,
()
=>
{
it
(
'
commits jobs
'
,
done
=>
{
testAction
(
receiveStagesSuccess
,
stages
,
mockedState
,
[{
type
:
types
.
RECEIVE_STAGES_SUCCESS
,
payload
:
stages
}],
[],
done
,
);
beforeEach
(()
=>
{
jasmine
.
clock
().
install
();
});
});
describe
(
'
fetchStages
'
,
()
=>
{
beforeEach
(()
=>
{
mockedState
.
latestPipeline
=
pipelines
[
0
];
afterEach
(()
=>
{
jasmine
.
clock
().
uninstall
();
stopPipelinePolling
();
clearEtagPoll
();
});
describe
(
'
success
'
,
()
=>
{
beforeEach
(()
=>
{
mock
.
onGet
(
/
\/(
.*
)\/
pipelines
\/(
.*
)\/
builds.json/
).
replyOnce
(
200
,
stages
);
mock
.
onGet
(
'
/abc/def/commit/abc123def456ghi789jkl/pipelines
'
)
.
reply
(
200
,
{
data
:
{
foo
:
'
bar
'
}
},
{
'
poll-interval
'
:
'
10000
'
});
});
it
(
'
dispatches request
'
,
done
=>
{
testAction
(
fetchStages
,
null
,
mockedState
,
[],
[{
type
:
'
requestStages
'
},
{
type
:
'
receiveStagesSuccess
'
}],
done
,
);
});
it
(
'
dispatches success with latest pipeline
'
,
done
=>
{
testAction
(
fetchStages
,
null
,
mockedState
,
[],
[{
type
:
'
requestStages
'
},
{
type
:
'
receiveStagesSuccess
'
,
payload
:
stages
}],
done
,
);
});
it
(
'
calls axios with correct URL
'
,
()
=>
{
const
apiSpy
=
spyOn
(
axios
,
'
get
'
).
and
.
callThrough
();
fetchStages
({
dispatch
()
{},
state
:
mockedState
,
rootState
:
mockedState
});
expect
(
apiSpy
).
toHaveBeenCalledWith
(
'
/test/project/pipelines/1/builds.json
'
,
jasmine
.
anything
(),
);
spyOn
(
axios
,
'
get
'
).
and
.
callThrough
();
spyOn
(
Visibility
,
'
hidden
'
).
and
.
returnValue
(
false
);
const
dispatch
=
jasmine
.
createSpy
(
'
dispatch
'
);
const
rootGetters
=
{
lastCommit
:
{
id
:
'
abc123def456ghi789jkl
'
},
currentProject
:
{
path_with_namespace
:
'
abc/def
'
},
};
fetchLatestPipeline
({
dispatch
,
rootGetters
});
expect
(
dispatch
.
calls
.
argsFor
(
0
)).
toEqual
([
'
requestLatestPipeline
'
]);
jasmine
.
clock
().
tick
(
1000
);
new
Promise
(
resolve
=>
requestAnimationFrame
(
resolve
))
.
then
(()
=>
{
expect
(
axios
.
get
).
toHaveBeenCalled
();
expect
(
axios
.
get
.
calls
.
count
()).
toBe
(
1
);
expect
(
dispatch
.
calls
.
argsFor
(
1
)).
toEqual
([
'
receiveLatestPipelineSuccess
'
,
jasmine
.
anything
(),
]);
jasmine
.
clock
().
tick
(
10000
);
})
.
then
(()
=>
new
Promise
(
resolve
=>
requestAnimationFrame
(
resolve
)))
.
then
(()
=>
{
expect
(
axios
.
get
).
toHaveBeenCalled
();
expect
(
axios
.
get
.
calls
.
count
()).
toBe
(
2
);
expect
(
dispatch
.
calls
.
argsFor
(
2
)).
toEqual
([
'
receiveLatestPipelineSuccess
'
,
jasmine
.
anything
(),
]);
})
.
then
(
done
)
.
catch
(
done
.
fail
);
});
});
describe
(
'
error
'
,
()
=>
{
beforeEach
(()
=>
{
mock
.
onGet
(
/
\/(
.*
)\/
pipelines
\/(
.*
)\/
builds.json/
).
replyOnce
(
500
);
mock
.
onGet
(
'
/abc/def/commit/abc123def456ghi789jkl/pipelines
'
).
reply
(
500
);
});
it
(
'
dispatches error
'
,
done
=>
{
testAction
(
fetchStages
,
null
,
mockedState
,
[],
[{
type
:
'
requestStages
'
},
{
type
:
'
receiveStagesError
'
}],
done
,
);
const
dispatch
=
jasmine
.
createSpy
(
'
dispatch
'
);
const
rootGetters
=
{
lastCommit
:
{
id
:
'
abc123def456ghi789jkl
'
},
currentProject
:
{
path_with_namespace
:
'
abc/def
'
},
};
fetchLatestPipeline
({
dispatch
,
rootGetters
});
jasmine
.
clock
().
tick
(
1500
);
new
Promise
(
resolve
=>
requestAnimationFrame
(
resolve
))
.
then
(()
=>
{
expect
(
dispatch
.
calls
.
argsFor
(
1
)).
toEqual
([
'
receiveLatestPipelineError
'
]);
})
.
then
(
done
)
.
catch
(
done
.
fail
);
});
});
});
...
...
spec/javascripts/ide/stores/mutations/branch_spec.js
View file @
cdc92d94
...
...
@@ -37,40 +37,4 @@ describe('Multi-file store branch mutations', () => {
expect
(
localState
.
projects
.
Example
.
branches
.
master
.
commit
.
title
).
toBe
(
'
Example commit
'
);
});
});
describe
(
'
SET_LAST_COMMIT_PIPELINE
'
,
()
=>
{
it
(
'
sets the pipeline for the last commit on current project
'
,
()
=>
{
localState
.
projects
=
{
Example
:
{
branches
:
{
master
:
{
commit
:
{},
},
},
},
};
mutations
.
SET_LAST_COMMIT_PIPELINE
(
localState
,
{
projectId
:
'
Example
'
,
branchId
:
'
master
'
,
pipeline
:
{
id
:
'
50
'
,
details
:
{
status
:
{
icon
:
'
status_passed
'
,
text
:
'
passed
'
,
},
},
},
});
expect
(
localState
.
projects
.
Example
.
branches
.
master
.
commit
.
pipeline
.
id
).
toBe
(
'
50
'
);
expect
(
localState
.
projects
.
Example
.
branches
.
master
.
commit
.
pipeline
.
details
.
status
.
text
).
toBe
(
'
passed
'
,
);
expect
(
localState
.
projects
.
Example
.
branches
.
master
.
commit
.
pipeline
.
details
.
status
.
icon
).
toBe
(
'
status_passed
'
,
);
});
});
});
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