diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-06-20 13:43:29 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-06-20 13:43:29 +0300 |
commit | 3b1af5cc7ed2666ff18b718ce5d30fa5a2756674 (patch) | |
tree | 3bc4a40e0ee51ec27eabf917c537033c0c5b14d4 /spec/support/shared_examples/features | |
parent | 9bba14be3f2c211bf79e15769cd9b77bc73a13bc (diff) |
Add latest changes from gitlab-org/gitlab@16-1-stable-eev16.1.0-rc42
Diffstat (limited to 'spec/support/shared_examples/features')
7 files changed, 175 insertions, 41 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 41114197ff5..f70288168d7 100644 --- a/spec/support/shared_examples/features/content_editor_shared_examples.rb +++ b/spec/support/shared_examples/features/content_editor_shared_examples.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.shared_examples 'edits content using the content editor' do +RSpec.shared_examples 'edits content using the content editor' do |params = { with_expanded_references: true }| include ContentEditorHelpers let(:content_editor_testid) { '[data-testid="content-editor"] [contenteditable].ProseMirror' } @@ -413,6 +413,21 @@ RSpec.shared_examples 'edits content using the content editor' do end end + describe 'rendering with initial content' do + it 'renders correctly with table as initial content' do + textarea = find 'textarea' + textarea.send_keys "\n\n" + textarea.send_keys "| First Header | Second Header |\n" + textarea.send_keys "|--------------|---------------|\n" + textarea.send_keys "| Content from cell 1 | Content from cell 2 |\n\n" + textarea.send_keys "Content below table" + + switch_to_content_editor + + expect(page).not_to have_text('An error occurred') + end + end + describe 'pasting text' do before do switch_to_content_editor @@ -493,6 +508,28 @@ RSpec.shared_examples 'edits content using the content editor' do type_in_content_editor :enter end + if params[:with_expanded_references] + describe 'when expanding an issue reference' do + it 'displays full reference name' do + new_issue = create(:issue, project: project, title: 'Brand New Issue') + + type_in_content_editor "##{new_issue.iid}+s " + + expect(page).to have_text('Brand New Issue') + end + end + + describe 'when expanding an MR reference' do + it 'displays full reference name' do + new_mr = create(:merge_request, source_project: project, source_branch: 'branch-2', title: 'Brand New MR') + + type_in_content_editor "!#{new_mr.iid}+s " + + expect(page).to have_text('Brand New') + end + end + end + it 'shows suggestions for members with descriptions' do type_in_content_editor '@a' diff --git a/spec/support/shared_examples/features/milestone_showing_shared_examples.rb b/spec/support/shared_examples/features/milestone_showing_shared_examples.rb new file mode 100644 index 00000000000..7bcaf1fe64a --- /dev/null +++ b/spec/support/shared_examples/features/milestone_showing_shared_examples.rb @@ -0,0 +1,54 @@ +# frozen_string_literal: true + +RSpec.shared_examples 'milestone with interactive markdown task list items in description' do + let(:markdown) do + <<-MARKDOWN.strip_heredoc + This is a task list: + + - [ ] Incomplete task list item 1 + - [x] Complete task list item 1 + - [ ] Incomplete task list item 2 + - [x] Complete task list item 2 + - [ ] Incomplete task list item 3 + - [ ] Incomplete task list item 4 + MARKDOWN + end + + before do + milestone.update!(description: markdown) + end + + it 'renders task list in description' do + visit milestone_path + + wait_for_requests + + within('ul.task-list') do + expect(page).to have_selector('li.task-list-item', count: 6) + expect(page).to have_selector('li.task-list-item input.task-list-item-checkbox[checked]', count: 2) + end + end + + it 'allows interaction with task list item checkboxes' do + visit milestone_path + + wait_for_requests + + within('ul.task-list') do + within('li.task-list-item', text: 'Incomplete task list item 1') do + find('input.task-list-item-checkbox').click + wait_for_requests + end + + expect(page).to have_selector('li.task-list-item', count: 6) + page.all('li.task-list-item input.task-list-item-checkbox') { |element| expect(element).to be_checked } + + # After page reload, the task list items should still be checked + visit milestone_path + + wait_for_requests + + expect(page).to have_selector('ul input[type="checkbox"][checked]', count: 3) + end + end +end diff --git a/spec/support/shared_examples/features/runners_shared_examples.rb b/spec/support/shared_examples/features/runners_shared_examples.rb index 7edf306183e..54a4db0e81d 100644 --- a/spec/support/shared_examples/features/runners_shared_examples.rb +++ b/spec/support/shared_examples/features/runners_shared_examples.rb @@ -127,7 +127,7 @@ RSpec.shared_examples 'pauses, resumes and deletes a runner' do it 'deletes a runner' do within_modal do - click_on 'Delete runner' + click_on 'Permanently delete runner' end expect(page.find('.gl-toast')).to have_text(/Runner .+ deleted/) @@ -201,13 +201,13 @@ RSpec.shared_examples 'submits edit runner form' do describe 'runner header', :js do it 'contains the runner id' do - expect(page).to have_content("Runner ##{runner.id} created") + expect(page).to have_content("##{runner.id} (#{runner.short_sha})") end end context 'when a runner is updated', :js do before do - find('[data-testid="runner-field-description"] input').set('new-runner-description') + fill_in s_('Runners|Runner description'), with: 'new-runner-description' click_on _('Save changes') wait_for_requests @@ -232,7 +232,7 @@ RSpec.shared_examples 'creates runner and shows register page' do before do fill_in s_('Runners|Runner description'), with: 'runner-foo' fill_in s_('Runners|Tags'), with: 'tag1' - click_on _('Submit') + click_on s_('Runners|Create runner') wait_for_requests end diff --git a/spec/support/shared_examples/features/sidebar/sidebar_labels_shared_examples.rb b/spec/support/shared_examples/features/sidebar/sidebar_labels_shared_examples.rb index a332fdec963..8ebec19a884 100644 --- a/spec/support/shared_examples/features/sidebar/sidebar_labels_shared_examples.rb +++ b/spec/support/shared_examples/features/sidebar/sidebar_labels_shared_examples.rb @@ -47,7 +47,8 @@ RSpec.shared_examples 'labels sidebar widget' do end end - it 'adds first label by pressing enter when search' do + it 'adds first label by pressing enter when search', + quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/414877' do within(labels_widget) do page.within('[data-testid="value-wrapper"]') do expect(page).not_to have_content(development.name) diff --git a/spec/support/shared_examples/features/variable_list_shared_examples.rb b/spec/support/shared_examples/features/variable_list_shared_examples.rb index 1211c9d19e6..3a91b798bbd 100644 --- a/spec/support/shared_examples/features/variable_list_shared_examples.rb +++ b/spec/support/shared_examples/features/variable_list_shared_examples.rb @@ -32,7 +32,7 @@ RSpec.shared_examples 'variable list' do page.within('[data-testid="ci-variable-table"]') do expect(find(".js-ci-variable-row:nth-child(1) td[data-label='#{s_('CiVariables|Key')}']").text).to eq('key') - expect(find(".js-ci-variable-row:nth-child(1) td[data-label='#{s_('CiVariables|Options')}']")).to have_content(s_('CiVariables|Protected')) + expect(find(".js-ci-variable-row:nth-child(1) td[data-label='#{s_('CiVariables|Attributes')}']")).to have_content(s_('CiVariables|Protected')) end end @@ -47,7 +47,7 @@ RSpec.shared_examples 'variable list' do page.within('[data-testid="ci-variable-table"]') do expect(find(".js-ci-variable-row:nth-child(1) td[data-label='#{s_('CiVariables|Key')}']").text).to eq('key') - expect(find(".js-ci-variable-row:nth-child(1) td[data-label='#{s_('CiVariables|Options')}']")).not_to have_content(s_('CiVariables|Masked')) + expect(find(".js-ci-variable-row:nth-child(1) td[data-label='#{s_('CiVariables|Attributes')}']")).not_to have_content(s_('CiVariables|Masked')) end end @@ -116,8 +116,8 @@ RSpec.shared_examples 'variable list' do wait_for_requests page.within('[data-testid="ci-variable-table"]') do - expect(find(".js-ci-variable-row:nth-child(1) td[data-label='#{s_('CiVariables|Options')}']")).to have_content(s_('CiVariables|Protected')) - expect(find(".js-ci-variable-row:nth-child(1) td[data-label='#{s_('CiVariables|Options')}']")).not_to have_content(s_('CiVariables|Masked')) + expect(find(".js-ci-variable-row:nth-child(1) td[data-label='#{s_('CiVariables|Attributes')}']")).to have_content(s_('CiVariables|Protected')) + expect(find(".js-ci-variable-row:nth-child(1) td[data-label='#{s_('CiVariables|Attributes')}']")).not_to have_content(s_('CiVariables|Masked')) end end @@ -145,7 +145,7 @@ RSpec.shared_examples 'variable list' do end page.within('[data-testid="ci-variable-table"]') do - expect(find(".js-ci-variable-row:nth-child(1) td[data-label='#{s_('CiVariables|Options')}']")).to have_content(s_('CiVariables|Masked')) + expect(find(".js-ci-variable-row:nth-child(1) td[data-label='#{s_('CiVariables|Attributes')}']")).to have_content(s_('CiVariables|Masked')) end end @@ -170,15 +170,13 @@ RSpec.shared_examples 'variable list' do expect(find('[data-testid="alert-danger"]').text).to have_content('(key) has already been taken') end - it 'prevents a variable to be added if no values are provided when a variable is set to masked' do + it 'allows variable to be added even if no value is provided' do click_button('Add variable') page.within('#add-ci-variable') do find('[data-testid="pipeline-form-ci-variable-key"] input').set('empty_mask_key') - find('[data-testid="ci-variable-protected-checkbox"]').click - find('[data-testid="ci-variable-masked-checkbox"]').click - expect(find_button('Add variable', disabled: true)).to be_present + expect(find_button('Add variable', disabled: false)).to be_present end end @@ -186,7 +184,7 @@ RSpec.shared_examples 'variable list' do click_button('Add variable') fill_variable('empty_mask_key', '???', protected: true, masked: true) do - expect(page).to have_content('This variable can not be masked') + expect(page).to have_content('This variable value does not meet the masking requirements.') expect(find_button('Add variable', disabled: true)).to be_present end end diff --git a/spec/support/shared_examples/features/wiki/user_updates_wiki_page_shared_examples.rb b/spec/support/shared_examples/features/wiki/user_updates_wiki_page_shared_examples.rb index c1e4185e058..91cacaf9209 100644 --- a/spec/support/shared_examples/features/wiki/user_updates_wiki_page_shared_examples.rb +++ b/spec/support/shared_examples/features/wiki/user_updates_wiki_page_shared_examples.rb @@ -6,9 +6,12 @@ RSpec.shared_examples 'User updates wiki page' do include WikiHelpers + let(:diagramsnet_url) { 'https://embed.diagrams.net' } before do sign_in(user) + allow(Gitlab::CurrentSettings).to receive(:diagramsnet_enabled).and_return(true) + allow(Gitlab::CurrentSettings).to receive(:diagramsnet_url).and_return(diagramsnet_url) end context 'when wiki is empty', :js do @@ -149,7 +152,7 @@ RSpec.shared_examples 'User updates wiki page' do end end - it_behaves_like 'edits content using the content editor' + it_behaves_like 'edits content using the content editor', { with_expanded_references: false } it_behaves_like 'inserts diagrams.net diagram using the content editor' it_behaves_like 'autocompletes items' end @@ -245,7 +248,7 @@ RSpec.shared_examples 'User updates wiki page' do click_on 'Save changes' expect(page).to have_content('The form contains the following error:') - expect(page).to have_content('Content is too long (11 Bytes). The maximum size is 10 Bytes.') + expect(page).to have_content('Content is too long (11 B). The maximum size is 10 B.') end end end diff --git a/spec/support/shared_examples/features/work_items_shared_examples.rb b/spec/support/shared_examples/features/work_items_shared_examples.rb index 526a56e7dab..128bd28410c 100644 --- a/spec/support/shared_examples/features/work_items_shared_examples.rb +++ b/spec/support/shared_examples/features/work_items_shared_examples.rb @@ -32,6 +32,7 @@ end RSpec.shared_examples 'work items comments' do |type| let(:form_selector) { '[data-testid="work-item-add-comment"]' } + let(:edit_button) { '[data-testid="edit-work-item-note"]' } let(:textarea_selector) { '[data-testid="work-item-add-comment"] #work-item-add-or-edit-comment' } let(:is_mac) { page.evaluate_script('navigator.platform').include?('Mac') } let(:modifier_key) { is_mac ? :command : :control } @@ -53,21 +54,48 @@ RSpec.shared_examples 'work items comments' do |type| end end + it 'successfully updates existing comments' do + set_comment + click_button "Comment" + wait_for_all_requests + + find(edit_button).click + send_keys(" updated") + click_button "Save comment" + + wait_for_all_requests + + page.within(".main-notes-list") do + expect(page).to have_content "Test comment updated" + end + end + context 'for work item note actions signed in user with developer role' do + let_it_be(:owner) { create(:user) } + + before do + project.add_owner(owner) + end + it 'shows work item note actions' do set_comment - click_button "Comment" - + send_keys([modifier_key, :enter]) wait_for_requests page.within(".main-notes-list") do + expect(page).to have_content comment + end + + page.within('.timeline-entry.note.note-wrapper.note-comment:last-child') do expect(page).to have_selector('[data-testid="work-item-note-actions"]') - find('[data-testid="work-item-note-actions"]', match: :first).click + find('[data-testid="work-item-note-actions"]').click expect(page).to have_selector('[data-testid="copy-link-action"]') - expect(page).not_to have_selector('[data-testid="assign-note-action"]') + expect(page).to have_selector('[data-testid="assign-note-action"]') + expect(page).to have_selector('[data-testid="delete-note-action"]') + expect(page).to have_selector('[data-testid="edit-work-item-note"]') end end end @@ -148,7 +176,7 @@ RSpec.shared_examples 'work items assignees' do find("body").click wait_for_requests - expect(work_item.assignees).to include(user) + expect(work_item.reload.assignees).to include(user) end end @@ -278,7 +306,6 @@ RSpec.shared_examples 'work items comment actions for guest users' do expect(page).to have_selector('[data-testid="work-item-note-actions"]') find('[data-testid="work-item-note-actions"]', match: :first).click - expect(page).to have_selector('[data-testid="copy-link-action"]') expect(page).not_to have_selector('[data-testid="assign-note-action"]') end @@ -344,42 +371,56 @@ RSpec.shared_examples 'work items todos' do end RSpec.shared_examples 'work items award emoji' do - let(:award_section_selector) { '[data-testid="work-item-award-list"]' } - let(:award_action_selector) { '[data-testid="award-button"]' } - let(:selected_award_action_selector) { '[data-testid="award-button"].selected' } - let(:emoji_picker_action_selector) { '[data-testid="emoji-picker"]' } + let(:award_section_selector) { '.awards' } + let(:award_button_selector) { '[data-testid="award-button"]' } + let(:selected_award_button_selector) { '[data-testid="award-button"].selected' } + let(:emoji_picker_button_selector) { '[data-testid="emoji-picker"]' } let(:basketball_emoji_selector) { 'gl-emoji[data-name="basketball"]' } + let(:tooltip_selector) { '.gl-tooltip' } def select_emoji - first(award_action_selector).click + page.within(award_section_selector) do + page.first(award_button_selector).click + end wait_for_requests end - it 'adds award to the work item' do + before do + emoji_upvote + end + + it 'adds award to the work item for current user' do + select_emoji + within(award_section_selector) do - select_emoji + expect(page).to have_selector(selected_award_button_selector) - expect(page).to have_selector(selected_award_action_selector) - expect(first(award_action_selector)).to have_content '1' + # As the user2 has already awarded the `:thumbsup:` emoji, the emoji count will be 2 + expect(first(award_button_selector)).to have_content '2' end + expect(page.find(tooltip_selector)).to have_content("You and John reacted with :thumbsup:") end - it 'removes award from work item' do - within(award_section_selector) do - select_emoji + it 'removes award from work item for current user' do + select_emoji - expect(first(award_action_selector)).to have_content '1' + page.within(award_section_selector) do + # As the user2 has already awarded the `:thumbsup:` emoji, the emoji count will be 2 + expect(first(award_button_selector)).to have_content '2' + end - select_emoji + select_emoji - expect(first(award_action_selector)).to have_content '0' + page.within(award_section_selector) do + # The emoji count will be back to 1 + expect(first(award_button_selector)).to have_content '1' end end - it 'add custom award to the work item' do + it 'add custom award to the work item for current user' do within(award_section_selector) do - find(emoji_picker_action_selector).click + find(emoji_picker_button_selector).click find(basketball_emoji_selector).click expect(page).to have_selector(basketball_emoji_selector) |