18 |
18 |
require_relative '../application_system_test_case'
|
19 |
19 |
class CopyPreContentToClipboardSystemTest < ApplicationSystemTestCase
|
20 |
20 |
def test_copy_issue_pre_content_to_clipboard_if_common_mark
|
21 |
|
log_user('jsmith', 'jsmith')
|
22 |
21 |
issue = Issue.find(1)
|
23 |
|
issue.journals.first.update(notes: "```\ntest\n```")
|
24 |
|
visit "/issues/#{issue.id}"
|
25 |
|
# A button appears when hovering over the <pre> tag
|
26 |
|
find("#journal-#{issue.journals.first.id}-notes div.pre-wrapper:first-of-type").hover
|
27 |
|
find("#journal-#{issue.journals.first.id}-notes div.pre-wrapper:first-of-type .copy-pre-content-link")
|
28 |
|
# Copy pre content to Clipboard
|
29 |
|
find("#journal-#{issue.journals.first.id}-notes div.pre-wrapper:first-of-type .copy-pre-content-link").click
|
30 |
|
# Paste the value copied to the clipboard into the textarea to get and test
|
31 |
|
first('.icon-edit').click
|
32 |
|
find('textarea#issue_notes').send_keys([modifier_key, 'v'])
|
33 |
|
assert_equal find('textarea#issue_notes').value, 'test'
|
|
22 |
issue.update(description: "```\ntest\ncommon mark\n```")
|
|
23 |
assert_copied_pre_content_matches(issue_id: issue.id, expected_value: "test\ncommon mark")
|
34 |
24 |
end
|
|
25 |
|
35 |
26 |
def test_copy_issue_code_content_to_clipboard_if_common_mark
|
36 |
|
log_user('jsmith', 'jsmith')
|
37 |
27 |
issue = Issue.find(1)
|
38 |
|
issue.journals.first.update(notes: "```ruby\nputs \"Hello, World.\"\n```")
|
39 |
|
visit "/issues/#{issue.id}"
|
40 |
|
# A button appears when hovering over the <pre> tag
|
41 |
|
find("#journal-#{issue.journals.first.id}-notes div.pre-wrapper:first-of-type").hover
|
42 |
|
find("#journal-#{issue.journals.first.id}-notes div.pre-wrapper:first-of-type .copy-pre-content-link")
|
43 |
|
# Copy pre content to Clipboard
|
44 |
|
find("#journal-#{issue.journals.first.id}-notes div.pre-wrapper:first-of-type .copy-pre-content-link").click
|
45 |
|
# Paste the value copied to the clipboard into the textarea to get and test
|
46 |
|
first('.icon-edit').click
|
47 |
|
find('textarea#issue_notes').send_keys([modifier_key, 'v'])
|
48 |
|
assert_equal find('textarea#issue_notes').value, 'puts "Hello, World."'
|
|
28 |
issue.update(description: "```ruby\nputs 'Hello, World.'\ncommon mark\n```")
|
|
29 |
assert_copied_pre_content_matches(issue_id: issue.id, expected_value: "puts 'Hello, World.'\ncommon mark")
|
49 |
30 |
end
|
|
31 |
|
50 |
32 |
def test_copy_issue_pre_content_to_clipboard_if_textile
|
51 |
|
log_user('jsmith', 'jsmith')
|
52 |
33 |
issue = Issue.find(1)
|
53 |
|
issue.journals.first.update(notes: "<pre>\ntest\n</pre>")
|
|
34 |
issue.update(description: "<pre>\ntest\ntextile\n</pre>")
|
54 |
35 |
with_settings text_formatting: :textile do
|
55 |
|
visit "/issues/#{issue.id}"
|
56 |
|
# A button appears when hovering over the <pre> tag
|
57 |
|
find("#journal-#{issue.journals.first.id}-notes div.pre-wrapper:first-of-type").hover
|
58 |
|
find("#journal-#{issue.journals.first.id}-notes div.pre-wrapper:first-of-type .copy-pre-content-link")
|
59 |
|
# Copy pre content to Clipboard
|
60 |
|
find("#journal-#{issue.journals.first.id}-notes div.pre-wrapper:first-of-type .copy-pre-content-link").click
|
61 |
|
# Paste the value copied to the clipboard into the textarea to get and test
|
62 |
|
first('.icon-edit').click
|
63 |
|
find('textarea#issue_notes').send_keys([modifier_key, 'v'])
|
64 |
|
assert_equal find('textarea#issue_notes').value, 'test'
|
|
36 |
assert_copied_pre_content_matches(issue_id: issue.id, expected_value: "test\ntextile")
|
65 |
37 |
end
|
66 |
38 |
end
|
|
39 |
|
67 |
40 |
def test_copy_issue_code_content_to_clipboard_if_textile
|
68 |
|
log_user('jsmith', 'jsmith')
|
69 |
41 |
issue = Issue.find(1)
|
70 |
|
issue.journals.first.update(notes: "<pre><code class=\"ruby\">\nputs \"Hello, World.\"\n</code></pre>")
|
|
42 |
issue.update(description: "<pre><code class=\"ruby\">\nputs 'Hello, World.'\ntextile\n</code></pre>")
|
71 |
43 |
with_settings text_formatting: :textile do
|
72 |
|
visit "/issues/#{issue.id}"
|
73 |
|
# A button appears when hovering over the <pre> tag
|
74 |
|
find("#journal-#{issue.journals.first.id}-notes div.pre-wrapper:first-of-type").hover
|
75 |
|
find("#journal-#{issue.journals.first.id}-notes div.pre-wrapper:first-of-type .copy-pre-content-link")
|
76 |
|
# Copy pre content to Clipboard
|
77 |
|
find("#journal-#{issue.journals.first.id}-notes div.pre-wrapper:first-of-type .copy-pre-content-link").click
|
78 |
|
# Paste the value copied to the clipboard into the textarea to get and test
|
79 |
|
first('.icon-edit').click
|
80 |
|
find('textarea#issue_notes').send_keys([modifier_key, 'v'])
|
81 |
|
assert_equal find('textarea#issue_notes').value, 'puts "Hello, World."'
|
|
44 |
assert_copied_pre_content_matches(issue_id: issue.id, expected_value: "puts 'Hello, World.'\ntextile")
|
82 |
45 |
end
|
83 |
46 |
end
|
|
47 |
|
84 |
48 |
private
|
85 |
49 |
def modifier_key
|
86 |
50 |
modifier = osx? ? 'command' : 'control'
|
87 |
51 |
modifier.to_sym
|
88 |
52 |
end
|
|
53 |
|
|
54 |
def assert_copied_pre_content_matches(issue_id:, expected_value:)
|
|
55 |
visit "/issues/#{issue_id}"
|
|
56 |
# A button appears when hovering over the <pre> tag
|
|
57 |
find("#issue_description_wiki div.pre-wrapper:first-of-type").hover
|
|
58 |
assert_selector('#issue_description_wiki div.pre-wrapper:first-of-type .copy-pre-content-link')
|
|
59 |
|
|
60 |
# Copy pre content to Clipboard
|
|
61 |
find("#issue_description_wiki div.pre-wrapper:first-of-type .copy-pre-content-link").click
|
|
62 |
|
|
63 |
# Paste the value copied to the clipboard into the textarea to get and test
|
|
64 |
first('.icon-edit').click
|
|
65 |
find('textarea#issue_notes').set('')
|
|
66 |
find('textarea#issue_notes').send_keys([modifier_key, 'v'])
|
|
67 |
assert_equal find('textarea#issue_notes').value, expected_value
|
|
68 |
end
|
89 |
69 |
end
|