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

user_visits_board_spec.rb « boards « features « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 7fe32557d6a03ae06c882a70ab4f2ba4933b026e (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
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe 'User visits issue boards', :js do
  using RSpec::Parameterized::TableSyntax

  let_it_be(:group) { create_default(:group, :public) }
  let_it_be(:project) { create_default(:project, :public, group: group) }

  # TODO use 'let' when rspec-parameterized supports it.
  # https://gitlab.com/gitlab-org/gitlab/-/issues/329746
  label_name1 = 'foobar'
  label_name2 = 'in dev'
  assignee_username = 'root'
  issue_with_label1 = "issue with label1"
  issue_with_label2 = "issue with label2"
  issue_with_assignee = "issue with assignee"
  issue_with_milestone = "issue with milestone"
  issue_with_all_filters = "issue with all filters"

  let_it_be(:label1) { create(:group_label, group: group, name: label_name1) }
  let_it_be(:label2) { create(:group_label, group: group, name: label_name2) }
  let_it_be(:assignee) { create_default(:group_member, :maintainer, user: create(:user, username: assignee_username), group: group ).user }
  let_it_be(:milestone) { create_default(:milestone, project: project, start_date: Date.today - 1, due_date: 7.days.from_now) }

  before_all do
    create_default(:issue, project: project, title: issue_with_label1, labels: [label1])
    create_default(:issue, project: project, title: issue_with_label2, labels: [label2])
    create_default(:issue, project: project, title: issue_with_assignee, assignees: [assignee])
    create_default(:issue, project: project, title: issue_with_milestone, milestone: milestone)
    create_default(:issue, project: project, title: issue_with_all_filters, labels: [label1, label2], assignees: [assignee], milestone: milestone)
  end

  shared_examples "visiting board path with search params" do
    where(:params, :expected_issues) do
      { "label_name" => [label_name1] }              | [issue_with_label1, issue_with_all_filters]
      { "label_name" => [label_name2] }              | [issue_with_label2, issue_with_all_filters]
      { "label_name" => [label_name1, label_name2] } | [issue_with_all_filters]
      { "assignee_username" => assignee_username }   | [issue_with_assignee, issue_with_all_filters]
      { "milestone_title" => '#started' }            | [issue_with_milestone, issue_with_all_filters]
      { "label_name" => [label_name1, label_name2], "assignee_username" => assignee_username } | [issue_with_all_filters]
    end

    with_them do
      before do
        visit board_path

        wait_for_requests
      end

      it 'displays all issues satisfiying filter params and correctly sets url params' do
        expect(page).to have_current_path(board_path)

        page.assert_selector('[data-testid="board_card"]', count: expected_issues.length)
        expected_issues.each { |issue_title| expect(page).to have_link issue_title }
      end
    end
  end

  context "project boards" do
    let_it_be(:board) { create_default(:board, project: project) }
    let_it_be(:backlog_list) { create_default(:backlog_list, board: board) }

    let(:board_path) { project_boards_path(project, params) }

    include_examples "visiting board path with search params"
  end

  context "group boards" do
    let_it_be(:board) { create_default(:board, group: group) }
    let_it_be(:backlog_list) { create_default(:backlog_list, board: board) }

    let(:board_path) { group_boards_path(group, params) }

    include_examples 'visiting board path with search params'
  end
end