Permalink
Browse files

Integration Tests

  • Loading branch information...
mraible committed Feb 2, 2015
1 parent f3551cc commit 12e37eb7ad8cde82c6ec92c8562700a7fb6952cc
Showing with 60 additions and 2 deletions.
  1. +1 −1 app/search/edit.html
  2. +1 −1 app/search/index.html
  3. +58 −0 e2e-tests/scenarios.js
View
@@ -17,6 +17,6 @@
</address>
</fieldset>
<div>
<button type="submit">Save</button>
<button type="submit" id="save">Save</button>
</div>
</form>
View
@@ -1,6 +1,6 @@
<form ng-submit="search()">
<input type="search" name="search" ng-model="term">
<button>Search</button>
<button id="search">Search</button>
</form>
<table ng-show="searchResults.length" style="width: 100%">
View
@@ -39,4 +39,62 @@ describe('my app', function() {
});
});
describe('search', function() {
var searchTerm = element(by.model('term'));
var searchButton = element(by.id('search'));
beforeEach(function() {
browser.get('index.html#/search');
});
it('should allow searching at /search', function() {
searchTerm.sendKeys("M");
searchButton.click().then(function() {
expect(element.all(by.repeater('person in searchResults')).count()).toEqual(3);
});
});
});
describe('edit person', function() {
var name = element(by.model('person.name'));
var street = element(by.model('person.address.street'));
var city = element(by.model('person.address.city'));
beforeEach(function() {
browser.get('index.html#/edit/1');
});
it('should allow viewing a person', function() {
// getText() doesn't work with input elements, see the following for more information:
// https://github.com/angular/protractor/blob/master/docs/faq.md#the-result-of-gettext-from-an-input-element-is-always-empty
expect(name.getAttribute('value')).toEqual("Peyton Manning");
expect(street.getAttribute('value')).toEqual("1234 Main Street");
expect(city.getAttribute('value')).toEqual("Greenwood Village");
});
});
describe('save person', function() {
var name = element(by.model('person.name'));
var save = element(by.id('save'));
beforeEach(function() {
browser.get('index.html#/edit/1');
});
it('should allow updating a name', function() {
name.sendKeys(" Updated");
save.click().then(function() {
// verify url set back to search results
browser.driver.wait(function() {
return browser.driver.getCurrentUrl().then(function(url) {
expect(url).toContain('/search/Peyton%20Manning%20Updated');
return url;
});
});
// verify one element matched this change
expect(element.all(by.repeater('person in searchResults')).count()).toEqual(1);
});
});
});
});

0 comments on commit 12e37eb

Please sign in to comment.