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
86cc91aa
Commit
86cc91aa
authored
Jul 21, 2020
by
Terri Chu
Committed by
Igor Drozdov
Jul 21, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add feature tests to search bar dropdown scoped search shortcuts
parent
00b75ff4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
73 additions
and
3 deletions
+73
-3
spec/features/search/user_uses_header_search_field_spec.rb
spec/features/search/user_uses_header_search_field_spec.rb
+73
-3
No files found.
spec/features/search/user_uses_header_search_field_spec.rb
View file @
86cc91aa
...
...
@@ -104,6 +104,14 @@ RSpec.describe 'User uses header search field', :js do
let
(
:scope_name
)
{
'All GitLab'
}
end
it
'displays search options'
do
page
.
within
(
'.search-input-wrap'
)
do
fill_in
(
'search'
,
with:
'test'
)
end
expect
(
page
).
to
have_selector
(
scoped_search_link
(
'test'
))
end
context
'when searching through the search field'
do
before
do
create
(
:issue
,
project:
project
,
title:
'project issue'
)
...
...
@@ -122,9 +130,41 @@ RSpec.describe 'User uses header search field', :js do
end
context
'when user is in a project scope'
do
include_examples
'search field examples'
do
let
(
:url
)
{
project_path
(
project
)
}
let
(
:scope_name
)
{
project
.
name
}
context
'and it belongs to a group'
do
let
(
:group
)
{
create
(
:group
)
}
let
(
:project
)
{
create
(
:project
,
namespace:
group
)
}
include_examples
'search field examples'
do
let
(
:url
)
{
project_path
(
project
)
}
let
(
:scope_name
)
{
project
.
name
}
end
it
'displays search options'
do
page
.
within
(
'.search-input-wrap'
)
do
fill_in
(
'search'
,
with:
'test'
)
end
expect
(
page
).
to
have_selector
(
scoped_search_link
(
'test'
))
expect
(
page
).
to
have_selector
(
scoped_search_link
(
'test'
,
group_id:
group
.
id
))
expect
(
page
).
to
have_selector
(
scoped_search_link
(
'test'
,
project_id:
project
.
id
,
group_id:
group
.
id
))
end
end
context
'and it belongs to a user'
do
include_examples
'search field examples'
do
let
(
:url
)
{
project_path
(
project
)
}
let
(
:scope_name
)
{
project
.
name
}
end
it
'displays search options'
do
page
.
within
(
'.search-input-wrap'
)
do
fill_in
(
'search'
,
with:
'test'
)
end
expect
(
page
).
to
have_selector
(
scoped_search_link
(
'test'
))
expect
(
page
).
not_to
have_selector
(
scoped_search_link
(
'test'
,
group_id:
project
.
namespace_id
))
expect
(
page
).
to
have_selector
(
scoped_search_link
(
'test'
,
project_id:
project
.
id
))
end
end
end
...
...
@@ -140,6 +180,16 @@ RSpec.describe 'User uses header search field', :js do
let
(
:url
)
{
group_path
(
group
)
}
let
(
:scope_name
)
{
group
.
name
}
end
it
'displays search options'
do
page
.
within
(
'.search-input-wrap'
)
do
fill_in
(
'search'
,
with:
'test'
)
end
expect
(
page
).
to
have_selector
(
scoped_search_link
(
'test'
))
expect
(
page
).
to
have_selector
(
scoped_search_link
(
'test'
,
group_id:
group
.
id
))
expect
(
page
).
not_to
have_selector
(
scoped_search_link
(
'test'
,
project_id:
project
.
id
))
end
end
context
'when user is in a subgroup scope'
do
...
...
@@ -156,5 +206,25 @@ RSpec.describe 'User uses header search field', :js do
let
(
:url
)
{
group_path
(
subgroup
)
}
let
(
:scope_name
)
{
subgroup
.
name
}
end
it
'displays search options'
do
page
.
within
(
'.search-input-wrap'
)
do
fill_in
(
'search'
,
with:
'test'
)
end
expect
(
page
).
to
have_selector
(
scoped_search_link
(
'test'
))
expect
(
page
).
to
have_selector
(
scoped_search_link
(
'test'
,
group_id:
subgroup
.
id
))
expect
(
page
).
not_to
have_selector
(
scoped_search_link
(
'test'
,
project_id:
project
.
id
))
end
end
def
scoped_search_link
(
term
,
project_id:
nil
,
group_id:
nil
)
# search_path will accept group_id and project_id but the order does not match
# what is expected in the href, so the variable must be built manually
href
=
search_path
(
search:
term
)
href
.
concat
(
"&project_id=
#{
project_id
}
"
)
if
project_id
href
.
concat
(
"&group_id=
#{
group_id
}
"
)
if
group_id
".dropdown a[href='
#{
href
}
']"
end
end
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