mirror of
https://github.com/scratchfoundation/scratch-www.git
synced 2024-11-26 17:16:11 -05:00
Merge pull request #1626 from jwzimmer/issue/add-signing-out
Issue/add signing out
This commit is contained in:
commit
3d277c118b
3 changed files with 78 additions and 2 deletions
|
@ -18,6 +18,10 @@ const clickText = (text) => {
|
|||
return clickXpath(`//*[contains(text(), '${text}')]`);
|
||||
};
|
||||
|
||||
const findText = (text) => {
|
||||
return driver.wait(until.elementLocated(By.xpath(`//*[contains(text(), '${text}')]`), 5 * 1000));
|
||||
};
|
||||
|
||||
const clickButton = (text) => {
|
||||
return clickXpath(`//button[contains(text(), '${text}')]`);
|
||||
};
|
||||
|
@ -57,6 +61,7 @@ module.exports = {
|
|||
clickXpath,
|
||||
findByXpath,
|
||||
clickText,
|
||||
findText,
|
||||
clickButton,
|
||||
findByCss,
|
||||
getLogs
|
||||
|
|
|
@ -0,0 +1,59 @@
|
|||
/*
|
||||
* Tests from:
|
||||
*
|
||||
* https://github.com/LLK/scratchr2/wiki/Smoke-Testing-Test-Cases
|
||||
*
|
||||
*/
|
||||
|
||||
const {
|
||||
clickText,
|
||||
findByXpath,
|
||||
findText,
|
||||
clickXpath,
|
||||
clickButton,
|
||||
driver
|
||||
} = require('../../helpers/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 + '/discuss';
|
||||
|
||||
tap.plan(2);
|
||||
|
||||
tap.tearDown(function () {
|
||||
driver.quit();
|
||||
});
|
||||
|
||||
tap.beforeEach(function () {
|
||||
return driver.get(url);
|
||||
});
|
||||
|
||||
test('Sign in to Scratch 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(password))
|
||||
.then(() => clickButton('Sign in'))
|
||||
.then(() => findByXpath('//li[contains(@class, "logged-in-user")'
|
||||
+ 'and contains(@class, "dropdown")]/span'))
|
||||
.then((element) => element.getText('span'))
|
||||
.then((text) => t.match(text.toLowerCase(), username.substring(0,10).toLowerCase(),
|
||||
'first part of username should be displayed in navbar'))
|
||||
.then(() => t.end());
|
||||
});
|
||||
|
||||
test('Sign out of Scratch using scratchr2 navbar', t => {
|
||||
clickXpath('//span[contains(@class, "user-name")'
|
||||
+ ' and contains(@class, "dropdown-toggle")]/img[@class="user-icon"]')
|
||||
.then(() => clickXpath('//input[@value="Sign out"]'))
|
||||
.then(() => findText('Sign in'))
|
||||
.then((element) => t.ok(element, 'Sign in reappeared on the page after signing out'))
|
||||
.then(() => t.end());
|
||||
});
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Tests signing in according to smoke-tests at:
|
||||
* Tests from:
|
||||
*
|
||||
* https://github.com/LLK/scratchr2/wiki/Smoke-Testing-Test-Cases
|
||||
*
|
||||
|
@ -7,6 +7,7 @@
|
|||
|
||||
const {
|
||||
clickText,
|
||||
findText,
|
||||
findByXpath,
|
||||
clickXpath,
|
||||
driver
|
||||
|
@ -20,7 +21,7 @@ const test = tap.test;
|
|||
|
||||
var rootUrl = process.env.ROOT_URL || 'https://scratch.ly';
|
||||
|
||||
tap.plan(1);
|
||||
tap.plan(2);
|
||||
|
||||
tap.tearDown(function () {
|
||||
driver.quit();
|
||||
|
@ -44,3 +45,14 @@ test('Sign in to Scratch using scratch-www navbar', t => {
|
|||
'first part of username should be displayed in navbar'))
|
||||
.then(() => t.end());
|
||||
});
|
||||
|
||||
test('Sign out of Scratch using scratch-www navbar', t => {
|
||||
clickXpath('//a[@class="user-info"]')
|
||||
.then(() => clickText('Sign out'))
|
||||
.then(() => findText('Sign in'))
|
||||
.then((element) => t.ok(element, 'Sign in reappeared on the page after signing out'))
|
||||
.then(() => t.end());
|
||||
});
|
||||
|
||||
|
||||
|
Loading…
Reference in a new issue