2016-12-16 11:07:42 -05:00
|
|
|
/*
|
2016-12-18 21:36:47 -05:00
|
|
|
* Checks the behavior of the organization step in the educators registration process
|
2016-12-16 11:07:42 -05:00
|
|
|
*
|
|
|
|
* 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');
|
|
|
|
|
2016-12-17 23:07:49 -05:00
|
|
|
var utils = require('./teacher_registration_utils.js');
|
|
|
|
var constants = utils.constants;
|
2016-12-16 11:07:42 -05:00
|
|
|
|
2018-01-19 14:06:26 -05:00
|
|
|
// Set test url through environment variable
|
2016-12-21 16:54:51 -05:00
|
|
|
var rootUrl = process.env.ROOT_URL || 'http://localhost:8333';
|
2016-12-16 11:07:42 -05:00
|
|
|
|
2018-01-19 14:06:26 -05:00
|
|
|
// chrome driver
|
|
|
|
var driver = new seleniumWebdriver.Builder().withCapabilities(seleniumWebdriver.Capabilities.chrome())
|
|
|
|
.build();
|
2016-12-16 11:07:42 -05:00
|
|
|
|
2016-12-18 21:36:47 -05:00
|
|
|
tap.plan(4);
|
2016-12-16 11:07:42 -05:00
|
|
|
|
|
|
|
tap.tearDown(function () {
|
|
|
|
driver.quit();
|
|
|
|
});
|
|
|
|
|
|
|
|
tap.beforeEach(function () {
|
2016-12-21 16:54:51 -05:00
|
|
|
driver.get(rootUrl + '/educators/register');
|
2016-12-21 15:18:24 -05:00
|
|
|
return utils.fillUsernameSlide(driver, seleniumWebdriver)
|
2018-01-19 14:06:26 -05:00
|
|
|
.then(utils.fillDemographicsSlide.bind(this, driver, seleniumWebdriver)) // eslint-disable-line no-invalid-this
|
|
|
|
.then(utils.fillNameSlide.bind(this, driver, seleniumWebdriver)) // eslint-disable-line no-invalid-this
|
|
|
|
.then(utils.fillPhoneSlide.bind(this, driver, seleniumWebdriver)); // eslint-disable-line no-invalid-this
|
2016-12-16 11:07:42 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
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));
|
2018-01-19 14:06:26 -05:00
|
|
|
var errorMessageXPath = '//input[@name="organization.name"]/following-sibling::' +
|
|
|
|
'span[@class="help-block validation-message"]/span[contains(text(),' +
|
|
|
|
'"This field is required")]';
|
2016-12-16 11:07:42 -05:00
|
|
|
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));
|
2018-01-19 14:06:26 -05:00
|
|
|
var errorMessageXPath = '//input[@name="organization.title"]/following-sibling::' +
|
|
|
|
'span[@class="help-block validation-message"]/span[contains(text(),' +
|
|
|
|
'"This field is required")]';
|
2016-12-16 11:07:42 -05:00
|
|
|
nextStepButton.click().then(function () {
|
|
|
|
driver.findElements(seleniumWebdriver.By.xpath(errorMessageXPath))
|
|
|
|
.then(function (validationMessages) {
|
|
|
|
t.equal(validationMessages.length, 1);
|
|
|
|
t.end();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
2016-12-18 21:36:47 -05:00
|
|
|
|
|
|
|
tap.test('checkOrganizationTypeRequired', function (t) {
|
|
|
|
var nextStepButton = driver.findElement(seleniumWebdriver.By.xpath(constants.nextStepXpath));
|
2018-01-19 14:06:26 -05:00
|
|
|
var errorMessageXPath = '//div[@class="checkbox"]/following-sibling::' +
|
|
|
|
'span[@class="help-block validation-message" and contains(text(),' +
|
|
|
|
'"This field is required")]';
|
2016-12-18 21:36:47 -05:00
|
|
|
nextStepButton.click().then(function () {
|
|
|
|
driver.findElements(seleniumWebdriver.By.xpath(errorMessageXPath))
|
|
|
|
.then(function (validationMessages) {
|
|
|
|
t.equal(validationMessages.length, 1);
|
|
|
|
t.end();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|