Merge pull request #3247 from BryceLTaylor/move-integration-tests-to-jest-2

Move sign in and out integration tests to jest
This commit is contained in:
Bryce Taylor 2019-08-30 15:31:06 -04:00 committed by GitHub
commit e8a8d6ab94
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 109 additions and 134 deletions

6
package-lock.json generated
View file

@ -3245,9 +3245,9 @@
}
},
"chromedriver": {
"version": "75.1.0",
"resolved": "https://registry.npmjs.org/chromedriver/-/chromedriver-75.1.0.tgz",
"integrity": "sha512-N2P0fg6FS4c+tTG0R7cCOD5qiVo+E6uAz6xVjmbZesYv1xs1iGdcCUo0IqOY+ppD/4OOObG+XWV1CFWXT6UIgA==",
"version": "76.0.0",
"resolved": "https://registry.npmjs.org/chromedriver/-/chromedriver-76.0.0.tgz",
"integrity": "sha512-jGyqs0N+lMo9iaNQxGKNPiLJWb2L9s2rwbRr1jJeQ37n6JQ1+5YMGviv/Fx5Z08vBWYbAvrKEzFsuYf8ppl+lw==",
"dev": true,
"requires": {
"del": "^4.1.1",

View file

@ -8,7 +8,8 @@
"test:lint": "eslint . --ext .js,.jsx,.json",
"test:integration": "npm run test:integration:jest && npm run test:smoke",
"test:integration:jest": "jest ./test/integration/*.test.js",
"test:integration:remote": "npm run test:integration:jest && npm run test:smoke:sauce",
"test:integration:remote": "npm run test:integration:jest:remote && npm run test:smoke:sauce",
"test:integration:jest:remote": "SMOKE_REMOTE=true jest ./test/integration/*.test.js",
"test:smoke": "tap ./test/integration-legacy/smoke-testing/*.js --timeout=3600 --no-coverage -R classic",
"test:smoke:verbose": "tap ./test/integration-legacy/smoke-testing/*.js --timeout=3600 --no-coverage -R spec",
"test:smoke:sauce": "SMOKE_REMOTE=true tap ./test/integration-legacy/smoke-testing/*.js --timeout=60000 --no-coverage -R classic",
@ -66,7 +67,7 @@
"babel-preset-react": "6.22.0",
"bowser": "1.9.4",
"cheerio": "1.0.0-rc.2",
"chromedriver": "75.1.0",
"chromedriver": "76.0.0",
"classnames": "2.2.5",
"cookie": "0.2.2",
"copy-webpack-plugin": "0.2.0",

View file

@ -68,7 +68,7 @@ class SeleniumHelper {
let driverConfig = {
browserName: 'chrome',
platform: 'macOS 10.14',
version: '75.0'
version: '76.0'
};
var driver = new webdriver.Builder()
.withCapabilities({

View file

@ -1,62 +0,0 @@
/*
* Tests from:
*
* https://github.com/LLK/scratchr2/wiki/Smoke-Testing-Test-Cases
*
*/
const SeleniumHelper = require('../selenium-helpers.js');
const helper = new SeleniumHelper();
var tap = require('tap');
const test = tap.test;
const driver = helper.buildDriver('www-smoke test_sign_in_out_discuss');
const {
clickText,
findByXpath,
findText,
clickXpath,
clickButton
} = helper;
var username = process.env.SMOKE_USERNAME;
var password = process.env.SMOKE_PASSWORD;
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[contains(@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());
});

View file

@ -1,59 +0,0 @@
/*
* Tests from:
*
* https://github.com/LLK/scratchr2/wiki/Smoke-Testing-Test-Cases
*
*/
const SeleniumHelper = require('../selenium-helpers.js');
const helper = new SeleniumHelper();
var tap = require('tap');
const test = tap.test;
const driver = helper.buildDriver('www-smoke test_sign_in_out_homepage');
const {
clickText,
findText,
findByXpath,
clickXpath
} = helper;
var username = process.env.SMOKE_USERNAME;
var password = process.env.SMOKE_PASSWORD;
var rootUrl = process.env.ROOT_URL || 'https://scratch.ly';
tap.plan(2);
tap.tearDown(function () {
driver.quit();
});
tap.beforeEach(function () {
return driver.get(rootUrl);
});
test('Sign in to Scratch using scratch-www navbar', {skip: true}, t => {
clickText('Sign in')
.then(() => findByXpath('//input[@id="frc-username-1088"]'))
.then((element) => element.sendKeys(username))
.then(() => findByXpath('//input[@id="frc-password-1088"]'))
.then((element) => element.sendKeys(password))
.then(() => clickXpath('//button[contains(@class, "button") and ' +
'contains(@class, "submit-button") and contains(@class, "white")]'))
.then(() => findByXpath('//span[contains(@class, "profile-name")]'))
.then((element) => element.getText())
.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 scratch-www navbar', {skip: true}, t => {
clickXpath('//a[contains(@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());
});

View file

@ -67,8 +67,8 @@ class SeleniumHelper {
// https://wiki.saucelabs.com/display/DOCS/Platform+Configurator
let driverConfig = {
browserName: 'chrome',
platform: 'macOS 10.13',
version: '70.0'
platform: 'macOS 10.14',
version: '76.0'
};
var driver = new webdriver.Builder()
.withCapabilities({

View file

@ -0,0 +1,100 @@
const SeleniumHelper = require('./selenium-helpers.js');
const {
clickText,
findByXpath,
clickXpath,
clickButton,
buildDriver
} = new SeleniumHelper();
let username = process.env.SMOKE_USERNAME;
let password = process.env.SMOKE_PASSWORD;
let remote = process.env.SMOKE_REMOTE || false;
let rootUrl = process.env.ROOT_URL || 'https://scratch.ly';
let scratchr2url = rootUrl + '/users/' + username;
let wwwURL = rootUrl;
if (remote){
jest.setTimeout(60000);
}
let driver;
describe('www-integration sign-in-and-out', () => {
beforeAll(async () => {
driver = await buildDriver('www-integration sign-in-out');
});
describe('sign in', () => {
afterEach(async () => {
await driver.get(wwwURL);
await clickXpath('//div[@class="account-nav"]');
await clickText('Sign out');
});
test('sign in on www', async () => {
await driver.get(wwwURL);
await driver.sleep(1000);
await clickXpath('//li[@class="link right login-item"]/a');
let name = await findByXpath('//input[@id="frc-username-1088"]');
await name.sendKeys(username);
let word = await findByXpath('//input[@id="frc-password-1088"]');
await word.sendKeys(password);
await clickXpath('//button[contains(@class, "button") and ' +
'contains(@class, "submit-button") and contains(@class, "white")]');
let element = await findByXpath('//span[contains(@class, "profile-name")]');
let text = await element.getText();
await expect(text.toLowerCase()).toEqual(username.toLowerCase());
});
test('sign in on scratchr2', async () => {
await driver.get(scratchr2url);
await clickXpath('//li[@class="sign-in dropdown"]/span');
let name = await findByXpath('//input[@id="login_dropdown_username"]');
await name.sendKeys(username);
let word = await findByXpath('//input[@name="password"]');
await word.sendKeys(password);
await clickButton('Sign in');
let element = await findByXpath('//span[@class="user-name dropdown-toggle"]');
let text = await element.getText();
await expect(text.toLowerCase()).toEqual(username.toLowerCase());
});
});
describe('sign out', () => {
beforeEach(async () => {
await driver.get(wwwURL);
await clickXpath('//li[@class="link right login-item"]');
let name = await findByXpath('//input[@id="frc-username-1088"]');
await name.sendKeys(username);
let word = await findByXpath('//input[@id="frc-password-1088"]');
await word.sendKeys(password);
await clickXpath('//button[contains(@class, "button") and ' +
'contains(@class, "submit-button") and contains(@class, "white")]');
});
test('sign out on www', async () => {
await clickXpath('//a[contains(@class, "user-info")]');
await clickText('Sign out');
let element = await findByXpath('//li[@class="link right login-item"]/a/span');
let text = await element.getText();
await expect(text.toLowerCase()).toEqual('Sign In'.toLowerCase());
});
test('sign out on scratchr2', async () => {
await driver.get(scratchr2url);
await clickXpath('//span[@class="user-name dropdown-toggle"]');
await clickXpath('//li[@id="logout"]');
let element = await findByXpath('//li[@class="link right login-item"]/a/span');
let text = await element.getText();
await expect(text.toLowerCase()).toEqual('Sign In'.toLowerCase());
});
});
afterAll(async () => {
await driver.quit();
});
});

View file

@ -1,5 +0,0 @@
describe('test jest integration', () => {
test('testing test', () => {
expect('integration').toEqual('integration');
});
});