-
Notifications
You must be signed in to change notification settings - Fork 311
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Infrastructure: Changes tests to not follow external links (pull #1600)
* Fixes #1594 by changing link tests to not follow external links. * Adds replace external links helper function
- Loading branch information
1 parent
69e09e1
commit ffa58e3
Showing
5 changed files
with
75 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/** | ||
* Replace and href with an link -- typically use url fragement -- to test behavior related to link following | ||
* | ||
* @param {ExecutionContext} t - Test execution context | ||
* @param {String} newUrl - the url to replace the external url | ||
* @param {String} linkSelector - CSS selector string | ||
* @param {Number} index - if the link selector returns a list, the index of the item to test | ||
* | ||
* @returns {Promise} Resolves to array of elements | ||
*/ | ||
module.exports = async function replaceExternalLinks( | ||
t, | ||
newUrl, | ||
linkSelector, | ||
index | ||
) { | ||
await t.context.session.executeScript( | ||
function () { | ||
let [selector, index, newUrl] = arguments; | ||
document.querySelectorAll(selector)[index].href = newUrl; | ||
}, | ||
linkSelector, | ||
index || 0, | ||
newUrl | ||
); | ||
}; |