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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Léo-Paul Géneau
gitlab-ce
Commits
5e63566b
Commit
5e63566b
authored
Oct 17, 2017
by
Mike Greiling
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add InputHelper rspec helper to simulate non-BMP character input
parent
585a2ab5
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
45 additions
and
5 deletions
+45
-5
app/assets/javascripts/test_utils/index.js
app/assets/javascripts/test_utils/index.js
+2
-0
app/assets/javascripts/test_utils/simulate_input.js
app/assets/javascripts/test_utils/simulate_input.js
+23
-0
spec/features/issues/gfm_autocomplete_spec.rb
spec/features/issues/gfm_autocomplete_spec.rb
+12
-5
spec/support/input_helper.rb
spec/support/input_helper.rb
+8
-0
No files found.
app/assets/javascripts/test_utils/index.js
View file @
5e63566b
import
'
core-js/es6/map
'
;
import
'
core-js/es6/map
'
;
import
'
core-js/es6/set
'
;
import
'
core-js/es6/set
'
;
import
simulateDrag
from
'
./simulate_drag
'
;
import
simulateDrag
from
'
./simulate_drag
'
;
import
simulateInput
from
'
./simulate_input
'
;
// Export to global space for rspec to use
// Export to global space for rspec to use
window
.
simulateDrag
=
simulateDrag
;
window
.
simulateDrag
=
simulateDrag
;
window
.
simulateInput
=
simulateInput
;
app/assets/javascripts/test_utils/simulate_input.js
0 → 100644
View file @
5e63566b
function
triggerEvents
(
input
)
{
input
.
dispatchEvent
(
new
Event
(
'
keydown
'
));
input
.
dispatchEvent
(
new
Event
(
'
keypress
'
));
input
.
dispatchEvent
(
new
Event
(
'
input
'
));
input
.
dispatchEvent
(
new
Event
(
'
keyup
'
));
}
export
default
function
simulateInput
(
target
,
text
)
{
const
input
=
document
.
querySelector
(
target
);
if
(
!
input
||
!
input
.
matches
(
'
textarea, input
'
))
{
return
false
;
}
if
(
text
.
length
>
0
)
{
Array
.
prototype
.
forEach
.
call
(
text
,
(
char
)
=>
{
input
.
value
+=
char
;
triggerEvents
(
input
);
});
}
else
{
triggerEvents
();
}
return
true
;
}
spec/features/issues/gfm_autocomplete_spec.rb
View file @
5e63566b
require
'rails_helper'
require
'rails_helper'
feature
'GFM autocomplete'
,
:js
do
feature
'GFM autocomplete'
,
:js
do
include
InputHelper
let
(
:user
)
{
create
(
:user
,
name:
'💃speciąl someone💃'
,
username:
'someone.special'
)
}
let
(
:user
)
{
create
(
:user
,
name:
'💃speciąl someone💃'
,
username:
'someone.special'
)
}
let
(
:project
)
{
create
(
:project
)
}
let
(
:project
)
{
create
(
:project
)
}
let
(
:label
)
{
create
(
:label
,
project:
project
,
title:
'special+'
)
}
let
(
:label
)
{
create
(
:label
,
project:
project
,
title:
'special+'
)
}
...
@@ -14,10 +16,14 @@ feature 'GFM autocomplete', :js do
...
@@ -14,10 +16,14 @@ feature 'GFM autocomplete', :js do
wait_for_requests
wait_for_requests
end
end
after
do
execute_script
(
"localStorage.clear();"
);
end
it
'updates issue descripton with GFM reference'
do
it
'updates issue descripton with GFM reference'
do
find
(
'.issuable-edit'
).
click
find
(
'.issuable-edit'
).
click
find
(
'#issue-description'
).
native
.
send_keys
(
"@
#{
user
.
name
[
0
...
3
]
}
"
)
simulateInput
(
'#issue-description'
,
"@
#{
user
.
name
[
0
...
3
]
}
"
)
find
(
'.atwho-view .cur'
).
click
find
(
'.atwho-view .cur'
).
click
...
@@ -100,7 +106,7 @@ feature 'GFM autocomplete', :js do
...
@@ -100,7 +106,7 @@ feature 'GFM autocomplete', :js do
it
'includes items for assignee dropdowns with non-ASCII characters in name'
do
it
'includes items for assignee dropdowns with non-ASCII characters in name'
do
page
.
within
'.timeline-content-form'
do
page
.
within
'.timeline-content-form'
do
find
(
'#note-body'
).
native
.
send_keys
(
''
)
find
(
'#note-body'
).
native
.
send_keys
(
''
)
find
(
'#note-body'
).
native
.
send_keys
(
"@
#{
user
.
name
[
0
...
8
]
}
"
)
simulateInput
(
'#note-body'
,
"@
#{
user
.
name
[
0
...
8
]
}
"
);
end
end
expect
(
page
).
to
have_selector
(
'.atwho-container'
)
expect
(
page
).
to
have_selector
(
'.atwho-container'
)
...
@@ -128,7 +134,7 @@ feature 'GFM autocomplete', :js do
...
@@ -128,7 +134,7 @@ feature 'GFM autocomplete', :js do
note
=
find
(
'#note-body'
)
note
=
find
(
'#note-body'
)
page
.
within
'.timeline-content-form'
do
page
.
within
'.timeline-content-form'
do
note
.
native
.
send_keys
(
''
)
note
.
native
.
send_keys
(
''
)
note
.
native
.
send_keys
(
"~
#{
label
.
title
[
0
]
}
"
)
simulateInput
(
'#note-body'
,
"~
#{
label
.
title
[
0
]
}
"
)
note
.
click
note
.
click
end
end
...
@@ -195,7 +201,7 @@ feature 'GFM autocomplete', :js do
...
@@ -195,7 +201,7 @@ feature 'GFM autocomplete', :js do
note
=
find
(
'#note-body'
)
note
=
find
(
'#note-body'
)
page
.
within
'.timeline-content-form'
do
page
.
within
'.timeline-content-form'
do
note
.
native
.
send_keys
(
''
)
note
.
native
.
send_keys
(
''
)
note
.
native
.
send_keys
(
":cartwheel"
)
note
.
native
.
send_keys
(
":cartwheel
_
"
)
note
.
click
note
.
click
end
end
...
@@ -228,7 +234,8 @@ feature 'GFM autocomplete', :js do
...
@@ -228,7 +234,8 @@ feature 'GFM autocomplete', :js do
note
.
click
note
.
click
end
end
find
(
'.atwho-view li'
,
text:
'/assign'
).
native
.
send_keys
(
:tab
)
find
(
'.atwho-view li'
,
text:
'/assign'
)
note
.
native
.
send_keys
(
:tab
)
user_item
=
find
(
'.atwho-view li'
,
text:
user
.
username
)
user_item
=
find
(
'.atwho-view li'
,
text:
user
.
username
)
expect
(
user_item
).
to
have_content
(
user
.
username
)
expect
(
user_item
).
to
have_content
(
user
.
username
)
...
...
spec/support/input_helper.rb
0 → 100644
View file @
5e63566b
# see app/assets/javascripts/test_utils/simulate_input.js
module
InputHelper
def
simulateInput
(
selector
,
input
=
''
)
evaluate_script
(
"window.simulateInput(
#{
selector
.
to_json
}
,
#{
input
.
to_json
}
);"
)
end
end
\ No newline at end of file
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