Welcome to mirror list, hosted at ThFree Co, Russian Federation.

broadcast_messages_spec.rb « admin « features « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: b89ebc34d6a89adecbc2144fb145af9ad6ef9dc4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe 'Admin Broadcast Messages', :js, feature_category: :onboarding do
  context 'when creating and editing' do
    it 'previews, creates and edits a broadcast message' do
      admin = create(:admin)
      sign_in(admin)
      gitlab_enable_admin_mode_sign_in(admin)

      # create
      visit admin_broadcast_messages_path

      click_button('Add new message')

      page.within(preview_container) do
        expect(page).to have_content('Your message here')
      end

      fill_in 'Message', with: 'test message'

      wait_for_requests

      page.within(preview_container) do
        expect(page).to have_content('test message')
      end

      click_button 'Add broadcast message'

      wait_for_requests

      page.within(first_message_container) do
        expect(page).to have_content('test message')
      end

      # edit
      page.within(first_message_container) do
        find('[data-testid="edit-message"]').click
      end

      wait_for_requests

      expect(find('[data-testid="message-input"]').value).to eq('test message')

      fill_in 'Message', with: 'changed test message'

      wait_for_requests

      page.within(preview_container) do
        expect(page).to have_content('changed test message')
      end

      click_button 'Update broadcast message'

      wait_for_requests

      page.within(first_message_container) do
        expect(page).to have_content('changed test message')
      end
    end

    def preview_container
      find('[data-testid="preview-broadcast-message"]')
    end

    def first_message_container
      find('[data-testid="message-row"]', match: :first)
    end
  end
end