Skip to content

Commit

Permalink
Change regex test against url in goto to include about:*
Browse files Browse the repository at this point in the history
Signed-off-by: Radheshyam Etikala <radheshyame@sahajsoft.com>
  • Loading branch information
Radheshyam Etikala committed Oct 26, 2021
1 parent dec13ae commit 1551d11
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/taiko.js
Original file line number Diff line number Diff line change
Expand Up @@ -733,7 +733,7 @@ module.exports.goto = async (
options = { navigationTimeout: defaultConfig.navigationTimeout },
) => {
validate();
if (!/:\/\//i.test(url)) {
if (!/^about:|:\/\//i.test(url)) {
url = 'http://' + url;
}
if (options.headers) {
Expand Down Expand Up @@ -1249,7 +1249,7 @@ async function mouseAction(selector, action, coordinates, options = {}) {
* Scrolls the page to the given element.
* The alignment parameters can be overridden, see below.
* Tthe possible values reference are available at the https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView.
*
*
*
* @example
* await scrollTo('Get Started')
Expand All @@ -1266,7 +1266,7 @@ async function mouseAction(selector, action, coordinates, options = {}) {
* @param {number} [options.waitForStart = 100] - time to wait for navigation to start. Accepts value in milliseconds.
* @param {string} [options.blockAlignment = 'nearest'] - Defines vertical alignment.
* @param {string} [options.inlineAligment = 'nearest'] - Defines horizontal alignment.
*
*
* @returns {Promise<void>}
*/
module.exports.scrollTo = async (selector, options = {}) => {
Expand Down
14 changes: 14 additions & 0 deletions test/unit-tests/goto.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,20 @@ describe(test_name, () => {
expect(actualUrl).to.equal(expectedUrl);
});

it('should not add protocol http:// if url is "about:*"', async () => {
let aboutBlank = 'about:randomString';
let expectedUrl = aboutBlank;
await taiko.goto(aboutBlank);
expect(actualUrl).to.equal(expectedUrl);
});

it('should add protocol http:// for url with port specified', async () => {
let urlWithPort = 'localhost:8080';
let expectedUrl = 'http://' + urlWithPort;
await taiko.goto(urlWithPort);
expect(actualUrl).to.equal(expectedUrl);
});

it('should configure provided headers for the domain', async () => {
let options = {
headers: { Authorization: 'Basic cG9zdG1hbjpwYXNzd29y2A==' },
Expand Down

0 comments on commit 1551d11

Please sign in to comment.