-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixed emoji text matching with repeated symbols in a single line #2452
Changes from 5 commits
c98159e
0f90307
65cfb17
0cfef02
c05424e
2850ae1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,6 +31,12 @@ | |
|
||
var stub = null; | ||
|
||
// Disable autocomplete throttling so the tests can be run synchronously. | ||
var throttle = CKEDITOR.tools.buffers.throttle; | ||
sinon.stub( CKEDITOR.tools.buffers, 'throttle', function( minInterval, output, contextObj ) { | ||
return new throttle( 0, output, contextObj ); | ||
} ); | ||
|
||
var singleTests = { | ||
'test for custom emoji characters': function() { | ||
var editor = this.editors.divarea, | ||
|
@@ -46,18 +52,12 @@ | |
emojiTools.assertIsNullOrUndefined( autocomplete.model.query ); | ||
emojiTools.assertIsNullOrUndefined( autocomplete.model.data ); | ||
|
||
// Handle throttle in autocomplete which by defualt is 20ms; | ||
setTimeout( function() { | ||
resume( function() { | ||
bot.setHtmlWithSelection( '<p>foo :dagg^</p>' ); | ||
editor.editable().fire( 'keyup', new CKEDITOR.dom.event( {} ) ); | ||
assert.areSame( ':dagg', autocomplete.model.query, 'Model keeps wrong querry.' ); | ||
assert.areSame( 1, autocomplete.model.data.length, 'Emoji result contains more than one result.' ); | ||
objectAssert.areEqual( { id: ':dagger:', symbol: '🗡' }, autocomplete.model.data[ 0 ], 'Emoji result contains wrong result' ); | ||
autocomplete.close(); | ||
} ); | ||
}, 50 ); | ||
wait(); | ||
bot.setHtmlWithSelection( '<p>foo :dagg^</p>' ); | ||
editor.editable().fire( 'keyup', new CKEDITOR.dom.event( {} ) ); | ||
assert.areSame( ':dagg', autocomplete.model.query, 'Model keeps wrong querry.' ); | ||
assert.areSame( 1, autocomplete.model.data.length, 'Emoji result contains more than one result.' ); | ||
objectAssert.areEqual( { id: ':dagger:', symbol: '🗡' }, autocomplete.model.data[ 0 ], 'Emoji result contains wrong result' ); | ||
autocomplete.close(); | ||
} ); | ||
} | ||
}; | ||
|
@@ -136,15 +136,11 @@ | |
var autocomplete = editor._.emoji.autocomplete, | ||
queries = [ ':OK_HAND', ':ok_hand', ':OK_hand', ':ok_HAND', ':Ok_hanD', 'oK_HANd' ]; | ||
|
||
CKEDITOR.tools.array.forEach( queries, function( query, index ) { | ||
setTimeout( function() { | ||
resume(); | ||
bot.setHtmlWithSelection( '<p>foo ' + query + '^</p>' ); | ||
editor.editable().fire( 'keyup', new CKEDITOR.dom.event( {} ) ); | ||
CKEDITOR.tools.array.forEach( queries, function( query ) { | ||
bot.setHtmlWithSelection( '<p>foo ' + query + '^</p>' ); | ||
editor.editable().fire( 'keyup', new CKEDITOR.dom.event( {} ) ); | ||
|
||
objectAssert.areEqual( { id: ':ok_hand:', symbol: '👌' }, autocomplete.model.data[ 0 ], 'Emoji result contains wrong result' ); | ||
}, 50 * ( index + 1 ) ); | ||
wait(); | ||
objectAssert.areEqual( { id: ':ok_hand:', symbol: '👌' }, autocomplete.model.data[ 0 ], 'Emoji result contains wrong result' ); | ||
} ); | ||
} ); | ||
}, | ||
|
@@ -157,16 +153,10 @@ | |
|
||
bot.setHtmlWithSelection( '<p>foo:bug^</p>' ); | ||
|
||
// Delay assertions because of autocomplete throttle. | ||
setTimeout( function() { | ||
resume( function() { | ||
emojiTools.assertIsNullOrUndefined( autocomplete.model.query ); | ||
emojiTools.assertIsNullOrUndefined( autocomplete.model.data ); | ||
} ); | ||
}, 50 ); | ||
emojiTools.assertIsNullOrUndefined( autocomplete.model.query ); | ||
emojiTools.assertIsNullOrUndefined( autocomplete.model.data ); | ||
|
||
editable.fire( 'keyup', new CKEDITOR.dom.event( {} ) ); | ||
wait(); | ||
} ); | ||
}, | ||
|
||
|
@@ -177,16 +167,21 @@ | |
editable = editor.editable(); | ||
|
||
bot.setHtmlWithSelection( '<p>foo</p><p>:bug^</p>' ); | ||
editable.fire( 'keyup', new CKEDITOR.dom.event( {} ) ); | ||
objectAssert.areEqual( { id: ':bug:', symbol: '🐛' }, autocomplete.model.data[ 0 ], 'Emoji result contains wrong result' ); | ||
} ); | ||
}, | ||
|
||
// Delay assertions because of autocomplete throttle. | ||
setTimeout( function() { | ||
resume( function() { | ||
objectAssert.areEqual( { id: ':bug:', symbol: '🐛' }, autocomplete.model.data[ 0 ], 'Emoji result contains wrong result' ); | ||
} ); | ||
}, 50 ); | ||
// (#2394) | ||
'test emoji correctly matches repeated keywords': function( editor, bot ) { | ||
emojiTools.runAfterInstanceReady( editor, bot, function( editor, bot ) { | ||
var autocomplete = editor._.emoji.autocomplete; | ||
|
||
editable.fire( 'keyup', new CKEDITOR.dom.event( {} ) ); | ||
wait(); | ||
bot.setHtmlWithSelection( '<p>foo :collision :collision^</p>' ); | ||
editor.editable().fire( 'keyup', new CKEDITOR.dom.event( {} ) ); | ||
assert.areSame( ':collision', autocomplete.model.query, 'Model keeps wrong querry.' ); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There should be no dots at the end of assert msg. I can see that you might have take it from other asserts in this suite. What's interesting is that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. typo querry -> query |
||
assert.areSame( 1, autocomplete.model.data.length, 'Emoji result contains more than one result.' ); | ||
objectAssert.areEqual( { id: ':collision:', symbol: '💥' }, autocomplete.model.data[ 0 ], 'Emoji result contains wrong result' ); | ||
} ); | ||
} | ||
}; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<h2>Classic editor</h2> | ||
<div id="classic"></div> | ||
<h2>Inline editor</h2> | ||
<div id="inline" contenteditable="true"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just a detail, but since you're closing all of the tags in a single line, it would be nice to close this one as well. |
||
</div> | ||
|
||
<script> | ||
CKEDITOR.replace( 'classic' ); | ||
CKEDITOR.inline( 'inline' ); | ||
</script> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
@bender-tags: 4.11.0, bug, emoji, 2394 | ||
@bender-ckeditor-plugins: wysiwygarea, sourcearea, emoji | ||
@bender-ui: collapsed | ||
@bender-include: ../_helpers/tools.js | ||
|
||
## For both editors: | ||
|
||
1. Focus the editor. | ||
1. Type `:bu :bu`. | ||
|
||
### Expected | ||
|
||
Dropdown shows up with `:bug` (🐛) suggestion symbol. | ||
|
||
### Unexpected | ||
|
||
* Dropdown doesn't appear. | ||
* Dropdown contains different sugestion symbols. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If possible try to merge subsequent var statements.