chore: convert all e2e specs to typescript
This commit is contained in:
parent
14ab2c5110
commit
c2c3177545
|
@ -7,13 +7,13 @@ describe('Architecture', function () {
|
|||
browser.get('');
|
||||
});
|
||||
|
||||
function itReset(name: string, func: (v: void) => any) {
|
||||
function itReset(name: string, func: () => any) {
|
||||
it(name, function() {
|
||||
browser.get('').then(func);
|
||||
});
|
||||
}
|
||||
|
||||
it('should display correct title: ' + title, function () {
|
||||
it(`should display correct title: ${title}`, function () {
|
||||
expect(element(by.css('h2')).getText()).toEqual(title);
|
||||
});
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ describe('Attribute directives', function () {
|
|||
browser.get('');
|
||||
});
|
||||
|
||||
it('should display correct title: ' + _title, function () {
|
||||
it(`should display correct title: ${_title}`, function () {
|
||||
expect(element(by.css('h1')).getText()).toEqual(_title);
|
||||
});
|
||||
|
||||
|
|
|
@ -29,19 +29,18 @@ describe('Hierarchical dependency injection', function () {
|
|||
testEdit(false);
|
||||
});
|
||||
|
||||
function testEdit(shouldSave) {
|
||||
let inputEle;
|
||||
function testEdit(shouldSave: boolean) {
|
||||
// select 2nd ele
|
||||
let heroEle = element.all(by.css('heroes-list li')).get(1);
|
||||
// get the 2nd span which is the name of the hero
|
||||
let heroNameEle = heroEle.all(by.css('hero-card span')).get(1);
|
||||
let editButtonEle = heroEle.element(by.cssContainingText('button','edit'));
|
||||
editButtonEle.click().then(function() {
|
||||
inputEle = heroEle.element(by.css('hero-editor input'));
|
||||
let inputEle = heroEle.element(by.css('hero-editor input'));
|
||||
// return inputEle.sendKeys("foo");
|
||||
return sendKeys(inputEle, "foo");
|
||||
}).then(function() {
|
||||
buttonName = shouldSave ? 'save' : 'cancel';
|
||||
let buttonName = shouldSave ? 'save' : 'cancel';
|
||||
let buttonEle = heroEle.element(by.cssContainingText('button', buttonName));
|
||||
return buttonEle.click();
|
||||
}).then(function() {
|
||||
|
|
|
@ -7,18 +7,17 @@ describe('Homepage Hello World', function () {
|
|||
|
||||
// Does it even launch?
|
||||
let expectedLabel = 'Name:';
|
||||
it('should display the label: ' + expectedLabel, function () {
|
||||
it(`should display the label: ${expectedLabel}`, function () {
|
||||
expect(element(by.css('label')).getText()).toEqual(expectedLabel);
|
||||
});
|
||||
|
||||
it('should display entered name', function () {
|
||||
let testName = 'Bobby Joe';
|
||||
let newValue;
|
||||
let nameEle = element.all(by.css('input')).get(0);
|
||||
nameEle.getAttribute('value').then(function(value) {
|
||||
// nameEle.sendKeys(testName); // should work but doesn't
|
||||
sendKeys(nameEle, testName); // utility that does work
|
||||
newValue = value + testName; // old input box value + new name
|
||||
let newValue = value + testName; // old input box value + new name
|
||||
expect(nameEle.getAttribute('value')).toEqual(newValue);
|
||||
}).then(function() {
|
||||
// Check the interpolated message built from name
|
||||
|
|
|
@ -7,7 +7,7 @@ describe('Homepage Tabs', function () {
|
|||
|
||||
// Does it even launch?
|
||||
let expectedAppTitle = 'Tabs Demo';
|
||||
it('should display app title: ' + expectedAppTitle, function () {
|
||||
it(`should display app title: ${expectedAppTitle}`, function () {
|
||||
expect(element(by.css('h4')).getText()).toEqual(expectedAppTitle);
|
||||
});
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ describe('Homepage Todo', function () {
|
|||
|
||||
// Does it even launch?
|
||||
let expectedAppTitle = 'Todo';
|
||||
it('should display app title: ' + expectedAppTitle, function () {
|
||||
it(`should display app title: ${expectedAppTitle}`, function () {
|
||||
expect(element(by.css('h2')).getText()).toEqual(expectedAppTitle);
|
||||
});
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@ describe('Lifecycle hooks', function () {
|
|||
let powerInputEle = inputEles.get(0);
|
||||
let titleEle = doCheckViewEle.element(by.css('p'));
|
||||
let changeLogEles = doCheckViewEle.all(by.css('div'));
|
||||
let logCount;
|
||||
let logCount: number;
|
||||
|
||||
expect(titleEle.getText()).toContain('Windstorm can sing');
|
||||
changeLogEles.count().then(function(count) {
|
||||
|
@ -92,7 +92,7 @@ describe('Lifecycle hooks', function () {
|
|||
let commentEle = parentEle.element(by.className('comment'));
|
||||
let logEles = parentEle.all(by.css('h4 ~ div'));
|
||||
let childViewInputEle = parentEle.element(by.css('my-child input'));
|
||||
let logCount;
|
||||
let logCount: number;
|
||||
|
||||
expect(childViewInputEle.getAttribute('value')).toContain('Magneta');
|
||||
expect(commentEle.isPresent()).toBe(false, 'comment should not be in DOM');
|
||||
|
@ -121,7 +121,7 @@ describe('Lifecycle hooks', function () {
|
|||
let commentEle = parentEle.element(by.className('comment'));
|
||||
let logEles = parentEle.all(by.css('h4 ~ div'));
|
||||
let childViewInputEle = parentEle.element(by.css('my-child input'));
|
||||
let logCount;
|
||||
let logCount: number;
|
||||
|
||||
expect(childViewInputEle.getAttribute('value')).toContain('Magneta');
|
||||
expect(commentEle.isPresent()).toBe(false, 'comment should not be in DOM');
|
||||
|
|
|
@ -65,7 +65,7 @@ describe('Pipes', function () {
|
|||
|
||||
it('should support flying heroes (pure) ', function () {
|
||||
let nameEle = element(by.css('flying-heroes input[type="text"]'));
|
||||
let canFlyCheckEle = element(by.css('flying-heroes #can-fly'));
|
||||
let canFlyCheckEle = element(by.css('flying-heroes #can-fly'));
|
||||
let mutateCheckEle = element(by.css('flying-heroes #mutate'));
|
||||
let resetEle = element(by.css('flying-heroes button'));
|
||||
let flyingHeroesEle = element.all(by.css('flying-heroes #flyers div'));
|
||||
|
|
|
@ -3,12 +3,11 @@ describe('QuickStart E2E Tests', function () {
|
|||
|
||||
let expectedMsg = 'My First Angular 2 App';
|
||||
|
||||
|
||||
beforeEach(function () {
|
||||
browser.get('');
|
||||
});
|
||||
|
||||
it('should display: ' + expectedMsg, function () {
|
||||
it(`should display: ${expectedMsg}`, function () {
|
||||
expect(element(by.css('h1')).getText()).toEqual(expectedMsg);
|
||||
});
|
||||
|
||||
|
|
|
@ -1,111 +0,0 @@
|
|||
/// <reference path="../_protractor/e2e.d.ts" />
|
||||
describe('Router', function () {
|
||||
beforeAll(function () {
|
||||
browser.get('');
|
||||
});
|
||||
function getPageStruct() {
|
||||
hrefEles = element.all(by.css('my-app a'));
|
||||
return {
|
||||
hrefs: hrefEles,
|
||||
routerParent: element(by.css('my-app > undefined')),
|
||||
routerTitle: element(by.css('my-app > undefined > h2')),
|
||||
crisisHref: hrefEles.get(0),
|
||||
crisisList: element.all(by.css('my-app > undefined > undefined li')),
|
||||
crisisDetail: element(by.css('my-app > undefined > undefined > div')),
|
||||
crisisDetailTitle: element(by.css('my-app > undefined > undefined > div > h3')),
|
||||
heroesHref: hrefEles.get(1),
|
||||
heroesList: element.all(by.css('my-app > undefined li')),
|
||||
heroDetail: element(by.css('my-app > undefined > div')),
|
||||
heroDetailTitle: element(by.css('my-app > undefined > div > h3')),
|
||||
};
|
||||
}
|
||||
it('should be able to see the start screen', function () {
|
||||
var page = getPageStruct();
|
||||
expect(page.hrefs.count()).toEqual(2, 'should be two dashboard choices');
|
||||
expect(page.crisisHref.getText()).toEqual("Crisis Center");
|
||||
expect(page.heroesHref.getText()).toEqual("Heroes");
|
||||
});
|
||||
it('should be able to see crises center items', function () {
|
||||
var page = getPageStruct();
|
||||
expect(page.crisisList.count()).toBe(4, "should be 4 crisis center entries at start");
|
||||
});
|
||||
it('should be able to see hero items', function () {
|
||||
var page = getPageStruct();
|
||||
page.heroesHref.click().then(function () {
|
||||
expect(page.routerTitle.getText()).toContain('HEROES');
|
||||
expect(page.heroesList.count()).toBe(6, "should be 6 heroes");
|
||||
});
|
||||
});
|
||||
it('should be able to toggle the views', function () {
|
||||
var page = getPageStruct();
|
||||
page.crisisHref.click().then(function () {
|
||||
expect(page.crisisList.count()).toBe(4, "should be 4 crisis center entries");
|
||||
return page.heroesHref.click();
|
||||
}).then(function () {
|
||||
expect(page.heroesList.count()).toBe(6, "should be 6 heroes");
|
||||
});
|
||||
});
|
||||
it('should be able to edit and save details from the crisis center view', function () {
|
||||
crisisCenterEdit(2, true);
|
||||
});
|
||||
it('should be able to edit and cancel details from the crisis center view', function () {
|
||||
crisisCenterEdit(3, false);
|
||||
});
|
||||
it('should be able to edit and save details from the heroes view', function () {
|
||||
var page = getPageStruct();
|
||||
var heroEle, heroText;
|
||||
page.heroesHref.click().then(function () {
|
||||
heroEle = page.heroesList.get(4);
|
||||
return heroEle.getText();
|
||||
}).then(function (text) {
|
||||
expect(text.length).toBeGreaterThan(0, 'should have some text');
|
||||
// remove leading id from text
|
||||
heroText = text.substr(text.indexOf(' ')).trim();
|
||||
return heroEle.click();
|
||||
}).then(function () {
|
||||
expect(page.heroesList.count()).toBe(0, "should no longer see crisis center entries");
|
||||
expect(page.heroDetail.isPresent()).toBe(true, 'should be able to see crisis detail');
|
||||
expect(page.heroDetailTitle.getText()).toContain(heroText);
|
||||
var inputEle = page.heroDetail.element(by.css('input'));
|
||||
return sendKeys(inputEle, '-foo');
|
||||
}).then(function () {
|
||||
expect(page.heroDetailTitle.getText()).toContain(heroText + '-foo');
|
||||
var buttonEle = page.heroDetail.element(by.css('button'));
|
||||
return buttonEle.click();
|
||||
}).then(function () {
|
||||
expect(heroEle.getText()).toContain(heroText + '-foo');
|
||||
});
|
||||
});
|
||||
function crisisCenterEdit(index, shouldSave) {
|
||||
var page = getPageStruct();
|
||||
var crisisEle, crisisText;
|
||||
page.crisisHref.click()
|
||||
.then(function () {
|
||||
crisisEle = page.crisisList.get(index);
|
||||
return crisisEle.getText();
|
||||
}).then(function (text) {
|
||||
expect(text.length).toBeGreaterThan(0, 'should have some text');
|
||||
// remove leading id from text
|
||||
crisisText = text.substr(text.indexOf(' ')).trim();
|
||||
return crisisEle.click();
|
||||
}).then(function () {
|
||||
expect(page.crisisList.count()).toBe(0, "should no longer see crisis center entries");
|
||||
expect(page.crisisDetail.isPresent()).toBe(true, 'should be able to see crisis detail');
|
||||
expect(page.crisisDetailTitle.getText()).toContain(crisisText);
|
||||
var inputEle = page.crisisDetail.element(by.css('input'));
|
||||
return sendKeys(inputEle, '-foo');
|
||||
}).then(function () {
|
||||
expect(page.crisisDetailTitle.getText()).toContain(crisisText + '-foo');
|
||||
var buttonEle = page.crisisDetail.element(by.cssContainingText('button', shouldSave ? 'Save' : 'Cancel'));
|
||||
return buttonEle.click();
|
||||
}).then(function () {
|
||||
if (shouldSave) {
|
||||
expect(crisisEle.getText()).toContain(crisisText + '-foo');
|
||||
}
|
||||
else {
|
||||
expect(crisisEle.getText()).not.toContain(crisisText + '-foo');
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
//# sourceMappingURL=e2e-spec.js.map
|
|
@ -6,7 +6,7 @@ describe('Router', function () {
|
|||
});
|
||||
|
||||
function getPageStruct() {
|
||||
hrefEles = element.all(by.css('my-app a'));
|
||||
let hrefEles = element.all(by.css('my-app a'));
|
||||
|
||||
return {
|
||||
hrefs: hrefEles,
|
||||
|
@ -66,7 +66,8 @@ describe('Router', function () {
|
|||
|
||||
it('should be able to edit and save details from the heroes view', function () {
|
||||
let page = getPageStruct();
|
||||
let heroEle, heroText;
|
||||
let heroEle: protractor.ElementFinder;
|
||||
let heroText: string;
|
||||
page.heroesHref.click().then(function() {
|
||||
heroEle = page.heroesList.get(4);
|
||||
return heroEle.getText();
|
||||
|
@ -90,9 +91,10 @@ describe('Router', function () {
|
|||
})
|
||||
});
|
||||
|
||||
function crisisCenterEdit(index, shouldSave) {
|
||||
function crisisCenterEdit(index: number, shouldSave: boolean) {
|
||||
let page = getPageStruct();
|
||||
let crisisEle, crisisText;
|
||||
let crisisEle: protractor.ElementFinder;
|
||||
let crisisText: string;
|
||||
page.crisisHref.click()
|
||||
.then(function () {
|
||||
crisisEle = page.crisisList.get(index);
|
||||
|
|
|
@ -6,7 +6,7 @@ describe('Router', function () {
|
|||
});
|
||||
|
||||
function getPageStruct() {
|
||||
hrefEles = element.all(by.css('my-app a'));
|
||||
let hrefEles = element.all(by.css('my-app a'));
|
||||
|
||||
return {
|
||||
hrefs: hrefEles,
|
||||
|
@ -66,7 +66,8 @@ describe('Router', function () {
|
|||
|
||||
it('should be able to edit and save details from the heroes view', function () {
|
||||
let page = getPageStruct();
|
||||
let heroEle, heroText;
|
||||
let heroEle: protractor.ElementFinder;
|
||||
let heroText: string;
|
||||
page.heroesHref.click().then(function() {
|
||||
heroEle = page.heroesList.get(4);
|
||||
return heroEle.getText();
|
||||
|
@ -90,9 +91,10 @@ describe('Router', function () {
|
|||
})
|
||||
});
|
||||
|
||||
function crisisCenterEdit(index, shouldSave) {
|
||||
function crisisCenterEdit(index: number, shouldSave: boolean) {
|
||||
let page = getPageStruct();
|
||||
let crisisEle, crisisText;
|
||||
let crisisEle: protractor.ElementFinder;
|
||||
let crisisText: string;
|
||||
page.crisisHref.click()
|
||||
.then(function () {
|
||||
crisisEle = page.crisisList.get(index);
|
||||
|
|
|
@ -70,7 +70,7 @@ describe('Server Communication', function () {
|
|||
});
|
||||
});
|
||||
|
||||
function testForRefreshedResult(keyPressed, done) {
|
||||
function testForRefreshedResult(keyPressed: string, done: () => void) {
|
||||
testForResult('my-wiki', keyPressed, false, done)
|
||||
}
|
||||
});
|
||||
|
@ -101,17 +101,17 @@ describe('Server Communication', function () {
|
|||
});
|
||||
|
||||
|
||||
function testForNewResult(keyPressed, done) {
|
||||
function testForNewResult(keyPressed: string, done: () => void) {
|
||||
testForResult('my-wiki-smart', keyPressed, false, done)
|
||||
}
|
||||
|
||||
function testForStaleResult(keyPressed, done) {
|
||||
function testForStaleResult(keyPressed: string, done: () => void) {
|
||||
testForResult('my-wiki-smart', keyPressed, true, done)
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
function testForResult(componentTagName, keyPressed, hasListBeforeSearch, done) {
|
||||
function testForResult(componentTagName: string, keyPressed: string, hasListBeforeSearch: boolean, done: () => void) {
|
||||
let searchWait = 1000; // Wait for wikipedia but not so long that tests timeout
|
||||
let wikiComponent = element(by.tagName(componentTagName));
|
||||
expect(wikiComponent).toBeDefined('<' + componentTagName + '> must exist');
|
||||
|
|
|
@ -32,7 +32,7 @@ describe('Structural Directives', function () {
|
|||
let ngIfSiblingEle = ngIfParentEle.element(by.css('heavy-loader'));
|
||||
let cssButtonEle = element(by.cssContainingText('button', 'show | hide'));
|
||||
let cssSiblingEle = cssButtonEle.element(by.xpath('..')).element(by.css('heavy-loader'));
|
||||
let setConditionText;
|
||||
let setConditionText: string;
|
||||
setConditionButtonEle.getText().then(function(text) {
|
||||
setConditionText = text;
|
||||
expect(ngIfButtonEle.isPresent()).toBe(true, 'should be able to find ngIfButton');
|
||||
|
|
|
@ -6,7 +6,7 @@ describe('Getting Started E2E Tests', function() {
|
|||
let expectedMsg = 'My First Angular 2 App';
|
||||
|
||||
// tests shared across languages
|
||||
function sharedTests(basePath) {
|
||||
function sharedTests(basePath: string) {
|
||||
beforeEach(function () {
|
||||
browser.get(basePath + 'index.html');
|
||||
});
|
||||
|
|
|
@ -5,9 +5,8 @@ describe('Tutorial', function () {
|
|||
browser.get('');
|
||||
});
|
||||
|
||||
|
||||
function getPageStruct() {
|
||||
hrefEles = element.all(by.css('my-app a'));
|
||||
let hrefEles = element.all(by.css('my-app a'));
|
||||
|
||||
return {
|
||||
hrefs: hrefEles,
|
||||
|
@ -54,7 +53,7 @@ describe('Tutorial', function () {
|
|||
expect(page.myDashboardParent.isPresent()).toBe(true, 'dashboard element should be available');
|
||||
let heroEle = page.topHeroes.get(3);
|
||||
let heroDescrEle = heroEle.element(by.css('h4'));
|
||||
let heroDescr;
|
||||
let heroDescr: string;
|
||||
return heroDescrEle.getText().then(function(text) {
|
||||
heroDescr = text;
|
||||
return heroEle.click();
|
||||
|
@ -70,7 +69,8 @@ describe('Tutorial', function () {
|
|||
let page = getPageStruct();
|
||||
expect(page.myDashboardParent.isPresent()).toBe(true, 'dashboard element should be present');
|
||||
let viewDetailsButtonEle = page.myHeroesParent.element(by.cssContainingText('button', 'View Details'));
|
||||
let heroEle, heroDescr;
|
||||
let heroEle: protractor.ElementFinder;
|
||||
let heroDescr: string;
|
||||
page.myHeroesHref.click().then(function() {
|
||||
expect(page.myDashboardParent.isPresent()).toBe(false, 'dashboard element should NOT be present');
|
||||
expect(page.myHeroesParent.isPresent()).toBe(true, 'myHeroes element should be present');
|
||||
|
@ -93,7 +93,7 @@ describe('Tutorial', function () {
|
|||
});
|
||||
});
|
||||
|
||||
function editDetails(page, origValue, textToAdd) {
|
||||
function editDetails(page: any, origValue: string, textToAdd: string) {
|
||||
expect(page.myDashboardParent.isPresent()).toBe(false, 'dashboard element should NOT be present');
|
||||
expect(page.myHeroesParent.isPresent()).toBe(false, 'myHeroes element should NOT be present');
|
||||
expect(page.heroDetail.isDisplayed()).toBe(true, 'should be able to see hero-details');
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/// <reference path="../_protractor/typings/index.d.ts" />
|
||||
/// <reference path="../_protractor/e2e.d.ts" />
|
||||
'use strict';
|
||||
|
||||
// Angular E2E Testing Guide:
|
||||
|
|
|
@ -7,7 +7,7 @@ describe('User Input Tests', function () {
|
|||
|
||||
it('should support the click event', function () {
|
||||
let mainEle = element(by.css('click-me'));
|
||||
let buttonEle =element(by.css('click-me button'));
|
||||
let buttonEle = element(by.css('click-me button'));
|
||||
expect(mainEle.getText()).not.toContain('You are my hero!');
|
||||
buttonEle.click().then(function() {
|
||||
expect(mainEle.getText()).toContain('You are my hero!');
|
||||
|
@ -16,7 +16,7 @@ describe('User Input Tests', function () {
|
|||
|
||||
it('should support the click event with an event payload', function () {
|
||||
let mainEle = element(by.css('click-me2'));
|
||||
let buttonEle =element(by.css('click-me2 button'));
|
||||
let buttonEle = element(by.css('click-me2 button'));
|
||||
expect(mainEle.getText()).not.toContain('Event target is ');
|
||||
buttonEle.click().then(function() {
|
||||
expect(mainEle.getText()).toContain('Event target is BUTTON');
|
||||
|
@ -86,7 +86,7 @@ describe('User Input Tests', function () {
|
|||
let inputEle = mainEle.element(by.css('input'));
|
||||
let addButtonEle = mainEle.element(by.css('button'));
|
||||
let heroEles = mainEle.all(by.css('li'));
|
||||
let numHeroes;
|
||||
let numHeroes: number;
|
||||
expect(heroEles.count()).toBeGreaterThan(0);
|
||||
heroEles.count().then(function(count) {
|
||||
numHeroes = count;
|
||||
|
|
Loading…
Reference in New Issue