summaryrefslogtreecommitdiff
path: root/spec/support/shared_examples/boards/multiple_issue_boards_shared_examples.rb
blob: 15590fd10dc77289e6bf5a7eca9959910421c2b6 (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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
# frozen_string_literal: true

RSpec.shared_examples 'multiple issue boards' do
  context 'authorized user' do
    before do
      parent.add_maintainer(user)

      login_as(user)

      visit boards_path
      wait_for_requests
    end

    it 'shows current board name' do
      page.within('.boards-switcher') do
        expect(page).to have_content(board.name)
      end
    end

    it 'shows a list of boards' do
      in_boards_switcher_dropdown do
        expect(page).to have_content(board.name)
        expect(page).to have_content(board2.name)
      end
    end

    it 'switches current board' do
      in_boards_switcher_dropdown do
        click_link board2.name
      end

      wait_for_requests

      page.within('.boards-switcher') do
        expect(page).to have_content(board2.name)
      end
    end

    it 'creates new board without detailed configuration' do
      in_boards_switcher_dropdown do
        click_button 'Create new board'
      end

      fill_in 'board-new-name', with: 'This is a new board'
      click_button 'Create board'
      wait_for_requests

      expect(page).to have_button('This is a new board')
    end

    it 'deletes board', quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/280554' do
      in_boards_switcher_dropdown do
        click_button 'Delete board'
      end

      expect(page).to have_content('Are you sure you want to delete this board?')
      click_button 'Delete'

      wait_for_requests

      in_boards_switcher_dropdown do
        expect(page).not_to have_content(board.name)
        expect(page).to have_content(board2.name)
      end
    end

    it 'adds a list to the none default board' do
      in_boards_switcher_dropdown do
        click_link board2.name
      end

      wait_for_requests

      page.within('.boards-switcher') do
        expect(page).to have_content(board2.name)
      end

      click_button 'Create list'

      click_button 'Select a label'

      page.choose(planning.title)

      click_button 'Add to board'

      wait_for_requests

      expect(page).to have_selector('.board', count: 3)

      in_boards_switcher_dropdown do
        click_link board.name
      end

      wait_for_requests

      expect(page).to have_selector('.board', count: 2)
    end

    it 'maintains sidebar state over board switch' do
      assert_boards_nav_active

      in_boards_switcher_dropdown do
        click_link board2.name
      end

      assert_boards_nav_active
    end

    it 'switches current board back' do
      in_boards_switcher_dropdown do
        click_link board.name
      end

      wait_for_requests

      page.within('.boards-switcher') do
        expect(page).to have_content(board.name)
      end
    end
  end

  context 'unauthorized user' do
    before do
      visit boards_path
      wait_for_requests
    end

    it 'does not show action links' do
      in_boards_switcher_dropdown do
        expect(page).not_to have_content('Create new board')
        expect(page).not_to have_content('Delete board')
      end
    end
  end

  def in_boards_switcher_dropdown
    find('.boards-switcher').click

    wait_for_requests

    dropdown_selector = '[data-testid="boards-selector"] .dropdown-menu'
    page.within(dropdown_selector) do
      yield
    end
  end

  def assert_boards_nav_active
    expect(find('.nav-sidebar .active .active')).to have_selector('a', text: 'Boards')
  end
end