scratch-www/test/integration-legacy/teacher-registration/test_teacher_registration_demographics_step.js

61 lines
2.3 KiB
JavaScript
Raw Permalink Normal View History

2019-07-17 14:56:48 -04: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
*/
const seleniumWebdriver = require('selenium-webdriver');
const tap = require('tap');
2019-07-17 14:56:48 -04:00
const utils = require('./teacher_registration_utils.js');
const constants = utils.constants;
2019-07-17 14:56:48 -04:00
// Set test url through environment variable
const rootUrl = process.env.ROOT_URL || 'http://localhost:8333';
2019-07-17 14:56:48 -04:00
// chrome driver
const driver = new seleniumWebdriver.Builder().withCapabilities(seleniumWebdriver.Capabilities.chrome())
2019-07-17 14:56:48 -04:00
.build();
tap.plan(2);
tap.tearDown(() => {
2019-07-17 14:56:48 -04:00
driver.quit();
});
tap.beforeEach(() => {
driver.get(`${rootUrl}/educators/register`);
2019-07-17 14:56:48 -04:00
return utils.fillUsernameSlide(driver, seleniumWebdriver);
});
// if the user selects the other gender option, they must input a gender
// selects the other gender option and attempt to advance the slide
tap.test('checkOtherGenderInput', t => {
const otherGenderRadio = driver.findElement(seleniumWebdriver.By.xpath('//input[@value="other"' +
2019-07-17 14:56:48 -04:00
'and @type="radio"]'));
const nextStepButton = driver.findElement(seleniumWebdriver.By.xpath(constants.nextStepXpath));
2019-07-17 14:56:48 -04:00
driver.findElement(seleniumWebdriver.By.xpath('//select[@name="user.country"]/option[2]')).click();
otherGenderRadio.click().then(() => {
nextStepButton.click().then(() => {
2019-07-17 14:56:48 -04:00
driver.findElements(seleniumWebdriver.By.xpath(constants.generalErrorMessageXpath))
.then(validationMessages => {
2019-07-17 14:56:48 -04:00
t.equal(validationMessages.length, 1);
t.end();
});
});
});
});
// the user must select a gender
// tries to advance the slide without selecting a gender
tap.test('checkNoGenderInput', t => {
const nextStepButton = driver.findElement(seleniumWebdriver.By.xpath(constants.nextStepXpath));
2019-07-17 14:56:48 -04:00
driver.findElement(seleniumWebdriver.By.xpath('//select[@name="user.country"]/option[2]')).click();
nextStepButton.click().then(() => {
2019-07-17 14:56:48 -04:00
driver.findElements(seleniumWebdriver.By.xpath(constants.generalErrorMessageXpath))
.then(validationMessages => {
2019-07-17 14:56:48 -04:00
t.equal(validationMessages.length, 1);
t.end();
});
});
});