Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
cac2ed25
G
gitlab-foss
项目概览
李少辉-开发者
/
gitlab-foss
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gitlab-foss
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
cac2ed25
编写于
4月 11, 2018
作者:
F
Filipa Lacerda
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Handle cancelled request
[ci skip] Adds specs Adds specs
上级
0bc8440d
变更
5
展开全部
隐藏空白更改
内联
并排
Showing
5 changed file
with
427 addition
and
13 deletion
+427
-13
app/assets/javascripts/pipelines/constants.js
app/assets/javascripts/pipelines/constants.js
+2
-0
app/assets/javascripts/pipelines/mixins/pipelines.js
app/assets/javascripts/pipelines/mixins/pipelines.js
+19
-12
spec/javascripts/pipelines/mock_data.js
spec/javascripts/pipelines/mock_data.js
+326
-0
spec/javascripts/pipelines/pipelines_spec.js
spec/javascripts/pipelines/pipelines_spec.js
+76
-0
spec/javascripts/pipelines/stage_spec.js
spec/javascripts/pipelines/stage_spec.js
+4
-1
未找到文件。
app/assets/javascripts/pipelines/constants.js
0 → 100644
浏览文件 @
cac2ed25
// eslint-disable-next-line import/prefer-default-export
export
const
CANCEL_REQUEST
=
'
CANCEL_REQUEST
'
;
app/assets/javascripts/pipelines/mixins/pipelines.js
浏览文件 @
cac2ed25
...
...
@@ -7,6 +7,7 @@ import SvgBlankState from '../components/blank_state.vue';
import
LoadingIcon
from
'
../../vue_shared/components/loading_icon.vue
'
;
import
PipelinesTableComponent
from
'
../components/pipelines_table.vue
'
;
import
eventHub
from
'
../event_hub
'
;
import
{
CANCEL_REQUEST
}
from
'
../constants
'
;
export
default
{
components
:
{
...
...
@@ -65,15 +66,13 @@ export default {
updateTable
()
{
// Cancel ongoing request
if
(
this
.
isMakingRequest
)
{
this
.
service
.
cancelationSource
.
cancel
();
this
.
service
.
cancelationSource
.
cancel
(
CANCEL_REQUEST
);
}
// Stop polling
this
.
poll
.
stop
();
// make new request
this
.
getPipelines
();
// restart polling
this
.
poll
.
restart
();
// Update the table
return
this
.
getPipelines
()
.
then
(()
=>
this
.
poll
.
restart
());
},
fetchPipelines
()
{
if
(
!
this
.
isMakingRequest
)
{
...
...
@@ -83,21 +82,29 @@ export default {
}
},
getPipelines
()
{
this
.
service
.
getPipelines
(
this
.
requestData
)
return
this
.
service
.
getPipelines
(
this
.
requestData
)
.
then
(
response
=>
this
.
successCallback
(
response
))
.
catch
((
)
=>
this
.
errorCallback
(
));
.
catch
((
error
)
=>
this
.
errorCallback
(
error
));
},
setCommonData
(
pipelines
)
{
this
.
store
.
storePipelines
(
pipelines
);
this
.
isLoading
=
false
;
this
.
updateGraphDropdown
=
true
;
this
.
hasMadeRequest
=
true
;
// In case the previous polling request returned an error, we need to reset it
if
(
this
.
hasError
)
{
this
.
hasError
=
false
;
}
},
errorCallback
()
{
this
.
hasError
=
true
;
this
.
isLoading
=
false
;
this
.
updateGraphDropdown
=
false
;
errorCallback
(
error
)
{
this
.
hasMadeRequest
=
true
;
this
.
isLoading
=
false
;
if
(
error
&&
error
.
message
&&
error
.
message
!==
CANCEL_REQUEST
)
{
this
.
hasError
=
true
;
this
.
updateGraphDropdown
=
false
;
}
},
setIsMakingRequest
(
isMakingRequest
)
{
this
.
isMakingRequest
=
isMakingRequest
;
...
...
spec/javascripts/pipelines/mock_data.js
0 → 100644
浏览文件 @
cac2ed25
此差异已折叠。
点击以展开。
spec/javascripts/pipelines/pipelines_spec.js
浏览文件 @
cac2ed25
...
...
@@ -4,6 +4,7 @@ import axios from '~/lib/utils/axios_utils';
import
pipelinesComp
from
'
~/pipelines/components/pipelines.vue
'
;
import
Store
from
'
~/pipelines/stores/pipelines_store
'
;
import
mountComponent
from
'
spec/helpers/vue_mount_component_helper
'
;
import
{
pipelineWithStages
,
stageReply
}
from
'
./mock_data
'
;
describe
(
'
Pipelines
'
,
()
=>
{
const
jsonFixtureName
=
'
pipelines/pipelines.json
'
;
...
...
@@ -668,4 +669,79 @@ describe('Pipelines', () => {
});
});
});
describe
(
'
updates results when a staged is clicked
'
,
()
=>
{
beforeEach
(()
=>
{
const
copyPipeline
=
Object
.
assign
({},
pipelineWithStages
);
copyPipeline
.
id
+=
1
;
mock
.
onGet
(
'
twitter/flight/pipelines.json
'
).
reply
(
200
,
{
pipelines
:
[
pipelineWithStages
],
count
:
{
all
:
1
,
finished
:
1
,
pending
:
0
,
running
:
0
,
},
},
{
'
POLL-INTERVAL
'
:
100
,
})
.
onGet
(
pipelineWithStages
.
details
.
stages
[
0
].
dropdown_path
)
.
reply
(
200
,
stageReply
);
vm
=
mountComponent
(
PipelinesComponent
,
{
store
:
new
Store
(),
hasGitlabCi
:
true
,
canCreatePipeline
:
true
,
...
paths
,
});
});
describe
(
'
when a request is being made
'
,
()
=>
{
it
(
'
stops polling, cancels the request, fetches pipelines & restarts polling
'
,
(
done
)
=>
{
spyOn
(
vm
.
poll
,
'
stop
'
);
spyOn
(
vm
.
poll
,
'
restart
'
);
spyOn
(
vm
,
'
getPipelines
'
).
and
.
returnValue
(
Promise
.
resolve
());
spyOn
(
vm
.
service
.
cancelationSource
,
'
cancel
'
).
and
.
callThrough
();
setTimeout
(()
=>
{
vm
.
isMakingRequest
=
true
;
return
vm
.
$nextTick
()
.
then
(()
=>
{
vm
.
$el
.
querySelector
(
'
.js-builds-dropdown-button
'
).
click
();
})
.
then
(()
=>
{
expect
(
vm
.
service
.
cancelationSource
.
cancel
).
toHaveBeenCalled
();
expect
(
vm
.
poll
.
stop
).
toHaveBeenCalled
();
setTimeout
(()
=>
{
expect
(
vm
.
getPipelines
).
toHaveBeenCalled
();
expect
(
vm
.
poll
.
restart
).
toHaveBeenCalled
();
done
();
},
0
);
});
},
0
);
});
});
describe
(
'
when no request is being made
'
,
()
=>
{
it
(
'
stops polling, fetches pipelines & restarts polling
'
,
(
done
)
=>
{
spyOn
(
vm
.
poll
,
'
stop
'
);
spyOn
(
vm
.
poll
,
'
restart
'
);
spyOn
(
vm
,
'
getPipelines
'
).
and
.
returnValue
(
Promise
.
resolve
());
setTimeout
(()
=>
{
vm
.
$el
.
querySelector
(
'
.js-builds-dropdown-button
'
).
click
();
expect
(
vm
.
poll
.
stop
).
toHaveBeenCalled
();
setTimeout
(()
=>
{
expect
(
vm
.
getPipelines
).
toHaveBeenCalled
();
expect
(
vm
.
poll
.
restart
).
toHaveBeenCalled
();
done
();
},
0
);
},
0
);
});
});
});
});
spec/javascripts/pipelines/stage_spec.js
浏览文件 @
cac2ed25
...
...
@@ -2,6 +2,7 @@ import Vue from 'vue';
import
MockAdapter
from
'
axios-mock-adapter
'
;
import
axios
from
'
~/lib/utils/axios_utils
'
;
import
stage
from
'
~/pipelines/components/stage.vue
'
;
import
eventHub
from
'
~/pipelines/event_hub
'
;
import
mountComponent
from
'
spec/helpers/vue_mount_component_helper
'
;
describe
(
'
Pipelines stage component
'
,
()
=>
{
...
...
@@ -43,13 +44,15 @@ describe('Pipelines stage component', () => {
mock
.
onGet
(
'
path.json
'
).
reply
(
200
,
{
html
:
'
foo
'
});
});
it
(
'
should render the received data
'
,
done
=>
{
it
(
'
should render the received data and emit `clickedDropdown` event
'
,
done
=>
{
spyOn
(
eventHub
,
'
$emit
'
);
component
.
$el
.
querySelector
(
'
button
'
).
click
();
setTimeout
(()
=>
{
expect
(
component
.
$el
.
querySelector
(
'
.js-builds-dropdown-container ul
'
).
textContent
.
trim
(),
).
toEqual
(
'
foo
'
);
expect
(
eventHub
.
$emit
).
toHaveBeenCalledWith
(
'
clickedDropdown
'
);
done
();
},
0
);
});
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录