Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
9a054955
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,发现更多精彩内容 >>
提交
9a054955
编写于
7月 12, 2018
作者:
W
Winnie Hellmann
提交者:
Phil Hughes
7月 12, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove timeouts from TimeTracker tests
上级
ba38931d
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
243 addition
and
0 deletion
+243
-0
spec/javascripts/sidebar/components/time_tracking/time_tracker_spec.js
...pts/sidebar/components/time_tracking/time_tracker_spec.js
+243
-0
未找到文件。
spec/javascripts/
issuable_
time_tracker_spec.js
→
spec/javascripts/
sidebar/components/time_tracking/
time_tracker_spec.js
浏览文件 @
9a054955
/* eslint-disable no-unused-vars, func-call-spacing, no-spaced-func, semi, quotes, space-infix-ops, max-len */
import
$
from
'
jquery
'
;
import
Vue
from
'
vue
'
;
import
timeTracker
from
'
~/sidebar/components/time_tracking/time_tracker.vue
'
;
import
TimeTracker
from
'
~/sidebar/components/time_tracking/time_tracker.vue
'
;
import
mountComponent
from
'
spec/helpers/vue_mount_component_helper
'
;
function
initTimeTrackingComponent
(
opts
)
{
setFixtures
(
`
describe
(
'
Issuable Time Tracker
'
,
()
=>
{
let
initialData
;
let
vm
;
const
initTimeTrackingComponent
=
opts
=>
{
setFixtures
(
`
<div>
<div id="mock-container"></div>
</div>
`
);
this
.
initialData
=
{
time_estimate
:
opts
.
timeEstimate
,
time_spent
:
opts
.
timeSpent
,
human_time_estimate
:
opts
.
timeEstimateHumanReadable
,
human_time_spent
:
opts
.
timeSpentHumanReadable
,
rootPath
:
'
/
'
,
initialData
=
{
time_estimate
:
opts
.
timeEstimate
,
time_spent
:
opts
.
timeSpent
,
human_time_estimate
:
opts
.
timeEstimateHumanReadable
,
human_time_spent
:
opts
.
timeSpentHumanReadable
,
rootPath
:
'
/
'
,
};
const
TimeTrackingComponent
=
Vue
.
extend
({
...
TimeTracker
,
components
:
{
...
TimeTracker
.
components
,
transition
:
{
// disable animations
template
:
'
<div><slot></slot></div>
'
,
},
},
});
vm
=
mountComponent
(
TimeTrackingComponent
,
initialData
,
'
#mock-container
'
);
};
const
TimeTrackingComponent
=
Vue
.
extend
(
timeTracker
);
this
.
timeTracker
=
new
TimeTrackingComponent
({
el
:
'
#mock-container
'
,
propsData
:
this
.
initialData
,
afterEach
(()
=>
{
vm
.
$destroy
();
});
}
describe
(
'
Issuable Time Tracker
'
,
function
()
{
describe
(
'
Initialization
'
,
function
()
{
beforeEach
(
function
()
{
initTimeTrackingComponent
.
call
(
this
,
{
timeEstimate
:
100000
,
timeSpent
:
5000
,
timeEstimateHumanReadable
:
'
2h 46m
'
,
timeSpentHumanReadable
:
'
1h 23m
'
});
describe
(
'
Initialization
'
,
()
=>
{
beforeEach
(()
=>
{
initTimeTrackingComponent
({
timeEstimate
:
100000
,
timeSpent
:
5000
,
timeEstimateHumanReadable
:
'
2h 46m
'
,
timeSpentHumanReadable
:
'
1h 23m
'
,
});
});
it
(
'
should return something defined
'
,
function
()
{
expect
(
this
.
timeTracker
).
toBeDefined
();
it
(
'
should return something defined
'
,
()
=>
{
expect
(
vm
).
toBeDefined
();
});
it
(
'
should correctly set timeEstimate
'
,
function
(
done
)
{
it
(
'
should correctly set timeEstimate
'
,
done
=>
{
Vue
.
nextTick
(()
=>
{
expect
(
this
.
timeTracker
.
timeEstimate
).
toBe
(
this
.
initialData
.
time_estimate
);
expect
(
vm
.
timeEstimate
).
toBe
(
initialData
.
time_estimate
);
done
();
});
});
it
(
'
should correctly set time_spent
'
,
function
(
done
)
{
it
(
'
should correctly set time_spent
'
,
done
=>
{
Vue
.
nextTick
(()
=>
{
expect
(
this
.
timeTracker
.
timeSpent
).
toBe
(
this
.
initialData
.
time_spent
);
expect
(
vm
.
timeSpent
).
toBe
(
initialData
.
time_spent
);
done
();
});
});
});
describe
(
'
Content Display
'
,
function
()
{
describe
(
'
Panes
'
,
function
()
{
describe
(
'
Comparison pane
'
,
function
()
{
beforeEach
(
function
()
{
initTimeTrackingComponent
.
call
(
this
,
{
timeEstimate
:
100000
,
timeSpent
:
5000
,
timeEstimateHumanReadable
:
''
,
timeSpentHumanReadable
:
''
});
describe
(
'
Content Display
'
,
()
=>
{
describe
(
'
Panes
'
,
()
=>
{
describe
(
'
Comparison pane
'
,
()
=>
{
beforeEach
(()
=>
{
initTimeTrackingComponent
({
timeEstimate
:
100000
,
timeSpent
:
5000
,
timeEstimateHumanReadable
:
''
,
timeSpentHumanReadable
:
''
,
});
});
it
(
'
should show the "Comparison" pane when timeEstimate and time_spent are truthy
'
,
function
(
done
)
{
it
(
'
should show the "Comparison" pane when timeEstimate and time_spent are truthy
'
,
done
=>
{
Vue
.
nextTick
(()
=>
{
const
$comparisonPane
=
this
.
timeTracker
.
$el
.
querySelector
(
'
.time-tracking-comparison-pane
'
);
expect
(
this
.
timeTracker
.
showComparisonState
).
toBe
(
true
);
expect
(
vm
.
showComparisonState
).
toBe
(
true
);
const
$comparisonPane
=
vm
.
$el
.
querySelector
(
'
.time-tracking-comparison-pane
'
);
expect
(
$comparisonPane
).
toBeVisible
();
done
();
});
});
describe
(
'
Remaining meter
'
,
function
()
{
it
(
'
should display the remaining meter with the correct width
'
,
function
(
done
)
{
describe
(
'
Remaining meter
'
,
()
=>
{
it
(
'
should display the remaining meter with the correct width
'
,
done
=>
{
Vue
.
nextTick
(()
=>
{
const
meterWidth
=
this
.
timeTracker
.
$el
.
querySelector
(
'
.time-tracking-comparison-pane .meter-fill
'
).
style
.
width
;
const
meterWidth
=
vm
.
$el
.
querySelector
(
'
.time-tracking-comparison-pane .meter-fill
'
)
.
style
.
width
;
const
correctWidth
=
'
5%
'
;
expect
(
meterWidth
).
toBe
(
correctWidth
);
done
();
})
})
;
});
it
(
'
should display the remaining meter with the correct background color when within estimate
'
,
function
(
done
)
{
it
(
'
should display the remaining meter with the correct background color when within estimate
'
,
done
=>
{
Vue
.
nextTick
(()
=>
{
const
styledMeter
=
$
(
this
.
timeTracker
.
$el
).
find
(
'
.time-tracking-comparison-pane .within_estimate .meter-fill
'
);
const
styledMeter
=
$
(
vm
.
$el
).
find
(
'
.time-tracking-comparison-pane .within_estimate .meter-fill
'
,
);
expect
(
styledMeter
.
length
).
toBe
(
1
);
done
()
done
()
;
});
});
it
(
'
should display the remaining meter with the correct background color when over estimate
'
,
function
(
done
)
{
this
.
timeTracker
.
time_estimate
=
100000
;
this
.
timeTracker
.
time_spent
=
20000000
;
it
(
'
should display the remaining meter with the correct background color when over estimate
'
,
done
=>
{
vm
.
time_estimate
=
100000
;
vm
.
time_spent
=
20000000
;
Vue
.
nextTick
(()
=>
{
const
styledMeter
=
$
(
this
.
timeTracker
.
$el
).
find
(
'
.time-tracking-comparison-pane .over_estimate .meter-fill
'
);
const
styledMeter
=
$
(
vm
.
$el
).
find
(
'
.time-tracking-comparison-pane .over_estimate .meter-fill
'
,
);
expect
(
styledMeter
.
length
).
toBe
(
1
);
done
();
});
...
...
@@ -97,14 +127,20 @@ describe('Issuable Time Tracker', function() {
});
});
describe
(
"
Estimate only pane
"
,
function
()
{
beforeEach
(
function
()
{
initTimeTrackingComponent
.
call
(
this
,
{
timeEstimate
:
100000
,
timeSpent
:
0
,
timeEstimateHumanReadable
:
'
2h 46m
'
,
timeSpentHumanReadable
:
''
});
describe
(
'
Estimate only pane
'
,
()
=>
{
beforeEach
(()
=>
{
initTimeTrackingComponent
({
timeEstimate
:
100000
,
timeSpent
:
0
,
timeEstimateHumanReadable
:
'
2h 46m
'
,
timeSpentHumanReadable
:
''
,
});
});
it
(
'
should display the human readable version of time estimated
'
,
function
(
done
)
{
it
(
'
should display the human readable version of time estimated
'
,
done
=>
{
Vue
.
nextTick
(()
=>
{
const
estimateText
=
this
.
timeTracker
.
$el
.
querySelector
(
'
.time-tracking-estimate-only-pane
'
).
innerText
;
const
estimateText
=
vm
.
$el
.
querySelector
(
'
.time-tracking-estimate-only-pane
'
)
.
innerText
;
const
correctText
=
'
Estimated: 2h 46m
'
;
expect
(
estimateText
).
toBe
(
correctText
);
...
...
@@ -113,14 +149,19 @@ describe('Issuable Time Tracker', function() {
});
});
describe
(
'
Spent only pane
'
,
function
()
{
beforeEach
(
function
()
{
initTimeTrackingComponent
.
call
(
this
,
{
timeEstimate
:
0
,
timeSpent
:
5000
,
timeEstimateHumanReadable
:
'
2h 46m
'
,
timeSpentHumanReadable
:
'
1h 23m
'
});
describe
(
'
Spent only pane
'
,
()
=>
{
beforeEach
(()
=>
{
initTimeTrackingComponent
({
timeEstimate
:
0
,
timeSpent
:
5000
,
timeEstimateHumanReadable
:
'
2h 46m
'
,
timeSpentHumanReadable
:
'
1h 23m
'
,
});
});
it
(
'
should display the human readable version of time spent
'
,
function
(
done
)
{
it
(
'
should display the human readable version of time spent
'
,
done
=>
{
Vue
.
nextTick
(()
=>
{
const
spentText
=
this
.
timeTracker
.
$el
.
querySelector
(
'
.time-tracking-spend-only-pane
'
).
innerText
;
const
spentText
=
vm
.
$el
.
querySelector
(
'
.time-tracking-spend-only-pane
'
).
innerText
;
const
correctText
=
'
Spent: 1h 23m
'
;
expect
(
spentText
).
toBe
(
correctText
);
...
...
@@ -129,18 +170,23 @@ describe('Issuable Time Tracker', function() {
});
});
describe
(
'
No time tracking pane
'
,
function
()
{
beforeEach
(
function
()
{
initTimeTrackingComponent
.
call
(
this
,
{
timeEstimate
:
0
,
timeSpent
:
0
,
timeEstimateHumanReadable
:
''
,
timeSpentHumanReadable
:
''
});
describe
(
'
No time tracking pane
'
,
()
=>
{
beforeEach
(()
=>
{
initTimeTrackingComponent
({
timeEstimate
:
0
,
timeSpent
:
0
,
timeEstimateHumanReadable
:
''
,
timeSpentHumanReadable
:
''
,
});
});
it
(
'
should only show the "No time tracking" pane when both timeEstimate and time_spent are falsey
'
,
function
(
done
)
{
it
(
'
should only show the "No time tracking" pane when both timeEstimate and time_spent are falsey
'
,
done
=>
{
Vue
.
nextTick
(()
=>
{
const
$noTrackingPane
=
this
.
timeTracker
.
$el
.
querySelector
(
'
.time-tracking-no-tracking-pane
'
);
const
noTrackingText
=
$noTrackingPane
.
innerText
;
const
$noTrackingPane
=
vm
.
$el
.
querySelector
(
'
.time-tracking-no-tracking-pane
'
);
const
noTrackingText
=
$noTrackingPane
.
innerText
;
const
correctText
=
'
No estimate or time spent
'
;
expect
(
this
.
timeTracker
.
showNoTimeTrackingState
).
toBe
(
true
);
expect
(
vm
.
showNoTimeTrackingState
).
toBe
(
true
);
expect
(
$noTrackingPane
).
toBeVisible
();
expect
(
noTrackingText
).
toBe
(
correctText
);
done
();
...
...
@@ -148,52 +194,48 @@ describe('Issuable Time Tracker', function() {
});
});
describe
(
"
Help pane
"
,
function
()
{
beforeEach
(
function
()
{
initTimeTrackingComponent
.
call
(
this
,
{
timeEstimate
:
0
,
timeSpent
:
0
}
);
}
);
describe
(
'
Help pane
'
,
()
=>
{
const
helpButton
=
()
=>
vm
.
$el
.
querySelector
(
'
.help-button
'
);
const
closeHelpButton
=
()
=>
vm
.
$el
.
querySelector
(
'
.close-help-button
'
);
const
helpPane
=
()
=>
vm
.
$el
.
querySelector
(
'
.time-tracking-help-state
'
);
it
(
'
should not show the "Help" pane by default
'
,
function
(
done
)
{
Vue
.
nextTick
(()
=>
{
const
$helpPane
=
this
.
timeTracker
.
$el
.
querySelector
(
'
.time-tracking-help-state
'
);
beforeEach
(
done
=>
{
initTimeTrackingComponent
({
timeEstimate
:
0
,
timeSpent
:
0
});
expect
(
this
.
timeTracker
.
showHelpState
).
toBe
(
false
);
expect
(
$helpPane
).
toBeNull
();
done
();
});
Vue
.
nextTick
()
.
then
(
done
)
.
catch
(
done
.
fail
);
});
it
(
'
should show the "Help" pane when help button is clicked
'
,
function
(
done
)
{
Vue
.
nextTick
(()
=>
{
$
(
this
.
timeTracker
.
$el
).
find
(
'
.help-button
'
).
click
();
setTimeout
(()
=>
{
const
$helpPane
=
this
.
timeTracker
.
$el
.
querySelector
(
'
.time-tracking-help-state
'
);
expect
(
this
.
timeTracker
.
showHelpState
).
toBe
(
true
);
expect
(
$helpPane
).
toBeVisible
();
done
();
},
10
);
});
it
(
'
should not show the "Help" pane by default
'
,
()
=>
{
expect
(
vm
.
showHelpState
).
toBe
(
false
);
expect
(
helpPane
()).
toBeNull
();
});
it
(
'
should not show the "Help" pane when help button is clicked and then closed
'
,
function
(
done
)
{
Vue
.
nextTick
(()
=>
{
$
(
this
.
timeTracker
.
$el
).
find
(
'
.help-button
'
).
click
();
setTimeout
(()
=>
{
it
(
'
should show the "Help" pane when help button is clicked
'
,
done
=>
{
helpButton
().
click
();
$
(
this
.
timeTracker
.
$el
).
find
(
'
.close-help-button
'
).
click
();
setTimeout
(()
=>
{
const
$helpPane
=
this
.
timeTracker
.
$el
.
querySelector
(
'
.time-tracking-help-state
'
);
Vue
.
nextTick
()
.
then
(()
=>
{
expect
(
vm
.
showHelpState
).
toBe
(
true
);
expect
(
helpPane
()).
toBeVisible
();
})
.
then
(
done
)
.
catch
(
done
.
fail
);
});
expect
(
this
.
timeTracker
.
showHelpState
).
toBe
(
false
);
expect
(
$helpPane
).
toBeNull
();
it
(
'
should not show the "Help" pane when help button is clicked and then closed
'
,
done
=>
{
helpButton
().
click
();
done
();
},
1000
);
},
1000
);
});
Vue
.
nextTick
()
.
then
(()
=>
closeHelpButton
().
click
())
.
then
(()
=>
Vue
.
nextTick
())
.
then
(()
=>
{
expect
(
vm
.
showHelpState
).
toBe
(
false
);
expect
(
helpPane
()).
toBeNull
();
})
.
then
(
done
)
.
catch
(
done
.
fail
);
});
});
});
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录