diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-06-20 14:10:13 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-06-20 14:10:13 +0300 |
commit | 0ea3fcec397b69815975647f5e2aa5fe944a8486 (patch) | |
tree | 7979381b89d26011bcf9bdc989a40fcc2f1ed4ff /spec/support/shared_examples/features | |
parent | 72123183a20411a36d607d70b12d57c484394c8e (diff) |
Add latest changes from gitlab-org/gitlab@15-1-stable-eev15.1.0-rc42
Diffstat (limited to 'spec/support/shared_examples/features')
8 files changed, 92 insertions, 40 deletions
diff --git a/spec/support/shared_examples/features/2fa_shared_examples.rb b/spec/support/shared_examples/features/2fa_shared_examples.rb index 94c91556ea7..44f30c32472 100644 --- a/spec/support/shared_examples/features/2fa_shared_examples.rb +++ b/spec/support/shared_examples/features/2fa_shared_examples.rb @@ -2,6 +2,7 @@ RSpec.shared_examples 'hardware device for 2fa' do |device_type| include Spec::Support::Helpers::Features::TwoFactorHelpers + include Spec::Support::Helpers::ModalHelpers def register_device(device_type, **kwargs) case device_type.downcase @@ -18,7 +19,6 @@ RSpec.shared_examples 'hardware device for 2fa' do |device_type| let(:user) { create(:user) } before do - stub_feature_flags(bootstrap_confirmation_modals: false) gitlab_sign_in(user) user.update_attribute(:otp_required_for_login, true) end @@ -59,7 +59,7 @@ RSpec.shared_examples 'hardware device for 2fa' do |device_type| expect(page).to have_content(first_device.name) expect(page).to have_content(second_device.name) - accept_confirm { click_on 'Delete', match: :first } + accept_gl_confirm(button_text: 'Delete') { click_on 'Delete', match: :first } expect(page).to have_content('Successfully deleted') expect(page.body).not_to have_content(first_device.name) diff --git a/spec/support/shared_examples/features/access_tokens_shared_examples.rb b/spec/support/shared_examples/features/access_tokens_shared_examples.rb index 215d9d3e5a8..c162ed36881 100644 --- a/spec/support/shared_examples/features/access_tokens_shared_examples.rb +++ b/spec/support/shared_examples/features/access_tokens_shared_examples.rb @@ -51,7 +51,7 @@ RSpec.shared_examples 'resource access tokens creation disallowed' do |error_mes it 'does not show access token creation form' do visit resource_settings_access_tokens_path - expect(page).not_to have_selector('#new_resource_access_token') + expect(page).not_to have_selector('#js-new-access-token-form') end it 'shows access token creation disabled text' do @@ -135,7 +135,7 @@ RSpec.shared_examples 'inactive resource access tokens' do |no_active_tokens_tex it 'allows revocation of an active token' do visit resource_settings_access_tokens_path - accept_confirm { click_on 'Revoke' } + accept_gl_confirm(button_text: 'Revoke') { click_on 'Revoke' } expect(page).to have_selector('.settings-message') expect(no_resource_access_tokens_message).to have_text(no_active_tokens_text) @@ -156,7 +156,7 @@ RSpec.shared_examples 'inactive resource access tokens' do |no_active_tokens_tex it 'allows revocation of an active token' do visit resource_settings_access_tokens_path - accept_confirm { click_on 'Revoke' } + accept_gl_confirm(button_text: 'Revoke') { click_on 'Revoke' } expect(page).to have_selector('.settings-message') expect(no_resource_access_tokens_message).to have_text(no_active_tokens_text) diff --git a/spec/support/shared_examples/features/cascading_settings_shared_examples.rb b/spec/support/shared_examples/features/cascading_settings_shared_examples.rb index 395f4fc54e0..cb80751ff49 100644 --- a/spec/support/shared_examples/features/cascading_settings_shared_examples.rb +++ b/spec/support/shared_examples/features/cascading_settings_shared_examples.rb @@ -6,7 +6,8 @@ RSpec.shared_examples 'a cascading setting' do visit group_path page.within form_group_selector do - find(setting_field_selector).check + enable_setting.call + find('[data-testid="enforce-for-all-subgroups-checkbox"]').check end diff --git a/spec/support/shared_examples/features/container_registry_shared_examples.rb b/spec/support/shared_examples/features/container_registry_shared_examples.rb index 6aa7e6e6270..784f82fdda1 100644 --- a/spec/support/shared_examples/features/container_registry_shared_examples.rb +++ b/spec/support/shared_examples/features/container_registry_shared_examples.rb @@ -19,8 +19,7 @@ RSpec.shared_examples 'rejecting tags destruction for an importing repository on expect(find('.modal .modal-title')).to have_content _('Remove tag') find('.modal .modal-footer .btn-danger').click - alert_body = find('.gl-alert-body') - expect(alert_body).to have_content('Tags temporarily cannot be marked for deletion. Please try again in a few minutes.') - expect(alert_body).to have_link('More details', href: help_page_path('user/packages/container_registry/index', anchor: 'tags-temporarily-cannot-be-marked-for-deletion')) + expect(page).to have_content('Tags temporarily cannot be marked for deletion. Please try again in a few minutes.') + expect(page).to have_link('More details', href: help_page_path('user/packages/container_registry/index', anchor: 'tags-temporarily-cannot-be-marked-for-deletion')) end end 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 c93d8e3d511..591f7973454 100644 --- a/spec/support/shared_examples/features/content_editor_shared_examples.rb +++ b/spec/support/shared_examples/features/content_editor_shared_examples.rb @@ -21,6 +21,31 @@ RSpec.shared_examples 'edits content using the content editor' do end end + describe 'code block' do + before do + visit(profile_preferences_path) + + find('.syntax-theme').choose('Dark') + + wait_for_requests + + page.go_back + refresh + + click_button 'Edit rich text' + end + + it 'applies theme classes to code blocks' do + expect(page).not_to have_css('.content-editor-code-block.code.highlight.dark') + + find(content_editor_testid).send_keys [:enter, :enter] + find(content_editor_testid).send_keys '```js ' # trigger input rule + find(content_editor_testid).send_keys 'var a = 0' + + expect(page).to have_css('.content-editor-code-block.code.highlight.dark') + end + end + describe 'code block bubble menu' do it 'shows a code block bubble menu for a code block' do find(content_editor_testid).send_keys [:enter, :enter] @@ -51,4 +76,49 @@ RSpec.shared_examples 'edits content using the content editor' do expect(find('[data-testid="code-block-bubble-menu"]')).to have_text('Custom (nomnoml)') end end + + describe 'mermaid diagram' do + before do + find(content_editor_testid).send_keys [:enter, :enter] + + find(content_editor_testid).send_keys '```mermaid ' + find(content_editor_testid).send_keys ['graph TD;', :enter, ' JohnDoe12 --> HelloWorld34'] + end + + it 'renders and updates the diagram correctly in a sandboxed iframe' do + iframe = find(content_editor_testid).find('iframe') + expect(iframe['src']).to include('/-/sandbox/mermaid') + + within_frame(iframe) do + expect(find('svg').text).to include('JohnDoe12') + expect(find('svg').text).to include('HelloWorld34') + end + + expect(iframe['height'].to_i).to be > 100 + + find(content_editor_testid).send_keys [:enter, ' JaneDoe34 --> HelloWorld56'] + + within_frame(iframe) do + page.has_content?('JaneDoe34') + + expect(find('svg').text).to include('JaneDoe34') + expect(find('svg').text).to include('HelloWorld56') + end + end + + it 'toggles the diagram when preview button is clicked' do + find('[data-testid="preview-diagram"]').click + + expect(find(content_editor_testid)).not_to have_selector('iframe') + + find('[data-testid="preview-diagram"]').click + + iframe = find(content_editor_testid).find('iframe') + + within_frame(iframe) do + expect(find('svg').text).to include('JohnDoe12') + expect(find('svg').text).to include('HelloWorld34') + end + end + end end diff --git a/spec/support/shared_examples/features/issuables_user_dropdown_behaviors_shared_examples.rb b/spec/support/shared_examples/features/issuables_user_dropdown_behaviors_shared_examples.rb deleted file mode 100644 index 1848b4fffd9..00000000000 --- a/spec/support/shared_examples/features/issuables_user_dropdown_behaviors_shared_examples.rb +++ /dev/null @@ -1,23 +0,0 @@ -# frozen_string_literal: true - -RSpec.shared_examples 'issuable user dropdown behaviors' do - include FilteredSearchHelpers - - before do - issuable # ensure we have at least one issuable - sign_in(user_in_dropdown) - end - - %w[author assignee].each do |dropdown| - describe "#{dropdown} dropdown", :js do - it 'only includes members of the project/group' do - visit issuables_path - - filtered_search.set("#{dropdown}:=") - - expect(find("#js-dropdown-#{dropdown} .filter-dropdown")).to have_content(user_in_dropdown.name) - expect(find("#js-dropdown-#{dropdown} .filter-dropdown")).not_to have_content(user_not_in_dropdown.name) - end - 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 d9460c7b8f1..52f3fd60c07 100644 --- a/spec/support/shared_examples/features/runners_shared_examples.rb +++ b/spec/support/shared_examples/features/runners_shared_examples.rb @@ -35,11 +35,11 @@ RSpec.shared_examples 'shows and resets runner registration token' do it 'has a registration token' do click_on 'Click to reveal' - expect(page.find('[data-testid="token-value"] input').value).to have_content(registration_token) + expect(page.find_field('token-value').value).to have_content(registration_token) end describe 'reset registration token' do - let!(:old_registration_token) { find('[data-testid="token-value"] input').value } + let!(:old_registration_token) { find_field('token-value').value } before do click_on 'Reset registration token' @@ -62,7 +62,7 @@ RSpec.shared_examples 'shows and resets runner registration token' do end end -RSpec.shared_examples 'shows no runners' do +RSpec.shared_examples 'shows no runners registered' do it 'shows counts with 0' do expect(page).to have_text "Online runners 0" expect(page).to have_text "Offline runners 0" @@ -70,13 +70,19 @@ RSpec.shared_examples 'shows no runners' do end it 'shows "no runners" message' do - expect(page).to have_text 'No runners found' + expect(page).to have_text s_('Runners|Get started with runners') + end +end + +RSpec.shared_examples 'shows no runners found' do + it 'shows "no runners" message' do + expect(page).to have_text s_('Runners|No results found') end end RSpec.shared_examples 'shows runner in list' do it 'does not show empty state' do - expect(page).not_to have_content 'No runners found' + expect(page).not_to have_content s_('Runners|Get started with runners') end it 'shows runner row' do diff --git a/spec/support/shared_examples/features/sidebar_shared_examples.rb b/spec/support/shared_examples/features/sidebar_shared_examples.rb index af3ea0600a2..77334db6a36 100644 --- a/spec/support/shared_examples/features/sidebar_shared_examples.rb +++ b/spec/support/shared_examples/features/sidebar_shared_examples.rb @@ -109,9 +109,8 @@ RSpec.shared_examples 'issue boards sidebar' do wait_for_requests expect(page).to have_content( - _('Only project members with at least' \ - ' Reporter role can view or be' \ - ' notified about this issue.') + _('Only project members with at least the Reporter role, the author, and assignees' \ + ' can view or be notified about this issue.') ) end end |