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
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
50b3b8ce
Commit
50b3b8ce
authored
Jun 07, 2016
by
Fatih Acet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added tests for categorised search autocomplete.
parent
36f67b30
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
221 additions
and
3 deletions
+221
-3
app/assets/javascripts/search_autocomplete.js.coffee
app/assets/javascripts/search_autocomplete.js.coffee
+1
-1
spec/features/search_spec.rb
spec/features/search_spec.rb
+79
-0
spec/javascripts/fixtures/search_autocomplete.html.haml
spec/javascripts/fixtures/search_autocomplete.html.haml
+10
-0
spec/javascripts/notes_spec.js.coffee
spec/javascripts/notes_spec.js.coffee
+1
-1
spec/javascripts/project_title_spec.js.coffee
spec/javascripts/project_title_spec.js.coffee
+1
-1
spec/javascripts/search_autocomplete_spec.js.coffee
spec/javascripts/search_autocomplete_spec.js.coffee
+129
-0
No files found.
app/assets/javascripts/search_autocomplete.js.coffee
View file @
50b3b8ce
...
@@ -134,7 +134,7 @@ class @SearchAutocomplete
...
@@ -134,7 +134,7 @@ class @SearchAutocomplete
userId
=
gon
.
current_user_id
userId
=
gon
.
current_user_id
projectName
=
'Dashboard'
projectName
=
'Dashboard'
projectSlug
=
gl
.
utils
.
getProjectSlug
()
projectSlug
=
gl
.
utils
.
getProjectSlug
()
projectOptions
=
gl
.
projectOptions
[
projectSlug
]
projectOptions
=
gl
.
projectOptions
?
[
projectSlug
]
if
projectSlug
and
projectOptions
if
projectSlug
and
projectOptions
{
issuesPath
,
mrPath
,
projectName
}
=
projectOptions
{
issuesPath
,
mrPath
,
projectName
}
=
projectOptions
...
...
spec/features/search_spec.rb
View file @
50b3b8ce
...
@@ -47,4 +47,83 @@ describe "Search", feature: true do
...
@@ -47,4 +47,83 @@ describe "Search", feature: true do
expect
(
page
).
to
have_link
(
snippet
.
title
)
expect
(
page
).
to
have_link
(
snippet
.
title
)
end
end
end
end
describe
'Right header search field'
,
feature:
true
do
describe
'Search in project page'
do
before
do
visit
namespace_project_path
(
project
.
namespace
,
project
)
end
it
'top right search form is present'
do
expect
(
page
).
to
have_selector
(
'#search'
)
end
it
'top right search form contains location badge'
do
expect
(
page
).
to
have_selector
(
'.has-location-badge'
)
end
context
'clicking the search field'
,
js:
true
do
it
'should show category search dropdown'
do
page
.
find
(
'#search'
).
click
expect
(
page
).
to
have_selector
(
'.dropdown-header'
,
text:
/go to in
#{
project
.
name
}
/i
)
end
end
context
'click the links in the category search dropdown'
,
js:
true
do
before
do
page
.
find
(
'#search'
).
click
end
it
'should take user to her issues page when issues assigned is clicked'
do
find
(
'.dropdown-menu'
).
click_link
'Issues assigned to me'
sleep
2
expect
(
page
).
to
have_selector
(
'.issues-holder'
)
expect
(
find
(
'.js-assignee-search .dropdown-toggle-text'
)).
to
have_content
(
user
.
name
)
end
it
'should take user to her issues page when issues authored is clicked'
do
find
(
'.dropdown-menu'
).
click_link
"Issues I've created"
sleep
2
expect
(
page
).
to
have_selector
(
'.issues-holder'
)
expect
(
find
(
'.js-author-search .dropdown-toggle-text'
)).
to
have_content
(
user
.
name
)
end
it
'should take user to her MR page when MR assigned is clicked'
do
find
(
'.dropdown-menu'
).
click_link
'Merge requests assigned to me'
sleep
2
expect
(
page
).
to
have_selector
(
'.merge-requests-holder'
)
expect
(
find
(
'.js-assignee-search .dropdown-toggle-text'
)).
to
have_content
(
user
.
name
)
end
it
'should take user to her MR page when MR authored is clicked'
do
find
(
'.dropdown-menu'
).
click_link
"Merge requests I've created"
sleep
2
expect
(
page
).
to
have_selector
(
'.merge-requests-holder'
)
expect
(
find
(
'.js-author-search .dropdown-toggle-text'
)).
to
have_content
(
user
.
name
)
end
end
context
'entering text into the search field'
,
js:
true
do
before
do
page
.
within
'.search-input-wrap'
do
fill_in
"search"
,
with:
project
.
name
[
0
..
3
]
end
end
it
'should not display the category search dropdown'
do
expect
(
page
).
not_to
have_selector
(
'.dropdown-header'
,
text:
/go to in
#{
project
.
name
}
/i
)
end
end
end
end
end
end
spec/javascripts/fixtures/search_autocomplete.html.haml
0 → 100644
View file @
50b3b8ce
.search.search-form.has-location-badge
%form
.navbar-form
.search-input-container
%div
.location-badge
This project
.search-input-wrap
.dropdown
%input
#search
.search-input.dropdown-menu-toggle
.dropdown-menu.dropdown-select
.dropdown-content
spec/javascripts/notes_spec.js.coffee
View file @
50b3b8ce
#= require notes
#= require notes
#= require gl_form
#= require gl_form
window
.
gon
=
{}
window
.
gon
or
=
{}
window
.
disableButtonIfEmptyField
=
->
null
window
.
disableButtonIfEmptyField
=
->
null
describe
'Notes'
,
->
describe
'Notes'
,
->
...
...
spec/javascripts/project_title_spec.js.coffee
View file @
50b3b8ce
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
#= require project_select
#= require project_select
#= require project
#= require project
window
.
gon
=
{}
window
.
gon
or
=
{}
window
.
gon
.
api_version
=
'v3'
window
.
gon
.
api_version
=
'v3'
describe
'Project Title'
,
->
describe
'Project Title'
,
->
...
...
spec/javascripts/search_autocomplete_spec.js.coffee
0 → 100644
View file @
50b3b8ce
#= require gl_dropdown
#= require search_autocomplete
#= require jquery
#= require lib/common_utils
#= require lib/type_utility
#= require fuzzaldrin-plus
widget
=
null
userId
=
1
window
.
gon
or=
{}
window
.
gon
.
current_user_id
=
userId
dashboardIssuesPath
=
'/dashboard/issues'
dashboardMRsPath
=
'/dashboard/merge_requests'
projectIssuesPath
=
"/gitlab-org/gitlab-ce/issues"
projectMRsPath
=
"/gitlab-org/gitlab-ce/merge_requests"
projectName
=
'GitLab Community Edition'
# Add required attributes to body before starting the test.
addBodyAttributes
=
(
page
=
'groups'
)
->
$
(
'body'
).
removeAttr
'data-page'
$
(
'body'
).
removeAttr
'data-project'
$
(
'body'
).
data
'page'
,
"
#{
page
}
:show"
$
(
'body'
).
data
'project'
,
'gitlab-ce'
# Mock `gl` object in window for dashboard specific page. App code will need it.
mockDashboardOptions
=
->
window
.
gl
or=
{}
window
.
gl
.
dashboardOptions
=
issuesPath
:
dashboardIssuesPath
mrPath
:
dashboardMRsPath
# Mock `gl` object in window for project specific page. App code will need it.
mockProjectOptions
=
->
window
.
gl
or=
{}
window
.
gl
.
projectOptions
=
'gitlab-ce'
:
issuesPath
:
projectIssuesPath
mrPath
:
projectMRsPath
projectName
:
projectName
assertLinks
=
(
list
,
a1
,
a2
,
a3
,
a4
)
->
expect
(
list
.
find
(
a1
).
length
).
toBe
1
expect
(
list
.
find
(
a1
).
text
()).
toBe
' Issues assigned to me '
expect
(
list
.
find
(
a2
).
length
).
toBe
1
expect
(
list
.
find
(
a2
).
text
()).
toBe
" Issues I've created "
expect
(
list
.
find
(
a3
).
length
).
toBe
1
expect
(
list
.
find
(
a3
).
text
()).
toBe
' Merge requests assigned to me '
expect
(
list
.
find
(
a4
).
length
).
toBe
1
expect
(
list
.
find
(
a4
).
text
()).
toBe
" Merge requests I've created "
describe
'Search autocomplete dropdown'
,
->
fixture
.
preload
'search_autocomplete.html'
beforeEach
->
fixture
.
load
'search_autocomplete.html'
widget
=
new
SearchAutocomplete
it
'should show Dashboard specific dropdown menu'
,
->
addBodyAttributes
()
mockDashboardOptions
()
# Focus input to show dropdown list.
widget
.
searchInput
.
focus
()
w
=
widget
.
wrap
.
find
'.dropdown-menu'
l
=
w
.
find
'ul'
# # 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
issuesAssignedToMeLink
=
"
#{
dashboardIssuesPath
}
/?assignee_id=
#{
userId
}
"
issuesIHaveCreatedLink
=
"
#{
dashboardIssuesPath
}
/?author_id=
#{
userId
}
"
mrsAssignedToMeLink
=
"
#{
dashboardMRsPath
}
/?assignee_id=
#{
userId
}
"
mrsIHaveCreatedLink
=
"
#{
dashboardMRsPath
}
/?author_id=
#{
userId
}
"
a1
=
"a[href='
#{
issuesAssignedToMeLink
}
']"
a2
=
"a[href='
#{
issuesIHaveCreatedLink
}
']"
a3
=
"a[href='
#{
mrsAssignedToMeLink
}
']"
a4
=
"a[href='
#{
mrsIHaveCreatedLink
}
']"
assertLinks
l
,
a1
,
a2
,
a3
,
a4
it
'should show Project specific dropdown menu'
,
->
addBodyAttributes
'projects'
mockProjectOptions
()
# Focus input to show dropdown list.
widget
.
searchInput
.
focus
()
w
=
widget
.
wrap
.
find
'.dropdown-menu'
l
=
w
.
find
'ul'
# 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
issuesAssignedToMeLink
=
"
#{
projectIssuesPath
}
/?assignee_id=
#{
userId
}
"
issuesIHaveCreatedLink
=
"
#{
projectIssuesPath
}
/?author_id=
#{
userId
}
"
mrsAssignedToMeLink
=
"
#{
projectMRsPath
}
/?assignee_id=
#{
userId
}
"
mrsIHaveCreatedLink
=
"
#{
projectMRsPath
}
/?author_id=
#{
userId
}
"
a1
=
"a[href='
#{
issuesAssignedToMeLink
}
']"
a2
=
"a[href='
#{
issuesIHaveCreatedLink
}
']"
a3
=
"a[href='
#{
mrsAssignedToMeLink
}
']"
a4
=
"a[href='
#{
mrsIHaveCreatedLink
}
']"
assertLinks
l
,
a1
,
a2
,
a3
,
a4
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