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

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/features/dashboard/todos')
-rw-r--r--spec/features/dashboard/todos/todos_filtering_spec.rb43
-rw-r--r--spec/features/dashboard/todos/todos_spec.rb20
2 files changed, 63 insertions, 0 deletions
diff --git a/spec/features/dashboard/todos/todos_filtering_spec.rb b/spec/features/dashboard/todos/todos_filtering_spec.rb
index 990b2f18120..c38b3ab3e80 100644
--- a/spec/features/dashboard/todos/todos_filtering_spec.rb
+++ b/spec/features/dashboard/todos/todos_filtering_spec.rb
@@ -188,4 +188,47 @@ RSpec.describe 'Dashboard > User filters todos', :js, feature_category: :team_pl
end
end
end
+
+ describe 'todos tab count' do
+ context 'when filtering by open todos' do
+ it 'includes all open todos' do
+ expect(find('.js-todos-pending .gl-badge')).to have_content('3')
+ end
+
+ it 'only counts open todos that match when filtered by project' do
+ click_button 'Project'
+
+ within '.dropdown-menu-project' do
+ fill_in 'Search projects', with: project_1.full_name
+ click_link project_1.full_name
+ end
+
+ expect(find('.js-todos-pending .gl-badge')).to have_content('1')
+ end
+ end
+
+ context 'when filtering by done todos' do
+ before do
+ create(:todo, user: user_1, author: user_2, project: project_1, target: issue1, action: 1, state: :done)
+ create(:todo, user: user_1, author: user_1, project: project_2, target: merge_request, action: 2, state: :done)
+
+ visit dashboard_todos_path(state: 'done')
+ end
+
+ it 'includes all done todos' do
+ expect(find('.js-todos-done .gl-badge')).to have_content('2')
+ end
+
+ it 'only counts done todos that match when filtered by project' do
+ click_button 'Project'
+
+ within '.dropdown-menu-project' do
+ fill_in 'Search projects', with: project_1.full_name
+ click_link project_1.full_name
+ end
+
+ expect(find('.js-todos-done .gl-badge')).to have_content('1')
+ end
+ end
+ end
end
diff --git a/spec/features/dashboard/todos/todos_spec.rb b/spec/features/dashboard/todos/todos_spec.rb
index 5642d083673..ade7da0cb49 100644
--- a/spec/features/dashboard/todos/todos_spec.rb
+++ b/spec/features/dashboard/todos/todos_spec.rb
@@ -7,6 +7,7 @@ RSpec.describe 'Dashboard Todos', feature_category: :team_planning do
let_it_be(:user) { create(:user, :no_super_sidebar, username: 'john') }
let_it_be(:user2) { create(:user, :no_super_sidebar, username: 'diane') }
+ let_it_be(:user3) { create(:user) }
let_it_be(:author) { create(:user, :no_super_sidebar) }
let_it_be(:project) { create(:project, :public) }
let_it_be(:issue) { create(:issue, project: project, due_date: Date.today, title: "Fix bug") }
@@ -424,6 +425,25 @@ RSpec.describe 'Dashboard Todos', feature_category: :team_planning do
wait_for_requests
end
end
+
+ describe 'shows a count of todos' do
+ before do
+ allow(Todo).to receive(:default_per_page).and_return(1)
+ create_list(:todo, 2, :mentioned, user: user3, project: project, target: issue, author: author, state: :pending)
+ create_list(:todo, 2, :mentioned, user: user3, project: project, target: issue, author: author, state: :done)
+ sign_in(user3)
+ end
+
+ it 'displays a count of all pending todos' do
+ visit dashboard_todos_path
+ expect(find('.js-todos-pending')).to have_content('2')
+ end
+
+ it 'displays a count of all done todos' do
+ visit dashboard_todos_path(state: 'done')
+ expect(find('.js-todos-done')).to have_content('2')
+ end
+ end
end
context 'User has a Build Failed todo' do