BigW Consortium Gitlab

fix shared discussion_comments examples (for realz this time!)

parent 53e11239
require 'spec_helper' require 'spec_helper'
describe 'Discussion Comments Merge Request', :js do describe 'Discussion Comments Commit', :js do
include RepoHelpers include RepoHelpers
let(:user) { create(:user) } let(:user) { create(:user) }
......
require 'spec_helper' require 'spec_helper'
describe 'Discussion Comments Issue', :js do describe 'Discussion Comments Snippet', :js do
let(:user) { create(:user) } let(:user) { create(:user) }
let(:project) { create(:project) } let(:project) { create(:project) }
let(:snippet) { create(:project_snippet, :private, project: project, author: user) } let(:snippet) { create(:project_snippet, :private, project: project, author: user) }
......
...@@ -4,7 +4,6 @@ shared_examples 'discussion comments' do |resource_name| ...@@ -4,7 +4,6 @@ shared_examples 'discussion comments' do |resource_name|
let(:toggle_selector) { "#{dropdown_selector} .dropdown-toggle" } let(:toggle_selector) { "#{dropdown_selector} .dropdown-toggle" }
let(:menu_selector) { "#{dropdown_selector} .dropdown-menu" } let(:menu_selector) { "#{dropdown_selector} .dropdown-menu" }
let(:submit_selector) { "#{form_selector} .js-comment-submit-button" } let(:submit_selector) { "#{form_selector} .js-comment-submit-button" }
let(:submit_button) { ".js-comment-submit-button" }
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' }
...@@ -78,34 +77,27 @@ shared_examples 'discussion comments' do |resource_name| ...@@ -78,34 +77,27 @@ shared_examples 'discussion comments' do |resource_name|
end end
it 'clicking the ul padding or divider should not change the text' do it 'clicking the ul padding or divider should not change the text' do
find(menu_selector).click execute_script("document.querySelector('#{menu_selector}').click()")
# on issues page, the menu closes when clicking anywhere, on other pages it will
# remain open if clicking divider or menu padding, but should not change button action
if resource_name == 'issue' if resource_name == 'issue'
expect(find(dropdown_selector)).to have_content 'Comment' expect(find(dropdown_selector)).to have_content 'Comment'
find(toggle_selector).click find(toggle_selector).click
find("#{menu_selector} .divider").click execute_script("document.querySelector('#{menu_selector} .divider').click()")
else else
within dropdown_selector do execute_script("document.querySelector('#{menu_selector}').click()")
find('.dropdown-toggle').click
expect(find('.dropdown-menu')).not_to be_nil expect(page).to have_selector menu_selector
find('li[data-submit-text="Comment"]').click expect(find(dropdown_selector)).to have_content 'Comment'
expect(find(submit_button).value).to eq "Comment"
find('.dropdown-toggle').click execute_script("document.querySelector('#{menu_selector} .divider').click()")
page.driver.execute_script(
"document.querySelector('.comment-type-dropdown .dropdown-menu .divider').click()"
)
expect(find('.dropdown-menu')).not_to be_nil expect(page).to have_selector menu_selector
find('li[data-submit-text="Comment"]').click
end
end end
within dropdown_selector do expect(find(dropdown_selector)).to have_content 'Comment'
expect(find(submit_button).value).to eq "Comment"
end
end end
describe 'when selecting "Start discussion"' do describe 'when selecting "Start discussion"' do
...@@ -115,8 +107,11 @@ shared_examples 'discussion comments' do |resource_name| ...@@ -115,8 +107,11 @@ shared_examples 'discussion comments' do |resource_name|
end end
it 'updates the submit button text and closes the dropdown' do it 'updates the submit button text and closes the dropdown' do
within dropdown_selector do # on issues page, the submit input is a <button>, on other pages it is <input>
expect(find(submit_button).value).to eq "Start discussion" if resource_name == 'issue'
expect(find(submit_selector)).to have_content 'Start discussion'
else
expect(find(submit_selector).value).to eq 'Start discussion'
end end
expect(page).not_to have_selector menu_selector expect(page).not_to have_selector menu_selector
end end
...@@ -182,8 +177,11 @@ shared_examples 'discussion comments' do |resource_name| ...@@ -182,8 +177,11 @@ shared_examples 'discussion comments' do |resource_name|
end end
it 'updates the submit button text and closes the dropdown' do it 'updates the submit button text and closes the dropdown' do
within dropdown_selector do # on issues page, the submit input is a <button>, on other pages it is <input>
expect(find(submit_button).value).to eq "Comment" if resource_name == 'issue'
expect(find(submit_selector)).to have_content 'Comment'
else
expect(find(submit_selector).value).to eq 'Comment'
end end
expect(page).not_to have_selector menu_selector expect(page).not_to have_selector menu_selector
end end
...@@ -223,6 +221,7 @@ shared_examples 'discussion comments' do |resource_name| ...@@ -223,6 +221,7 @@ shared_examples 'discussion comments' do |resource_name|
describe "on a closed #{resource_name}" do describe "on a closed #{resource_name}" do
before do before do
find("#{form_selector} .js-note-target-close").click find("#{form_selector} .js-note-target-close").click
wait_for_requests
find("#{form_selector} .note-textarea").send_keys('a') find("#{form_selector} .note-textarea").send_keys('a')
end end
...@@ -232,7 +231,7 @@ shared_examples 'discussion comments' do |resource_name| ...@@ -232,7 +231,7 @@ shared_examples 'discussion comments' do |resource_name|
end end
it "should show a 'Start discussion & reopen #{resource_name}' button when 'Start discussion' is selected" do it "should show a 'Start discussion & reopen #{resource_name}' button when 'Start discussion' is selected" do
find(toggle_selector).send_keys(:return) find(toggle_selector).click
find("#{menu_selector} li", match: :first) find("#{menu_selector} li", match: :first)
all("#{menu_selector} li").last.click all("#{menu_selector} li").last.click
......
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