2016-06-15 21:01:03 -04:00
|
|
|
/// <reference path='../_protractor/e2e.d.ts' />
|
|
|
|
'use strict';
|
2016-01-26 03:13:18 -05:00
|
|
|
describeIf(browser.appIsTs || browser.appIsJs, 'Forms Tests', function () {
|
2015-12-20 16:17:16 -05:00
|
|
|
|
|
|
|
beforeEach(function () {
|
|
|
|
browser.get('');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should display correct title', function () {
|
|
|
|
expect(element.all(by.css('h1')).get(0).getText()).toEqual('Hero Form');
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
it('should not display message before submit', function () {
|
2016-05-30 14:05:09 -04:00
|
|
|
let ele = element(by.css('h2'));
|
2015-12-20 16:17:16 -05:00
|
|
|
expect(ele.isDisplayed()).toBe(false);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should hide form after submit', function () {
|
2016-05-30 14:05:09 -04:00
|
|
|
let ele = element.all(by.css('h1')).get(0);
|
2015-12-20 16:17:16 -05:00
|
|
|
expect(ele.isDisplayed()).toBe(true);
|
2016-05-30 14:05:09 -04:00
|
|
|
let b = element.all(by.css('button[type=submit]')).get(0);
|
2015-12-20 16:17:16 -05:00
|
|
|
b.click().then(function() {
|
|
|
|
expect(ele.isDisplayed()).toBe(false);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should display message after submit', function () {
|
2016-05-30 14:05:09 -04:00
|
|
|
let b = element.all(by.css('button[type=submit]')).get(0);
|
2015-12-20 16:17:16 -05:00
|
|
|
b.click().then(function() {
|
|
|
|
expect(element(by.css('h2')).getText()).toContain('You submitted the following');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should hide form after submit', function () {
|
2016-06-19 11:50:27 -04:00
|
|
|
let alterEgoEle = element.all(by.css('input[name=alterEgo]')).get(0);
|
2015-12-20 16:17:16 -05:00
|
|
|
expect(alterEgoEle.isDisplayed()).toBe(true);
|
2016-05-30 14:05:09 -04:00
|
|
|
let submitButtonEle = element.all(by.css('button[type=submit]')).get(0);
|
2015-12-20 16:17:16 -05:00
|
|
|
submitButtonEle.click().then(function() {
|
|
|
|
expect(alterEgoEle.isDisplayed()).toBe(false);
|
2016-05-30 14:05:09 -04:00
|
|
|
});
|
2015-12-20 16:17:16 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should reflect submitted data after submit', function () {
|
2016-05-30 14:05:09 -04:00
|
|
|
let test = 'testing 1 2 3';
|
|
|
|
let newValue: string;
|
2016-06-19 11:50:27 -04:00
|
|
|
let alterEgoEle = element.all(by.css('input[name=alterEgo]')).get(0);
|
2015-12-20 16:17:16 -05:00
|
|
|
alterEgoEle.getAttribute('value').then(function(value) {
|
2016-01-03 14:32:57 -05:00
|
|
|
// alterEgoEle.sendKeys(test);
|
|
|
|
sendKeys(alterEgoEle, test);
|
2015-12-20 16:17:16 -05:00
|
|
|
newValue = value + test;
|
|
|
|
expect(alterEgoEle.getAttribute('value')).toEqual(newValue);
|
|
|
|
}).then(function() {
|
2016-05-30 14:05:09 -04:00
|
|
|
let b = element.all(by.css('button[type=submit]')).get(0);
|
2015-12-20 16:17:16 -05:00
|
|
|
return b.click();
|
|
|
|
}).then(function() {
|
2016-05-30 14:05:09 -04:00
|
|
|
let alterEgoTextEle = element(by.cssContainingText('div', 'Alter Ego'));
|
2015-12-20 16:17:16 -05:00
|
|
|
expect(alterEgoTextEle.isPresent()).toBe(true, 'cannot locate "Alter Ego" label');
|
2016-05-30 14:05:09 -04:00
|
|
|
let divEle = element(by.cssContainingText('div', newValue));
|
2015-12-20 16:17:16 -05:00
|
|
|
expect(divEle.isPresent()).toBe(true, 'cannot locate div with this text: ' + newValue);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|