Collapse similar sibling scenarios
This commit is contained in:
parent
3d227e2722
commit
7e52501574
1 changed files with 13 additions and 42 deletions
|
@ -9,11 +9,9 @@ shared_examples 'discussion comments' do |resource_name|
|
||||||
let(:close_selector) { "#{form_selector} .btn-comment-and-close" }
|
let(:close_selector) { "#{form_selector} .btn-comment-and-close" }
|
||||||
let(:comments_selector) { '.timeline > .note.timeline-entry' }
|
let(:comments_selector) { '.timeline > .note.timeline-entry' }
|
||||||
|
|
||||||
it 'should show a comment type toggle' do
|
|
||||||
expect(page).to have_selector toggle_selector
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'clicking "Comment" will post a comment' do
|
it 'clicking "Comment" will post a comment' do
|
||||||
|
expect(page).to have_selector toggle_selector
|
||||||
|
|
||||||
find("#{form_selector} .note-textarea").send_keys('a')
|
find("#{form_selector} .note-textarea").send_keys('a')
|
||||||
|
|
||||||
find(submit_selector).click
|
find(submit_selector).click
|
||||||
|
@ -49,44 +47,29 @@ shared_examples 'discussion comments' do |resource_name|
|
||||||
find(toggle_selector).click
|
find(toggle_selector).click
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'opens a comment type dropdown with "Comment" and "Start discussion"' do
|
it 'has a "Comment" item (selected by default) and "Start discussion" item' do
|
||||||
expect(page).to have_selector menu_selector
|
expect(page).to have_selector menu_selector
|
||||||
end
|
|
||||||
|
|
||||||
it 'has a "Comment" item' do
|
|
||||||
menu = find(menu_selector)
|
|
||||||
|
|
||||||
expect(menu).to have_content 'Comment'
|
|
||||||
expect(menu).to have_content "Add a general comment to this #{resource_name}."
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'has a "Start discussion" item' do
|
|
||||||
menu = find(menu_selector)
|
|
||||||
|
|
||||||
expect(menu).to have_content 'Start discussion'
|
|
||||||
expect(menu).to have_content "Discuss a specific suggestion or question#{' that needs to be resolved' if resource_name == 'merge request'}."
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'has the "Comment" item selected by default' do
|
|
||||||
find("#{menu_selector} li", match: :first)
|
find("#{menu_selector} li", match: :first)
|
||||||
items = all("#{menu_selector} li")
|
items = all("#{menu_selector} li")
|
||||||
|
|
||||||
expect(items.first).to have_content 'Comment'
|
expect(items.first).to have_content 'Comment'
|
||||||
|
expect(items.first).to have_content "Add a general comment to this #{resource_name}."
|
||||||
expect(items.first).to have_selector '.fa-check'
|
expect(items.first).to have_selector '.fa-check'
|
||||||
expect(items.first['class']).to match 'droplab-item-selected'
|
expect(items.first['class']).to match 'droplab-item-selected'
|
||||||
|
|
||||||
expect(items.last).to have_content 'Start discussion'
|
expect(items.last).to have_content 'Start discussion'
|
||||||
|
expect(items.last).to have_content "Discuss a specific suggestion or question#{' that needs to be resolved' if resource_name == 'merge request'}."
|
||||||
expect(items.last).not_to have_selector '.fa-check'
|
expect(items.last).not_to have_selector '.fa-check'
|
||||||
expect(items.last['class']).not_to match 'droplab-item-selected'
|
expect(items.last['class']).not_to match 'droplab-item-selected'
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'closes the menu when clicking the toggle' do
|
it 'closes the menu when clicking the toggle or body' do
|
||||||
find(toggle_selector).click
|
find(toggle_selector).click
|
||||||
|
|
||||||
expect(page).not_to have_selector menu_selector
|
expect(page).not_to have_selector menu_selector
|
||||||
end
|
|
||||||
|
|
||||||
it 'closes the menu when clicking the body' do
|
find(toggle_selector).click
|
||||||
find('body').click
|
find('body').click
|
||||||
|
|
||||||
expect(page).not_to have_selector menu_selector
|
expect(page).not_to have_selector menu_selector
|
||||||
|
@ -104,12 +87,10 @@ shared_examples 'discussion comments' do |resource_name|
|
||||||
all("#{menu_selector} li").last.click
|
all("#{menu_selector} li").last.click
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'updates the note_type input to "DiscussionNote"' do
|
it 'updates the submit button text, note_type input and closes the dropdown' do
|
||||||
expect(find("#{form_selector} #note_type", visible: false).value).to eq('DiscussionNote')
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'updates the submit button text' do
|
|
||||||
expect(find(dropdown_selector)).to have_content 'Start discussion'
|
expect(find(dropdown_selector)).to have_content 'Start discussion'
|
||||||
|
expect(find("#{form_selector} #note_type", visible: false).value).to eq('DiscussionNote')
|
||||||
|
expect(page).not_to have_selector menu_selector
|
||||||
end
|
end
|
||||||
|
|
||||||
if resource_name =~ /(issue|merge request)/
|
if resource_name =~ /(issue|merge request)/
|
||||||
|
@ -124,10 +105,6 @@ shared_examples 'discussion comments' do |resource_name|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'closes the dropdown' do
|
|
||||||
expect(page).not_to have_selector menu_selector
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'clicking "Start discussion" will post a discussion' do
|
it 'clicking "Start discussion" will post a discussion' do
|
||||||
find(submit_selector).click
|
find(submit_selector).click
|
||||||
|
|
||||||
|
@ -176,12 +153,10 @@ shared_examples 'discussion comments' do |resource_name|
|
||||||
find("#{menu_selector} li", match: :first).click
|
find("#{menu_selector} li", match: :first).click
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'clears the note_type input"' do
|
it 'updates the submit button text, clears the note_type input and closes the dropdown' do
|
||||||
expect(find("#{form_selector} #note_type", visible: false).value).to eq('')
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'updates the submit button text' do
|
|
||||||
expect(find(dropdown_selector)).to have_content 'Comment'
|
expect(find(dropdown_selector)).to have_content 'Comment'
|
||||||
|
expect(find("#{form_selector} #note_type", visible: false).value).to eq('')
|
||||||
|
expect(page).not_to have_selector menu_selector
|
||||||
end
|
end
|
||||||
|
|
||||||
if resource_name =~ /(issue|merge request)/
|
if resource_name =~ /(issue|merge request)/
|
||||||
|
@ -196,10 +171,6 @@ shared_examples 'discussion comments' do |resource_name|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'closes the dropdown' do
|
|
||||||
expect(page).not_to have_selector menu_selector
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should have "Comment" selected when opening the menu' do
|
it 'should have "Comment" selected when opening the menu' do
|
||||||
find(toggle_selector).click
|
find(toggle_selector).click
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue