Project

General

Profile

Feature #44642 » 0001-Add-a-system-test-for-pasting-an-image-from-the-clip.patch

Go MAEDA, 2026-10-29 00:54

View differences:

test/system/issues_test.rb
assert_no_selector '.add_attachment', :visible => true
end
def test_paste_image_from_clipboard
set_tmp_attachments_directory
log_user('jsmith', 'jsmith')
visit '/projects/ecookbook/issues/new'
page.execute_script(<<~JS)
// 1x1 1-bit grayscale PNG image
const png = Uint8Array.from(atob('iVBORw0KGgoAAAANSUhEUgAAAAEAAAABAQAAAAA3bvkkAAAACklEQVR42mNgAAAAAgAB5Sfe/AAAAABJRU5ErkJggg=='), c => c.charCodeAt(0));
const clipboardData = new DataTransfer();
clipboardData.items.add(new File([png], 'image.png', { type: 'image/png' }));
const event = new Event('paste', { bubbles: true, cancelable: true });
Object.defineProperty(event, 'clipboardData', { value: clipboardData });
document.getElementById('issue_description').dispatchEvent(event);
JS
filename = find('.attachments_fields input.filename').value
assert_match /\Aclipboard-\d{12}-[a-z0-9]{5}\.png\z/, filename
assert_field 'issue_description', :with => %(<img style="width: 1px;" src="#{filename}"><br>\n)
end
def test_pasting_image_beyond_max_attachments_at_once_should_show_error
set_tmp_attachments_directory
log_user('jsmith', 'jsmith')
(2-2/3)