summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Sotoudeh <matthewsot@outlook.com>2020-08-29 20:14:02 -0700
committerMatthew Sotoudeh <matthewsot@outlook.com>2020-08-29 20:14:14 -0700
commitfd1ff4b4d6517dab0936c64556ca3823ba573f78 (patch)
treececfe97df202a95a934e19a2b110fa027a6b9f55
parente8ffe5e7bb1a9983a39eac21389867dd1aa0cbfe (diff)
Added docs.insertLink(target, text)
Issue #3
-rw-r--r--docs.js9
-rw-r--r--test.js4
2 files changed, 13 insertions, 0 deletions
diff --git a/docs.js b/docs.js
index b59b72e..052ab41 100644
--- a/docs.js
+++ b/docs.js
@@ -161,6 +161,15 @@ docs.toggleBold = function () {
docs.pressKey(66, true, false);
};
+// Inserts a link with the given text.
+docs.insertLink = function (target, text) {
+ docs.pressButton($("[aria-label='Insert link (Ctrl+K)']")[0]);
+ $("[aria-label='Paste a link, or search']")[0].value = target;
+ $(".docs-link-insertlinkbubble-text.jfk-textinput.label-input-label")[0].value = text;
+ $("[aria-label='Paste a link, or search']")[0].dispatchEvent(new CustomEvent("input"));
+ docs.pressButton($(".docs-link-insertlinkbubble-buttonbar > div")[0]);
+};
+
/*********** MENU OPTIONS ***********/
docs.undo = function () {
docs.pressButton($("[aria-label='Undo u']")[0]);
diff --git a/test.js b/test.js
index c5e234c..d3e19b0 100644
--- a/test.js
+++ b/test.js
@@ -60,6 +60,10 @@ docs.keydown = async function (e) {
docs.pasteText("Back to normal.\n");
await sleep(500);
+ docs.insertLink("https://example.com/", "This should be a link to https://example.com/");
+ docs.pasteText("Back to normal.\n");
+ await sleep(500);
+
docs.pasteText("A few tests require user input:\n" +
"1) Select something (or not) and press alt+s to " +
"check the selection methods.\n" +
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback