-
Notifications
You must be signed in to change notification settings - Fork 827
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1879 from BryceLTaylor/Verbose-Testing
Verbose testing
- Loading branch information
Showing
12 changed files
with
160 additions
and
129 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"devDependencies": { | ||
"selenium-webdriver": "2.45.0", | ||
"chromedriver": "2.33.0" | ||
"selenium-webdriver": "3.6.0", | ||
"chromedriver": "2.37.0" | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
test/helpers/selenium-helpers.js → test/integration/selenium-helpers.js
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,130 @@ | ||
const { | ||
clickText, | ||
findByXpath, | ||
clickButton, | ||
driver, | ||
until, | ||
By | ||
} = require('../selenium-helpers.js'); | ||
|
||
var username = process.env.SMOKE_USERNAME; | ||
var password = process.env.SMOKE_PASSWORD; | ||
|
||
|
||
var tap = require('tap'); | ||
const test = tap.test; | ||
|
||
var rootUrl = process.env.ROOT_URL || 'https://scratch.ly'; | ||
var url = rootUrl + '/users/' + username; | ||
|
||
tap.plan(5); | ||
|
||
tap.tearDown(function () { | ||
driver.quit(); | ||
}); | ||
|
||
tap.beforeEach(function () { | ||
return driver.get(url); | ||
}); | ||
|
||
/* | ||
* This test fails sometimes because blank username eventually | ||
* triggers the captcha page, which is a bug: | ||
* https://github.com/LLK/scratchr2/issues/4762 | ||
*/ | ||
test('Trying to sign in with no username and no password using scratchr2 navbar', t => { | ||
clickText('Sign in') | ||
.then(() => clickButton('Sign in')) | ||
.then(() => driver.wait(until | ||
.elementLocated(By.xpath('//form[@id="login"]/button[@type="submit"]'))) | ||
) | ||
.then(() => driver.wait(until | ||
.elementLocated(By.xpath('//form[@id="login"]/div[@class="error"]'))) | ||
) | ||
.then(() => findByXpath('//form/div[@class="error"]')) | ||
.then(element => element.getText()) | ||
.then(text => t.match(text, 'This field is required.', | ||
'"This field is required" error should be displayed')) | ||
.then(() => t.end()); | ||
}); | ||
|
||
/* | ||
* This test fails sometimes because blank username eventually | ||
* triggers the captcha page, which is a bug: | ||
* https://github.com/LLK/scratchr2/issues/4762 | ||
*/ | ||
test('Trying to sign in with no username using scratchr2 navbar', t => { | ||
clickText('Sign in') | ||
.then(() => findByXpath('//input[@name="password"]')) | ||
.then((element) => element.sendKeys(password)) | ||
.then(() => clickButton('Sign in')) | ||
.then(() => driver.wait(until | ||
.elementLocated(By.xpath('//form[@id="login"]/button[@type="submit"]'))) | ||
) | ||
.then(() => driver.wait(until | ||
.elementLocated(By.xpath('//form[@id="login"]/div[@class="error"]'))) | ||
) | ||
.then(() => findByXpath('//form/div[@class="error"]')) | ||
.then((element) => element.getText()) | ||
.then((text) => t.match(text, 'This field is required.', | ||
'"This field is required" error should be displayed')) | ||
.then(() => t.end()); | ||
}); | ||
|
||
test('Trying to sign in with no password using scratchr2 navbar', t => { | ||
var nonsenseusername = Math.random().toString(36) | ||
.replace(/[^a-z]+/g, '') | ||
.substr(0, 5); | ||
clickText('Sign in') | ||
.then(() => findByXpath('//input[@id="login_dropdown_username"]')) | ||
.then((element) => element.sendKeys(nonsenseusername)) | ||
.then(() => clickButton('Sign in')) | ||
.then(() => driver.wait(until | ||
.elementLocated(By.xpath('//form[@id="login"]/button[@type="submit"]')))) | ||
.then(() => driver.wait(until | ||
.elementLocated(By.xpath('//form[@id="login"]/div[@class="error"]')))) | ||
.then(() => findByXpath('//form/div[@class="error"]')) | ||
.then((element) => element.getText()) | ||
.then((text) => t.match(text, 'This field is required.', | ||
'"This field is required" error should be displayed')) | ||
.then(() => t.end()); | ||
}); | ||
|
||
test('Trying to sign in with the wrong username using scratchr2 navbar', t => { | ||
var nonsenseusername = Math.random().toString(36) | ||
.replace(/[^a-z]+/g, '') | ||
.substr(0, 5); | ||
clickText('Sign in') | ||
.then(() => findByXpath('//input[@id="login_dropdown_username"]')) | ||
.then((element) => element.sendKeys(nonsenseusername)) | ||
.then(() => findByXpath('//input[@name="password"]')) | ||
.then((element) => element.sendKeys(password)) | ||
.then(() => clickButton('Sign in')) | ||
.then(() => driver.wait(until | ||
.elementLocated(By.xpath('//form[@id="login"]/button[@type="submit"]')))) | ||
.then(() => driver.wait(until | ||
.elementLocated(By.xpath('//form[@id="login"]/div[@class="error"]')))) | ||
.then(() => findByXpath('//form/div[@class="error"]')) | ||
.then((element) => element.getText()) | ||
.then((text) => t.match(text, 'Incorrect username or password.', | ||
'"Incorrect username or password" error should be displayed')) | ||
.then(() => t.end()); | ||
}); | ||
|
||
test('Trying to sign in with the wrong password using scratchr2 navbar', t => { | ||
clickText('Sign in') | ||
.then(() => findByXpath('//input[@id="login_dropdown_username"]')) | ||
.then((element) => element.sendKeys(username)) | ||
.then(() => findByXpath('//input[@name="password"]')) | ||
.then((element) => element.sendKeys('nonsensepassword')) | ||
.then(() => clickButton('Sign in')) | ||
.then(() => driver.wait(until | ||
.elementLocated(By.xpath('//form[@id="login"]/button[@type="submit"]')))) | ||
.then(() => driver.wait(until | ||
.elementLocated(By.xpath('//form[@id="login"]/div[@class="error"]')))) | ||
.then(() => findByXpath('//form/div[@class="error"]')) | ||
.then((element) => element.getText()) | ||
.then((text) => t.match(text, 'Incorrect username or password.', | ||
'"Incorrect username or password" error should be displayed')) | ||
.then(() => t.end()); | ||
}); |
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
Oops, something went wrong.