Sha256: 67618ba4f96721b96dca0c6977881dc2986e12d3bcf95575af118d52c7f61781
Contents?: true
Size: 1.33 KB
Versions: 9
Compression:
Stored size: 1.33 KB
Contents
# frozen_string_literal: true shared_examples "share link" do it "allows copying the share link from the share modal" do click_on("Share") # This overrides document.execCommand in order to ensure it was called. page.execute_script( <<~JS var origExec = document.execCommand; document.execCommand = function(cmd) { if (cmd === "copy") { var $test = $('<div id="urlShareTest" />'); $("#socialShare").append($test); var selObj = window.getSelection(); $test.text( "The following text was copied to clipboard: " + selObj.toString() ); return true; } else { return Reflect.apply(origExec, document, arguments) } }; JS ) within "#socialShare" do expect(page).to have_content("Share") expect(page).to have_content("Copy") input = find_by_id("urlShareLink") find("[data-clipboard-copy]").click expect(find("[data-clipboard-copy]")).to have_content("Copied!") expect(page).to have_content("The following text was copied to clipboard: #{input.value}") # Check that the screen reader announcement is properly added. expect(find("[aria-role='alert']")).to have_content("The link was successfully copied to clipboard.") end end end
Version data entries
9 entries across 9 versions & 1 rubygems