2016-07-21 11:42:37 +00:00
|
|
|
require 'rails_helper'
|
|
|
|
|
2018-07-05 06:32:05 +00:00
|
|
|
describe 'GFM autocomplete', :js do
|
2018-11-12 09:21:25 +00:00
|
|
|
let(:issue_xss_title) { 'This will execute alert<img src=x onerror=alert(2)<img src=x onerror=alert(1)>' }
|
|
|
|
let(:user_xss_title) { 'eve <img src=x onerror=alert(2)<img src=x onerror=alert(1)>' }
|
2018-12-11 12:22:08 +00:00
|
|
|
let(:label_xss_title) { 'alert label <img src=x onerror="alert(\'Hello xss\');" a'}
|
|
|
|
let(:milestone_xss_title) { 'alert milestone <img src=x onerror="alert(\'Hello xss\');" a' }
|
2018-11-12 09:21:25 +00:00
|
|
|
|
|
|
|
let(:user_xss) { create(:user, name: user_xss_title, username: 'xss.user') }
|
2017-01-23 23:30:03 +00:00
|
|
|
let(:user) { create(:user, name: '💃speciąl someone💃', username: 'someone.special') }
|
2017-08-02 19:55:11 +00:00
|
|
|
let(:project) { create(:project) }
|
2016-12-03 10:44:18 +00:00
|
|
|
let(:label) { create(:label, project: project, title: 'special+') }
|
2016-07-21 11:42:37 +00:00
|
|
|
let(:issue) { create(:issue, project: project) }
|
|
|
|
|
|
|
|
before do
|
2018-07-11 14:36:08 +00:00
|
|
|
project.add_maintainer(user)
|
2018-11-12 09:21:25 +00:00
|
|
|
project.add_maintainer(user_xss)
|
|
|
|
|
2017-06-21 23:44:10 +00:00
|
|
|
sign_in(user)
|
2017-07-06 16:20:50 +00:00
|
|
|
visit project_issue_path(project, issue)
|
2016-07-21 11:42:37 +00:00
|
|
|
|
2017-05-17 18:25:13 +00:00
|
|
|
wait_for_requests
|
2016-07-21 13:41:27 +00:00
|
|
|
end
|
2016-07-21 11:42:37 +00:00
|
|
|
|
2018-10-30 10:53:01 +00:00
|
|
|
it 'updates issue description with GFM reference' do
|
2017-12-08 17:21:31 +00:00
|
|
|
find('.js-issuable-edit').click
|
2017-07-07 17:08:39 +00:00
|
|
|
|
2017-10-20 05:28:38 +00:00
|
|
|
simulate_input('#issue-description', "@#{user.name[0...3]}")
|
2017-07-07 17:08:39 +00:00
|
|
|
|
2018-12-11 12:22:08 +00:00
|
|
|
wait_for_requests
|
|
|
|
|
2017-08-03 05:13:46 +00:00
|
|
|
find('.atwho-view .cur').click
|
2017-07-07 17:08:39 +00:00
|
|
|
|
|
|
|
click_button 'Save changes'
|
|
|
|
|
2018-12-11 12:22:08 +00:00
|
|
|
wait_for_requests
|
|
|
|
|
2017-07-07 17:08:39 +00:00
|
|
|
expect(find('.description')).to have_content(user.to_reference)
|
|
|
|
end
|
|
|
|
|
2016-07-21 13:41:27 +00:00
|
|
|
it 'opens autocomplete menu when field starts with text' do
|
2016-07-21 11:42:37 +00:00
|
|
|
page.within '.timeline-content-form' do
|
2017-07-20 20:43:54 +00:00
|
|
|
find('#note-body').native.send_keys('@')
|
2016-07-21 11:42:37 +00:00
|
|
|
end
|
|
|
|
|
2016-11-14 10:34:10 +00:00
|
|
|
expect(page).to have_selector('.atwho-container')
|
2016-07-21 11:42:37 +00:00
|
|
|
end
|
2016-07-21 13:41:27 +00:00
|
|
|
|
2018-11-12 09:21:25 +00:00
|
|
|
it 'opens autocomplete menu for Issues when field starts with text with item escaping HTML characters' do
|
|
|
|
create(:issue, project: project, title: issue_xss_title)
|
2018-10-19 10:14:17 +00:00
|
|
|
|
|
|
|
page.within '.timeline-content-form' do
|
|
|
|
find('#note-body').native.send_keys('#')
|
|
|
|
end
|
|
|
|
|
2018-12-11 12:22:08 +00:00
|
|
|
wait_for_requests
|
|
|
|
|
2018-10-19 10:14:17 +00:00
|
|
|
expect(page).to have_selector('.atwho-container')
|
|
|
|
|
|
|
|
page.within '.atwho-container #at-view-issues' do
|
2018-11-12 09:21:25 +00:00
|
|
|
expect(page.all('li').first.text).to include(issue_xss_title)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'opens autocomplete menu for Username when field starts with text with item escaping HTML characters' do
|
|
|
|
page.within '.timeline-content-form' do
|
|
|
|
find('#note-body').native.send_keys('@ev')
|
|
|
|
end
|
|
|
|
|
2018-12-11 12:22:08 +00:00
|
|
|
wait_for_requests
|
|
|
|
|
2018-11-12 09:21:25 +00:00
|
|
|
expect(page).to have_selector('.atwho-container')
|
|
|
|
|
|
|
|
page.within '.atwho-container #at-view-users' do
|
|
|
|
expect(find('li').text).to have_content(user_xss.username)
|
2018-10-19 10:14:17 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-12-11 12:22:08 +00:00
|
|
|
it 'opens autocomplete menu for Milestone when field starts with text with item escaping HTML characters' do
|
|
|
|
create(:milestone, project: project, title: milestone_xss_title)
|
|
|
|
|
|
|
|
page.within '.timeline-content-form' do
|
|
|
|
find('#note-body').native.send_keys('%')
|
|
|
|
end
|
|
|
|
|
|
|
|
wait_for_requests
|
|
|
|
|
|
|
|
expect(page).to have_selector('.atwho-container')
|
|
|
|
|
|
|
|
page.within '.atwho-container #at-view-milestones' do
|
|
|
|
expect(find('li').text).to have_content('alert milestone')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-12-03 10:44:18 +00:00
|
|
|
it 'doesnt open autocomplete menu character is prefixed with text' do
|
2016-07-21 13:41:27 +00:00
|
|
|
page.within '.timeline-content-form' do
|
2017-07-20 20:43:54 +00:00
|
|
|
find('#note-body').native.send_keys('testing')
|
|
|
|
find('#note-body').native.send_keys('@')
|
2016-07-21 13:41:27 +00:00
|
|
|
end
|
|
|
|
|
2016-12-03 10:44:18 +00:00
|
|
|
expect(page).not_to have_selector('.atwho-view')
|
2016-07-21 13:41:27 +00:00
|
|
|
end
|
|
|
|
|
2017-01-18 12:17:24 +00:00
|
|
|
it 'doesnt select the first item for non-assignee dropdowns' do
|
|
|
|
page.within '.timeline-content-form' do
|
2017-07-20 20:43:54 +00:00
|
|
|
find('#note-body').native.send_keys(':')
|
2017-01-18 12:17:24 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
expect(page).to have_selector('.atwho-container')
|
|
|
|
|
2017-05-17 18:25:13 +00:00
|
|
|
wait_for_requests
|
2017-01-18 12:17:24 +00:00
|
|
|
|
|
|
|
expect(find('#at-view-58')).not_to have_selector('.cur:first-of-type')
|
|
|
|
end
|
|
|
|
|
2017-04-25 10:06:24 +00:00
|
|
|
it 'does not open autocomplete menu when ":" is prefixed by a number and letters' do
|
2017-07-20 20:43:54 +00:00
|
|
|
note = find('#note-body')
|
2017-04-25 10:06:24 +00:00
|
|
|
|
|
|
|
# Number.
|
|
|
|
page.within '.timeline-content-form' do
|
|
|
|
note.native.send_keys('7:')
|
|
|
|
end
|
|
|
|
|
|
|
|
expect(page).not_to have_selector('.atwho-view')
|
|
|
|
|
|
|
|
# ASCII letter.
|
|
|
|
page.within '.timeline-content-form' do
|
|
|
|
note.set('')
|
|
|
|
note.native.send_keys('w:')
|
|
|
|
end
|
|
|
|
|
|
|
|
expect(page).not_to have_selector('.atwho-view')
|
|
|
|
|
|
|
|
# Non-ASCII letter.
|
|
|
|
page.within '.timeline-content-form' do
|
|
|
|
note.set('')
|
|
|
|
note.native.send_keys('Ё:')
|
|
|
|
end
|
|
|
|
|
|
|
|
expect(page).not_to have_selector('.atwho-view')
|
|
|
|
end
|
|
|
|
|
2017-01-18 12:17:24 +00:00
|
|
|
it 'selects the first item for assignee dropdowns' do
|
|
|
|
page.within '.timeline-content-form' do
|
2017-07-20 20:43:54 +00:00
|
|
|
find('#note-body').native.send_keys('@')
|
2017-01-18 12:17:24 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
expect(page).to have_selector('.atwho-container')
|
|
|
|
|
2017-05-17 18:25:13 +00:00
|
|
|
wait_for_requests
|
2017-01-18 12:17:24 +00:00
|
|
|
|
2018-11-12 09:21:25 +00:00
|
|
|
expect(find('#at-view-users')).to have_selector('.cur:first-of-type')
|
2017-01-18 12:17:24 +00:00
|
|
|
end
|
|
|
|
|
2017-01-23 23:30:03 +00:00
|
|
|
it 'includes items for assignee dropdowns with non-ASCII characters in name' do
|
|
|
|
page.within '.timeline-content-form' do
|
2017-07-20 20:43:54 +00:00
|
|
|
find('#note-body').native.send_keys('')
|
2017-10-20 05:28:38 +00:00
|
|
|
simulate_input('#note-body', "@#{user.name[0...8]}")
|
2017-01-23 23:30:03 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
expect(page).to have_selector('.atwho-container')
|
|
|
|
|
2017-05-17 18:25:13 +00:00
|
|
|
wait_for_requests
|
2017-01-23 23:30:03 +00:00
|
|
|
|
2018-11-12 09:21:25 +00:00
|
|
|
expect(find('#at-view-users')).to have_content(user.name)
|
2017-01-23 23:30:03 +00:00
|
|
|
end
|
|
|
|
|
2017-01-18 12:17:24 +00:00
|
|
|
it 'selects the first item for non-assignee dropdowns if a query is entered' do
|
|
|
|
page.within '.timeline-content-form' do
|
2017-07-20 20:43:54 +00:00
|
|
|
find('#note-body').native.send_keys(':1')
|
2017-01-18 12:17:24 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
expect(page).to have_selector('.atwho-container')
|
|
|
|
|
2017-05-17 18:25:13 +00:00
|
|
|
wait_for_requests
|
2017-01-18 12:17:24 +00:00
|
|
|
|
|
|
|
expect(find('#at-view-58')).to have_selector('.cur:first-of-type')
|
|
|
|
end
|
|
|
|
|
2016-12-03 10:44:18 +00:00
|
|
|
context 'if a selected value has special characters' do
|
|
|
|
it 'wraps the result in double quotes' do
|
2017-07-20 20:43:54 +00:00
|
|
|
note = find('#note-body')
|
2016-12-03 10:44:18 +00:00
|
|
|
page.within '.timeline-content-form' do
|
2017-11-03 20:26:17 +00:00
|
|
|
find('#note-body').native.send_keys('')
|
2017-10-20 05:28:38 +00:00
|
|
|
simulate_input('#note-body', "~#{label.title[0]}")
|
2016-12-03 10:44:18 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
label_item = find('.atwho-view li', text: label.title)
|
|
|
|
|
|
|
|
expect_to_wrap(true, label_item, note, label.title)
|
2016-07-21 13:41:27 +00:00
|
|
|
end
|
|
|
|
|
2016-12-28 10:19:24 +00:00
|
|
|
it "shows dropdown after a new line" do
|
2017-07-20 20:43:54 +00:00
|
|
|
note = find('#note-body')
|
2016-12-28 10:19:24 +00:00
|
|
|
page.within '.timeline-content-form' do
|
|
|
|
note.native.send_keys('test')
|
|
|
|
note.native.send_keys(:enter)
|
|
|
|
note.native.send_keys(:enter)
|
|
|
|
note.native.send_keys('@')
|
|
|
|
end
|
|
|
|
|
|
|
|
expect(page).to have_selector('.atwho-container')
|
|
|
|
end
|
|
|
|
|
2016-12-23 09:05:01 +00:00
|
|
|
it "does not show dropdown when preceded with a special character" do
|
2017-07-20 20:43:54 +00:00
|
|
|
note = find('#note-body')
|
2016-12-22 18:39:00 +00:00
|
|
|
page.within '.timeline-content-form' do
|
|
|
|
note.native.send_keys("@")
|
|
|
|
end
|
|
|
|
|
|
|
|
expect(page).to have_selector('.atwho-container')
|
|
|
|
|
|
|
|
page.within '.timeline-content-form' do
|
|
|
|
note.native.send_keys("@")
|
|
|
|
end
|
|
|
|
|
|
|
|
expect(page).to have_selector('.atwho-container', visible: false)
|
|
|
|
end
|
|
|
|
|
2016-12-23 09:05:01 +00:00
|
|
|
it "does not throw an error if no labels exist" do
|
2017-07-20 20:43:54 +00:00
|
|
|
note = find('#note-body')
|
2016-12-23 09:05:01 +00:00
|
|
|
page.within '.timeline-content-form' do
|
|
|
|
note.native.send_keys('~')
|
|
|
|
end
|
|
|
|
|
|
|
|
expect(page).to have_selector('.atwho-container', visible: false)
|
|
|
|
end
|
|
|
|
|
2016-12-03 10:44:18 +00:00
|
|
|
it 'doesn\'t wrap for assignee values' do
|
2017-07-20 20:43:54 +00:00
|
|
|
note = find('#note-body')
|
2016-12-03 10:44:18 +00:00
|
|
|
page.within '.timeline-content-form' do
|
|
|
|
note.native.send_keys("@#{user.username[0]}")
|
|
|
|
end
|
|
|
|
|
|
|
|
user_item = find('.atwho-view li', text: user.username)
|
|
|
|
|
|
|
|
expect_to_wrap(false, user_item, note, user.username)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'doesn\'t wrap for emoji values' do
|
2017-07-20 20:43:54 +00:00
|
|
|
note = find('#note-body')
|
2016-12-03 10:44:18 +00:00
|
|
|
page.within '.timeline-content-form' do
|
2017-10-18 02:30:36 +00:00
|
|
|
note.native.send_keys(":cartwheel_")
|
2016-12-03 10:44:18 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
emoji_item = find('.atwho-view li', text: 'cartwheel_tone1')
|
|
|
|
|
|
|
|
expect_to_wrap(false, emoji_item, note, 'cartwheel_tone1')
|
|
|
|
end
|
|
|
|
|
2016-12-21 11:03:52 +00:00
|
|
|
it 'doesn\'t open autocomplete after non-word character' do
|
|
|
|
page.within '.timeline-content-form' do
|
2017-07-20 20:43:54 +00:00
|
|
|
find('#note-body').native.send_keys("@#{user.username[0..2]}!")
|
2016-12-21 11:03:52 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
expect(page).not_to have_selector('.atwho-view')
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'doesn\'t open autocomplete if there is no space before' do
|
|
|
|
page.within '.timeline-content-form' do
|
2017-07-20 20:43:54 +00:00
|
|
|
find('#note-body').native.send_keys("hello:#{user.username[0..2]}")
|
2016-12-21 11:03:52 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
expect(page).not_to have_selector('.atwho-view')
|
|
|
|
end
|
|
|
|
|
2017-05-31 05:50:53 +00:00
|
|
|
it 'triggers autocomplete after selecting a quick action' do
|
2017-07-20 20:43:54 +00:00
|
|
|
note = find('#note-body')
|
2017-02-10 03:35:32 +00:00
|
|
|
page.within '.timeline-content-form' do
|
|
|
|
note.native.send_keys('/as')
|
|
|
|
end
|
|
|
|
|
2017-10-18 02:30:36 +00:00
|
|
|
find('.atwho-view li', text: '/assign')
|
|
|
|
note.native.send_keys(:tab)
|
2017-02-10 03:35:32 +00:00
|
|
|
|
|
|
|
user_item = find('.atwho-view li', text: user.username)
|
|
|
|
expect(user_item).to have_content(user.username)
|
|
|
|
end
|
2017-11-13 14:30:22 +00:00
|
|
|
end
|
2017-02-10 03:35:32 +00:00
|
|
|
|
2017-11-28 03:51:03 +00:00
|
|
|
# This context has jsut one example in each contexts in order to improve spec performance.
|
2019-01-25 13:52:37 +00:00
|
|
|
context 'labels', :quarantine do
|
2017-11-28 03:51:03 +00:00
|
|
|
let!(:backend) { create(:label, project: project, title: 'backend') }
|
|
|
|
let!(:bug) { create(:label, project: project, title: 'bug') }
|
|
|
|
let!(:feature_proposal) { create(:label, project: project, title: 'feature proposal') }
|
|
|
|
|
2018-12-11 12:22:08 +00:00
|
|
|
it 'opens autocomplete menu for Labels when field starts with text with item escaping HTML characters' do
|
|
|
|
create(:label, project: project, title: label_xss_title)
|
|
|
|
|
|
|
|
note = find('#note-body')
|
|
|
|
|
|
|
|
# It should show all the labels on "~".
|
|
|
|
type(note, '~')
|
|
|
|
|
|
|
|
wait_for_requests
|
|
|
|
|
|
|
|
page.within '.atwho-container #at-view-labels' do
|
|
|
|
expect(find('.atwho-view-ul').text).to have_content('alert label')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-11-28 03:51:03 +00:00
|
|
|
context 'when no labels are assigned' do
|
|
|
|
it 'shows labels' do
|
|
|
|
note = find('#note-body')
|
|
|
|
|
|
|
|
# It should show all the labels on "~".
|
|
|
|
type(note, '~')
|
2018-12-11 12:22:08 +00:00
|
|
|
wait_for_requests
|
2017-11-28 03:51:03 +00:00
|
|
|
expect_labels(shown: [backend, bug, feature_proposal])
|
|
|
|
|
|
|
|
# It should show all the labels on "/label ~".
|
|
|
|
type(note, '/label ~')
|
|
|
|
expect_labels(shown: [backend, bug, feature_proposal])
|
|
|
|
|
|
|
|
# It should show all the labels on "/relabel ~".
|
|
|
|
type(note, '/relabel ~')
|
|
|
|
expect_labels(shown: [backend, bug, feature_proposal])
|
|
|
|
|
|
|
|
# It should show no labels on "/unlabel ~".
|
|
|
|
type(note, '/unlabel ~')
|
|
|
|
expect_labels(not_shown: [backend, bug, feature_proposal])
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when some labels are assigned' do
|
|
|
|
before do
|
|
|
|
issue.labels << [backend]
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows labels' do
|
|
|
|
note = find('#note-body')
|
|
|
|
|
|
|
|
# It should show all the labels on "~".
|
|
|
|
type(note, '~')
|
2018-12-11 12:22:08 +00:00
|
|
|
wait_for_requests
|
2017-11-28 03:51:03 +00:00
|
|
|
expect_labels(shown: [backend, bug, feature_proposal])
|
|
|
|
|
|
|
|
# It should show only unset labels on "/label ~".
|
|
|
|
type(note, '/label ~')
|
|
|
|
expect_labels(shown: [bug, feature_proposal], not_shown: [backend])
|
|
|
|
|
|
|
|
# It should show all the labels on "/relabel ~".
|
|
|
|
type(note, '/relabel ~')
|
|
|
|
expect_labels(shown: [backend, bug, feature_proposal])
|
|
|
|
|
|
|
|
# It should show only set labels on "/unlabel ~".
|
|
|
|
type(note, '/unlabel ~')
|
|
|
|
expect_labels(shown: [backend], not_shown: [bug, feature_proposal])
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when all labels are assigned' do
|
|
|
|
before do
|
|
|
|
issue.labels << [backend, bug, feature_proposal]
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows labels' do
|
|
|
|
note = find('#note-body')
|
|
|
|
|
|
|
|
# It should show all the labels on "~".
|
|
|
|
type(note, '~')
|
2018-12-11 12:22:08 +00:00
|
|
|
wait_for_requests
|
2017-11-28 03:51:03 +00:00
|
|
|
expect_labels(shown: [backend, bug, feature_proposal])
|
|
|
|
|
|
|
|
# It should show no labels on "/label ~".
|
|
|
|
type(note, '/label ~')
|
|
|
|
expect_labels(not_shown: [backend, bug, feature_proposal])
|
|
|
|
|
|
|
|
# It should show all the labels on "/relabel ~".
|
|
|
|
type(note, '/relabel ~')
|
|
|
|
expect_labels(shown: [backend, bug, feature_proposal])
|
|
|
|
|
|
|
|
# It should show all the labels on "/unlabel ~".
|
|
|
|
type(note, '/unlabel ~')
|
|
|
|
expect_labels(shown: [backend, bug, feature_proposal])
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-11-19 14:46:34 +00:00
|
|
|
shared_examples 'autocomplete suggestions' do
|
|
|
|
it 'suggests objects correctly' do
|
|
|
|
page.within '.timeline-content-form' do
|
|
|
|
find('#note-body').native.send_keys(object.class.reference_prefix)
|
|
|
|
end
|
|
|
|
|
|
|
|
page.within '.atwho-container' do
|
|
|
|
expect(page).to have_content(object.title)
|
2018-10-05 09:42:38 +00:00
|
|
|
|
2018-11-19 14:46:34 +00:00
|
|
|
find('ul li').click
|
|
|
|
end
|
|
|
|
|
|
|
|
expect(find('.new-note #note-body').value).to include(expected_body)
|
2018-10-05 09:42:38 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-11-19 14:46:34 +00:00
|
|
|
context 'issues' do
|
|
|
|
let(:object) { issue }
|
|
|
|
let(:expected_body) { object.to_reference }
|
|
|
|
|
|
|
|
it_behaves_like 'autocomplete suggestions'
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'merge requests' do
|
|
|
|
let(:object) { create(:merge_request, source_project: project) }
|
|
|
|
let(:expected_body) { object.to_reference }
|
|
|
|
|
|
|
|
it_behaves_like 'autocomplete suggestions'
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'project snippets' do
|
|
|
|
let!(:object) { create(:project_snippet, project: project, title: 'code snippet') }
|
|
|
|
let(:expected_body) { object.to_reference }
|
|
|
|
|
|
|
|
it_behaves_like 'autocomplete suggestions'
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'label' do
|
|
|
|
let!(:object) { label }
|
|
|
|
let(:expected_body) { object.title }
|
|
|
|
|
|
|
|
it_behaves_like 'autocomplete suggestions'
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'milestone' do
|
|
|
|
let!(:object) { create(:milestone, project: project) }
|
|
|
|
let(:expected_body) { object.to_reference }
|
|
|
|
|
|
|
|
it_behaves_like 'autocomplete suggestions'
|
|
|
|
end
|
|
|
|
|
2017-11-28 03:51:03 +00:00
|
|
|
private
|
|
|
|
|
2017-11-13 14:30:22 +00:00
|
|
|
def expect_to_wrap(should_wrap, item, note, value)
|
|
|
|
expect(item).to have_content(value)
|
|
|
|
expect(item).not_to have_content("\"#{value}\"")
|
2016-12-03 10:44:18 +00:00
|
|
|
|
2017-11-13 14:30:22 +00:00
|
|
|
item.click
|
2016-12-03 10:44:18 +00:00
|
|
|
|
2017-11-13 14:30:22 +00:00
|
|
|
if should_wrap
|
|
|
|
expect(note.value).to include("\"#{value}\"")
|
|
|
|
else
|
|
|
|
expect(note.value).not_to include("\"#{value}\"")
|
2016-12-03 10:44:18 +00:00
|
|
|
end
|
2016-07-21 13:41:27 +00:00
|
|
|
end
|
2017-11-28 03:51:03 +00:00
|
|
|
|
|
|
|
def expect_labels(shown: nil, not_shown: nil)
|
|
|
|
page.within('.atwho-container') do
|
|
|
|
if shown
|
|
|
|
expect(page).to have_selector('.atwho-view li', count: shown.size)
|
|
|
|
shown.each { |label| expect(page).to have_content(label.title) }
|
|
|
|
end
|
|
|
|
|
|
|
|
if not_shown
|
|
|
|
expect(page).not_to have_selector('.atwho-view li') unless shown
|
|
|
|
not_shown.each { |label| expect(page).not_to have_content(label.title) }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
# `note` is a textarea where the given text should be typed.
|
|
|
|
# We don't want to find it each time this function gets called.
|
|
|
|
def type(note, text)
|
|
|
|
page.within('.timeline-content-form') do
|
|
|
|
note.set('')
|
|
|
|
note.native.send_keys(text)
|
|
|
|
end
|
|
|
|
end
|
2016-07-21 11:42:37 +00:00
|
|
|
end
|