diff options
author | Jan Provaznik <jprovaznik@gitlab.com> | 2018-04-03 19:03:00 +0300 |
---|---|---|
committer | Fatih Acet <acetfatih@gmail.com> | 2018-04-03 19:03:00 +0300 |
commit | 65664c2eaeed853396c97a9b46e404c05209c42e (patch) | |
tree | e903e3afa6fe5c0f3492dc443776ebd1ce8ade57 /spec/support/features | |
parent | 67ca10f33ec41e7cecac152e016aa2c0956a7586 (diff) |
Refactor discussions/notes code
Diffstat (limited to 'spec/support/features')
-rw-r--r-- | spec/support/features/discussion_comments_shared_example.rb | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/spec/support/features/discussion_comments_shared_example.rb b/spec/support/features/discussion_comments_shared_example.rb index c8662d41769..80604395adf 100644 --- a/spec/support/features/discussion_comments_shared_example.rb +++ b/spec/support/features/discussion_comments_shared_example.rb @@ -81,7 +81,10 @@ shared_examples 'discussion comments' do |resource_name| # 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 dropdown menu is not toggled (and also not present), + # it's "issue-type" dropdown + if first(menu_selector).nil? expect(find(dropdown_selector)).to have_content 'Comment' find(toggle_selector).click @@ -107,8 +110,10 @@ shared_examples 'discussion comments' do |resource_name| end it 'updates the submit button text and closes the dropdown' do + button = find(submit_selector) + # on issues page, the submit input is a <button>, on other pages it is <input> - if resource_name == 'issue' + if button.tag_name == 'button' expect(find(submit_selector)).to have_content 'Start discussion' else expect(find(submit_selector).value).to eq 'Start discussion' @@ -132,6 +137,8 @@ shared_examples 'discussion comments' do |resource_name| describe 'creating a discussion' do before do find(submit_selector).click + wait_for_requests + find(comments_selector, match: :first) end @@ -197,11 +204,13 @@ shared_examples 'discussion comments' do |resource_name| end it 'updates the submit button text and closes the dropdown' do + button = find(submit_selector) + # on issues page, the submit input is a <button>, on other pages it is <input> - if resource_name == 'issue' - expect(find(submit_selector)).to have_content 'Comment' + if button.tag_name == 'button' + expect(button).to have_content 'Comment' else - expect(find(submit_selector).value).to eq 'Comment' + expect(button.value).to eq 'Comment' end expect(page).not_to have_selector menu_selector |