summaryrefslogtreecommitdiff
path: root/spec/support
diff options
context:
space:
mode:
Diffstat (limited to 'spec/support')
-rw-r--r--spec/support/fast_quarantine.rb1
-rw-r--r--spec/support/helpers/content_editor_helpers.rb8
-rw-r--r--spec/support/rspec_order_todo.yml1
-rw-r--r--spec/support/shared_examples/features/content_editor_shared_examples.rb25
-rw-r--r--spec/support/shared_examples/features/work_items_shared_examples.rb79
-rw-r--r--spec/support/shared_examples/lib/gitlab/json_logger_shared_examples.rb29
6 files changed, 109 insertions, 34 deletions
diff --git a/spec/support/fast_quarantine.rb b/spec/support/fast_quarantine.rb
index 18d4df887a3..b5ed1a2aa96 100644
--- a/spec/support/fast_quarantine.rb
+++ b/spec/support/fast_quarantine.rb
@@ -1,5 +1,6 @@
# frozen_string_literal: true
+return unless ENV['CI']
return if ENV['FAST_QUARANTINE'] == "false"
return if ENV['CI_MERGE_REQUEST_LABELS'].to_s.include?('pipeline:run-flaky-tests')
diff --git a/spec/support/helpers/content_editor_helpers.rb b/spec/support/helpers/content_editor_helpers.rb
index f19af0c9af8..83c18f8073f 100644
--- a/spec/support/helpers/content_editor_helpers.rb
+++ b/spec/support/helpers/content_editor_helpers.rb
@@ -17,14 +17,6 @@ module ContentEditorHelpers
find('.js-gfm-input').set content
end
- def expect_formatting_menu_to_be_visible
- expect(page).to have_css('[data-testid="formatting-bubble-menu"]')
- end
-
- def expect_formatting_menu_to_be_hidden
- expect(page).not_to have_css('[data-testid="formatting-bubble-menu"]')
- end
-
def expect_media_bubble_menu_to_be_visible
expect(page).to have_css('[data-testid="media-bubble-menu"]')
end
diff --git a/spec/support/rspec_order_todo.yml b/spec/support/rspec_order_todo.yml
index 724f45524d1..36118361546 100644
--- a/spec/support/rspec_order_todo.yml
+++ b/spec/support/rspec_order_todo.yml
@@ -6151,7 +6151,6 @@
- './spec/lib/gitlab/database/migrations/test_background_runner_spec.rb'
- './spec/lib/gitlab/database/migrations/test_batched_background_runner_spec.rb'
- './spec/lib/gitlab/database/no_cross_db_foreign_keys_spec.rb'
-- './spec/lib/gitlab/database/obsolete_ignored_columns_spec.rb'
- './spec/lib/gitlab/database/partitioning/detached_partition_dropper_spec.rb'
- './spec/lib/gitlab/database/partitioning_migration_helpers/backfill_partitioned_table_spec.rb'
- './spec/lib/gitlab/database/partitioning_migration_helpers/foreign_key_helpers_spec.rb'
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 7bcc82590ee..41114197ff5 100644
--- a/spec/support/shared_examples/features/content_editor_shared_examples.rb
+++ b/spec/support/shared_examples/features/content_editor_shared_examples.rb
@@ -27,27 +27,6 @@ RSpec.shared_examples 'edits content using the content editor' do
expect(page).to have_text('Typing text in the content editor')
end
- describe 'formatting bubble menu' do
- it 'shows a formatting bubble menu for a regular paragraph and headings' do
- switch_to_content_editor
-
- expect(page).to have_css(content_editor_testid)
-
- type_in_content_editor 'Typing text in the content editor'
- type_in_content_editor [:shift, :left]
-
- expect_formatting_menu_to_be_visible
-
- type_in_content_editor [:right, :right, :enter, '## Heading']
-
- expect_formatting_menu_to_be_hidden
-
- type_in_content_editor [:shift, :left]
-
- expect_formatting_menu_to_be_visible
- end
- end
-
describe 'creating and editing links' do
before do
switch_to_content_editor
@@ -319,14 +298,12 @@ RSpec.shared_examples 'edits content using the content editor' do
it 'displays correct media bubble menu for images', :js do
display_media_bubble_menu '[data-testid="content_editor_editablebox"] img[src]', 'dk.png'
- expect_formatting_menu_to_be_hidden
expect_media_bubble_menu_to_be_visible
end
it 'displays correct media bubble menu for video', :js do
display_media_bubble_menu '[data-testid="content_editor_editablebox"] video', 'video_sample.mp4'
- expect_formatting_menu_to_be_hidden
expect_media_bubble_menu_to_be_visible
end
end
@@ -367,7 +344,6 @@ RSpec.shared_examples 'edits content using the content editor' do
type_in_content_editor 'var a = 0'
type_in_content_editor [:shift, :left]
- expect_formatting_menu_to_be_hidden
expect(page).to have_css('[data-testid="code-block-bubble-menu"]')
end
@@ -618,7 +594,6 @@ RSpec.shared_examples 'inserts diagrams.net diagram using the content editor' do
it 'displays correct media bubble menu with edit diagram button' do
display_media_bubble_menu '[data-testid="content_editor_editablebox"] img[src]', 'diagram.drawio.svg'
- expect_formatting_menu_to_be_hidden
expect_media_bubble_menu_to_be_visible
click_edit_diagram_button
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 6d4d0a5dd0a..526a56e7dab 100644
--- a/spec/support/shared_examples/features/work_items_shared_examples.rb
+++ b/spec/support/shared_examples/features/work_items_shared_examples.rb
@@ -307,3 +307,82 @@ RSpec.shared_examples 'work items notifications' do
end
end
end
+
+RSpec.shared_examples 'work items todos' do
+ let(:todos_action_selector) { '[data-testid="work-item-todos-action"]' }
+ let(:todos_icon_selector) { '[data-testid="work-item-todos-icon"]' }
+ let(:header_section_selector) { '[data-testid="work-item-body"]' }
+
+ def toggle_todo_action
+ find(todos_action_selector).click
+ wait_for_requests
+ end
+
+ it 'adds item to the list' do
+ page.within(header_section_selector) do
+ expect(find(todos_action_selector)['aria-label']).to eq('Add a to do')
+
+ toggle_todo_action
+
+ expect(find(todos_action_selector)['aria-label']).to eq('Mark as done')
+ end
+
+ page.within ".header-content span[aria-label='#{_('Todos count')}']" do
+ expect(page).to have_content '1'
+ end
+ end
+
+ it 'marks a todo as done' do
+ page.within(header_section_selector) do
+ toggle_todo_action
+ toggle_todo_action
+ end
+
+ expect(find(todos_action_selector)['aria-label']).to eq('Add a to do')
+ expect(page).to have_selector(".header-content span[aria-label='#{_('Todos count')}']", visible: :hidden)
+ end
+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(:basketball_emoji_selector) { 'gl-emoji[data-name="basketball"]' }
+
+ def select_emoji
+ first(award_action_selector).click
+
+ wait_for_requests
+ end
+
+ it 'adds award to the work item' do
+ within(award_section_selector) do
+ select_emoji
+
+ expect(page).to have_selector(selected_award_action_selector)
+ expect(first(award_action_selector)).to have_content '1'
+ end
+ end
+
+ it 'removes award from work item' do
+ within(award_section_selector) do
+ select_emoji
+
+ expect(first(award_action_selector)).to have_content '1'
+
+ select_emoji
+
+ expect(first(award_action_selector)).to have_content '0'
+ end
+ end
+
+ it 'add custom award to the work item' do
+ within(award_section_selector) do
+ find(emoji_picker_action_selector).click
+ find(basketball_emoji_selector).click
+
+ expect(page).to have_selector(basketball_emoji_selector)
+ end
+ end
+end
diff --git a/spec/support/shared_examples/lib/gitlab/json_logger_shared_examples.rb b/spec/support/shared_examples/lib/gitlab/json_logger_shared_examples.rb
new file mode 100644
index 00000000000..8a5e8397c3d
--- /dev/null
+++ b/spec/support/shared_examples/lib/gitlab/json_logger_shared_examples.rb
@@ -0,0 +1,29 @@
+# frozen_string_literal: true
+
+RSpec.shared_examples 'a json logger' do |extra_params|
+ let(:now) { Time.now }
+ let(:correlation_id) { Labkit::Correlation::CorrelationId.current_id }
+
+ it 'formats strings' do
+ output = subject.format_message('INFO', now, 'test', 'Hello world')
+ data = Gitlab::Json.parse(output)
+
+ expect(data['severity']).to eq('INFO')
+ expect(data['time']).to eq(now.utc.iso8601(3))
+ expect(data['message']).to eq('Hello world')
+ expect(data['correlation_id']).to eq(correlation_id)
+ expect(data).to include(extra_params)
+ end
+
+ it 'formats hashes' do
+ output = subject.format_message('INFO', now, 'test', { hello: 1 })
+ data = Gitlab::Json.parse(output)
+
+ expect(data['severity']).to eq('INFO')
+ expect(data['time']).to eq(now.utc.iso8601(3))
+ expect(data['hello']).to eq(1)
+ expect(data['message']).to be_nil
+ expect(data['correlation_id']).to eq(correlation_id)
+ expect(data).to include(extra_params)
+ end
+end