From 90787183d188ac5540302c26c571176c6738aace Mon Sep 17 00:00:00 2001 From: MAEDA Go Date: Thu, 29 Oct 2026 08:45:19 +0900 Subject: [PATCH 1/2] Add a system test for pasting an image from the clipboard --- test/system/issues_test.rb | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/test/system/issues_test.rb b/test/system/issues_test.rb index e902a8df9..139b8687f 100644 --- a/test/system/issues_test.rb +++ b/test/system/issues_test.rb @@ -191,6 +191,25 @@ class IssuesSystemTest < ApplicationSystemTestCase 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 => %(
\n) + end + def test_pasting_image_beyond_max_attachments_at_once_should_show_error set_tmp_attachments_directory log_user('jsmith', 'jsmith') -- 2.55.0