mirror of
https://github.com/scratchfoundation/scratch-www.git
synced 2024-11-22 15:17:53 -05:00
Update tests to use an environment value for the url, and consolidate the slide advancement functions. Update utils with better xpath for error messages
This commit is contained in:
parent
e357a62c2c
commit
fe2ce902e6
8 changed files with 45 additions and 97 deletions
|
@ -1,6 +1,6 @@
|
|||
module.exports.constants = {
|
||||
'nextStepXpath': '//button[span[contains(text(), "Next Step")]]',
|
||||
'generalErrorMessageXpath': '//span[@class="help-block validation-message" and contains(text(),'
|
||||
'generalErrorMessageXpath': '//span[@class="help-block validation-message"]/span[contains(text(),'
|
||||
+ '"This field is required")]',
|
||||
'loremIpsumTextLong': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur viverra'
|
||||
+ 'nec mauris efficitur tincidunt. Vestibulum ut diam odio. Cum sociis natoque penatibus et magnis dis'
|
||||
|
|
|
@ -11,31 +11,11 @@ var utils = require('./teacher_registration_utils.js');
|
|||
var constants = utils.constants;
|
||||
|
||||
//Set test url through environment variable
|
||||
//var rootUrl = process.ENV.ROOT_URL || 'http://localhost:8333';
|
||||
var rootUrl = process.env.ROOT_URL || 'http://localhost:8333';
|
||||
|
||||
//chrome driver
|
||||
var driver = new seleniumWebdriver.Builder().withCapabilities(seleniumWebdriver.Capabilities.chrome()).build();
|
||||
|
||||
var fillUsernameSlide = function () {
|
||||
return utils.fillUsernameSlide(driver, seleniumWebdriver);
|
||||
};
|
||||
|
||||
var fillDemographicsSlide = function () {
|
||||
return utils.fillDemographicsSlide(driver, seleniumWebdriver);
|
||||
};
|
||||
|
||||
var fillNameSlide = function () {
|
||||
return utils.fillNameSlide(driver, seleniumWebdriver);
|
||||
};
|
||||
|
||||
var fillPhoneSlide = function () {
|
||||
return utils.fillPhoneSlide(driver, seleniumWebdriver);
|
||||
};
|
||||
|
||||
var fillOrganizationSlide = function () {
|
||||
return utils.fillOrganizationSlide(driver, seleniumWebdriver);
|
||||
};
|
||||
|
||||
tap.plan(2);
|
||||
|
||||
tap.tearDown(function () {
|
||||
|
@ -43,12 +23,12 @@ tap.tearDown(function () {
|
|||
});
|
||||
|
||||
tap.beforeEach(function () {
|
||||
driver.get('https://scratch.mit.edu/educators/register');
|
||||
return fillUsernameSlide()
|
||||
.then(fillDemographicsSlide)
|
||||
.then(fillNameSlide)
|
||||
.then(fillPhoneSlide)
|
||||
.then(fillOrganizationSlide);
|
||||
driver.get(rootUrl + '/educators/register');
|
||||
return utils.fillUsernameSlide(driver, seleniumWebdriver)
|
||||
.then(utils.fillDemographicsSlide.bind(this, driver, seleniumWebdriver))
|
||||
.then(utils.fillNameSlide.bind(this, driver, seleniumWebdriver))
|
||||
.then(utils.fillPhoneSlide.bind(this, driver, seleniumWebdriver))
|
||||
.then(utils.fillOrganizationSlide.bind(this, driver, seleniumWebdriver));
|
||||
});
|
||||
|
||||
//Selects Vatican City as the country, and checks that the state dropdown disappears
|
||||
|
|
|
@ -10,6 +10,9 @@ var tap = require('tap');
|
|||
var utils = require('./teacher_registration_utils.js');
|
||||
var constants = utils.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();
|
||||
|
||||
|
@ -20,7 +23,7 @@ tap.tearDown(function () {
|
|||
});
|
||||
|
||||
tap.beforeEach(function () {
|
||||
driver.get('https://scratch.mit.edu/educators/register');
|
||||
driver.get(rootUrl + '/educators/register');
|
||||
return utils.fillUsernameSlide(driver, seleniumWebdriver);
|
||||
});
|
||||
|
||||
|
@ -33,7 +36,7 @@ tap.test('checkOtherGenderInput', function (t) {
|
|||
driver.findElement(seleniumWebdriver.By.xpath('//select[@name="user.country"]/option[2]')).click();
|
||||
otherGenderRadio.click().then(function () {
|
||||
nextStepButton.click().then(function () {
|
||||
driver.findElements(seleniumWebdriver.By.xpath(constants.generalErrorMessageXPath))
|
||||
driver.findElements(seleniumWebdriver.By.xpath(constants.generalErrorMessageXpath))
|
||||
.then(function (validationMessages) {
|
||||
t.equal(validationMessages.length, 1);
|
||||
t.end();
|
||||
|
|
|
@ -10,17 +10,12 @@ var tap = require('tap');
|
|||
var utils = require('./teacher_registration_utils.js');
|
||||
var constants = utils.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 () {
|
||||
return utils.fillUsernameSlide(driver, seleniumWebdriver);
|
||||
};
|
||||
|
||||
var fillDemographicsSlide = function () {
|
||||
return utils.fillDemographicsSlide(driver, seleniumWebdriver);
|
||||
};
|
||||
|
||||
tap.plan(2);
|
||||
|
||||
tap.tearDown(function () {
|
||||
|
@ -28,16 +23,16 @@ tap.tearDown(function () {
|
|||
});
|
||||
|
||||
tap.beforeEach(function () {
|
||||
driver.get('https://scratch.mit.edu/educators/register');
|
||||
return fillUsernameSlide()
|
||||
.then(fillDemographicsSlide);
|
||||
driver.get(rootUrl + '/educators/register');
|
||||
return utils.fillUsernameSlide(driver, seleniumWebdriver)
|
||||
.then(utils.fillDemographicsSlide.bind(this, driver, seleniumWebdriver));
|
||||
});
|
||||
|
||||
//attempts to advance the slide without inputting either name, checks that both give the correct error
|
||||
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(),'
|
||||
+ 'span[@class="help-block validation-message"]/span[contains(text(),'
|
||||
+ '"This field is required")]';
|
||||
nextStepButton.click().then(function () {
|
||||
driver.findElements(seleniumWebdriver.By.xpath(errorMessageXPath))
|
||||
|
@ -52,7 +47,7 @@ tap.test('checkFirstNameRequired', function (t) {
|
|||
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(),'
|
||||
+ 'span[@class="help-block validation-message"]/span[contains(text(),'
|
||||
+ '"This field is required")]';
|
||||
nextStepButton.click().then(function () {
|
||||
driver.findElements(seleniumWebdriver.By.xpath(errorMessageXPath))
|
||||
|
|
|
@ -11,7 +11,7 @@ var utils = require('./teacher_registration_utils.js');
|
|||
var constants = utils.constants;
|
||||
|
||||
//Set test url through environment variable
|
||||
//var rootUrl = process.ENV.ROOT_URL || 'http://localhost:8333';
|
||||
var rootUrl = process.env.ROOT_URL || 'http://localhost:8333';
|
||||
|
||||
//chrome driver
|
||||
var driver = new seleniumWebdriver.Builder().withCapabilities(seleniumWebdriver.Capabilities.chrome()).build();
|
||||
|
@ -23,11 +23,11 @@ tap.tearDown(function () {
|
|||
});
|
||||
|
||||
tap.beforeEach(function () {
|
||||
driver.get('https://scratch.mit.edu/educators/register');
|
||||
driver.get(rootUrl + '/educators/register');
|
||||
return utils.fillUsernameSlide(driver, seleniumWebdriver)
|
||||
.then(function () { utils.fillDemographicsSlide(driver, seleniumWebdriver); })
|
||||
.then(function () { utils.fillNameSlide(driver, seleniumWebdriver); })
|
||||
.then(function () { utils.fillPhoneSlide(driver, seleniumWebdriver); });
|
||||
.then(utils.fillDemographicsSlide.bind(this, driver, seleniumWebdriver))
|
||||
.then(utils.fillNameSlide.bind(this, driver, seleniumWebdriver))
|
||||
.then(utils.fillPhoneSlide.bind(this, driver, seleniumWebdriver));
|
||||
});
|
||||
|
||||
tap.test('otherFieldRequiredIfChecked', function (t) {
|
||||
|
|
|
@ -9,21 +9,12 @@ var tap = require('tap');
|
|||
|
||||
var utils = require('./teacher_registration_utils.js');
|
||||
|
||||
//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 () {
|
||||
return utils.fillUsernameSlide(driver, seleniumWebdriver);
|
||||
};
|
||||
|
||||
var fillDemographicsSlide = function () {
|
||||
return utils.fillDemographicsSlide(driver, seleniumWebdriver);
|
||||
};
|
||||
|
||||
var fillNameSlide = function () {
|
||||
return utils.fillNameSlide(driver, seleniumWebdriver);
|
||||
};
|
||||
|
||||
tap.plan(1);
|
||||
|
||||
tap.tearDown(function () {
|
||||
|
@ -31,10 +22,10 @@ tap.tearDown(function () {
|
|||
});
|
||||
|
||||
tap.beforeEach(function () {
|
||||
driver.get('https://scratch.mit.edu/educators/register');
|
||||
return fillUsernameSlide()
|
||||
.then(fillDemographicsSlide)
|
||||
.then(fillNameSlide);
|
||||
driver.get(rootUrl + '/educators/register');
|
||||
return utils.fillUsernameSlide(driver, seleniumWebdriver)
|
||||
.then(utils.fillDemographicsSlide.bind(this, driver, seleniumWebdriver))
|
||||
.then(utils.fillNameSlide.bind(this, driver, seleniumWebdriver));
|
||||
});
|
||||
|
||||
//inputs an invalid phone number and checks that the correct error message appears
|
||||
|
|
|
@ -8,6 +8,9 @@ require('chromedriver');
|
|||
var seleniumWebdriver = require('selenium-webdriver');
|
||||
var tap = require('tap');
|
||||
|
||||
//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();
|
||||
|
||||
|
@ -18,7 +21,7 @@ tap.tearDown(function () {
|
|||
});
|
||||
|
||||
tap.beforeEach(function () {
|
||||
return driver.get('https://scratch.mit.edu/educators/register');
|
||||
return driver.get(rootUrl + '/educators/register');
|
||||
});
|
||||
|
||||
//an error message should appear for a username less than 3 characters long
|
||||
|
|
|
@ -11,35 +11,11 @@ var utils = require('./teacher_registration_utils.js');
|
|||
var constants = utils.constants;
|
||||
|
||||
//Set test url through environment variable
|
||||
//var rootUrl = process.ENV.ROOT_URL || 'http://localhost:8333';
|
||||
var rootUrl = process.env.ROOT_URL || 'http://localhost:8333';
|
||||
|
||||
//chrome driver
|
||||
var driver = new seleniumWebdriver.Builder().withCapabilities(seleniumWebdriver.Capabilities.chrome()).build();
|
||||
|
||||
var fillUsernameSlide = function () {
|
||||
return utils.fillUsernameSlide(driver, seleniumWebdriver);
|
||||
};
|
||||
|
||||
var fillDemographicsSlide = function () {
|
||||
return utils.fillDemographicsSlide(driver, seleniumWebdriver);
|
||||
};
|
||||
|
||||
var fillNameSlide = function () {
|
||||
return utils.fillNameSlide(driver, seleniumWebdriver);
|
||||
};
|
||||
|
||||
var fillPhoneSlide = function () {
|
||||
return utils.fillPhoneSlide(driver, seleniumWebdriver);
|
||||
};
|
||||
|
||||
var fillOrganizationSlide = function () {
|
||||
return utils.fillOrganizationSlide(driver, seleniumWebdriver);
|
||||
};
|
||||
|
||||
var fillAddressSlide = function () {
|
||||
return utils.fillAddressSlide(driver, seleniumWebdriver);
|
||||
};
|
||||
|
||||
tap.plan(3);
|
||||
|
||||
tap.tearDown(function () {
|
||||
|
@ -47,13 +23,13 @@ tap.tearDown(function () {
|
|||
});
|
||||
|
||||
tap.beforeEach(function () {
|
||||
driver.get('https://scratch.mit.edu/educators/register');
|
||||
return fillUsernameSlide()
|
||||
.then(fillDemographicsSlide)
|
||||
.then(fillNameSlide)
|
||||
.then(fillPhoneSlide)
|
||||
.then(fillOrganizationSlide)
|
||||
.then(fillAddressSlide);
|
||||
driver.get(rootUrl + '/educators/register');
|
||||
return utils.fillUsernameSlide(driver, seleniumWebdriver)
|
||||
.then(utils.fillDemographicsSlide.bind(this, driver, seleniumWebdriver))
|
||||
.then(utils.fillNameSlide.bind(this, driver, seleniumWebdriver))
|
||||
.then(utils.fillPhoneSlide.bind(this, driver, seleniumWebdriver))
|
||||
.then(utils.fillOrganizationSlide.bind(this, driver, seleniumWebdriver))
|
||||
.then(utils.fillAddressSlide.bind(this, driver, seleniumWebdriver));
|
||||
});
|
||||
|
||||
tap.test('checkCharacterCountIsCorrect', function (t) {
|
||||
|
|
Loading…
Reference in a new issue