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
31cbf8dc
Commit
31cbf8dc
authored
Apr 07, 2021
by
Coung Ngo
Committed by
Arturo Herrero
Apr 07, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Re-organise `gfm_autocomplete_spec.rb` spec
parent
9eec48b6
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
76 additions
and
130 deletions
+76
-130
spec/features/issues/gfm_autocomplete_spec.rb
spec/features/issues/gfm_autocomplete_spec.rb
+76
-130
No files found.
spec/features/issues/gfm_autocomplete_spec.rb
View file @
31cbf8dc
...
...
@@ -3,8 +3,6 @@
require
'spec_helper'
RSpec
.
describe
'GFM autocomplete'
,
:js
do
let_it_be
(
:user_xss_title
)
{
'eve <img src=x onerror=alert(2)<img src=x onerror=alert(1)>'
}
let_it_be
(
:user_xss
)
{
create
(
:user
,
name:
user_xss_title
,
username:
'xss.user'
)
}
let_it_be
(
:user
)
{
create
(
:user
,
name:
'💃speciąl someone💃'
,
username:
'someone.special'
)
}
let_it_be
(
:user2
)
{
create
(
:user
,
name:
'Marge Simpson'
,
username:
'msimpson'
)
}
...
...
@@ -14,8 +12,15 @@ RSpec.describe 'GFM autocomplete', :js do
let_it_be
(
:issue
)
{
create
(
:issue
,
project:
project
,
assignees:
[
user
])
}
let_it_be
(
:label
)
{
create
(
:label
,
project:
project
,
title:
'special+'
)
}
let_it_be
(
:label_scoped
)
{
create
(
:label
,
project:
project
,
title:
'scoped::label'
)
}
let_it_be
(
:label_with_spaces
)
{
create
(
:label
,
project:
project
,
title:
'Accepting merge requests'
)
}
let_it_be
(
:snippet
)
{
create
(
:project_snippet
,
project:
project
,
title:
'code snippet'
)
}
let_it_be
(
:user_xss_title
)
{
'eve <img src=x onerror=alert(2)<img src=x onerror=alert(1)>'
}
let_it_be
(
:user_xss
)
{
create
(
:user
,
name:
user_xss_title
,
username:
'xss.user'
)
}
let_it_be
(
:label_xss_title
)
{
'alert label <img src=x onerror="alert(\'Hello xss\');" a'
}
let_it_be
(
:label_xss
)
{
create
(
:label
,
project:
project
,
title:
label_xss_title
)
}
before_all
do
project
.
add_maintainer
(
user
)
project
.
add_maintainer
(
user_xss
)
...
...
@@ -117,6 +122,7 @@ RSpec.describe 'GFM autocomplete', :js do
end
end
context
'xss checks'
do
it
'opens autocomplete menu for Issues when field starts with text with item escaping HTML characters'
do
issue_xss_title
=
'This will execute alert<img src=x onerror=alert(2)<img src=x onerror=alert(1)>'
create
(
:issue
,
project:
project
,
title:
issue_xss_title
)
...
...
@@ -147,6 +153,15 @@ RSpec.describe 'GFM autocomplete', :js do
expect
(
find_autocomplete_menu
).
to
have_text
(
'alert milestone'
)
end
it
'opens autocomplete menu for Labels when field starts with text with item escaping HTML characters'
do
fill_in
'Comment'
,
with:
'~'
wait_for_requests
expect
(
find_autocomplete_menu
).
to
have_text
(
'alert label'
)
end
end
describe
'autocomplete highlighting'
do
it
'auto-selects the first item when there is a query, and only for assignees with no query'
,
:aggregate_failures
do
fill_in
'Comment'
,
with:
':'
...
...
@@ -232,7 +247,7 @@ RSpec.describe 'GFM autocomplete', :js do
context
'if a selected value has special characters'
do
it
'wraps the result in double quotes'
do
fill_in
'Comment'
,
with:
"~
#{
label
.
title
[
0
]
}
"
fill_in
'Comment'
,
with:
"~
#{
label
.
title
[
0
..
2
]
}
"
find_highlighted_autocomplete_item
.
click
...
...
@@ -246,15 +261,9 @@ RSpec.describe 'GFM autocomplete', :js do
expect
(
find_field
(
'Comment'
).
value
).
to
have_text
(
'cartwheel_tone1'
)
end
it
'triggers autocomplete after selecting a quick action'
do
fill_in
'Comment'
,
with:
'/as'
find_highlighted_autocomplete_item
.
click
expect
(
find_autocomplete_menu
).
to
have_text
(
user2
.
username
)
end
context
'quick actions'
do
it
'does not limit quick actions autocomplete list to 5'
do
fill_in
'Comment'
,
with:
'/'
...
...
@@ -263,40 +272,15 @@ RSpec.describe 'GFM autocomplete', :js do
end
context
'labels'
do
it
'opens autocomplete menu for Labels when field starts with text with item escaping HTML characters'
do
label_xss_title
=
'alert label <img src=x onerror="alert(\'Hello xss\');" a'
create
(
:label
,
project:
project
,
title:
label_xss_title
)
fill_in
'Comment'
,
with:
'~'
wait_for_requests
expect
(
find_autocomplete_menu
).
to
have_text
(
'alert label'
)
end
it
'allows colons when autocompleting scoped labels'
do
create
(
:label
,
project:
project
,
title:
'scoped:label'
)
fill_in
'Comment'
,
with:
'~scoped:'
wait_for_requests
expect
(
find_autocomplete_menu
).
to
have_text
(
'scoped:label'
)
end
it
'allows colons when autocompleting scoped labels with double colons'
do
create
(
:label
,
project:
project
,
title:
'scoped::label'
)
fill_in
'Comment'
,
with:
'~scoped::'
wait_for_requests
expect
(
find_autocomplete_menu
).
to
have_text
(
'scoped::label'
)
end
it
'allows spaces when autocompleting multi-word labels'
do
create
(
:label
,
project:
project
,
title:
'Accepting merge requests'
)
fill_in
'Comment'
,
with:
'~Accepting merge'
wait_for_requests
...
...
@@ -304,20 +288,15 @@ RSpec.describe 'GFM autocomplete', :js do
expect
(
find_autocomplete_menu
).
to
have_text
(
'Accepting merge requests'
)
end
it
'only autocompletes the latest label'
do
create
(
:label
,
project:
project
,
title:
'Accepting merge requests'
)
create
(
:label
,
project:
project
,
title:
'Accepting job applicants'
)
fill_in
'Comment'
,
with:
'~Accepting merge requests foo bar ~Accepting job'
it
'only autocompletes the last label'
do
fill_in
'Comment'
,
with:
'~scoped:: foo bar ~Accepting merge'
wait_for_requests
expect
(
find_autocomplete_menu
).
to
have_text
(
'Accepting
job applican
ts'
)
expect
(
find_autocomplete_menu
).
to
have_text
(
'Accepting
merge reques
ts'
)
end
it
'does not autocomplete labels if no tilde is typed'
do
create
(
:label
,
project:
project
,
title:
'Accepting merge requests'
)
fill_in
'Comment'
,
with:
'Accepting merge'
wait_for_requests
...
...
@@ -376,13 +355,6 @@ RSpec.describe 'GFM autocomplete', :js do
it_behaves_like
'autocomplete suggestions'
end
context
'label'
do
let!
(
:object
)
{
label
}
let
(
:expected_body
)
{
object
.
title
}
it_behaves_like
'autocomplete suggestions'
end
context
'milestone'
do
let_it_be
(
:milestone_expired
)
{
create
(
:milestone
,
project:
project
,
due_date:
5
.
days
.
ago
)
}
let_it_be
(
:milestone_no_duedate
)
{
create
(
:milestone
,
project:
project
,
title:
'Foo - No due date'
)
}
...
...
@@ -486,6 +458,7 @@ RSpec.describe 'GFM autocomplete', :js do
end
end
context
'xss checks'
do
it
'opens autocomplete menu for Issues when field starts with text with item escaping HTML characters'
do
issue_xss_title
=
'This will execute alert<img src=x onerror=alert(2)<img src=x onerror=alert(1)>'
create
(
:issue
,
project:
project
,
title:
issue_xss_title
)
...
...
@@ -516,6 +489,15 @@ RSpec.describe 'GFM autocomplete', :js do
expect
(
find_tribute_autocomplete_menu
).
to
have_text
(
'alert milestone'
)
end
it
'opens autocomplete menu for Labels when field starts with text with item escaping HTML characters'
do
fill_in
'Comment'
,
with:
'~'
wait_for_requests
expect
(
find_tribute_autocomplete_menu
).
to
have_text
(
'alert label'
)
end
end
describe
'autocomplete highlighting'
do
it
'auto-selects the first item with query'
,
:aggregate_failures
do
fill_in
'Comment'
,
with:
':1'
...
...
@@ -592,7 +574,7 @@ RSpec.describe 'GFM autocomplete', :js do
context
'if a selected value has special characters'
do
it
'wraps the result in double quotes'
do
fill_in
'Comment'
,
with:
"~
#{
label
.
title
[
0
]
}
"
fill_in
'Comment'
,
with:
"~
#{
label
.
title
[
0
..
2
]
}
"
find_highlighted_tribute_autocomplete_menu
.
click
...
...
@@ -606,7 +588,9 @@ RSpec.describe 'GFM autocomplete', :js do
expect
(
find_field
(
'Comment'
).
value
).
to
have_text
(
'cartwheel_tone1'
)
end
end
context
'quick actions'
do
it
'autocompletes for quick actions'
do
fill_in
'Comment'
,
with:
'/as'
...
...
@@ -617,40 +601,15 @@ RSpec.describe 'GFM autocomplete', :js do
end
context
'labels'
do
it
'opens autocomplete menu for Labels when field starts with text with item escaping HTML characters'
do
label_xss_title
=
'alert label <img src=x onerror="alert(\'Hello xss\');" a'
create
(
:label
,
project:
project
,
title:
label_xss_title
)
fill_in
'Comment'
,
with:
'~'
wait_for_requests
expect
(
find_tribute_autocomplete_menu
).
to
have_text
(
'alert label'
)
end
it
'allows colons when autocompleting scoped labels'
do
create
(
:label
,
project:
project
,
title:
'scoped:label'
)
fill_in
'Comment'
,
with:
'~scoped:'
wait_for_requests
expect
(
find_tribute_autocomplete_menu
).
to
have_text
(
'scoped:label'
)
end
it
'allows colons when autocompleting scoped labels with double colons'
do
create
(
:label
,
project:
project
,
title:
'scoped::label'
)
fill_in
'Comment'
,
with:
'~scoped::'
wait_for_requests
expect
(
find_tribute_autocomplete_menu
).
to
have_text
(
'scoped::label'
)
end
it
'autocompletes multi-word labels'
do
create
(
:label
,
project:
project
,
title:
'Accepting merge requests'
)
fill_in
'Comment'
,
with:
'~Acceptingmerge'
wait_for_requests
...
...
@@ -658,24 +617,18 @@ RSpec.describe 'GFM autocomplete', :js do
expect
(
find_tribute_autocomplete_menu
).
to
have_text
(
'Accepting merge requests'
)
end
it
'only autocompletes the latest label'
do
create
(
:label
,
project:
project
,
title:
'documentation'
)
create
(
:label
,
project:
project
,
title:
'feature'
)
fill_in
'Comment'
,
with:
'~documentation foo bar ~feat'
it
'only autocompletes the last label'
do
fill_in
'Comment'
,
with:
'~scoped:: foo bar ~Acceptingmerge'
# Invoke autocompletion
find_field
(
'Comment'
).
native
.
send_keys
(
:right
)
wait_for_requests
expect
(
find_tribute_autocomplete_menu
).
to
have_text
(
'feature'
)
expect
(
find_tribute_autocomplete_menu
).
not_to
have_text
(
'documentation'
)
expect
(
find_tribute_autocomplete_menu
).
to
have_text
(
'Accepting merge requests'
)
end
it
'does not autocomplete labels if no tilde is typed'
do
create
(
:label
,
project:
project
,
title:
'documentation'
)
fill_in
'Comment'
,
with:
'document'
fill_in
'Comment'
,
with:
'Accepting'
wait_for_requests
...
...
@@ -733,13 +686,6 @@ RSpec.describe 'GFM autocomplete', :js do
it_behaves_like
'autocomplete suggestions'
end
context
'label'
do
let!
(
:object
)
{
label
}
let
(
:expected_body
)
{
object
.
title
}
it_behaves_like
'autocomplete suggestions'
end
context
'milestone'
do
let!
(
:object
)
{
create
(
:milestone
,
project:
project
)
}
let
(
:expected_body
)
{
object
.
to_reference
}
...
...
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