cleanup(router): fix e2e tests
This commit is contained in:
parent
b625f2471a
commit
9f784dcc5a
@ -22,7 +22,7 @@ import {ObservableWrapper} from '../facade/async';
|
|||||||
@Directive({selector: '[routerLink]'})
|
@Directive({selector: '[routerLink]'})
|
||||||
export class RouterLink implements OnDestroy {
|
export class RouterLink implements OnDestroy {
|
||||||
@Input() target: string;
|
@Input() target: string;
|
||||||
private _comands: any[] = [];
|
private _commands: any[] = [];
|
||||||
private _subscription: any;
|
private _subscription: any;
|
||||||
|
|
||||||
@HostBinding() href: string;
|
@HostBinding() href: string;
|
||||||
@ -38,9 +38,9 @@ export class RouterLink implements OnDestroy {
|
|||||||
@Input()
|
@Input()
|
||||||
set routerLink(data: any[]|any) {
|
set routerLink(data: any[]|any) {
|
||||||
if (isArray(data)) {
|
if (isArray(data)) {
|
||||||
this._comands = <any[]>data;
|
this._commands = <any[]>data;
|
||||||
} else {
|
} else {
|
||||||
this._comands = [data];
|
this._commands = [data];
|
||||||
}
|
}
|
||||||
this._updateTargetUrlAndHref();
|
this._updateTargetUrlAndHref();
|
||||||
}
|
}
|
||||||
@ -49,14 +49,14 @@ export class RouterLink implements OnDestroy {
|
|||||||
@HostListener("click")
|
@HostListener("click")
|
||||||
onClick(): boolean {
|
onClick(): boolean {
|
||||||
if (!isString(this.target) || this.target == '_self') {
|
if (!isString(this.target) || this.target == '_self') {
|
||||||
this._router.navigate(this._comands, this._routeSegment);
|
this._router.navigate(this._commands, this._routeSegment);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private _updateTargetUrlAndHref(): void {
|
private _updateTargetUrlAndHref(): void {
|
||||||
let tree = this._router.createUrlTree(this._comands, this._routeSegment);
|
let tree = this._router.createUrlTree(this._commands, this._routeSegment);
|
||||||
if (isPresent(tree)) {
|
if (isPresent(tree)) {
|
||||||
this.href = this._router.serializeUrl(tree);
|
this.href = this._router.serializeUrl(tree);
|
||||||
this.isActive = this._router.urlTree.contains(tree);
|
this.isActive = this._router.urlTree.contains(tree);
|
||||||
|
@ -7,12 +7,11 @@ function waitForElement(selector) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
describe('alt-routing inbox-app', () => {
|
describe('alt-routing inbox-app', () => {
|
||||||
|
var URL = 'all/playground/src/alt_routing/';
|
||||||
|
|
||||||
afterEach(verifyNoBrowserErrors);
|
afterEach(verifyNoBrowserErrors);
|
||||||
|
|
||||||
describe('index view', () => {
|
describe('index view', () => {
|
||||||
var URL = 'all/playground/src/alt_routing/';
|
|
||||||
|
|
||||||
it('should list out the current collection of items', () => {
|
it('should list out the current collection of items', () => {
|
||||||
browser.get(URL);
|
browser.get(URL);
|
||||||
waitForElement('.inbox-item-record');
|
waitForElement('.inbox-item-record');
|
||||||
@ -31,8 +30,6 @@ describe('alt-routing inbox-app', () => {
|
|||||||
|
|
||||||
|
|
||||||
describe('drafts view', () => {
|
describe('drafts view', () => {
|
||||||
var URL = 'all/playground/src/alt_routing/#/drafts';
|
|
||||||
|
|
||||||
it('should navigate to the drafts view when the drafts link is clicked', () => {
|
it('should navigate to the drafts view when the drafts link is clicked', () => {
|
||||||
browser.get(URL);
|
browser.get(URL);
|
||||||
waitForElement('.inbox-item-record');
|
waitForElement('.inbox-item-record');
|
||||||
@ -55,8 +52,6 @@ describe('alt-routing inbox-app', () => {
|
|||||||
|
|
||||||
|
|
||||||
describe('detail view', () => {
|
describe('detail view', () => {
|
||||||
var URL = 'all/playground/src/alt_routing/';
|
|
||||||
|
|
||||||
it('should navigate to the detail view when an email is clicked', () => {
|
it('should navigate to the detail view when an email is clicked', () => {
|
||||||
browser.get(URL);
|
browser.get(URL);
|
||||||
waitForElement('#item-10');
|
waitForElement('#item-10');
|
||||||
@ -83,7 +78,7 @@ describe('alt-routing inbox-app', () => {
|
|||||||
element(by.css('#item-10')).click();
|
element(by.css('#item-10')).click();
|
||||||
waitForElement('.sort-button');
|
waitForElement('.sort-button');
|
||||||
element(by.css('.sort-button')).click();
|
element(by.css('.sort-button')).click();
|
||||||
expect(browser.getCurrentUrl()).toMatch(/\/;sort=date$/);
|
expect(browser.getCurrentUrl()).toContain(';sort=date');
|
||||||
waitForElement('.inbox-item-record');
|
waitForElement('.inbox-item-record');
|
||||||
expect(element(by.css(".inbox-item-record > a")).getAttribute("id")).toEqual("item-137");
|
expect(element(by.css(".inbox-item-record > a")).getAttribute("id")).toEqual("item-137");
|
||||||
});
|
});
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<inbox-side-menu class="inbox-aside">
|
<inbox-side-menu class="inbox-aside">
|
||||||
<a [routerLink]="['/']" class="link" [class.active]="inboxPageActive()">Inbox</a>
|
<a [routerLink]="['/inbox']" class="link" [class.active]="inboxPageActive()">Inbox</a>
|
||||||
<a [routerLink]="['/drafts']" class="link" [class.active]="draftsPageActive()">Drafts</a>
|
<a [routerLink]="['/drafts']" class="link" [class.active]="draftsPageActive()">Drafts</a>
|
||||||
</inbox-side-menu>
|
</inbox-side-menu>
|
||||||
<router-outlet></router-outlet>
|
<router-outlet></router-outlet>
|
||||||
|
@ -156,6 +156,7 @@ class DraftsCmp {
|
|||||||
})
|
})
|
||||||
@Routes([
|
@Routes([
|
||||||
new Route({path: '/', component: InboxCmp}),
|
new Route({path: '/', component: InboxCmp}),
|
||||||
|
new Route({path: '/inbox', component: InboxCmp}),
|
||||||
new Route({path: '/drafts', component: DraftsCmp}),
|
new Route({path: '/drafts', component: DraftsCmp}),
|
||||||
new Route({path: '/detail/:id', component: InboxDetailCmp})
|
new Route({path: '/detail/:id', component: InboxDetailCmp})
|
||||||
])
|
])
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
<hr />
|
<hr />
|
||||||
|
|
||||||
<a [routerLink]="['/', { sort: 'date'} ]" class="sort-button">
|
<a [routerLink]="['/inbox', { sort: 'date'} ]" class="sort-button">
|
||||||
View Latest Messages
|
View Latest Messages
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user