diff options
Diffstat (limited to 'spec/support/shared_examples/features/content_editor_shared_examples.rb')
-rw-r--r-- | spec/support/shared_examples/features/content_editor_shared_examples.rb | 71 |
1 files changed, 53 insertions, 18 deletions
diff --git a/spec/support/shared_examples/features/content_editor_shared_examples.rb b/spec/support/shared_examples/features/content_editor_shared_examples.rb index 6bfb60c3f34..d0b2d0c9cae 100644 --- a/spec/support/shared_examples/features/content_editor_shared_examples.rb +++ b/spec/support/shared_examples/features/content_editor_shared_examples.rb @@ -449,6 +449,9 @@ RSpec.shared_examples 'edits content using the content editor' do |params = { before do switch_to_content_editor + type_in_content_editor [modifier_key, 'a'] + type_in_content_editor :delete + type_in_content_editor "Some **rich** _text_ ~~content~~ [link](https://gitlab.com)" type_in_content_editor [modifier_key, 'a'] @@ -488,6 +491,26 @@ RSpec.shared_examples 'edits content using the content editor' do |params = { end end + it 'pastes raw markdown with formatting when pasting inside a markdown code block' do + type_in_content_editor '```md' + type_in_content_editor :enter + type_in_content_editor [modifier_key, 'v'] + + page.within content_editor_testid do + expect(page).to have_selector('pre', text: 'Some **rich** _text_ ~~content~~ [link](https://gitlab.com)') + end + end + + it 'pastes raw markdown without formatting when pasting inside a plaintext code block' do + type_in_content_editor '```' + type_in_content_editor :enter + type_in_content_editor [modifier_key, 'v'] + + page.within content_editor_testid do + expect(page).to have_selector('pre', text: 'Some rich text content link') + end + end + it 'pastes raw text without formatting, stripping whitespaces, if shift + ctrl + v is pressed' do type_in_content_editor " Some **rich**" type_in_content_editor :enter @@ -570,7 +593,7 @@ RSpec.shared_examples 'edits content using the content editor' do |params = { type_in_content_editor '/assign' expect(find(suggestions_dropdown)).to have_text('/assign') - send_keys [:arrow_down, :enter] + send_keys :enter expect(page).to have_text('/assign @') end @@ -579,7 +602,7 @@ RSpec.shared_examples 'edits content using the content editor' do |params = { type_in_content_editor '/label' expect(find(suggestions_dropdown)).to have_text('/label') - send_keys [:arrow_down, :enter] + send_keys :enter expect(page).to have_text('/label ~') end @@ -588,10 +611,23 @@ RSpec.shared_examples 'edits content using the content editor' do |params = { type_in_content_editor '/milestone' expect(find(suggestions_dropdown)).to have_text('/milestone') - send_keys [:arrow_down, :enter] + send_keys :enter expect(page).to have_text('/milestone %') end + + it 'scrolls selected item into view when navigating with keyboard' do + type_in_content_editor '/' + + expect(find(suggestions_dropdown)).to have_text('label') + + expect(dropdown_scroll_top).to be 0 + + send_keys :arrow_up + + expect(dropdown_scroll_top).to be > 100 + end + end it 'shows suggestions for members with descriptions' do @@ -603,7 +639,18 @@ RSpec.shared_examples 'edits content using the content editor' do |params = { type_in_content_editor 'bc' - send_keys [:arrow_down, :enter] + send_keys :enter + + expect(page).not_to have_css(suggestions_dropdown) + expect(page).to have_text('@abc123') + end + + it 'allows selecting element with tab key' do + type_in_content_editor '@abc' + + expect(find(suggestions_dropdown)).to have_text('abc123') + + send_keys :tab expect(page).not_to have_css(suggestions_dropdown) expect(page).to have_text('@abc123') @@ -701,11 +748,11 @@ RSpec.shared_examples 'edits content using the content editor' do |params = { expect(find(suggestions_dropdown)).to have_text('😃 smiley') expect(find(suggestions_dropdown)).to have_text('😸 smile_cat') - send_keys [:arrow_down, :enter] + send_keys :enter expect(page).not_to have_css(suggestions_dropdown) - expect(page).to have_text('😃') + expect(page).to have_text('😄') end it 'doesn\'t show suggestions dropdown if there are no suggestions to show' do @@ -718,18 +765,6 @@ RSpec.shared_examples 'edits content using the content editor' do |params = { expect(page).not_to have_css(suggestions_dropdown) end - it 'scrolls selected item into view when navigating with keyboard' do - type_in_content_editor ':' - - expect(find(suggestions_dropdown)).to have_text('grinning') - - expect(dropdown_scroll_top).to be 0 - - send_keys :arrow_up - - expect(dropdown_scroll_top).to be > 100 - end - def dropdown_scroll_top evaluate_script("document.querySelector('#{suggestions_dropdown}').scrollTop") end |