Commit 7a5072c5 authored by Vinnie Okada's avatar Vinnie Okada

Fix test assertions

Make sure we're asserting the correct thing when testing visible and
invisible DOM elements.
parent 5bb8aff5
...@@ -132,26 +132,26 @@ module SharedDiffNote ...@@ -132,26 +132,26 @@ module SharedDiffNote
step 'I should see the diff comment preview' do step 'I should see the diff comment preview' do
within("#{diff_file_selector} form") do within("#{diff_file_selector} form") do
expect(page).to have_css('.js-md-preview') expect(page).to have_css('.js-md-preview', visible: true)
end end
end end
step 'I should see the diff comment write tab' do step 'I should see the diff comment write tab' do
within(diff_file_selector) do within(diff_file_selector) do
expect(page).to have_css('.js-md-write-button') expect(page).to have_css('.js-md-write-button', visible: true)
end end
end end
step 'The diff comment preview tab should display rendered Markdown' do step 'The diff comment preview tab should display rendered Markdown' do
within(diff_file_selector) do within(diff_file_selector) do
find('.js-md-preview-button').click find('.js-md-preview-button').click
expect(find('.js-md-preview')).to have_css('img.emoji') expect(find('.js-md-preview')).to have_css('img.emoji', visible: true)
end end
end end
step 'I should see two separate previews' do step 'I should see two separate previews' do
within(diff_file_selector) do within(diff_file_selector) do
expect(page).to have_css('.js-md-preview', count: 2) expect(page).to have_css('.js-md-preview', visible: true, count: 2)
expect(page).to have_content('Should fix it') expect(page).to have_content('Should fix it')
expect(page).to have_content('DRY this up') expect(page).to have_content('DRY this up')
end end
......
...@@ -56,7 +56,7 @@ EOT ...@@ -56,7 +56,7 @@ EOT
end end
step 'I should not see the Markdown preview' do step 'I should not see the Markdown preview' do
expect(find('.gfm-form')).not_to have_css('.js-md-preview', visible: true) expect(find('.gfm-form .js-md-preview')).not_to be_visible
end end
step 'The Markdown preview tab should say there is nothing to do' do step 'The Markdown preview tab should say there is nothing to do' do
...@@ -67,21 +67,21 @@ EOT ...@@ -67,21 +67,21 @@ EOT
end end
step 'I should not see the Markdown text field' do step 'I should not see the Markdown text field' do
expect(find('.gfm-form')).not_to have_css('textarea', visible: true) expect(find('.gfm-form textarea')).not_to be_visible
end end
step 'I should see the Markdown write tab' do step 'I should see the Markdown write tab' do
expect(find('.gfm-form')).to have_css('.js-md-write-button') expect(find('.gfm-form')).to have_css('.js-md-write-button', visible: true)
end end
step 'I should see the Markdown preview' do step 'I should see the Markdown preview' do
expect(find('.gfm-form')).to have_css('.js-md-preview') expect(find('.gfm-form')).to have_css('.js-md-preview', visible: true)
end end
step 'The Markdown preview tab should display rendered Markdown' do step 'The Markdown preview tab should display rendered Markdown' do
within('.gfm-form') do within('.gfm-form') do
find('.js-md-preview-button').click find('.js-md-preview-button').click
expect(find('.js-md-preview')).to have_css('img.emoji') expect(find('.js-md-preview')).to have_css('img.emoji', visible: true)
end end
end end
......
...@@ -51,7 +51,7 @@ module SharedNote ...@@ -51,7 +51,7 @@ module SharedNote
step 'I should not see the comment preview' do step 'I should not see the comment preview' do
within(".js-main-target-form") do within(".js-main-target-form") do
expect(page).not_to have_css('.js-md-preview', visible: true) expect(find('.js-md-preview')).not_to be_visible
end end
end end
...@@ -82,20 +82,20 @@ module SharedNote ...@@ -82,20 +82,20 @@ module SharedNote
step 'I should see the comment write tab' do step 'I should see the comment write tab' do
within(".js-main-target-form") do within(".js-main-target-form") do
expect(page).to have_css('.js-md-write-button') expect(page).to have_css('.js-md-write-button', visible: true)
end end
end end
step 'The comment preview tab should be display rendered Markdown' do step 'The comment preview tab should be display rendered Markdown' do
within(".js-main-target-form") do within(".js-main-target-form") do
find('.js-md-preview-button').click find('.js-md-preview-button').click
expect(find('.js-md-preview')).to have_css('img.emoji') expect(find('.js-md-preview')).to have_css('img.emoji', visible: true)
end end
end end
step 'I should see the comment preview' do step 'I should see the comment preview' do
within(".js-main-target-form") do within(".js-main-target-form") do
expect(page).to have_css('.js-md-preview') expect(page).to have_css('.js-md-preview', visible: true)
end end
end end
......
...@@ -34,7 +34,7 @@ describe 'Comments' do ...@@ -34,7 +34,7 @@ describe 'Comments' do
it 'should have enable submit button and preview button' do it 'should have enable submit button and preview button' do
within('.js-main-target-form') do within('.js-main-target-form') do
expect(page).not_to have_css('.js-comment-button[disabled]') expect(page).not_to have_css('.js-comment-button[disabled]')
expect(page).to have_css('.js-md-preview-button') expect(page).to have_css('.js-md-preview-button', visible: true)
end end
end end
end end
...@@ -53,7 +53,7 @@ describe 'Comments' do ...@@ -53,7 +53,7 @@ describe 'Comments' do
should have_content("This is awsome!") should have_content("This is awsome!")
within('.js-main-target-form') do within('.js-main-target-form') do
expect(page).to have_no_field('note[note]', with: 'This is awesome!') expect(page).to have_no_field('note[note]', with: 'This is awesome!')
expect(page).not_to have_css('.js-md-preview', visible: true) expect(page).to have_css('.js-md-preview', visible: :hidden)
end end
within(".js-main-target-form") { should have_css(".js-note-text", visible: true) } within(".js-main-target-form") { should have_css(".js-note-text", visible: true) }
end end
......
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