Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
9172c45b
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,体验更适合开发者的 AI 搜索 >>
提交
9172c45b
编写于
8月 03, 2016
作者:
P
Phil Hughes
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Added simulate drag JS for tests
上级
c7b210eb
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
218 addition
and
4 deletion
+218
-4
app/assets/javascripts/boards/test_utils/simulate_drag.js
app/assets/javascripts/boards/test_utils/simulate_drag.js
+121
-0
app/assets/stylesheets/pages/boards.scss
app/assets/stylesheets/pages/boards.scss
+24
-4
app/views/projects/boards/index.html.haml
app/views/projects/boards/index.html.haml
+1
-0
config/application.rb
config/application.rb
+1
-0
spec/features/boards/boards_spec.rb
spec/features/boards/boards_spec.rb
+71
-0
未找到文件。
app/assets/javascripts/boards/test_utils/simulate_drag.js
0 → 100755
浏览文件 @
9172c45b
(
function
()
{
'
use strict
'
;
function
simulateEvent
(
el
,
type
,
options
)
{
var
event
;
var
ownerDocument
=
el
.
ownerDocument
;
options
=
options
||
{};
if
(
/^mouse/
.
test
(
type
))
{
event
=
ownerDocument
.
createEvent
(
'
MouseEvents
'
);
event
.
initMouseEvent
(
type
,
true
,
true
,
ownerDocument
.
defaultView
,
options
.
button
,
options
.
screenX
,
options
.
screenY
,
options
.
clientX
,
options
.
clientY
,
options
.
ctrlKey
,
options
.
altKey
,
options
.
shiftKey
,
options
.
metaKey
,
options
.
button
,
el
);
}
else
{
event
=
ownerDocument
.
createEvent
(
'
CustomEvent
'
);
event
.
initCustomEvent
(
type
,
true
,
true
,
ownerDocument
.
defaultView
,
options
.
button
,
options
.
screenX
,
options
.
screenY
,
options
.
clientX
,
options
.
clientY
,
options
.
ctrlKey
,
options
.
altKey
,
options
.
shiftKey
,
options
.
metaKey
,
options
.
button
,
el
);
event
.
dataTransfer
=
{
data
:
{},
setData
:
function
(
type
,
val
)
{
this
.
data
[
type
]
=
val
;
},
getData
:
function
(
type
)
{
return
this
.
data
[
type
];
}
};
}
if
(
el
.
dispatchEvent
)
{
el
.
dispatchEvent
(
event
);
}
else
if
(
el
.
fireEvent
)
{
el
.
fireEvent
(
'
on
'
+
type
,
event
);
}
return
event
;
}
function
getTraget
(
target
)
{
var
el
=
typeof
target
.
el
===
'
string
'
?
document
.
getElementById
(
target
.
el
.
substr
(
1
))
:
target
.
el
;
var
children
=
el
.
children
;
return
(
children
[
target
.
index
]
||
children
[
target
.
index
===
'
first
'
?
0
:
-
1
]
||
children
[
target
.
index
===
'
last
'
?
children
.
length
-
1
:
-
1
]
);
}
function
getRect
(
el
)
{
var
rect
=
el
.
getBoundingClientRect
();
var
width
=
rect
.
right
-
rect
.
left
;
var
height
=
rect
.
bottom
-
rect
.
top
;
return
{
x
:
rect
.
left
,
y
:
rect
.
top
,
cx
:
rect
.
left
+
width
/
2
,
cy
:
rect
.
top
+
height
/
2
,
w
:
width
,
h
:
height
,
hw
:
width
/
2
,
wh
:
height
/
2
};
}
function
simulateDrag
(
options
,
callback
)
{
options
.
to
.
el
=
options
.
to
.
el
||
options
.
from
.
el
;
var
fromEl
=
getTraget
(
options
.
from
);
var
toEl
=
getTraget
(
options
.
to
);
var
scrollable
=
options
.
scrollable
;
var
fromRect
=
getRect
(
fromEl
);
var
toRect
=
getRect
(
toEl
);
var
startTime
=
new
Date
().
getTime
();
var
duration
=
options
.
duration
||
1000
;
simulateEvent
(
fromEl
,
'
mousedown
'
,
{
button
:
0
});
options
.
ontap
&&
options
.
ontap
();
requestAnimationFrame
(
function
()
{
options
.
ondragstart
&&
options
.
ondragstart
();
});
requestAnimationFrame
(
function
loop
()
{
var
progress
=
(
new
Date
().
getTime
()
-
startTime
)
/
duration
;
var
x
=
(
fromRect
.
cx
+
(
toRect
.
cx
-
fromRect
.
cx
)
*
progress
)
-
scrollable
.
scrollLeft
;
var
y
=
fromRect
.
cy
+
(
toRect
.
cy
-
fromRect
.
cy
)
*
progress
;
var
overEl
=
fromEl
.
ownerDocument
.
elementFromPoint
(
x
,
y
);
simulateEvent
(
overEl
,
'
mousemove
'
,
{
clientX
:
x
,
clientY
:
y
});
if
(
progress
<
1
)
{
requestAnimationFrame
(
loop
);
}
else
{
options
.
ondragend
&&
options
.
ondragend
();
simulateEvent
(
toEl
,
'
mouseup
'
);
}
});
return
{
target
:
fromEl
,
fromList
:
fromEl
.
parentNode
,
toList
:
toEl
.
parentNode
};
}
// Export
window
.
simulateEvent
=
simulateEvent
;
window
.
simulateDrag
=
simulateDrag
;
})();
app/assets/stylesheets/pages/boards.scss
浏览文件 @
9172c45b
...
...
@@ -23,18 +23,33 @@
}
.issue-boards-page
{
.content-wrapper
{
display
:
-
webkit-flex
;
display
:
flex
;
}
.sub-nav
,
.issues-filters
{
-webkit-flex
:
none
;
flex
:
none
;
}
.page-with-sidebar
{
display
:
-
webkit-flex
;
display
:
flex
;
min-height
:
100vh
;
max-height
:
100vh
;
}
.issue-boards-content
{
display
:
-
webkit-flex
;
display
:
flex
;
height
:
100%
;
width
:
100%
;
.content
{
display
:
-
webkit-flex
;
display
:
flex
;
-webkit-flex-direction
:
column
;
flex-direction
:
column
;
width
:
100%
;
}
...
...
@@ -42,8 +57,10 @@
}
.boards-list
{
display
:
-
webkit-flex
;
display
:
flex
;
height
:
100%
;
-webkit-flex
:
1
;
flex
:
1
;
min-height
:
455px
;
padding-top
:
25px
;
padding-right
:
(
$gl-padding
/
2
);
...
...
@@ -52,17 +69,19 @@
}
.board
{
display
:
-
webkit-flex
;
display
:
flex
;
min-width
:
400px
;
max-width
:
400px
;
height
:
100%
;
padding-right
:
(
$gl-padding
/
2
);
padding-left
:
(
$gl-padding
/
2
);
}
.board-inner
{
display
:
-
webkit-flex
;
display
:
flex
;
-webkit-flex-direction
:
column
;
flex-direction
:
column
;
height
:
100%
;
width
:
100%
;
font-size
:
$issue-boards-font-size
;
background
:
$background-color
;
...
...
@@ -162,6 +181,7 @@
}
.board-list
{
-webkit-flex
:
1
;
flex
:
1
;
margin
:
0
;
padding
:
5px
;
...
...
app/views/projects/boards/index.html.haml
浏览文件 @
9172c45b
...
...
@@ -4,6 +4,7 @@
-
content_for
:page_specific_javascripts
do
=
page_specific_javascript_tag
(
'boards/boards_bundle.js'
)
=
page_specific_javascript_tag
(
'boards/test_utils/simulate_drag.js'
)
if
Rails
.
env
.
test?
=
render
"projects/issues/head"
...
...
config/application.rb
浏览文件 @
9172c45b
...
...
@@ -86,6 +86,7 @@ module Gitlab
config
.
assets
.
precompile
<<
"network/network_bundle.js"
config
.
assets
.
precompile
<<
"profile/profile_bundle.js"
config
.
assets
.
precompile
<<
"boards/boards_bundle.js"
config
.
assets
.
precompile
<<
"boards/test_utils/simulate_drag.js"
config
.
assets
.
precompile
<<
"lib/utils/*.js"
config
.
assets
.
precompile
<<
"lib/*.js"
config
.
assets
.
precompile
<<
"u2f.js"
...
...
spec/features/boards/boards_spec.rb
0 → 100644
浏览文件 @
9172c45b
require
'rails_helper'
describe
'Issue Boards'
,
feature:
true
,
js:
true
do
let
(
:project
)
{
create
(
:project
)
}
let
(
:user
)
{
create
(
:user
)
}
before
do
project
.
team
<<
[
user
,
:master
]
login_as
(
user
)
visit
namespace_project_boards_path
(
project
.
namespace
,
project
)
end
it
'shows default lists'
do
lists
=
all
(
'.board'
)
page
.
within
lists
.
first
do
expect
(
page
).
to
have_content
'Backlog'
end
page
.
within
lists
.
last
do
expect
(
page
).
to
have_content
'Done'
end
end
it
'removes blank state list'
do
click_button
'Nevermind, i\'ll use my own'
expect
(
page
).
to
have_selector
(
'.board'
,
count:
2
)
end
it
'can drag card to new list'
do
sleep
0.5
lists
=
all
(
'.board'
)
drag_to
(
list_from_index:
0
,
list_to_index:
1
)
page
.
within
lists
[
1
].
find
(
'.board-list'
)
do
expect
(
page
).
to
have_content
(
'Test'
)
expect
(
page
).
to
have_selector
(
'.card'
,
count:
2
)
page
.
within
first
(
'.card .card-footer'
)
do
expect
(
page
).
to
have_content
'Frontend'
end
end
end
it
'removes all labels from card'
do
sleep
0.5
lists
=
all
(
'.board'
)
drag_to
(
list_from_index:
1
,
list_to_index:
3
)
page
.
within
lists
[
3
].
find
(
'.board-list'
)
do
expect
(
page
).
to
have_content
(
'Frontend bug'
)
expect
(
page
).
to
have_selector
(
'.card'
,
count:
2
)
page
.
within
first
(
'.card .card-footer'
)
do
expect
(
page
).
not_to
have_content
'Frontend'
end
end
page
.
within
lists
[
1
].
find
(
'.board-list'
)
do
expect
(
page
).
not_to
have_content
(
'Frontend bug'
)
expect
(
page
).
not_to
have_selector
(
'.card'
)
end
end
def
drag_to
(
list_from_index:
0
,
card_index:
0
,
to_index:
0
,
list_to_index:
0
)
evaluate_script
(
"simulateDrag({scrollable: document.getElementById('board-app'), from: {el: $('.board-list').eq(
#{
list_from_index
}
).get(0), index:
#{
card_index
}
}, to: {el: $('.board-list').eq(
#{
list_to_index
}
).get(0), index:
#{
to_index
}
}});"
)
sleep
1
end
end
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录