Commit c6e49881 authored by Jarka Kadlecová's avatar Jarka Kadlecová

Add feature specs for epic todos

parent e4569d25
require 'rails_helper'
feature 'Manually create a todo item from epic', :js do
let(:group) { create(:group) }
let(:epic) { create(:epic, group: group) }
let(:user) { create(:user)}
before do
stub_licensed_features(epics: true)
sign_in(user)
visit group_epic_path(group, epic)
end
it 'creates todo when clicking button' do
page.within '.issuable-sidebar' do
click_button 'Add todo'
expect(page).to have_content 'Mark todo as done'
end
page.within '.header-content .todos-count' do
expect(page).to have_content '1'
end
end
it 'marks a todo as done' do
page.within '.issuable-sidebar' do
click_button 'Add todo'
end
expect(page).to have_selector('.todos-count', visible: true)
page.within '.header-content .todos-count' do
expect(page).to have_content '1'
end
page.within '.issuable-sidebar' do
click_button 'Mark todo as done'
end
expect(page).to have_selector('.todos-count', visible: false)
end
end
......@@ -57,6 +57,32 @@ feature 'Update Epic', :js do
expect(find('.issuable-details .description')).to have_content('New epic description')
end
it 'creates a todo only for mentioned users' do
mentioned = create(:user)
fill_in 'issue-description', with: "FYI #{mentioned.to_reference}"
click_button 'Save changes'
expect(find('.issuable-details h2.title')).to have_content('title')
visit dashboard_todos_path
expect(page).to have_selector('.todos-list .todo', count: 0)
sign_in(mentioned)
visit dashboard_todos_path
page.within '.header-content .todos-count' do
expect(page).to have_content '1'
end
expect(page).to have_selector('.todos-list .todo', count: 1)
within first('.todo') do
expect(page).to have_content "epic #{epic.to_reference(full: true)}"
end
end
it 'edits full screen' do
page.within('.detail-page-description') { find('.js-zen-enter').click }
......
......@@ -4,23 +4,36 @@ feature 'Dashboard > User filters todos', :js 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(:project, name: 'project_1') }
let(:project_2) { create(:project, name: 'project_2') }
let(:group1) { create(:group) }
let(:group2) { create(:group) }
let(:issue) { create(:issue, title: 'issue', project: project_1) }
let(:project_1) { create(:project, name: 'project_1', namespace: group1) }
let(:project_2) { create(:project, name: 'project_2', namespace: group1) }
let(:project_3) { create(:project, name: 'project_3', namespace: group2) }
let(:issue1) { create(:issue, title: 'issue', project: project_1) }
let(:issue2) { create(:issue, title: 'issue', project: project_3) }
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_2, project: project_1, target: issue1, action: 1)
create(:todo, user: user_1, author: user_2, project: project_3, target: issue2, action: 1)
create(:todo, user: user_1, author: user_1, project: project_2, target: merge_request, action: 2)
project_1.add_developer(user_1)
project_2.add_developer(user_1)
project_3.add_developer(user_1)
sign_in(user_1)
visit dashboard_todos_path
end
it 'displays all todos without a filter' do
expect(page).to have_content issue1.to_reference(full: true)
expect(page).to have_content merge_request.to_reference(full: true)
expect(page).to have_content issue2.to_reference(full: true)
end
it 'filters by project' do
click_button 'Project'
within '.dropdown-menu-project' do
......@@ -34,6 +47,20 @@ feature 'Dashboard > User filters todos', :js do
expect(page).not_to have_content project_2.full_name
end
it 'filters by group' do
click_button 'Group'
within '.dropdown-menu-group' do
fill_in 'Search groups', with: group1.full_name
click_link group1.full_name
end
wait_for_requests
expect(page).to have_content issue1.to_reference(full: true)
expect(page).to have_content merge_request.to_reference(full: true)
expect(page).not_to have_content issue2.to_reference(full: true)
end
context 'Author filter' do
it 'filters by author' do
click_button 'Author'
......@@ -63,7 +90,7 @@ feature 'Dashboard > User filters todos', :js do
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_3, project: project_1, target: issue1, action: 1, state: :done)
create(:todo, user: user_1, author: user_4, project: project_2, target: merge_request, action: 2, state: :done)
project_1.add_developer(user_3)
......@@ -92,14 +119,15 @@ feature 'Dashboard > User filters todos', :js do
wait_for_requests
expect(find('.todos-list')).to have_content issue.to_reference
expect(find('.todos-list')).to have_content issue1.to_reference
expect(find('.todos-list')).to have_content issue2.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)
create(:todo, :marked, user: user_1, author: user_2, project: project_1, target: issue1)
end
it 'filters by Assigned' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment