Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
jenkins
提交
cdbbc8cc
J
jenkins
项目概览
xxadev
/
jenkins
与 Fork 源项目一致
从无法访问的项目Fork
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
J
jenkins
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
cdbbc8cc
编写于
2月 17, 2016
作者:
T
tfennelly
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Added some finder tests
上级
cd604628
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
140 addition
and
24 deletion
+140
-24
war/src/main/js/widgets/config/model/ConfigSection.js
war/src/main/js/widgets/config/model/ConfigSection.js
+32
-4
war/src/main/js/widgets/config/model/ConfigTableMetaData.js
war/src/main/js/widgets/config/model/ConfigTableMetaData.js
+4
-18
war/src/main/js/widgets/jenkins-widgets.less
war/src/main/js/widgets/jenkins-widgets.less
+6
-1
war/src/test/js/widgets/config/freestyle-config.html
war/src/test/js/widgets/config/freestyle-config.html
+2
-1
war/src/test/js/widgets/config/tabbar-spec.js
war/src/test/js/widgets/config/tabbar-spec.js
+96
-0
未找到文件。
war/src/main/js/widgets/config/model/ConfigSection.js
浏览文件 @
cdbbc8cc
...
@@ -102,6 +102,29 @@ ConfigSection.prototype.markRowsAsActive = function() {
...
@@ -102,6 +102,29 @@ ConfigSection.prototype.markRowsAsActive = function() {
this
.
updateRowGroupVisibility
();
this
.
updateRowGroupVisibility
();
};
};
ConfigSection
.
prototype
.
hasText
=
function
(
text
)
{
var
$
=
jQD
.
getJQuery
();
var
selector
=
"
:containsci('
"
+
text
+
"
')
"
;
var
sectionRows
=
this
.
getRows
();
for
(
var
i1
=
0
;
i1
<
sectionRows
.
length
;
i1
++
)
{
var
row
=
sectionRows
[
i1
];
var
elementsWithText
=
$
(
selector
,
row
);
if
(
elementsWithText
.
size
()
>
0
)
{
return
true
;
}
}
for
(
var
i2
=
0
;
i2
<
this
.
subSections
.
length
;
i2
++
)
{
if
(
this
.
subSections
[
i2
].
hasText
(
text
))
{
return
true
;
}
}
return
false
;
};
ConfigSection
.
prototype
.
activeRowCount
=
function
()
{
ConfigSection
.
prototype
.
activeRowCount
=
function
()
{
var
activeRowCount
=
0
;
var
activeRowCount
=
0
;
var
rows
=
this
.
getRows
();
var
rows
=
this
.
getRows
();
...
@@ -190,8 +213,8 @@ ConfigSection.prototype.highlightText = function(text) {
...
@@ -190,8 +213,8 @@ ConfigSection.prototype.highlightText = function(text) {
var
selector
=
"
:containsci('
"
+
text
+
"
')
"
;
var
selector
=
"
:containsci('
"
+
text
+
"
')
"
;
var
rows
=
this
.
getRows
();
var
rows
=
this
.
getRows
();
for
(
var
i
=
0
;
i
<
rows
.
length
;
i
++
)
{
for
(
var
i
1
=
0
;
i1
<
rows
.
length
;
i1
++
)
{
var
row
=
rows
[
i
];
var
row
=
rows
[
i
1
];
/*jshint loopfunc: true */
/*jshint loopfunc: true */
$
(
'
span.highlight-split
'
,
row
).
each
(
function
()
{
// jshint ignore:line
$
(
'
span.highlight-split
'
,
row
).
each
(
function
()
{
// jshint ignore:line
...
@@ -209,11 +232,16 @@ ConfigSection.prototype.highlightText = function(text) {
...
@@ -209,11 +232,16 @@ ConfigSection.prototype.highlightText = function(text) {
$this
.
contents
().
each
(
function
()
{
$this
.
contents
().
each
(
function
()
{
// We specifically only mess with text nodes
// We specifically only mess with text nodes
if
(
this
.
nodeType
===
3
)
{
if
(
this
.
nodeType
===
3
)
{
var
highlightedMarkup
=
this
.
wholeText
.
replace
(
regex
,
'
<span class="highlight">$1</span>
'
);
var
$textNode
=
$
(
this
);
$
(
this
).
replaceWith
(
'
<span class="highlight-split">
'
+
highlightedMarkup
+
'
</span>
'
);
var
highlightedMarkup
=
$textNode
.
text
().
replace
(
regex
,
'
<span class="highlight">$1</span>
'
);
$textNode
.
replaceWith
(
'
<span class="highlight-split">
'
+
highlightedMarkup
+
'
</span>
'
);
}
}
});
});
});
});
}
}
}
}
for
(
var
i2
=
0
;
i2
<
this
.
subSections
.
length
;
i2
++
)
{
this
.
subSections
[
i2
].
highlightText
(
text
);
}
};
};
war/src/main/js/widgets/config/model/ConfigTableMetaData.js
浏览文件 @
cdbbc8cc
...
@@ -262,7 +262,7 @@ ConfigTableMetaData.prototype.showSections = function(withText) {
...
@@ -262,7 +262,7 @@ ConfigTableMetaData.prototype.showSections = function(withText) {
if
(
withText
===
''
)
{
if
(
withText
===
''
)
{
if
(
this
.
hasSections
())
{
if
(
this
.
hasSections
())
{
for
(
var
i1
=
0
;
i1
<
this
.
sections
.
length
;
i1
++
)
{
for
(
var
i1
=
0
;
i1
<
this
.
sections
.
length
;
i1
++
)
{
this
.
sections
[
i1
].
activator
.
show
(
);
this
.
sections
[
i1
].
activator
.
removeClass
(
'
hidden
'
);
}
}
var
activeSection
=
this
.
activeSection
();
var
activeSection
=
this
.
activeSection
();
if
(
!
activeSection
)
{
if
(
!
activeSection
)
{
...
@@ -273,30 +273,16 @@ ConfigTableMetaData.prototype.showSections = function(withText) {
...
@@ -273,30 +273,16 @@ ConfigTableMetaData.prototype.showSections = function(withText) {
}
}
}
else
{
}
else
{
if
(
this
.
hasSections
())
{
if
(
this
.
hasSections
())
{
var
$
=
jQD
.
getJQuery
();
var
selector
=
"
:containsci('
"
+
withText
+
"
')
"
;
var
sectionsWithText
=
[];
var
sectionsWithText
=
[];
for
(
var
i2
=
0
;
i2
<
this
.
sections
.
length
;
i2
++
)
{
for
(
var
i2
=
0
;
i2
<
this
.
sections
.
length
;
i2
++
)
{
var
section
=
this
.
sections
[
i2
];
var
section
=
this
.
sections
[
i2
];
var
containsText
=
false
;
var
sectionRows
=
section
.
getRows
();
for
(
var
i3
=
0
;
i3
<
sectionRows
.
length
;
i3
++
)
{
var
row
=
sectionRows
[
i3
];
var
elementsWithText
=
$
(
selector
,
row
);
if
(
elementsWithText
.
size
()
>
0
)
{
containsText
=
true
;
break
;
}
}
if
(
containsText
)
{
if
(
section
.
hasText
(
withText
)
)
{
section
.
activator
.
show
(
);
section
.
activator
.
removeClass
(
'
hidden
'
);
sectionsWithText
.
push
(
section
);
sectionsWithText
.
push
(
section
);
}
else
{
}
else
{
section
.
activator
.
hide
(
);
section
.
activator
.
addClass
(
'
hidden
'
);
}
}
}
}
...
...
war/src/main/js/widgets/jenkins-widgets.less
浏览文件 @
cdbbc8cc
...
@@ -11,3 +11,8 @@
...
@@ -11,3 +11,8 @@
* Widget styles
* Widget styles
*/
*/
@import "config/tabbar";
@import "config/tabbar";
.hidden {
display: none;
}
\ No newline at end of file
war/src/test/js/widgets/config/freestyle-config.html
浏览文件 @
cdbbc8cc
...
@@ -129,7 +129,8 @@
...
@@ -129,7 +129,8 @@
<tr
class=
"optional-block-start row-group-start row-set-start"
hashelp=
"true"
ref=
"cb19"
>
<tr
class=
"optional-block-start row-group-start row-set-start"
hashelp=
"true"
ref=
"cb19"
>
<td
colspan=
"3"
>
<td
colspan=
"3"
>
<input
class=
"optional-block-control block-control "
type=
"checkbox"
>
<input
class=
"optional-block-control block-control "
type=
"checkbox"
>
<label
class=
"attach-previous"
>
Build after other projects are built
</label>
<!-- We added the text "Trigger" here for testing the finder -->
<label
class=
"attach-previous"
>
Build (Trigger) after other projects are built
</label>
</td>
</td>
</tr>
</tr>
<tr>
<tr>
...
...
war/src/test/js/widgets/config/tabbar-spec.js
浏览文件 @
cdbbc8cc
...
@@ -71,6 +71,102 @@ describe("tabbar-spec tests", function () {
...
@@ -71,6 +71,102 @@ describe("tabbar-spec tests", function () {
done
();
done
();
},
'
widgets/config/freestyle-config.html
'
);
},
'
widgets/config/freestyle-config.html
'
);
});
});
it
(
"
- test finder - via handler triggering
"
,
function
(
done
)
{
jsTest
.
onPage
(
function
()
{
var
configTabBarWidget
=
jsTest
.
requireSrcModule
(
'
widgets/config/tabbar
'
);
var
configTabBar
=
configTabBarWidget
.
addTabsOnFirst
();
var
jQD
=
require
(
'
jquery-detached
'
);
var
$
=
jQD
.
getJQuery
();
var
tabBar
=
$
(
'
.tabBar
'
);
// All tabs should be visible...
expect
(
$
(
'
.tab
'
,
tabBar
).
size
()).
toBe
(
4
);
expect
(
$
(
'
.tab.hidden
'
,
tabBar
).
size
()).
toBe
(
0
);
var
finder
=
configTabBar
.
findInput
;
expect
(
finder
.
size
()).
toBe
(
1
);
// Find sections that have the text "trigger" in them...
keydowns
(
'
trigger
'
,
finder
);
// Need to wait for the change to happen ... there's a 300ms delay.
// We could just call configTabBar.showSections(), but ...
setTimeout
(
function
()
{
expect
(
$
(
'
.tab.hidden
'
,
tabBar
).
size
()).
toBe
(
3
);
expect
(
textCleanup
(
$
(
'
.tab.hidden
'
,
tabBar
).
text
())).
toBe
(
'
General|#Advanced Project Options|#Build
'
);
var
activeSection
=
configTabBar
.
activeSection
();
expect
(
textCleanup
(
activeSection
.
title
)).
toBe
(
'
#Build Triggers
'
);
expect
(
$
(
'
.highlight-split .highlight
'
).
text
()).
toBe
(
'
Trigger
'
);
done
();
},
600
);
},
'
widgets/config/freestyle-config.html
'
);
});
it
(
"
- test finder - via showSections()
"
,
function
(
done
)
{
jsTest
.
onPage
(
function
()
{
var
configTabBarWidget
=
jsTest
.
requireSrcModule
(
'
widgets/config/tabbar
'
);
var
configTabBar
=
configTabBarWidget
.
addTabsOnFirst
();
var
jQD
=
require
(
'
jquery-detached
'
);
var
$
=
jQD
.
getJQuery
();
var
tabBar
=
$
(
'
.tabBar
'
);
configTabBar
.
showSections
(
'
quiet period
'
);
expect
(
$
(
'
.tab.hidden
'
,
tabBar
).
size
()).
toBe
(
3
);
expect
(
textCleanup
(
$
(
'
.tab.hidden
'
,
tabBar
).
text
())).
toBe
(
'
General|#Build Triggers|#Build
'
);
var
activeSection
=
configTabBar
.
activeSection
();
expect
(
textCleanup
(
activeSection
.
title
)).
toBe
(
'
#Advanced Project Options
'
);
done
();
},
'
widgets/config/freestyle-config.html
'
);
});
it
(
"
- test finder - via showSections() - in inner row-group
"
,
function
(
done
)
{
jsTest
.
onPage
(
function
()
{
var
configTabBarWidget
=
jsTest
.
requireSrcModule
(
'
widgets/config/tabbar
'
);
var
configTabBar
=
configTabBarWidget
.
addTabsOnFirst
();
var
jQD
=
require
(
'
jquery-detached
'
);
var
$
=
jQD
.
getJQuery
();
var
tabBar
=
$
(
'
.tabBar
'
);
configTabBar
.
showSections
(
'
Strategy
'
);
expect
(
$
(
'
.tab.hidden
'
,
tabBar
).
size
()).
toBe
(
3
);
expect
(
textCleanup
(
$
(
'
.tab.hidden
'
,
tabBar
).
text
())).
toBe
(
'
#Advanced Project Options|#Build Triggers|#Build
'
);
var
activeSection
=
configTabBar
.
activeSection
();
expect
(
textCleanup
(
activeSection
.
title
)).
toBe
(
'
General
'
);
done
();
},
'
widgets/config/freestyle-config.html
'
);
});
function
keydowns
(
text
,
onInput
)
{
var
jQD
=
require
(
'
jquery-detached
'
);
var
$
=
jQD
.
getJQuery
();
// hmmm, for some reason, the key events do not result in the text being
// set in the input, so setting it manually.
onInput
.
val
(
text
);
// Now fire a keydown event to trigger the handler
var
e
=
$
.
Event
(
"
keydown
"
);
e
.
which
=
116
;
onInput
.
trigger
(
e
);
}
function
textCleanup
(
text
)
{
return
text
.
trim
().
replace
(
/
(\r\n
|
\n
|
\r)
/gm
,
""
).
replace
(
/ +/g
,
"
|
"
);
}
});
});
// TODO: lots more tests !!!
// TODO: lots more tests !!!
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录