2016-06-23 12:47:54 -04:00
|
|
|
/**
|
|
|
|
* @license
|
|
|
|
* Copyright Google Inc. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by an MIT-style license that can be
|
|
|
|
* found in the LICENSE file at https://angular.io/license
|
|
|
|
*/
|
|
|
|
|
2016-07-13 13:10:02 -04:00
|
|
|
import {verifyNoBrowserErrors} from 'e2e_util/e2e_util';
|
2015-10-30 11:48:47 -04:00
|
|
|
|
2016-06-08 18:45:15 -04:00
|
|
|
function waitForElement(selector: any /** TODO #9100 */) {
|
2015-10-30 11:48:47 -04:00
|
|
|
var EC = (<any>protractor).ExpectedConditions;
|
|
|
|
// Waits for the element with id 'abc' to be present on the dom.
|
|
|
|
browser.wait(EC.presenceOf($(selector)), 20000);
|
|
|
|
}
|
|
|
|
|
|
|
|
describe('hash routing example app', function() {
|
|
|
|
afterEach(verifyNoBrowserErrors);
|
|
|
|
|
2016-05-02 01:54:19 -04:00
|
|
|
var URL = 'all/playground/src/hash_routing/index.html';
|
2015-10-30 11:48:47 -04:00
|
|
|
|
|
|
|
it('should navigate between routes', function() {
|
|
|
|
browser.get(URL + '#/bye');
|
|
|
|
waitForElement('goodbye-cmp');
|
|
|
|
|
|
|
|
element(by.css('#hello-link')).click();
|
|
|
|
waitForElement('hello-cmp');
|
|
|
|
|
|
|
|
expect(element(by.css('hello-cmp')).getText()).toContain('hello');
|
|
|
|
|
|
|
|
browser.navigate().back();
|
|
|
|
waitForElement('goodbye-cmp');
|
|
|
|
|
|
|
|
expect(element(by.css('goodbye-cmp')).getText()).toContain('goodbye');
|
|
|
|
});
|
2015-11-02 18:11:57 -05:00
|
|
|
|
|
|
|
|
|
|
|
it('should open in new window if target is _blank', () => {
|
2016-05-02 01:54:19 -04:00
|
|
|
var URL = 'all/playground/src/hash_routing/index.html';
|
2015-11-02 18:11:57 -05:00
|
|
|
browser.get(URL + '#/');
|
|
|
|
waitForElement('hello-cmp');
|
|
|
|
|
|
|
|
element(by.css('#goodbye-link-blank')).click();
|
|
|
|
expect(browser.driver.getCurrentUrl()).not.toContain('#/bye');
|
|
|
|
browser.getAllWindowHandles().then(function(windows) {
|
2016-08-05 12:56:53 -04:00
|
|
|
browser.switchTo().window(windows[1]).then(function() {
|
|
|
|
expect(browser.driver.getCurrentUrl()).toContain('#/bye');
|
|
|
|
});
|
2015-11-02 18:11:57 -05:00
|
|
|
});
|
|
|
|
});
|
2015-10-30 11:48:47 -04:00
|
|
|
});
|