Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gitlab-ce
Commits
e864bdf2
Commit
e864bdf2
authored
Jun 10, 2016
by
Fatih Acet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix specs and add new tests.
parent
639347ba
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
64 additions
and
44 deletions
+64
-44
spec/features/search_spec.rb
spec/features/search_spec.rb
+2
-2
spec/javascripts/search_autocomplete_spec.js.coffee
spec/javascripts/search_autocomplete_spec.js.coffee
+62
-42
No files found.
spec/features/search_spec.rb
View file @
e864bdf2
...
@@ -68,7 +68,7 @@ describe "Search", feature: true do
...
@@ -68,7 +68,7 @@ describe "Search", feature: true do
it
'should show category search dropdown'
do
it
'should show category search dropdown'
do
page
.
find
(
'#search'
).
click
page
.
find
(
'#search'
).
click
expect
(
page
).
to
have_selector
(
'.dropdown-header'
,
text:
/
go to in
#{
project
.
name
}
/i
)
expect
(
page
).
to
have_selector
(
'.dropdown-header'
,
text:
/
#{
project
.
name
}
/i
)
end
end
end
end
...
@@ -119,7 +119,7 @@ describe "Search", feature: true do
...
@@ -119,7 +119,7 @@ describe "Search", feature: true do
end
end
it
'should not display the category search dropdown'
do
it
'should not display the category search dropdown'
do
expect
(
page
).
not_to
have_selector
(
'.dropdown-header'
,
text:
/
go to in
#{
project
.
name
}
/i
)
expect
(
page
).
not_to
have_selector
(
'.dropdown-header'
,
text:
/
#{
project
.
name
}
/i
)
end
end
end
end
end
end
...
...
spec/javascripts/search_autocomplete_spec.js.coffee
View file @
e864bdf2
...
@@ -13,18 +13,33 @@ window.gon.current_user_id = userId
...
@@ -13,18 +13,33 @@ window.gon.current_user_id = userId
dashboardIssuesPath
=
'/dashboard/issues'
dashboardIssuesPath
=
'/dashboard/issues'
dashboardMRsPath
=
'/dashboard/merge_requests'
dashboardMRsPath
=
'/dashboard/merge_requests'
projectIssuesPath
=
"/gitlab-org/gitlab-ce/issues"
projectIssuesPath
=
'/gitlab-org/gitlab-ce/issues'
projectMRsPath
=
"/gitlab-org/gitlab-ce/merge_requests"
projectMRsPath
=
'/gitlab-org/gitlab-ce/merge_requests'
groupIssuesPath
=
'/groups/gitlab-org/issues'
groupMRsPath
=
'/groups/gitlab-org/merge_requests'
projectName
=
'GitLab Community Edition'
projectName
=
'GitLab Community Edition'
groupName
=
'Gitlab Org'
# Add required attributes to body before starting the test.
# Add required attributes to body before starting the test.
addBodyAttributes
=
(
page
=
'groups'
)
->
# section would be dashboard|group|project
addBodyAttributes
=
(
section
=
'dashboard'
)
->
$body
=
$
'body'
$
(
'body'
).
removeAttr
'data-page'
$body
.
removeAttr
'data-page'
$
(
'body'
).
removeAttr
'data-project'
$body
.
removeAttr
'data-project'
$body
.
removeAttr
'data-group'
$
(
'body'
).
data
'page'
,
"
#{
page
}
:show"
switch
section
$
(
'body'
).
data
'project'
,
'gitlab-ce'
when
'dashboard'
$body
.
data
'page'
,
'root:index'
when
'group'
$body
.
data
'page'
,
'groups:show'
$body
.
data
'group'
,
'gitlab-org'
when
'project'
$body
.
data
'page'
,
'projects:show'
$body
.
data
'project'
,
'gitlab-ce'
# Mock `gl` object in window for dashboard specific page. App code will need it.
# Mock `gl` object in window for dashboard specific page. App code will need it.
...
@@ -47,7 +62,27 @@ mockProjectOptions = ->
...
@@ -47,7 +62,27 @@ mockProjectOptions = ->
projectName
:
projectName
projectName
:
projectName
assertLinks
=
(
list
,
a1
,
a2
,
a3
,
a4
)
->
mockGroupOptions
=
->
window
.
gl
or=
{}
window
.
gl
.
groupOptions
=
'gitlab-org'
:
issuesPath
:
groupIssuesPath
mrPath
:
groupMRsPath
projectName
:
groupName
assertLinks
=
(
list
,
issuesPath
,
mrsPath
)
->
issuesAssignedToMeLink
=
"
#{
issuesPath
}
/?assignee_id=
#{
userId
}
"
issuesIHaveCreatedLink
=
"
#{
issuesPath
}
/?author_id=
#{
userId
}
"
mrsAssignedToMeLink
=
"
#{
mrsPath
}
/?assignee_id=
#{
userId
}
"
mrsIHaveCreatedLink
=
"
#{
mrsPath
}
/?author_id=
#{
userId
}
"
a1
=
"a[href='
#{
issuesAssignedToMeLink
}
']"
a2
=
"a[href='
#{
issuesIHaveCreatedLink
}
']"
a3
=
"a[href='
#{
mrsAssignedToMeLink
}
']"
a4
=
"a[href='
#{
mrsIHaveCreatedLink
}
']"
expect
(
list
.
find
(
a1
).
length
).
toBe
1
expect
(
list
.
find
(
a1
).
length
).
toBe
1
expect
(
list
.
find
(
a1
).
text
()).
toBe
' Issues assigned to me '
expect
(
list
.
find
(
a1
).
text
()).
toBe
' Issues assigned to me '
...
@@ -62,7 +97,6 @@ assertLinks = (list, a1, a2, a3, a4) ->
...
@@ -62,7 +97,6 @@ assertLinks = (list, a1, a2, a3, a4) ->
expect
(
list
.
find
(
a4
).
text
()).
toBe
" Merge requests I've created "
expect
(
list
.
find
(
a4
).
text
()).
toBe
" Merge requests I've created "
describe
'Search autocomplete dropdown'
,
->
describe
'Search autocomplete dropdown'
,
->
fixture
.
preload
'search_autocomplete.html'
fixture
.
preload
'search_autocomplete.html'
...
@@ -77,53 +111,39 @@ describe 'Search autocomplete dropdown', ->
...
@@ -77,53 +111,39 @@ describe 'Search autocomplete dropdown', ->
addBodyAttributes
()
addBodyAttributes
()
mockDashboardOptions
()
mockDashboardOptions
()
# Focus input to show dropdown list.
widget
.
searchInput
.
focus
()
widget
.
searchInput
.
focus
()
w
=
widget
.
wrap
.
find
'.dropdown-menu
'
list
=
widget
.
wrap
.
find
(
'.dropdown-menu'
).
find
'ul
'
l
=
w
.
find
'ul'
assertLinks
list
,
dashboardIssuesPath
,
dashboardMRsPath
# # Expect dropdown and dropdown header
expect
(
w
.
find
(
'.dropdown-header'
).
text
()).
toBe
'Go to in Dashboard'
# Create links then assert link urls and inner texts
it
'should show Group specific dropdown menu'
,
->
issuesAssignedToMeLink
=
"
#{
dashboardIssuesPath
}
/?assignee_id=
#{
userId
}
"
issuesIHaveCreatedLink
=
"
#{
dashboardIssuesPath
}
/?author_id=
#{
userId
}
"
mrsAssignedToMeLink
=
"
#{
dashboardMRsPath
}
/?assignee_id=
#{
userId
}
"
mrsIHaveCreatedLink
=
"
#{
dashboardMRsPath
}
/?author_id=
#{
userId
}
"
a1
=
"a[href='
#{
issuesAssignedToMeLink
}
']"
addBodyAttributes
'group'
a2
=
"a[href='
#{
issuesIHaveCreatedLink
}
']"
mockGroupOptions
()
a3
=
"a[href='
#{
mrsAssignedToMeLink
}
']"
widget
.
searchInput
.
focus
()
a4
=
"a[href='
#{
mrsIHaveCreatedLink
}
']"
assertLinks
l
,
a1
,
a2
,
a3
,
a4
list
=
widget
.
wrap
.
find
(
'.dropdown-menu'
).
find
'ul'
assertLinks
list
,
groupIssuesPath
,
groupMRsPath
it
'should show Project specific dropdown menu'
,
->
it
'should show Project specific dropdown menu'
,
->
addBodyAttributes
'project
s
'
addBodyAttributes
'project'
mockProjectOptions
()
mockProjectOptions
()
# Focus input to show dropdown list.
widget
.
searchInput
.
focus
()
widget
.
searchInput
.
focus
()
w
=
widget
.
wrap
.
find
'.dropdown-menu
'
list
=
widget
.
wrap
.
find
(
'.dropdown-menu'
).
find
'ul
'
l
=
w
.
find
'ul'
assertLinks
list
,
projectIssuesPath
,
projectMRsPath
# Expect dropdown and dropdown header
expect
(
w
.
find
(
'.dropdown-header'
).
text
()).
toBe
"Go to in
#{
projectName
}
"
# Create links then verify link urls and inner texts
it
'should not show category related menu if there is text in the input'
,
->
issuesAssignedToMeLink
=
"
#{
projectIssuesPath
}
/?assignee_id=
#{
userId
}
"
issuesIHaveCreatedLink
=
"
#{
projectIssuesPath
}
/?author_id=
#{
userId
}
"
mrsAssignedToMeLink
=
"
#{
projectMRsPath
}
/?assignee_id=
#{
userId
}
"
mrsIHaveCreatedLink
=
"
#{
projectMRsPath
}
/?author_id=
#{
userId
}
"
a
1
=
"a[href='
#{
issuesAssignedToMeLink
}
']"
a
ddBodyAttributes
'project'
a2
=
"a[href='
#{
issuesIHaveCreatedLink
}
']"
mockProjectOptions
()
a3
=
"a[href='
#{
mrsAssignedToMeLink
}
']"
widget
.
searchInput
.
val
'help'
a4
=
"a[href='
#{
mrsIHaveCreatedLink
}
']"
widget
.
searchInput
.
focus
()
assertLinks
l
,
a1
,
a2
,
a3
,
a4
list
=
widget
.
wrap
.
find
(
'.dropdown-menu'
).
find
'ul'
link
=
"a[href='
#{
projectIssuesPath
}
/?assignee_id=
#{
userId
}
']"
expect
(
list
.
find
(
link
).
length
).
toBe
0
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment