2016-12-08 17:45:17 -05:00
|
|
|
/*
|
|
|
|
* Checks the behavior of demographics 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');
|
|
|
|
|
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-30 11:53:12 -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';
|
|
|
|
|
2018-01-30 11:53:12 -05:00
|
|
|
// chrome driver
|
|
|
|
var driver = new seleniumWebdriver.Builder().withCapabilities(seleniumWebdriver.Capabilities.chrome())
|
|
|
|
.build();
|
2016-12-08 17:45:17 -05:00
|
|
|
|
|
|
|
tap.plan(2);
|
|
|
|
|
|
|
|
tap.tearDown(function () {
|
|
|
|
driver.quit();
|
|
|
|
});
|
|
|
|
|
|
|
|
tap.beforeEach(function () {
|
2016-12-21 16:54:51 -05:00
|
|
|
driver.get(rootUrl + '/educators/register');
|
2016-12-17 23:07:49 -05:00
|
|
|
return utils.fillUsernameSlide(driver, seleniumWebdriver);
|
2016-12-08 17:45:17 -05:00
|
|
|
});
|
|
|
|
|
2018-01-30 11:53:12 -05:00
|
|
|
// if the user selects the other gender option, they must input a gender
|
|
|
|
// selects the other gender option and attempt to advance the slide
|
2016-12-08 17:45:17 -05:00
|
|
|
tap.test('checkOtherGenderInput', function (t) {
|
|
|
|
var otherGenderRadio = driver.findElement(seleniumWebdriver.By.xpath('//input[@value="other"' +
|
|
|
|
'and @type="radio"]'));
|
2016-12-21 15:18:24 -05:00
|
|
|
var nextStepButton = driver.findElement(seleniumWebdriver.By.xpath(constants.nextStepXpath));
|
2016-12-08 17:45:17 -05:00
|
|
|
driver.findElement(seleniumWebdriver.By.xpath('//select[@name="user.country"]/option[2]')).click();
|
|
|
|
otherGenderRadio.click().then(function () {
|
|
|
|
nextStepButton.click().then(function () {
|
2016-12-21 16:54:51 -05:00
|
|
|
driver.findElements(seleniumWebdriver.By.xpath(constants.generalErrorMessageXpath))
|
2018-01-30 11:53:12 -05:00
|
|
|
.then(function (validationMessages) {
|
|
|
|
t.equal(validationMessages.length, 1);
|
|
|
|
t.end();
|
|
|
|
});
|
2016-12-08 17:45:17 -05:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2018-01-30 11:53:12 -05:00
|
|
|
// the user must select a gender
|
|
|
|
// tries to advance the slide without selecting a gender
|
2016-12-08 17:45:17 -05:00
|
|
|
tap.test('checkNoGenderInput', function (t) {
|
2016-12-16 11:07:42 -05:00
|
|
|
var nextStepButton = driver.findElement(seleniumWebdriver.By.xpath(constants.nextStepXpath));
|
2016-12-08 17:45:17 -05:00
|
|
|
driver.findElement(seleniumWebdriver.By.xpath('//select[@name="user.country"]/option[2]')).click();
|
|
|
|
nextStepButton.click().then(function () {
|
2018-01-30 11:53:12 -05:00
|
|
|
driver.findElements(seleniumWebdriver.By.xpath(constants.generalErrorMessageXpath))
|
2016-12-08 17:45:17 -05:00
|
|
|
.then(function (validationMessages) {
|
|
|
|
t.equal(validationMessages.length, 1);
|
|
|
|
t.end();
|
|
|
|
});
|
2018-01-30 11:53:12 -05:00
|
|
|
});
|
2016-12-08 17:45:17 -05:00
|
|
|
});
|