Commit e06f0ead authored by Vinnie Okada's avatar Vinnie Okada

Fix Markdown preview tests

Update Spinach tests for Markdown previews for the new-ish tab UI that
replaced the old preview/edit toggle button.
parent e1491465
...@@ -16,12 +16,12 @@ Feature: Project Commits Comments ...@@ -16,12 +16,12 @@ Feature: Project Commits Comments
@javascript @javascript
Scenario: I can't preview without text Scenario: I can't preview without text
Given I haven't written any comment text Given I haven't written any comment text
Then I should not see the comment preview button Then The comment preview tab should say there is nothing to do
@javascript @javascript
Scenario: I can preview with text Scenario: I can preview with text
Given I write a comment like "Nice" Given I write a comment like ":+1: Nice"
Then I should see the comment preview button Then The comment preview tab should be display rendered Markdown
@javascript @javascript
Scenario: I preview a comment Scenario: I preview a comment
...@@ -32,7 +32,7 @@ Feature: Project Commits Comments ...@@ -32,7 +32,7 @@ Feature: Project Commits Comments
@javascript @javascript
Scenario: I can edit after preview Scenario: I can edit after preview
Given I preview a comment text like "Bug fixed :smile:" Given I preview a comment text like "Bug fixed :smile:"
Then I should see the comment edit button Then I should see the comment write tab
@javascript @javascript
Scenario: I have a reset form after posting from preview Scenario: I have a reset form after posting from preview
......
...@@ -58,13 +58,13 @@ Feature: Project Commits Diff Comments ...@@ -58,13 +58,13 @@ Feature: Project Commits Diff Comments
Scenario: I can't preview without text Scenario: I can't preview without text
Given I open a diff comment form Given I open a diff comment form
And I haven't written any diff comment text And I haven't written any diff comment text
Then I should not see the diff comment preview button Then The diff comment preview tab should say there is nothing to do
@javascript @javascript
Scenario: I can preview with text Scenario: I can preview with text
Given I open a diff comment form Given I open a diff comment form
And I write a diff comment like ":-1: I don't like this" And I write a diff comment like ":-1: I don't like this"
Then I should see the diff comment preview button Then The diff comment preview tab should display rendered Markdown
@javascript @javascript
Scenario: I preview a diff comment Scenario: I preview a diff comment
...@@ -75,7 +75,7 @@ Feature: Project Commits Diff Comments ...@@ -75,7 +75,7 @@ Feature: Project Commits Diff Comments
@javascript @javascript
Scenario: I can edit after preview Scenario: I can edit after preview
Given I preview a diff comment text like "Should fix it :smile:" Given I preview a diff comment text like "Should fix it :smile:"
Then I should see the diff comment edit button Then I should see the diff comment write tab
@javascript @javascript
Scenario: The form gets removed after posting Scenario: The form gets removed after posting
......
...@@ -166,13 +166,13 @@ Feature: Project Issues ...@@ -166,13 +166,13 @@ Feature: Project Issues
Scenario: I can't preview without text Scenario: I can't preview without text
Given I click link "New Issue" Given I click link "New Issue"
And I haven't written any description text And I haven't written any description text
Then I should not see the Markdown preview button Then The Markdown preview tab should say there is nothing to do
@javascript @javascript
Scenario: I can preview with text Scenario: I can preview with text
Given I click link "New Issue" Given I click link "New Issue"
And I write a description like "Nice" And I write a description like ":+1: Nice"
Then I should see the Markdown preview button Then The Markdown preview tab should display rendered Markdown
@javascript @javascript
Scenario: I preview an issue description Scenario: I preview an issue description
...@@ -185,4 +185,4 @@ Feature: Project Issues ...@@ -185,4 +185,4 @@ Feature: Project Issues
Scenario: I can edit after preview Scenario: I can edit after preview
Given I click link "New Issue" Given I click link "New Issue"
And I preview a description text like "Bug fixed :smile:" And I preview a description text like "Bug fixed :smile:"
Then I should see the Markdown edit button Then I should see the Markdown write tab
...@@ -71,9 +71,10 @@ module SharedDiffNote ...@@ -71,9 +71,10 @@ module SharedDiffNote
end end
end end
step 'I should not see the diff comment preview button' do step 'The diff comment preview tab should say there is nothing to do' do
within(diff_file_selector) do within(diff_file_selector) do
expect(page).not_to have_css('.js-md-preview-button') find('.js-md-preview-button').click
expect(find('.js-md-preview')).to have_content('Nothing to preview.')
end end
end end
...@@ -135,15 +136,16 @@ module SharedDiffNote ...@@ -135,15 +136,16 @@ module SharedDiffNote
end end
end end
step 'I should see the diff comment edit button' 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')
end end
end end
step 'I should see the diff comment preview button' do step 'The diff comment preview tab should display rendered Markdown' do
within(diff_file_selector) do within(diff_file_selector) do
expect(page).to have_css('.js-md-preview-button') find('.js-md-preview-button').click
expect(find('.js-md-preview')).to have_css('img.emoji')
end end
end end
......
...@@ -56,18 +56,21 @@ EOT ...@@ -56,18 +56,21 @@ 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') expect(find('.gfm-form')).not_to have_css('.js-md-preview', visible: true)
end end
step 'I should not see the Markdown preview button' do step 'The Markdown preview tab should say there is nothing to do' do
expect(find('.gfm-form')).not_to have_css('.js-md-preview-button') within(".gfm-form") do
find('.js-md-preview-button').click
expect(find('.js-md-preview')).to have_content('Nothing to preview.')
end
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') expect(find('.gfm-form')).not_to have_css('textarea', visible: true)
end end
step 'I should see the Markdown edit button' 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')
end end
...@@ -75,12 +78,15 @@ EOT ...@@ -75,12 +78,15 @@ EOT
expect(find('.gfm-form')).to have_css('.js-md-preview') expect(find('.gfm-form')).to have_css('.js-md-preview')
end end
step 'I should see the Markdown preview button' do step 'The Markdown preview tab should display rendered Markdown' do
expect(find('.gfm-form')).to have_css('.js-md-preview-button') within(".gfm-form") do
find('.js-md-preview-button').click
expect(find('.js-md-preview')).to have_css('img.emoji')
end
end end
step 'I write a description like "Nice"' do step 'I write a description like ":+1: Nice"' do
find('.gfm-form').fill_in 'Description', with: 'Nice' find('.gfm-form').fill_in 'Description', with: ':+1: Nice'
end end
step 'I preview a description text like "Bug fixed :smile:"' do step 'I preview a description text like "Bug fixed :smile:"' do
......
...@@ -33,9 +33,9 @@ module SharedNote ...@@ -33,9 +33,9 @@ module SharedNote
end end
end end
step 'I write a comment like "Nice"' do step 'I write a comment like ":+1: Nice"' do
within(".js-main-target-form") do within(".js-main-target-form") do
fill_in "note[note]", with: "Nice" fill_in "note[note]", with: ":+1: Nice"
end end
end end
...@@ -51,13 +51,14 @@ module SharedNote ...@@ -51,13 +51,14 @@ 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') expect(page).not_to have_css('.js-md-preview', visible: true)
end end
end end
step 'I should not see the comment preview button' do step 'The comment preview tab should say there is nothing to do' do
within(".js-main-target-form") do within(".js-main-target-form") do
expect(page).not_to have_css('.js-md-preview-button') find('.js-md-preview-button').click
expect(find('.js-md-preview')).to have_content('Nothing to preview.')
end end
end end
...@@ -79,21 +80,22 @@ module SharedNote ...@@ -79,21 +80,22 @@ module SharedNote
end end
end end
step 'I should see the comment edit button' 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')
end end
end end
step 'I should see the comment preview' do step 'The comment preview tab should be display rendered Markdown' do
within(".js-main-target-form") do within(".js-main-target-form") do
expect(page).to have_css('.js-md-preview') find('.js-md-preview-button').click
expect(find('.js-md-preview')).to have_css('img.emoji')
end end
end end
step 'I should see the comment preview button' 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-button') expect(page).to have_css('.js-md-preview')
end end
end end
......
...@@ -21,7 +21,6 @@ describe 'Comments' do ...@@ -21,7 +21,6 @@ describe 'Comments' do
find(".js-main-target-form input[type=submit]").value.should == "Add Comment" find(".js-main-target-form input[type=submit]").value.should == "Add Comment"
within('.js-main-target-form') do within('.js-main-target-form') do
expect(page).not_to have_link('Cancel') expect(page).not_to have_link('Cancel')
expect(page).not_to have_css('.js-md-preview-button', visible: true)
end end
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