File: board_sidebar_labels_examples.rb

package info (click to toggle)
gitlab 17.6.5-19
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 629,368 kB
  • sloc: ruby: 1,915,304; javascript: 557,307; sql: 60,639; xml: 6,509; sh: 4,567; makefile: 1,239; python: 406
file content (142 lines) | stat: -rw-r--r-- 4,667 bytes parent folder | download
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
# frozen_string_literal: true

RSpec.shared_context 'labels from nested groups and projects' do
  let_it_be(:group) { create(:group) }
  let_it_be(:group_label) { create(:group_label, group: group, name: 'Group label') }
  let_it_be(:project) { create(:project, group: group) }
  let_it_be(:project_label) { create(:label, project: project, name: 'Project label') }

  let_it_be(:subgroup) { create(:group, parent: group) }
  let_it_be(:subgroup_label) { create(:group_label, group: subgroup, name: 'Subgroup label') }
  let_it_be(:subproject) { create(:project, group: subgroup) }
  let_it_be(:subproject_label) { create(:label, project: subproject, name: 'Subproject label') }

  let_it_be(:subgroup2) { create(:group, parent: group) }
  let_it_be(:subgroup2_label) { create(:group_label, group: subgroup2, name: 'Subgroup2 label') }

  let_it_be(:maintainer) { create(:user) }

  let(:labels_select) { find("[data-testid='sidebar-labels']") }
  let(:labels_dropdown) { labels_select.find('[data-testid="dropdown-content"]') }

  let(:work_item_labels_select) { find_by_testid('work-item-labels') }
  let(:work_item_labels_dropdown) { work_item_labels_select.find('[data-testid="base-dropdown-menu"]') }

  before do
    group.add_maintainer(maintainer)

    sign_in(maintainer)
  end
end

RSpec.shared_examples "an issue from a subgroup's project is selected" do
  context 'when editing labels' do
    before do
      click_card_and_edit_label
    end

    it 'displays the label from the top-level group' do
      expect(labels_dropdown).to have_content(group_label.name)
    end

    it 'displays the label from the subgroup' do
      expect(labels_dropdown).to have_content(subgroup_label.name)
    end

    it 'displays the label from the project' do
      expect(labels_dropdown).to have_content(subproject_label.name)
    end

    it "does not display labels from the subgroup's siblings (project or group)" do
      aggregate_failures do
        expect(labels_dropdown).not_to have_content(project_label.name)
        expect(labels_dropdown).not_to have_content(subgroup2_label.name)
      end
    end
  end
end

RSpec.shared_examples 'an issue from a direct descendant project is selected' do
  context 'when editing labels' do
    before do
      click_card_and_edit_label
    end

    it 'displays the label from the top-level group' do
      expect(labels_dropdown).to have_content(group_label.name)
    end

    it 'displays the label from the project' do
      expect(labels_dropdown).to have_content(project_label.name)
    end

    it "does not display labels from the project's siblings or their descendents" do
      aggregate_failures do
        expect(labels_dropdown).not_to have_content(subgroup_label.name)
        expect(labels_dropdown).not_to have_content(subproject_label.name)
      end
    end
  end
end

RSpec.shared_examples "work item from a direct descendant project is selected" do
  context 'when editing labels' do
    before do
      click_card(card)

      within(work_item_labels_select) do
        click_button 'Edit'

        wait_for_requests
      end
    end

    it 'displays the label from the top-level group' do
      expect(work_item_labels_dropdown).to have_content(group_label.name)
    end

    it 'displays the label from the project' do
      expect(work_item_labels_dropdown).to have_content(project_label.name)
    end

    it "does not display labels from the project's siblings or their descendents" do
      aggregate_failures do
        expect(work_item_labels_dropdown).not_to have_content(subgroup_label.name)
        expect(work_item_labels_dropdown).not_to have_content(subproject_label.name)
      end
    end
  end
end

RSpec.shared_examples "work item from a subgroup's project is selected" do
  context 'when editing labels' do
    before do
      click_card(card)

      within(work_item_labels_select) do
        click_button 'Edit'

        wait_for_requests
      end
    end

    it 'displays the label from the top-level group' do
      expect(work_item_labels_dropdown).to have_content(group_label.name)
    end

    it 'displays the label from the subgroup' do
      expect(work_item_labels_dropdown).to have_content(subgroup_label.name)
    end

    it 'displays the label from the project' do
      expect(work_item_labels_dropdown).to have_content(subproject_label.name)
    end

    it "does not display labels from the subgroup's siblings (project or group)" do
      aggregate_failures do
        expect(work_item_labels_dropdown).not_to have_content(project_label.name)
        expect(work_item_labels_dropdown).not_to have_content(subgroup2_label.name)
      end
    end
  end
end