Skip to content

Commit

Permalink
Merge pull request #1879 from BryceLTaylor/Verbose-Testing
Browse files Browse the repository at this point in the history
Verbose testing
  • Loading branch information
BryceLTaylor committed May 14, 2018
2 parents 297b4c1 + e88d5f8 commit fe1ef5a
Show file tree
Hide file tree
Showing 12 changed files with 160 additions and 129 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,4 @@ ENV
/test/integration-cypress/cypress/screenshots
/test/integration-cypress/cypress/videos
/test/integration-cypress/package-lock.json
/test/integration/node_modules/*
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ integration:

smoke:
$(TAP) ./test/integration/smoke-testing/*.js --timeout=3600

smoke-verbose:
$(TAP) ./test/integration/smoke-testing/*.js --timeout=3600 -R spec

localization:
$(TAP) ./test/localization/*.js
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"stop": "make stop",
"test": "make test",
"smoke": "make smoke",
"smoke-verbose": "make smoke-verbose",
"watch": "make watch",
"build": "make build",
"dev": "make watch && make start &"
Expand Down
4 changes: 2 additions & 2 deletions test/integration/package.json
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"
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const webdriver = require('selenium-webdriver');
var webdriver = require('selenium-webdriver');

const driver = new webdriver.Builder()
.forBrowser('chrome')
Expand Down
130 changes: 130 additions & 0 deletions test/integration/smoke-testing/test-login-failures.js
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());
});
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,8 @@ const {
findByXpath,
clickXpath,
clickButton,
driver,
until,
By
} = require('../../helpers/selenium-helpers.js');
driver
} = require('../selenium-helpers.js');

var username = process.env.SMOKE_USERNAME;
var password = process.env.SMOKE_PASSWORD;
Expand All @@ -23,9 +21,9 @@ var tap = require('tap');
const test = tap.test;

var rootUrl = process.env.ROOT_URL || 'https://scratch.ly';
var url = rootUrl + '/users/anyuser';
var url = rootUrl + '/users/' + username;

tap.plan(12);
tap.plan(7);

tap.tearDown(function () {
driver.quit();
Expand All @@ -35,108 +33,6 @@ 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());
});

test('Sign in to Scratch using scratchr2 navbar', t => {
clickText('Sign in')
.then(() => findByXpath('//input[@id="login_dropdown_username"]'))
Expand Down
4 changes: 2 additions & 2 deletions test/integration/smoke-testing/test_footer_links.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
*
* Test cases: https://github.com/LLK/scratch-www/wiki/Most-Important-Workflows
*/

const tap = require('tap');

const {
driver,
webdriver
} = require('../../helpers/selenium-helpers.js');
} = require('../selenium-helpers.js');

// Selenium's promise driver will be deprecated, so we should not rely on it
webdriver.SELENIUM_PROMISE_MANAGER = 0;
Expand Down
Loading

0 comments on commit fe1ef5a

Please sign in to comment.