diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-09-16 15:09:32 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-09-16 15:09:32 +0000 |
commit | 6de7d2c195a8a7fa5702cafa4365f7a9fcac37cd (patch) | |
tree | e976130993f87a9d1e1f19cdab0ebaf218dfff69 /spec/features/markdown | |
parent | 591b0e86e3dbaa31b68340a14dc32859306a27b1 (diff) | |
download | gitlab-ce-6de7d2c195a8a7fa5702cafa4365f7a9fcac37cd.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/features/markdown')
-rw-r--r-- | spec/features/markdown/keyboard_shortcuts_spec.rb | 38 |
1 files changed, 28 insertions, 10 deletions
diff --git a/spec/features/markdown/keyboard_shortcuts_spec.rb b/spec/features/markdown/keyboard_shortcuts_spec.rb index ff028a0281f..81b1928658c 100644 --- a/spec/features/markdown/keyboard_shortcuts_spec.rb +++ b/spec/features/markdown/keyboard_shortcuts_spec.rb @@ -6,6 +6,10 @@ RSpec.describe 'Markdown keyboard shortcuts', :js do let_it_be(:project) { create(:project, :repository) } let_it_be(:user) { create(:user) } + let(:is_mac) { page.evaluate_script('navigator.platform').include?('Mac') } + let(:modifier_key) { is_mac ? :command : :control } + let(:other_modifier_key) { is_mac ? :control : :command } + before do project.add_developer(user) @@ -16,7 +20,7 @@ RSpec.describe 'Markdown keyboard shortcuts', :js do wait_for_requests end - shared_examples 'keyboard shortcuts for modifier key' do + shared_examples 'keyboard shortcuts' do it 'bolds text when <modifier>+B is pressed' do type_and_select('bold') @@ -57,17 +61,29 @@ RSpec.describe 'Markdown keyboard shortcuts', :js do end end - shared_examples 'keyboard shortcuts for implementation' do - context 'Ctrl key' do - let(:modifier_key) { :control } + shared_examples 'no side effects' do + it 'does not bold text when <other modifier>+B is pressed' do + type_and_select('bold') + + markdown_field.send_keys([@other_modifier_key, 'b']) + + expect(markdown_field.value).not_to eq('**bold**') + end + + it 'does not italicize text when <other modifier>+I is pressed' do + type_and_select('italic') + + markdown_field.send_keys([@other_modifier_key, 'i']) - it_behaves_like 'keyboard shortcuts for modifier key' + expect(markdown_field.value).not_to eq('_italic_') end - context '⌘ key' do - let(:modifier_key) { :command } + it 'does not link text when <other modifier>+K is pressed' do + type_and_select('link') + + markdown_field.send_keys([@other_modifier_key, 'k']) - it_behaves_like 'keyboard shortcuts for modifier key' + expect(markdown_field.value).not_to eq('[link](url)') end end @@ -76,7 +92,8 @@ RSpec.describe 'Markdown keyboard shortcuts', :js do let(:markdown_field) { find_field('Release notes') } let(:non_markdown_field) { find_field('Release title') } - it_behaves_like 'keyboard shortcuts for implementation' + it_behaves_like 'keyboard shortcuts' + it_behaves_like 'no side effects' end context 'Haml markdown editor' do @@ -84,7 +101,8 @@ RSpec.describe 'Markdown keyboard shortcuts', :js do let(:markdown_field) { find_field('Description') } let(:non_markdown_field) { find_field('Title') } - it_behaves_like 'keyboard shortcuts for implementation' + it_behaves_like 'keyboard shortcuts' + it_behaves_like 'no side effects' end def type_and_select(text) |