mirror of
https://github.com/scratchfoundation/scratch-www.git
synced 2024-11-26 17:16:11 -05:00
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:
commit
e8a8d6ab94
8 changed files with 109 additions and 134 deletions
6
package-lock.json
generated
6
package-lock.json
generated
|
@ -3245,9 +3245,9 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"chromedriver": {
|
"chromedriver": {
|
||||||
"version": "75.1.0",
|
"version": "76.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/chromedriver/-/chromedriver-75.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/chromedriver/-/chromedriver-76.0.0.tgz",
|
||||||
"integrity": "sha512-N2P0fg6FS4c+tTG0R7cCOD5qiVo+E6uAz6xVjmbZesYv1xs1iGdcCUo0IqOY+ppD/4OOObG+XWV1CFWXT6UIgA==",
|
"integrity": "sha512-jGyqs0N+lMo9iaNQxGKNPiLJWb2L9s2rwbRr1jJeQ37n6JQ1+5YMGviv/Fx5Z08vBWYbAvrKEzFsuYf8ppl+lw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"del": "^4.1.1",
|
"del": "^4.1.1",
|
||||||
|
|
|
@ -8,7 +8,8 @@
|
||||||
"test:lint": "eslint . --ext .js,.jsx,.json",
|
"test:lint": "eslint . --ext .js,.jsx,.json",
|
||||||
"test:integration": "npm run test:integration:jest && npm run test:smoke",
|
"test:integration": "npm run test:integration:jest && npm run test:smoke",
|
||||||
"test:integration:jest": "jest ./test/integration/*.test.js",
|
"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": "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: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",
|
"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",
|
"babel-preset-react": "6.22.0",
|
||||||
"bowser": "1.9.4",
|
"bowser": "1.9.4",
|
||||||
"cheerio": "1.0.0-rc.2",
|
"cheerio": "1.0.0-rc.2",
|
||||||
"chromedriver": "75.1.0",
|
"chromedriver": "76.0.0",
|
||||||
"classnames": "2.2.5",
|
"classnames": "2.2.5",
|
||||||
"cookie": "0.2.2",
|
"cookie": "0.2.2",
|
||||||
"copy-webpack-plugin": "0.2.0",
|
"copy-webpack-plugin": "0.2.0",
|
||||||
|
|
|
@ -68,7 +68,7 @@ class SeleniumHelper {
|
||||||
let driverConfig = {
|
let driverConfig = {
|
||||||
browserName: 'chrome',
|
browserName: 'chrome',
|
||||||
platform: 'macOS 10.14',
|
platform: 'macOS 10.14',
|
||||||
version: '75.0'
|
version: '76.0'
|
||||||
};
|
};
|
||||||
var driver = new webdriver.Builder()
|
var driver = new webdriver.Builder()
|
||||||
.withCapabilities({
|
.withCapabilities({
|
||||||
|
|
|
@ -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());
|
|
||||||
});
|
|
|
@ -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());
|
|
||||||
});
|
|
|
@ -67,8 +67,8 @@ class SeleniumHelper {
|
||||||
// https://wiki.saucelabs.com/display/DOCS/Platform+Configurator
|
// https://wiki.saucelabs.com/display/DOCS/Platform+Configurator
|
||||||
let driverConfig = {
|
let driverConfig = {
|
||||||
browserName: 'chrome',
|
browserName: 'chrome',
|
||||||
platform: 'macOS 10.13',
|
platform: 'macOS 10.14',
|
||||||
version: '70.0'
|
version: '76.0'
|
||||||
};
|
};
|
||||||
var driver = new webdriver.Builder()
|
var driver = new webdriver.Builder()
|
||||||
.withCapabilities({
|
.withCapabilities({
|
||||||
|
|
100
test/integration/sign-in-and-out.test.js
Normal file
100
test/integration/sign-in-and-out.test.js
Normal 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();
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
|
@ -1,5 +0,0 @@
|
||||||
describe('test jest integration', () => {
|
|
||||||
test('testing test', () => {
|
|
||||||
expect('integration').toEqual('integration');
|
|
||||||
});
|
|
||||||
});
|
|
Loading…
Reference in a new issue