Feature #29214 » 0002-Fix-system-test-not-to-fail.patch
| test/system/copy_pre_content_to_clipboard_test.rb | ||
|---|---|---|
|
require_relative '../application_system_test_case'
|
||
|
class CopyPreContentToClipboardSystemTest < ApplicationSystemTestCase
|
||
|
def test_copy_issue_pre_content_to_clipboard_if_common_mark
|
||
|
log_user('jsmith', 'jsmith')
|
||
|
issue = Issue.find(1)
|
||
|
issue.journals.first.update(notes: "```\ntest\n```")
|
||
|
visit "/issues/#{issue.id}"
|
||
|
# A button appears when hovering over the <pre> tag
|
||
|
find("#journal-#{issue.journals.first.id}-notes div.pre-wrapper:first-of-type").hover
|
||
|
find("#journal-#{issue.journals.first.id}-notes div.pre-wrapper:first-of-type .copy-pre-content-link")
|
||
|
# Copy pre content to Clipboard
|
||
|
find("#journal-#{issue.journals.first.id}-notes div.pre-wrapper:first-of-type .copy-pre-content-link").click
|
||
|
# Paste the value copied to the clipboard into the textarea to get and test
|
||
|
first('.icon-edit').click
|
||
|
find('textarea#issue_notes').send_keys([modifier_key, 'v'])
|
||
|
assert_equal find('textarea#issue_notes').value, 'test'
|
||
|
issue.update(description: "```\ntest\ncommon mark\n```")
|
||
|
assert_copied_pre_content_matches(issue_id: issue.id, expected_value: "test\ncommon mark")
|
||
|
end
|
||
|
def test_copy_issue_code_content_to_clipboard_if_common_mark
|
||
|
log_user('jsmith', 'jsmith')
|
||
|
issue = Issue.find(1)
|
||
|
issue.journals.first.update(notes: "```ruby\nputs \"Hello, World.\"\n```")
|
||
|
visit "/issues/#{issue.id}"
|
||
|
# A button appears when hovering over the <pre> tag
|
||
|
find("#journal-#{issue.journals.first.id}-notes div.pre-wrapper:first-of-type").hover
|
||
|
find("#journal-#{issue.journals.first.id}-notes div.pre-wrapper:first-of-type .copy-pre-content-link")
|
||
|
# Copy pre content to Clipboard
|
||
|
find("#journal-#{issue.journals.first.id}-notes div.pre-wrapper:first-of-type .copy-pre-content-link").click
|
||
|
# Paste the value copied to the clipboard into the textarea to get and test
|
||
|
first('.icon-edit').click
|
||
|
find('textarea#issue_notes').send_keys([modifier_key, 'v'])
|
||
|
assert_equal find('textarea#issue_notes').value, 'puts "Hello, World."'
|
||
|
issue.update(description: "```ruby\nputs 'Hello, World.'\ncommon mark\n```")
|
||
|
assert_copied_pre_content_matches(issue_id: issue.id, expected_value: "puts 'Hello, World.'\ncommon mark")
|
||
|
end
|
||
|
def test_copy_issue_pre_content_to_clipboard_if_textile
|
||
|
log_user('jsmith', 'jsmith')
|
||
|
issue = Issue.find(1)
|
||
|
issue.journals.first.update(notes: "<pre>\ntest\n</pre>")
|
||
|
issue.update(description: "<pre>\ntest\ntextile\n</pre>")
|
||
|
with_settings text_formatting: :textile do
|
||
|
visit "/issues/#{issue.id}"
|
||
|
# A button appears when hovering over the <pre> tag
|
||
|
find("#journal-#{issue.journals.first.id}-notes div.pre-wrapper:first-of-type").hover
|
||
|
find("#journal-#{issue.journals.first.id}-notes div.pre-wrapper:first-of-type .copy-pre-content-link")
|
||
|
# Copy pre content to Clipboard
|
||
|
find("#journal-#{issue.journals.first.id}-notes div.pre-wrapper:first-of-type .copy-pre-content-link").click
|
||
|
# Paste the value copied to the clipboard into the textarea to get and test
|
||
|
first('.icon-edit').click
|
||
|
find('textarea#issue_notes').send_keys([modifier_key, 'v'])
|
||
|
assert_equal find('textarea#issue_notes').value, 'test'
|
||
|
assert_copied_pre_content_matches(issue_id: issue.id, expected_value: "test\ntextile")
|
||
|
end
|
||
|
end
|
||
|
def test_copy_issue_code_content_to_clipboard_if_textile
|
||
|
log_user('jsmith', 'jsmith')
|
||
|
issue = Issue.find(1)
|
||
|
issue.journals.first.update(notes: "<pre><code class=\"ruby\">\nputs \"Hello, World.\"\n</code></pre>")
|
||
|
issue.update(description: "<pre><code class=\"ruby\">\nputs 'Hello, World.'\ntextile\n</code></pre>")
|
||
|
with_settings text_formatting: :textile do
|
||
|
visit "/issues/#{issue.id}"
|
||
|
# A button appears when hovering over the <pre> tag
|
||
|
find("#journal-#{issue.journals.first.id}-notes div.pre-wrapper:first-of-type").hover
|
||
|
find("#journal-#{issue.journals.first.id}-notes div.pre-wrapper:first-of-type .copy-pre-content-link")
|
||
|
# Copy pre content to Clipboard
|
||
|
find("#journal-#{issue.journals.first.id}-notes div.pre-wrapper:first-of-type .copy-pre-content-link").click
|
||
|
# Paste the value copied to the clipboard into the textarea to get and test
|
||
|
first('.icon-edit').click
|
||
|
find('textarea#issue_notes').send_keys([modifier_key, 'v'])
|
||
|
assert_equal find('textarea#issue_notes').value, 'puts "Hello, World."'
|
||
|
assert_copied_pre_content_matches(issue_id: issue.id, expected_value: "puts 'Hello, World.'\ntextile")
|
||
|
end
|
||
|
end
|
||
|
private
|
||
|
def modifier_key
|
||
|
modifier = osx? ? 'command' : 'control'
|
||
|
modifier.to_sym
|
||
|
end
|
||
|
def assert_copied_pre_content_matches(issue_id:, expected_value:)
|
||
|
visit "/issues/#{issue_id}"
|
||
|
# A button appears when hovering over the <pre> tag
|
||
|
find("#issue_description_wiki div.pre-wrapper:first-of-type").hover
|
||
|
assert_selector('#issue_description_wiki div.pre-wrapper:first-of-type .copy-pre-content-link')
|
||
|
# Copy pre content to Clipboard
|
||
|
find("#issue_description_wiki div.pre-wrapper:first-of-type .copy-pre-content-link").click
|
||
|
# Paste the value copied to the clipboard into the textarea to get and test
|
||
|
first('.icon-edit').click
|
||
|
find('textarea#issue_notes').set('')
|
||
|
find('textarea#issue_notes').send_keys([modifier_key, 'v'])
|
||
|
assert_equal find('textarea#issue_notes').value, expected_value
|
||
|
end
|
||
|
end
|
||
- « Previous
- 1
- …
- 9
- 10
- 11
- Next »