summaryrefslogtreecommitdiff
path: root/spec/javascripts/pipelines/stage_spec.js
diff options
context:
space:
mode:
authorFilipa Lacerda <filipa@gitlab.com>2018-05-15 16:55:07 +0100
committerFilipa Lacerda <filipa@gitlab.com>2018-05-15 16:55:07 +0100
commit3593b83a0279bab40f8ba97dc339b32c56f6e0df (patch)
treea7fd75dd081e5b30795892582a3065ce3af0aac5 /spec/javascripts/pipelines/stage_spec.js
parentbf806712835869046c819f84ee515caa8829c10d (diff)
downloadgitlab-ce-3593b83a0279bab40f8ba97dc339b32c56f6e0df.tar.gz
Handles action icons requests in a contained way and shows a loading icon to the user
Diffstat (limited to 'spec/javascripts/pipelines/stage_spec.js')
-rw-r--r--spec/javascripts/pipelines/stage_spec.js49
1 files changed, 49 insertions, 0 deletions
diff --git a/spec/javascripts/pipelines/stage_spec.js b/spec/javascripts/pipelines/stage_spec.js
index 75156e7bdfd..2ba5ecf92e7 100644
--- a/spec/javascripts/pipelines/stage_spec.js
+++ b/spec/javascripts/pipelines/stage_spec.js
@@ -102,4 +102,53 @@ describe('Pipelines stage component', () => {
});
});
});
+
+ describe('pipelineActionRequestComplete', () => {
+ beforeEach(() => {
+ mock.onGet('path.json').reply(200, stageReply);
+
+ mock.onPost(`${stageReply.latest_statuses[0].status.action.path}.json`).reply(200);
+ });
+
+ describe('within pipeline table', () => {
+ it('emits `clickedDropdown` event when `pipelineActionRequestComplete` is triggered', done => {
+ spyOn(eventHub, '$emit');
+
+ component.type = 'PIPELINES_TABLE';
+ component.$el.querySelector('button').click();
+
+ setTimeout(() => {
+ component.$el.querySelector('.js-ci-action').click();
+ component.$nextTick()
+ .then(() => {
+ expect(eventHub.$emit).toHaveBeenCalledWith('clickedDropdown');
+
+ expect(eventHub.$emit).toHaveBeenCalledTimes(2);
+ })
+ .then(done)
+ .catch(done.fail);
+ }, 0);
+ });
+ });
+
+ describe('without a type', () => {
+ it('fetches dropdown content again', done => {
+ spyOn(component, 'fetchJobs').and.callThrough();
+
+ component.$el.querySelector('button').click();
+
+ expect(component.fetchJobs).toHaveBeenCalledTimes(1);
+
+ setTimeout(() => {
+ component.$el.querySelector('.js-ci-action').click();
+ component.$nextTick()
+ .then(() => {
+ expect(component.fetchJobs).toHaveBeenCalledTimes(2);
+ })
+ .then(done)
+ .catch(done.fail);
+ }, 0);
+ });
+ });
+ });
});