diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-07-07 00:08:58 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-07-07 00:08:58 +0300 |
commit | f71db8c5f0619b92c3fa65f202e62f8c0947e0d6 (patch) | |
tree | 332c07e82a4b15b4436526ecfc65b77356a54e19 /spec/frontend_integration/snippets | |
parent | 8280fa786e71c14d39b1ae80e93f251f3685286a (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend_integration/snippets')
-rw-r--r-- | spec/frontend_integration/snippets/snippets_notes_spec.js | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/spec/frontend_integration/snippets/snippets_notes_spec.js b/spec/frontend_integration/snippets/snippets_notes_spec.js new file mode 100644 index 00000000000..fdd3289bf58 --- /dev/null +++ b/spec/frontend_integration/snippets/snippets_notes_spec.js @@ -0,0 +1,62 @@ +import $ from 'jquery'; +import axios from '~/lib/utils/axios_utils'; +import initGFMInput from '~/behaviors/markdown/gfm_auto_complete'; +import initDeprecatedNotes from '~/init_deprecated_notes'; +import { loadHTMLFixture } from 'helpers/fixtures'; + +describe('Integration Snippets notes', () => { + beforeEach(async () => { + loadHTMLFixture('snippets/show.html'); + + // Check if we have to Load GFM Input + const $gfmInputs = $('.js-gfm-input:not(.js-gfm-input-initialized)'); + initGFMInput($gfmInputs); + + initDeprecatedNotes(); + }); + + describe('emoji autocomplete', () => { + const findNoteTextarea = () => document.getElementById('note_note'); + const findAtViewEmojiMenu = () => document.getElementById('at-view-58'); + const findAtwhoResult = () => { + return Array.from(findAtViewEmojiMenu().querySelectorAll('li')).map((x) => + x.innerText.trim(), + ); + }; + const fillNoteTextarea = (val) => { + const textarea = findNoteTextarea(); + + textarea.dispatchEvent(new Event('focus')); + textarea.value = val; + textarea.dispatchEvent(new Event('input')); + textarea.dispatchEvent(new Event('click')); + }; + + it.each([ + [ + ':heart', + ['heart', 'heart decoration', 'heart with arrow', 'heart with ribbon', 'heart_exclamation'], + ], + [':red', ['red apple', 'red_car', 'red_circle', 'credit card', 'tired face']], + [ + ':circle', + // TODO: https://gitlab.com/gitlab-org/gitlab/-/issues/347549 + // These autocompleted results aren't very good. The autocompletion should be improved. + [ + 'circled ideograph accept', + 'circled ideograph advantage', + 'circled ideograph congratulation', + 'circled ideograph secret', + 'circled latin capital letter m', + ], + ], + ])('shows a correct list of matching emojis when user enters %s', async (input, expected) => { + fillNoteTextarea(input); + + await axios.waitForAll(); + + const result = findAtwhoResult(); + expect(result).toEqual(expected); + }); + }); +}); |