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
|
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'Navigation bar counter', :use_clean_rails_memory_store_caching, feature_category: :team_planning do
let(:user) { create(:user) }
let(:project) { create(:project, namespace: user.namespace) }
let(:issue) { create(:issue, project: project) }
let(:merge_request) { create(:merge_request, source_project: project) }
before do
issue.assignees = [user]
merge_request.update!(assignees: [user])
sign_in(user)
stub_feature_flags(limit_assigned_issues_count: false)
end
it 'reflects dashboard issues count' do
visit issues_path
expect_counters('issues', '1', n_("%d assigned issue", "%d assigned issues", 1) % 1)
issue.assignees = []
user.invalidate_cache_counts
travel_to(3.minutes.from_now) do
visit issues_path
expect_counters('issues', '0', n_("%d assigned issue", "%d assigned issues", 0) % 0)
end
end
context 'when :limit_assigned_issues_count FF is used' do
before do
stub_feature_flags(limit_assigned_issues_count: true)
end
it 'reflects dashboard issues count' do
visit issues_path
expect_counters('issues', '1', n_("%d assigned issue", "%d assigned issues", 1) % 1)
issue.update!(assignees: [])
Users::AssignedIssuesCountService.new(current_user: user).delete_cache
travel_to(3.minutes.from_now) do
visit issues_path
expect_counters('issues', '0', n_("%d assigned issue", "%d assigned issues", 0) % 0)
end
end
end
it 'reflects dashboard merge requests count', :js do
visit merge_requests_path
expect_counters('merge_requests', '1', n_("%d merge request", "%d merge requests", 1) % 1)
merge_request.update!(assignees: [])
user.invalidate_cache_counts
travel_to(3.minutes.from_now) do
visit merge_requests_path
expect_counters('merge_requests', '0', n_("%d merge request", "%d merge requests", 0) % 0)
end
end
def issues_path
issues_dashboard_path(assignee_username: user.username)
end
def merge_requests_path
merge_requests_dashboard_path(assignee_username: user.username)
end
def expect_counters(issuable_type, count, badge_label)
dashboard_count = find('.gl-tabs-nav li a.active')
expect(dashboard_count).to have_content(count)
expect(page).to have_css(".dashboard-shortcuts-#{issuable_type}", visible: :all, text: count)
expect(page).to have_css("span[aria-label='#{badge_label}']", visible: :all, text: count)
end
end
|