2016-05-30 14:05:09 -04:00
|
|
|
/// <reference path="../_protractor/e2e.d.ts" />
|
2015-12-20 16:17:16 -05:00
|
|
|
describe('Hierarchical dependency injection', function () {
|
|
|
|
|
|
|
|
beforeEach(function () {
|
|
|
|
browser.get('');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should open with a card view', function () {
|
|
|
|
expect(element.all(by.cssContainingText('button','edit')).get(0).isDisplayed()).toBe(true,
|
|
|
|
"edit button should be displayed");
|
|
|
|
});
|
|
|
|
|
2016-05-01 17:04:47 -04:00
|
|
|
it('should have multiple heroes listed', function () {
|
2015-12-20 16:17:16 -05:00
|
|
|
expect(element.all(by.css('heroes-list li')).count()).toBeGreaterThan(1);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should change to editor view after selection', function () {
|
2016-05-30 14:05:09 -04:00
|
|
|
let editButtonEle = element.all(by.cssContainingText('button','edit')).get(0);
|
2015-12-20 16:17:16 -05:00
|
|
|
editButtonEle.click().then(function() {
|
|
|
|
expect(editButtonEle.isDisplayed()).toBe(false, "edit button should be hidden after selection");
|
|
|
|
})
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should be able to save editor change', function () {
|
|
|
|
testEdit(true);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should be able to cancel editor change', function () {
|
|
|
|
testEdit(false);
|
|
|
|
});
|
|
|
|
|
2016-06-01 12:11:58 -04:00
|
|
|
function testEdit(shouldSave: boolean) {
|
2015-12-20 16:17:16 -05:00
|
|
|
// select 2nd ele
|
2016-05-30 14:05:09 -04:00
|
|
|
let heroEle = element.all(by.css('heroes-list li')).get(1);
|
2015-12-20 16:17:16 -05:00
|
|
|
// get the 2nd span which is the name of the hero
|
2016-05-30 14:05:09 -04:00
|
|
|
let heroNameEle = heroEle.all(by.css('hero-card span')).get(1);
|
|
|
|
let editButtonEle = heroEle.element(by.cssContainingText('button','edit'));
|
2015-12-20 16:17:16 -05:00
|
|
|
editButtonEle.click().then(function() {
|
2016-06-01 12:11:58 -04:00
|
|
|
let inputEle = heroEle.element(by.css('hero-editor input'));
|
2016-01-03 14:32:57 -05:00
|
|
|
// return inputEle.sendKeys("foo");
|
|
|
|
return sendKeys(inputEle, "foo");
|
2015-12-20 16:17:16 -05:00
|
|
|
}).then(function() {
|
2016-06-01 12:11:58 -04:00
|
|
|
let buttonName = shouldSave ? 'save' : 'cancel';
|
2016-05-30 14:05:09 -04:00
|
|
|
let buttonEle = heroEle.element(by.cssContainingText('button', buttonName));
|
2015-12-20 16:17:16 -05:00
|
|
|
return buttonEle.click();
|
|
|
|
}).then(function() {
|
|
|
|
if (shouldSave) {
|
|
|
|
expect(heroNameEle.getText()).toContain('foo');
|
|
|
|
} else {
|
|
|
|
expect(heroNameEle.getText()).not.toContain('foo');
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
});
|