mirror of
https://github.com/scratchfoundation/scratch-www.git
synced 2025-03-14 15:09:59 -04:00
Add utils for reused strings in teacher registration tests, and update tests to import them. Add tests for the organization step.
This commit is contained in:
parent
871bb4b52d
commit
487b6cd152
5 changed files with 167 additions and 24 deletions
5
test/integration/educator_registration_utils.js
Normal file
5
test/integration/educator_registration_utils.js
Normal file
|
@ -0,0 +1,5 @@
|
|||
module.exports.constants = {
|
||||
'nextStepXpath': '//button[span[contains(text(), "Next Step")]]',
|
||||
'generalErrorMessageXpath': '//span[@class="help-block validation-message" and contains(text(),'
|
||||
+ '"This field is required")]'
|
||||
};
|
|
@ -7,6 +7,8 @@ require('chromedriver');
|
|||
var seleniumWebdriver = require('selenium-webdriver');
|
||||
var tap = require('tap');
|
||||
|
||||
var constants = require('./educator_registration_utils.js').constants;
|
||||
|
||||
//chrome driver
|
||||
var driver = new seleniumWebdriver.Builder().withCapabilities(seleniumWebdriver.Capabilities.chrome()).build();
|
||||
|
||||
|
@ -61,14 +63,10 @@ tap.test('checkOtherGenderInput', function (t) {
|
|||
//the user must select a gender
|
||||
//tries to advance the slide without selecting a gender
|
||||
tap.test('checkNoGenderInput', function (t) {
|
||||
var nextStepButton = driver.findElement(seleniumWebdriver.By.xpath('//button[span[contains(text(),'
|
||||
+ '"Next Step")]]'));
|
||||
var errorMessage = 'This field is required';
|
||||
var errorMessageXPath = '//span[@class="help-block validation-message" and contains(text(),"'
|
||||
+ errorMessage + '")]';
|
||||
var nextStepButton = driver.findElement(seleniumWebdriver.By.xpath(constants.nextStepXpath));
|
||||
driver.findElement(seleniumWebdriver.By.xpath('//select[@name="user.country"]/option[2]')).click();
|
||||
nextStepButton.click().then(function () {
|
||||
driver.findElements(seleniumWebdriver.By.xpath(errorMessageXPath))
|
||||
driver.findElements(seleniumWebdriver.By.xpath(constants.generalErrorMessageXpath))
|
||||
.then(function (validationMessages) {
|
||||
t.equal(validationMessages.length, 1);
|
||||
t.end();
|
||||
|
|
|
@ -7,6 +7,8 @@ require('chromedriver');
|
|||
var seleniumWebdriver = require('selenium-webdriver');
|
||||
var tap = require('tap');
|
||||
|
||||
var constants = require('./educator_registration_utils.js').constants;
|
||||
|
||||
//chrome driver
|
||||
var driver = new seleniumWebdriver.Builder().withCapabilities(seleniumWebdriver.Capabilities.chrome()).build();
|
||||
|
||||
|
@ -15,8 +17,7 @@ var fillUsernameSlide = function () {
|
|||
var usernameInput = driver.findElement(seleniumWebdriver.By.name('user.username'));
|
||||
var usernamePromise = usernameInput.sendKeys('clipspringer');
|
||||
var passwordPromise = passwordInput.sendKeys('educators');
|
||||
var nextStepButton = driver.findElement(seleniumWebdriver.By.xpath('//button[span[contains(text(),'
|
||||
+ '"Next Step")]]'));
|
||||
var nextStepButton = driver.findElement(seleniumWebdriver.By.xpath(constants.nextStepXpath));
|
||||
return Promise.all([usernamePromise, passwordPromise]).then(function () {
|
||||
nextStepButton.click().then(function () {
|
||||
driver.wait(seleniumWebdriver.until
|
||||
|
@ -30,8 +31,7 @@ var fillDemographicsSlide = function () {
|
|||
' and @type="radio"]')).click();
|
||||
var selectCountry = driver.findElement(seleniumWebdriver.By.xpath('//select[@name="user.country"]' +
|
||||
'/option[2]')).click();
|
||||
var nextStepButton = driver.findElement(seleniumWebdriver.By.xpath('//button[span[contains(text(),'
|
||||
+ '"Next Step")]]'));
|
||||
var nextStepButton = driver.findElement(seleniumWebdriver.By.xpath(constants.nextStepXpath));
|
||||
return Promise.all([clickMaleInput, selectCountry]).then(function () {
|
||||
nextStepButton.click().then(function () {
|
||||
driver.wait(seleniumWebdriver.until
|
||||
|
@ -40,7 +40,7 @@ var fillDemographicsSlide = function () {
|
|||
});
|
||||
};
|
||||
|
||||
tap.plan(1);
|
||||
tap.plan(2);
|
||||
|
||||
tap.tearDown(function () {
|
||||
driver.quit();
|
||||
|
@ -52,16 +52,30 @@ tap.beforeEach(function () {
|
|||
});
|
||||
|
||||
//attempts to advance the slide without inputting either name, checks that both give the correct error
|
||||
tap.test('checkBothNamesRequired', function (t) {
|
||||
var nextStepButton = driver.findElement(seleniumWebdriver.By.xpath('//button[span[contains(text(),'
|
||||
+ '"Next Step")]]'));
|
||||
var errorMessage = 'This field is required';
|
||||
var errorMessageXPath = '//span[@class="help-block validation-message" and contains(text(),"'
|
||||
+ errorMessage + '")]';
|
||||
tap.test('checkFirstNameRequired', function (t) {
|
||||
var nextStepButton = driver.findElement(seleniumWebdriver.By.xpath(constants.nextStepXpath));
|
||||
var errorMessageXPath = '//input[@name="user.name.first"]/following-sibling::'
|
||||
+ 'span[@class="help-block validation-message" and contains(text(),'
|
||||
+ '"This field is required")]';
|
||||
nextStepButton.click().then(function () {
|
||||
driver.findElements(seleniumWebdriver.By.xpath(errorMessageXPath))
|
||||
.then(function (validationMessages) {
|
||||
t.equal(validationMessages.length, 2);
|
||||
t.equal(validationMessages.length, 1);
|
||||
t.end();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
//attempts to advance the slide without inputting either name, checks that both give the correct error
|
||||
tap.test('checkLastNameRequired', function (t) {
|
||||
var nextStepButton = driver.findElement(seleniumWebdriver.By.xpath(constants.nextStepXpath));
|
||||
var errorMessageXPath = '//input[@name="user.name.last"]/following-sibling::'
|
||||
+ 'span[@class="help-block validation-message" and contains(text(),'
|
||||
+ '"This field is required")]';
|
||||
nextStepButton.click().then(function () {
|
||||
driver.findElements(seleniumWebdriver.By.xpath(errorMessageXPath))
|
||||
.then(function (validationMessages) {
|
||||
t.equal(validationMessages.length, 1);
|
||||
t.end();
|
||||
});
|
||||
});
|
||||
|
|
127
test/integration/test_educators_registration_organization.js
Normal file
127
test/integration/test_educators_registration_organization.js
Normal file
|
@ -0,0 +1,127 @@
|
|||
/*
|
||||
* Checks the behavior of the phone number step in the educators registration process
|
||||
*
|
||||
* Test cases: https://github.com/LLK/scratch-www/wiki/Testing-Scratch-www#All_Test_Cases_Teacher_Join_Flow
|
||||
*/
|
||||
require('chromedriver');
|
||||
var seleniumWebdriver = require('selenium-webdriver');
|
||||
var tap = require('tap');
|
||||
|
||||
var constants = require('./educator_registration_utils.js').constants;
|
||||
|
||||
//Set test url through environment variable
|
||||
//var rootUrl = process.ENV.ROOT_URL || 'http://localhost:8333';
|
||||
|
||||
//chrome driver
|
||||
var driver = new seleniumWebdriver.Builder().withCapabilities(seleniumWebdriver.Capabilities.chrome()).build();
|
||||
|
||||
var fillUsernameSlide = function () {
|
||||
var passwordInput = driver.findElement(seleniumWebdriver.By.name('user.password'));
|
||||
var usernameInput = driver.findElement(seleniumWebdriver.By.name('user.username'));
|
||||
var usernamePromise = usernameInput.sendKeys('clipspringer');
|
||||
var passwordPromise = passwordInput.sendKeys('educators');
|
||||
var nextStepButton = driver.findElement(seleniumWebdriver.By.xpath(constants.nextStepXpath));
|
||||
return Promise.all([usernamePromise, passwordPromise]).then(function () {
|
||||
nextStepButton.click().then(function () {
|
||||
driver.wait(seleniumWebdriver.until
|
||||
.elementLocated(seleniumWebdriver.By.className('demographics-step')));
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
var fillDemographicsSlide = function () {
|
||||
var clickMaleInput = driver.findElement(seleniumWebdriver.By.xpath('//input[@value="male"' +
|
||||
'and @type="radio"]')).click();
|
||||
var selectCountry = driver.findElement(seleniumWebdriver.By.xpath('//select[@name="user.country"]' +
|
||||
'/option[2]')).click();
|
||||
var nextStepButton = driver.findElement(seleniumWebdriver.By.xpath(constants.nextStepXpath));
|
||||
return Promise.all([clickMaleInput, selectCountry]).then(function () {
|
||||
nextStepButton.click().then(function () {
|
||||
driver.wait(seleniumWebdriver.until
|
||||
.elementLocated(seleniumWebdriver.By.className('name-step')));
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
var fillNameSlide = function () {
|
||||
var firstNamePromise = driver.findElement(seleniumWebdriver.By.name('user.name.first')).sendKeys('first');
|
||||
var lastNamePromise = driver.findElement(seleniumWebdriver.By.name('user.name.last')).sendKeys('surname');
|
||||
var nextStepButton = driver.findElement(seleniumWebdriver.By.xpath(constants.nextStepXpath));
|
||||
return Promise.all([firstNamePromise, lastNamePromise]).then(function () {
|
||||
nextStepButton.click().then(function () {
|
||||
driver.wait(seleniumWebdriver.until
|
||||
.elementLocated(seleniumWebdriver.By.className('phone-step')));
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
var fillPhoneSlide = function () {
|
||||
var phoneInput = driver.findElement(seleniumWebdriver.By.xpath('//input[@type="tel"]'));
|
||||
var consentCheckbox = driver.findElement(seleniumWebdriver.By.name('phoneConsent'));
|
||||
var nextStepButton = driver.findElement(seleniumWebdriver.By.xpath(constants.nextStepXpath));
|
||||
var phoneNumberPromise = phoneInput.sendKeys('6172535960');
|
||||
var consentPromise = consentCheckbox.click();
|
||||
return Promise.all([phoneNumberPromise, consentPromise]).then(function () {
|
||||
nextStepButton.click().then(function () {
|
||||
driver.wait(seleniumWebdriver.until
|
||||
.elementLocated(seleniumWebdriver.By.className('organization-step')));
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
tap.plan(3);
|
||||
|
||||
tap.tearDown(function () {
|
||||
driver.quit();
|
||||
});
|
||||
|
||||
tap.beforeEach(function () {
|
||||
driver.get('https://scratch.mit.edu/educators/register');
|
||||
return fillUsernameSlide()
|
||||
.then(fillDemographicsSlide)
|
||||
.then(fillNameSlide)
|
||||
.then(fillPhoneSlide);
|
||||
});
|
||||
|
||||
tap.test('otherFieldRequiredIfChecked', function (t) {
|
||||
var otherCheckbox = driver.findElement(seleniumWebdriver.By.xpath('//input[@type="checkbox" and @value="8"]'));
|
||||
var nextStepButton = driver.findElement(seleniumWebdriver.By.xpath(constants.nextStepXpath));
|
||||
var errorMessageXPath = '//div[@class="other-input"]' + constants.generalErrorMessageXpath;
|
||||
otherCheckbox.click().then(function () {
|
||||
nextStepButton.click().then(function () {
|
||||
driver.findElements(seleniumWebdriver.By.xpath(errorMessageXPath))
|
||||
.then(function (validationMessages) {
|
||||
t.equal(validationMessages.length, 1);
|
||||
t.end();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
tap.test('checkOrganizationFieldRequired', function (t) {
|
||||
var nextStepButton = driver.findElement(seleniumWebdriver.By.xpath(constants.nextStepXpath));
|
||||
var errorMessageXPath = '//input[@name="organization.name"]/following-sibling::'
|
||||
+ 'span[@class="help-block validation-message" and contains(text(),'
|
||||
+ '"This field is required")]';
|
||||
nextStepButton.click().then(function () {
|
||||
driver.findElements(seleniumWebdriver.By.xpath(errorMessageXPath))
|
||||
.then(function (validationMessages) {
|
||||
t.equal(validationMessages.length, 1);
|
||||
t.end();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
tap.test('checkRoleFieldRequired', function (t) {
|
||||
var nextStepButton = driver.findElement(seleniumWebdriver.By.xpath(constants.nextStepXpath));
|
||||
var errorMessageXPath = '//input[@name="organization.title"]/following-sibling::'
|
||||
+ 'span[@class="help-block validation-message" and contains(text(),'
|
||||
+ '"This field is required")]';
|
||||
nextStepButton.click().then(function () {
|
||||
driver.findElements(seleniumWebdriver.By.xpath(errorMessageXPath))
|
||||
.then(function (validationMessages) {
|
||||
t.equal(validationMessages.length, 1);
|
||||
t.end();
|
||||
});
|
||||
});
|
||||
});
|
|
@ -7,6 +7,8 @@ require('chromedriver');
|
|||
var seleniumWebdriver = require('selenium-webdriver');
|
||||
var tap = require('tap');
|
||||
|
||||
var constants = require('./educator_registration_utils.js').constants;
|
||||
|
||||
//chrome driver
|
||||
var driver = new seleniumWebdriver.Builder().withCapabilities(seleniumWebdriver.Capabilities.chrome()).build();
|
||||
|
||||
|
@ -15,8 +17,7 @@ var fillUsernameSlide = function () {
|
|||
var usernameInput = driver.findElement(seleniumWebdriver.By.name('user.username'));
|
||||
var usernamePromise = usernameInput.sendKeys('clipspringer');
|
||||
var passwordPromise = passwordInput.sendKeys('educators');
|
||||
var nextStepButton = driver.findElement(seleniumWebdriver.By.xpath('//button[span[contains(text(),'
|
||||
+ '"Next Step")]]'));
|
||||
var nextStepButton = driver.findElement(seleniumWebdriver.By.xpath(constants.nextStepXpath));
|
||||
return Promise.all([usernamePromise, passwordPromise]).then(function () {
|
||||
nextStepButton.click().then(function () {
|
||||
driver.wait(seleniumWebdriver.until
|
||||
|
@ -30,8 +31,7 @@ var fillDemographicsSlide = function () {
|
|||
'and @type="radio"]')).click();
|
||||
var selectCountry = driver.findElement(seleniumWebdriver.By.xpath('//select[@name="user.country"]' +
|
||||
'/option[2]')).click();
|
||||
var nextStepButton = driver.findElement(seleniumWebdriver.By.xpath('//button[span[contains(text(),'
|
||||
+ '"Next Step")]]'));
|
||||
var nextStepButton = driver.findElement(seleniumWebdriver.By.xpath(constants.nextStepXpath));
|
||||
return Promise.all([clickMaleInput, selectCountry]).then(function () {
|
||||
nextStepButton.click().then(function () {
|
||||
driver.wait(seleniumWebdriver.until
|
||||
|
@ -43,8 +43,7 @@ var fillDemographicsSlide = function () {
|
|||
var fillNameSlide = function () {
|
||||
var firstNamePromise = driver.findElement(seleniumWebdriver.By.name('user.name.first')).sendKeys('first');
|
||||
var lastNamePromise = driver.findElement(seleniumWebdriver.By.name('user.name.last')).sendKeys('surname');
|
||||
var nextStepButton = driver.findElement(seleniumWebdriver.By.xpath('//button[span[contains(text(),'
|
||||
+ '"Next Step")]]'));
|
||||
var nextStepButton = driver.findElement(seleniumWebdriver.By.xpath(constants.nextStepXpath));
|
||||
return Promise.all([firstNamePromise, lastNamePromise]).then(function () {
|
||||
nextStepButton.click().then(function () {
|
||||
driver.wait(seleniumWebdriver.until
|
||||
|
|
Loading…
Reference in a new issue