|
84 | 84 | end |
85 | 85 | end |
86 | 86 |
|
| 87 | + describe "right-click context menu 'Copy numeric ID to clipboard' item" do |
| 88 | + it "copies the numeric id and does not navigate away (regression: used to 404)" do |
| 89 | + numeric_id = work_package.id.to_s |
| 90 | + semantic_id = work_package.reload.identifier |
| 91 | + |
| 92 | + # Spy directly on navigator.clipboard.writeText (see the sibling |
| 93 | + # 'Copy link to clipboard' example for why the flash matcher won't do). |
| 94 | + page.execute_script(<<~JS) |
| 95 | + window.__lastCopiedText = null; |
| 96 | + navigator.clipboard.writeText = function(text) { |
| 97 | + window.__lastCopiedText = text; |
| 98 | + return Promise.resolve(); |
| 99 | + }; |
| 100 | + JS |
| 101 | + |
| 102 | + context_menu.open_for(work_package) |
| 103 | + context_menu.choose("Copy numeric ID to clipboard") |
| 104 | + |
| 105 | + copied = nil |
| 106 | + retry_block do |
| 107 | + copied = page.evaluate_script("window.__lastCopiedText") |
| 108 | + raise "clipboard write not yet observed" if copied.nil? |
| 109 | + end |
| 110 | + |
| 111 | + expect(copied).to eq(numeric_id) |
| 112 | + expect(copied).not_to eq(semantic_id) |
| 113 | + |
| 114 | + # The action used to fall through to `window.location.href = undefined`, |
| 115 | + # navigating to a non-existent URL. It must stay on the table instead. |
| 116 | + wp_table.expect_work_package_listed(work_package, other_wp) |
| 117 | + end |
| 118 | + end |
| 119 | + |
| 120 | + context "in classic (numeric) mode", with_settings: { work_packages_identifier: "classic" } do |
| 121 | + describe "right-click context menu 'Copy numeric ID to clipboard' item" do |
| 122 | + it "is not offered (the displayed id is already the numeric id)" do |
| 123 | + context_menu.open_for(work_package) |
| 124 | + context_menu.expect_no_options("Copy numeric ID to clipboard") |
| 125 | + end |
| 126 | + end |
| 127 | + end |
| 128 | + |
87 | 129 | describe "toolbar info icon" do |
88 | 130 | it "opens the split view at the semantic identifier URL" do |
89 | 131 | semantic_id = work_package.reload.identifier |
|
0 commit comments