summaryrefslogtreecommitdiff
path: root/spec/features/todos
diff options
context:
space:
mode:
Diffstat (limited to 'spec/features/todos')
-rw-r--r--spec/features/todos/target_state_spec.rb65
-rw-r--r--spec/features/todos/todos_filtering_spec.rb153
-rw-r--r--spec/features/todos/todos_sorting_spec.rb97
-rw-r--r--spec/features/todos/todos_spec.rb378
4 files changed, 0 insertions, 693 deletions
diff --git a/spec/features/todos/target_state_spec.rb b/spec/features/todos/target_state_spec.rb
deleted file mode 100644
index 32fa88a2b21..00000000000
--- a/spec/features/todos/target_state_spec.rb
+++ /dev/null
@@ -1,65 +0,0 @@
-require 'rails_helper'
-
-feature 'Todo target states', feature: true do
- let(:user) { create(:user) }
- let(:author) { create(:user) }
- let(:project) { create(:project, visibility_level: Gitlab::VisibilityLevel::PUBLIC) }
-
- before do
- login_as user
- end
-
- scenario 'on a closed issue todo has closed label' do
- issue_closed = create(:issue, state: 'closed')
- create_todo issue_closed
- visit dashboard_todos_path
-
- page.within '.todos-list' do
- expect(page).to have_content('Closed')
- end
- end
-
- scenario 'on an open issue todo does not have an open label' do
- issue_open = create(:issue)
- create_todo issue_open
- visit dashboard_todos_path
-
- page.within '.todos-list' do
- expect(page).not_to have_content('Open')
- end
- end
-
- scenario 'on a merged merge request todo has merged label' do
- mr_merged = create(:merge_request, :simple, author: user, state: 'merged')
- create_todo mr_merged
- visit dashboard_todos_path
-
- page.within '.todos-list' do
- expect(page).to have_content('Merged')
- end
- end
-
- scenario 'on a closed merge request todo has closed label' do
- mr_closed = create(:merge_request, :simple, author: user, state: 'closed')
- create_todo mr_closed
- visit dashboard_todos_path
-
- page.within '.todos-list' do
- expect(page).to have_content('Closed')
- end
- end
-
- scenario 'on an open merge request todo does not have an open label' do
- mr_open = create(:merge_request, :simple, author: user)
- create_todo mr_open
- visit dashboard_todos_path
-
- page.within '.todos-list' do
- expect(page).not_to have_content('Open')
- end
- end
-
- def create_todo(target)
- create(:todo, :mentioned, user: user, project: project, target: target, author: author)
- end
-end
diff --git a/spec/features/todos/todos_filtering_spec.rb b/spec/features/todos/todos_filtering_spec.rb
deleted file mode 100644
index bbfa4e08379..00000000000
--- a/spec/features/todos/todos_filtering_spec.rb
+++ /dev/null
@@ -1,153 +0,0 @@
-require 'spec_helper'
-
-describe 'Dashboard > User filters todos', feature: true, js: true do
- let(:user_1) { create(:user, username: 'user_1', name: 'user_1') }
- let(:user_2) { create(:user, username: 'user_2', name: 'user_2') }
-
- let(:project_1) { create(:empty_project, name: 'project_1') }
- let(:project_2) { create(:empty_project, name: 'project_2') }
-
- let(:issue) { create(:issue, title: 'issue', project: project_1) }
-
- let!(:merge_request) { create(:merge_request, source_project: project_2, title: 'merge_request') }
-
- before do
- create(:todo, user: user_1, author: user_2, project: project_1, target: issue, action: 1)
- create(:todo, user: user_1, author: user_1, project: project_2, target: merge_request, action: 2)
-
- project_1.team << [user_1, :developer]
- project_2.team << [user_1, :developer]
- login_as(user_1)
- visit dashboard_todos_path
- end
-
- it 'filters by project' do
- click_button 'Project'
- within '.dropdown-menu-project' do
- fill_in 'Search projects', with: project_1.name_with_namespace
- click_link project_1.name_with_namespace
- end
-
- wait_for_requests
-
- expect(page).to have_content project_1.name_with_namespace
- expect(page).not_to have_content project_2.name_with_namespace
- end
-
- context "Author filter" do
- it 'filters by author' do
- click_button 'Author'
-
- within '.dropdown-menu-author' do
- fill_in 'Search authors', with: user_1.name
- click_link user_1.name
- end
-
- wait_for_requests
-
- expect(find('.todos-list')).to have_content 'merge request'
- expect(find('.todos-list')).not_to have_content 'issue'
- end
-
- it "shows only authors of existing todos" do
- click_button 'Author'
-
- within '.dropdown-menu-author' do
- # It should contain two users + "Any Author"
- expect(page).to have_selector('.dropdown-menu-user-link', count: 3)
- expect(page).to have_content(user_1.name)
- expect(page).to have_content(user_2.name)
- end
- end
-
- it "shows only authors of existing done todos" do
- user_3 = create :user
- user_4 = create :user
- create(:todo, user: user_1, author: user_3, project: project_1, target: issue, action: 1, state: :done)
- create(:todo, user: user_1, author: user_4, project: project_2, target: merge_request, action: 2, state: :done)
-
- project_1.team << [user_3, :developer]
- project_2.team << [user_4, :developer]
-
- visit dashboard_todos_path(state: 'done')
-
- click_button 'Author'
-
- within '.dropdown-menu-author' do
- # It should contain two users + "Any Author"
- expect(page).to have_selector('.dropdown-menu-user-link', count: 3)
- expect(page).to have_content(user_3.name)
- expect(page).to have_content(user_4.name)
- expect(page).not_to have_content(user_1.name)
- expect(page).not_to have_content(user_2.name)
- end
- end
- end
-
- it 'filters by type' do
- click_button 'Type'
- within '.dropdown-menu-type' do
- click_link 'Issue'
- end
-
- wait_for_requests
-
- expect(find('.todos-list')).to have_content issue.to_reference
- expect(find('.todos-list')).not_to have_content merge_request.to_reference
- end
-
- describe 'filter by action' do
- before do
- create(:todo, :build_failed, user: user_1, author: user_2, project: project_1)
- create(:todo, :marked, user: user_1, author: user_2, project: project_1, target: issue)
- end
-
- it 'filters by Assigned' do
- filter_action('Assigned')
-
- expect_to_see_action(:assigned)
- end
-
- it 'filters by Mentioned' do
- filter_action('Mentioned')
-
- expect_to_see_action(:mentioned)
- end
-
- it 'filters by Added' do
- filter_action('Added')
-
- expect_to_see_action(:marked)
- end
-
- it 'filters by Pipelines' do
- filter_action('Pipelines')
-
- expect_to_see_action(:build_failed)
- end
-
- def filter_action(name)
- click_button 'Action'
- within '.dropdown-menu-action' do
- click_link name
- end
-
- wait_for_requests
- end
-
- def expect_to_see_action(action_name)
- action_names = {
- assigned: ' assigned you ',
- mentioned: ' mentioned ',
- marked: ' added a todo for ',
- build_failed: ' build failed for '
- }
-
- action_name_text = action_names.delete(action_name)
- expect(find('.todos-list')).to have_content action_name_text
- action_names.each_value do |other_action_text|
- expect(find('.todos-list')).not_to have_content other_action_text
- end
- end
- end
-end
diff --git a/spec/features/todos/todos_sorting_spec.rb b/spec/features/todos/todos_sorting_spec.rb
deleted file mode 100644
index 4d5bd476301..00000000000
--- a/spec/features/todos/todos_sorting_spec.rb
+++ /dev/null
@@ -1,97 +0,0 @@
-require 'spec_helper'
-
-describe "Dashboard > User sorts todos", feature: true do
- let(:user) { create(:user) }
- let(:project) { create(:empty_project) }
-
- let(:label_1) { create(:label, title: 'label_1', project: project, priority: 1) }
- let(:label_2) { create(:label, title: 'label_2', project: project, priority: 2) }
- let(:label_3) { create(:label, title: 'label_3', project: project, priority: 3) }
-
- before { project.team << [user, :developer] }
-
- context 'sort options' do
- let(:issue_1) { create(:issue, title: 'issue_1', project: project) }
- let(:issue_2) { create(:issue, title: 'issue_2', project: project) }
- let(:issue_3) { create(:issue, title: 'issue_3', project: project) }
- let(:issue_4) { create(:issue, title: 'issue_4', project: project) }
-
- let!(:merge_request_1) { create(:merge_request, source_project: project, title: "merge_request_1") }
-
- before do
- create(:todo, user: user, project: project, target: issue_4, created_at: 5.hours.ago)
- create(:todo, user: user, project: project, target: issue_2, created_at: 4.hours.ago)
- create(:todo, user: user, project: project, target: issue_3, created_at: 3.hours.ago)
- create(:todo, user: user, project: project, target: issue_1, created_at: 2.hours.ago)
- create(:todo, user: user, project: project, target: merge_request_1, created_at: 1.hour.ago)
-
- merge_request_1.labels << label_1
- issue_3.labels << label_1
- issue_2.labels << label_3
- issue_1.labels << label_2
-
- login_as(user)
- visit dashboard_todos_path
- end
-
- it "sorts with oldest created todos first" do
- click_link "Last created"
-
- results_list = page.find('.todos-list')
- expect(results_list.all('p')[0]).to have_content("merge_request_1")
- expect(results_list.all('p')[1]).to have_content("issue_1")
- expect(results_list.all('p')[2]).to have_content("issue_3")
- expect(results_list.all('p')[3]).to have_content("issue_2")
- expect(results_list.all('p')[4]).to have_content("issue_4")
- end
-
- it "sorts with newest created todos first" do
- click_link "Oldest created"
-
- results_list = page.find('.todos-list')
- expect(results_list.all('p')[0]).to have_content("issue_4")
- expect(results_list.all('p')[1]).to have_content("issue_2")
- expect(results_list.all('p')[2]).to have_content("issue_3")
- expect(results_list.all('p')[3]).to have_content("issue_1")
- expect(results_list.all('p')[4]).to have_content("merge_request_1")
- end
-
- it "sorts by label priority" do
- click_link "Label priority"
-
- results_list = page.find('.todos-list')
- expect(results_list.all('p')[0]).to have_content("issue_3")
- expect(results_list.all('p')[1]).to have_content("merge_request_1")
- expect(results_list.all('p')[2]).to have_content("issue_1")
- expect(results_list.all('p')[3]).to have_content("issue_2")
- expect(results_list.all('p')[4]).to have_content("issue_4")
- end
- end
-
- context 'issues and merge requests' do
- let(:issue_1) { create(:issue, id: 10000, title: 'issue_1', project: project) }
- let(:issue_2) { create(:issue, id: 10001, title: 'issue_2', project: project) }
- let(:merge_request_1) { create(:merge_request, id: 10000, title: 'merge_request_1', source_project: project) }
-
- before do
- issue_1.labels << label_1
- issue_2.labels << label_2
-
- create(:todo, user: user, project: project, target: issue_1)
- create(:todo, user: user, project: project, target: issue_2)
- create(:todo, user: user, project: project, target: merge_request_1)
-
- login_as(user)
- visit dashboard_todos_path
- end
-
- it "doesn't mix issues and merge requests label priorities" do
- click_link "Label priority"
-
- results_list = page.find('.todos-list')
- expect(results_list.all('p')[0]).to have_content("issue_1")
- expect(results_list.all('p')[1]).to have_content("issue_2")
- expect(results_list.all('p')[2]).to have_content("merge_request_1")
- end
- end
-end
diff --git a/spec/features/todos/todos_spec.rb b/spec/features/todos/todos_spec.rb
deleted file mode 100644
index bb4b2aed0e3..00000000000
--- a/spec/features/todos/todos_spec.rb
+++ /dev/null
@@ -1,378 +0,0 @@
-require 'spec_helper'
-
-describe 'Dashboard Todos', feature: true do
- let(:user) { create(:user) }
- let(:author) { create(:user) }
- let(:project) { create(:project, visibility_level: Gitlab::VisibilityLevel::PUBLIC) }
- let(:issue) { create(:issue, due_date: Date.today) }
-
- describe 'GET /dashboard/todos' do
- context 'User does not have todos' do
- before do
- login_as(user)
- visit dashboard_todos_path
- end
- it 'shows "All done" message' do
- expect(page).to have_content "Todos let you see what you should do next."
- end
- end
-
- context 'User has a todo', js: true do
- before do
- create(:todo, :mentioned, user: user, project: project, target: issue, author: author)
- login_as(user)
- visit dashboard_todos_path
- end
-
- it 'has todo present' do
- expect(page).to have_selector('.todos-list .todo', count: 1)
- end
-
- it 'shows due date as today' do
- within first('.todo') do
- expect(page).to have_content 'Due today'
- end
- end
-
- shared_examples 'deleting the todo' do
- before do
- within first('.todo') do
- click_link 'Done'
- end
- end
-
- it 'is marked as done-reversible in the list' do
- expect(page).to have_selector('.todos-list .todo.todo-pending.done-reversible')
- end
-
- it 'shows Undo button' do
- expect(page).to have_selector('.js-undo-todo', visible: true)
- expect(page).to have_selector('.js-done-todo', visible: false)
- end
-
- it 'updates todo count' do
- expect(page).to have_content 'To do 0'
- expect(page).to have_content 'Done 1'
- end
-
- it 'has not "All done" message' do
- expect(page).not_to have_selector('.todos-all-done')
- end
- end
-
- shared_examples 'deleting and restoring the todo' do
- before do
- within first('.todo') do
- click_link 'Done'
- wait_for_requests
- click_link 'Undo'
- end
- end
-
- it 'is marked back as pending in the list' do
- expect(page).not_to have_selector('.todos-list .todo.todo-pending.done-reversible')
- expect(page).to have_selector('.todos-list .todo.todo-pending')
- end
-
- it 'shows Done button' do
- expect(page).to have_selector('.js-undo-todo', visible: false)
- expect(page).to have_selector('.js-done-todo', visible: true)
- end
-
- it 'updates todo count' do
- expect(page).to have_content 'To do 1'
- expect(page).to have_content 'Done 0'
- end
- end
-
- it_behaves_like 'deleting the todo'
- it_behaves_like 'deleting and restoring the todo'
-
- context 'todo is stale on the page' do
- before do
- todos = TodosFinder.new(user, state: :pending).execute
- TodoService.new.mark_todos_as_done(todos, user)
- end
-
- it_behaves_like 'deleting the todo'
- it_behaves_like 'deleting and restoring the todo'
- end
- end
-
- context 'User created todos for themself' do
- before do
- login_as(user)
- end
-
- context 'issue assigned todo' do
- before do
- create(:todo, :assigned, user: user, project: project, target: issue, author: user)
- visit dashboard_todos_path
- end
-
- it 'shows issue assigned to yourself message' do
- page.within('.js-todos-all') do
- expect(page).to have_content("You assigned issue #{issue.to_reference(full: true)} to yourself")
- end
- end
- end
-
- context 'marked todo' do
- before do
- create(:todo, :marked, user: user, project: project, target: issue, author: user)
- visit dashboard_todos_path
- end
-
- it 'shows you added a todo message' do
- page.within('.js-todos-all') do
- expect(page).to have_content("You added a todo for issue #{issue.to_reference(full: true)}")
- expect(page).not_to have_content('to yourself')
- end
- end
- end
-
- context 'mentioned todo' do
- before do
- create(:todo, :mentioned, user: user, project: project, target: issue, author: user)
- visit dashboard_todos_path
- end
-
- it 'shows you mentioned yourself message' do
- page.within('.js-todos-all') do
- expect(page).to have_content("You mentioned yourself on issue #{issue.to_reference(full: true)}")
- expect(page).not_to have_content('to yourself')
- end
- end
- end
-
- context 'directly_addressed todo' do
- before do
- create(:todo, :directly_addressed, user: user, project: project, target: issue, author: user)
- visit dashboard_todos_path
- end
-
- it 'shows you directly addressed yourself message' do
- page.within('.js-todos-all') do
- expect(page).to have_content("You directly addressed yourself on issue #{issue.to_reference(full: true)}")
- expect(page).not_to have_content('to yourself')
- end
- end
- end
-
- context 'approval todo' do
- let(:merge_request) { create(:merge_request) }
-
- before do
- create(:todo, :approval_required, user: user, project: project, target: merge_request, author: user)
- visit dashboard_todos_path
- end
-
- it 'shows you set yourself as an approver message' do
- page.within('.js-todos-all') do
- expect(page).to have_content("You set yourself as an approver for merge request #{merge_request.to_reference(full: true)}")
- expect(page).not_to have_content('to yourself')
- end
- end
- end
- end
-
- context 'User has done todos', js: true do
- before do
- create(:todo, :mentioned, :done, user: user, project: project, target: issue, author: author)
- login_as(user)
- visit dashboard_todos_path(state: :done)
- end
-
- it 'has the done todo present' do
- expect(page).to have_selector('.todos-list .todo.todo-done', count: 1)
- end
-
- describe 'restoring the todo' do
- before do
- within first('.todo') do
- click_link 'Add todo'
- end
- end
-
- it 'is removed from the list' do
- expect(page).not_to have_selector('.todos-list .todo.todo-done')
- end
-
- it 'updates todo count' do
- expect(page).to have_content 'To do 1'
- expect(page).to have_content 'Done 0'
- end
- end
- end
-
- context 'User has Todos with labels spanning multiple projects' do
- before do
- label1 = create(:label, project: project)
- note1 = create(:note_on_issue, note: "Hello #{label1.to_reference(format: :name)}", noteable_id: issue.id, noteable_type: 'Issue', project: issue.project)
- create(:todo, :mentioned, project: project, target: issue, user: user, note_id: note1.id)
-
- project2 = create(:project, visibility_level: Gitlab::VisibilityLevel::PUBLIC)
- label2 = create(:label, project: project2)
- issue2 = create(:issue, project: project2)
- note2 = create(:note_on_issue, note: "Test #{label2.to_reference(format: :name)}", noteable_id: issue2.id, noteable_type: 'Issue', project: project2)
- create(:todo, :mentioned, project: project2, target: issue2, user: user, note_id: note2.id)
-
- login_as(user)
- visit dashboard_todos_path
- end
-
- it 'shows page with two Todos' do
- expect(page).to have_selector('.todos-list .todo', count: 2)
- end
- end
-
- context 'User has multiple pages of Todos' do
- before do
- allow(Todo).to receive(:default_per_page).and_return(1)
-
- # Create just enough records to cause us to paginate
- create_list(:todo, 2, :mentioned, user: user, project: project, target: issue, author: author)
-
- login_as(user)
- end
-
- it 'is paginated' do
- visit dashboard_todos_path
-
- expect(page).to have_selector('.gl-pagination')
- end
-
- it 'is has the right number of pages' do
- visit dashboard_todos_path
-
- expect(page).to have_selector('.gl-pagination .page', count: 2)
- end
-
- describe 'mark all as done', js: true do
- before do
- visit dashboard_todos_path
- find('.js-todos-mark-all').trigger('click')
- end
-
- it 'shows "All done" message!' do
- expect(page).to have_content 'To do 0'
- expect(page).to have_content "You're all done!"
- expect(page).not_to have_selector('.gl-pagination')
- end
-
- it 'shows "Undo mark all as done" button' do
- expect(page).to have_selector('.js-todos-mark-all', visible: false)
- expect(page).to have_selector('.js-todos-undo-all', visible: true)
- end
- end
-
- describe 'undo mark all as done', js: true do
- before do
- visit dashboard_todos_path
- end
-
- it 'shows the restored todo list' do
- mark_all_and_undo
-
- expect(page).to have_selector('.todos-list .todo', count: 1)
- expect(page).to have_selector('.gl-pagination')
- expect(page).not_to have_content "You're all done!"
- end
-
- it 'updates todo count' do
- mark_all_and_undo
-
- expect(page).to have_content 'To do 2'
- expect(page).to have_content 'Done 0'
- end
-
- it 'shows "Mark all as done" button' do
- mark_all_and_undo
-
- expect(page).to have_selector('.js-todos-mark-all', visible: true)
- expect(page).to have_selector('.js-todos-undo-all', visible: false)
- end
-
- context 'User has deleted a todo' do
- before do
- within first('.todo') do
- click_link 'Done'
- end
- end
-
- it 'shows the restored todo list with the deleted todo' do
- mark_all_and_undo
-
- expect(page).to have_selector('.todos-list .todo.todo-pending', count: 1)
- end
- end
-
- def mark_all_and_undo
- find('.js-todos-mark-all').trigger('click')
- wait_for_requests
- find('.js-todos-undo-all').trigger('click')
- wait_for_requests
- end
- end
- end
-
- context 'User has a Todo in a project pending deletion' do
- before do
- deleted_project = create(:project, visibility_level: Gitlab::VisibilityLevel::PUBLIC, pending_delete: true)
- create(:todo, :mentioned, user: user, project: deleted_project, target: issue, author: author)
- create(:todo, :mentioned, user: user, project: deleted_project, target: issue, author: author, state: :done)
- login_as(user)
- visit dashboard_todos_path
- end
-
- it 'shows "All done" message' do
- within('.todos-count') { expect(page).to have_content '0' }
- expect(page).to have_content 'To do 0'
- expect(page).to have_content 'Done 0'
- expect(page).to have_selector('.todos-all-done', count: 1)
- end
- end
-
- context 'User have large number of todos' do
- before do
- create_list(:todo, 101, :mentioned, user: user, project: project, target: issue, author: author)
-
- login_as(user)
- visit dashboard_todos_path
- end
-
- it 'shows 99+ for count >= 100 in notification' do
- expect(page).to have_selector('.todos-count', text: '99+')
- end
-
- it 'shows exact number in To do tab' do
- expect(page).to have_selector('.todos-pending .badge', text: '101')
- end
-
- it 'shows exact number for count < 100' do
- 3.times { first('.js-done-todo').click }
-
- expect(page).to have_selector('.todos-count', text: '98')
- end
- end
-
- context 'User has a Build Failed todo' do
- let!(:todo) { create(:todo, :build_failed, user: user, project: project, author: author) }
-
- before do
- login_as user
- visit dashboard_todos_path
- end
-
- it 'shows the todo' do
- expect(page).to have_content 'The build failed for merge request'
- end
-
- it 'links to the pipelines for the merge request' do
- href = pipelines_namespace_project_merge_request_path(project.namespace, project, todo.target)
-
- expect(page).to have_link "merge request #{todo.target.to_reference(full: true)}", href
- end
- end
- end
-end