Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions e2e/nested-router-tab-view/app/about/about.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<ActionBar class="action-bar">
<Label class="action-bar-title" text="About Component"></Label>
</ActionBar>

<GridLayout rows="auto, *">
<Button text="Back(ActivatedRoute)" automationText="Back(ActivatedRoute)" (tap)="backActivatedRoute()"></Button>
</GridLayout>
24 changes: 24 additions & 0 deletions e2e/nested-router-tab-view/app/about/about.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { Component, ViewContainerRef } from "@angular/core";
import { ModalDialogService, ModalDialogOptions } from "nativescript-angular/directives/dialogs";
import { RouterExtensions } from "nativescript-angular/router";
import { ActivatedRoute } from "@angular/router";

@Component({
moduleId: module.id,
selector: "about-page",
templateUrl: "./about.component.html"
})
export class AboutComponent {
constructor(
private modal: ModalDialogService,
private vcRef: ViewContainerRef,
private activeRoute: ActivatedRoute,
private routerExtension: RouterExtensions) { }

ngOnInit() {
}

backActivatedRoute() {
this.routerExtension.back({ relativeTo: this.activeRoute });
}
}
4 changes: 3 additions & 1 deletion e2e/nested-router-tab-view/app/app.routing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { TeamDetailComponent } from "./team/team-detail.component";
import { LoginComponent } from "./login/login.component";
import { TabsComponent } from "./tabs/tabs.component";
import { HomeComponent } from "./home/home.component";
import { AboutComponent } from "./about/about.component";

import { ModalComponent } from "./modal/modal.component";
import { NestedModalComponent } from "./modal-nested/modal-nested.component";
Expand Down Expand Up @@ -54,7 +55,8 @@ const routes: Routes = [
{ path: "teams", component: TeamsComponent, outlet: "teamTab" },
{ path: "team/:id", component: TeamDetailComponent, outlet: "teamTab" },
]
}
},
{ path: "about", component: AboutComponent }
];

@NgModule({
Expand Down
3 changes: 3 additions & 0 deletions e2e/nested-router-tab-view/app/shared.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { NativeScriptRouterModule } from "nativescript-angular/router";
import { DataService } from "./data.service";

import { HomeComponent } from "./home/home.component";
import { AboutComponent } from "./about/about.component";
import { PlayerComponent } from "./player/players.component";
import { PlayerDetailComponent } from "./player/player-detail.component";
import { TeamsComponent } from "./team/teams.component";
Expand All @@ -19,13 +20,15 @@ import { TeamDetailComponent } from "./team/team-detail.component";
],
declarations: [
HomeComponent,
AboutComponent,
PlayerComponent,
PlayerDetailComponent,
TeamsComponent,
TeamDetailComponent
],
exports: [
HomeComponent,
AboutComponent,
PlayerComponent,
PlayerDetailComponent,
TeamsComponent,
Expand Down
1 change: 1 addition & 0 deletions e2e/nested-router-tab-view/app/tabs/tabs.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<StackLayout>
<GridLayout rows="auto,*">
<WrapLayout row="0">
<Button text="Go To About Page" [nsRouterLink]="['../about']"></Button>
<Button text="Back()" (tap)="back()"></Button>
<Button text="CanGoBack(ActivatedRoute)" (tap)="canGoBack()"></Button>
<Button text="Back(ActivatedRoute)" (tap)="backActivatedRoute()"></Button>
Expand Down
22 changes: 22 additions & 0 deletions e2e/nested-router-tab-view/e2e/home-tabs.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,28 @@ describe("home-tabs:", () => {
await screen.loadedTeamList();
});

it("should navigate to Tabs then to About forward", async () => {
if (driver.isIOS) {
await screen.navigateToTabsPage();
await screen.loadedTabs();
await screen.loadedPlayersList();
await screen.navigateToAboutPage();
await screen.loadedAbout();
}
});

it("should go back to Tabs and then back to Home", async () => {
if (driver.isIOS) {
await backActivatedRoute(driver);
await screen.loadedTabs();
await screen.loadedPlayersList();
await backActivatedRoute(driver);
await screen.loadedHome();
await screen.loadedPlayersList();
await screen.loadedTeamList();
}
});

it("should navigate to Tabs without Players/Teams navigation", async () => {
await screen.navigateToTabsPage();
await screen.loadedTabs();
Expand Down
13 changes: 13 additions & 0 deletions e2e/nested-router-tab-view/e2e/screen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { AppiumDriver, SearchOptions } from "nativescript-dev-appium";
import { assert } from "chai";

const home = "Home Component";
const about = "About Component";
const login = "Login Component";
const tabs = "Tabs Component";

Expand All @@ -16,6 +17,7 @@ const gotoNextTeam = "next team";
const gotoTeams = "teams";

const gotoHomePage = "Go To Home Page";
const gotoAboutPage = "Go To About Page";
const gotoTabsPage = "Go To Tabs Page";
const confirmDialog = "Ok";

Expand Down Expand Up @@ -65,6 +67,12 @@ export class Screen {
console.log(home + " loaded!");
}

loadedAbout= async () => {
const lblAbout = await this._driver.findElementByAutomationText(about);
assert.isTrue(await lblAbout.isDisplayed());
console.log(home + " loaded!");
}

loadedTabs = async () => {
const lblTabs = await this._driver.findElementByAutomationText(tabs);
assert.isTrue(await lblTabs.isDisplayed());
Expand Down Expand Up @@ -113,6 +121,11 @@ export class Screen {
await btnNavToHomePage.tap();
}

navigateToAboutPage = async () => {
const btnNavToAboutPage = await this._driver.findElementByAutomationText(gotoAboutPage);
await btnNavToAboutPage.tap();
}

navigateToPlayer = async (player: string) => {
const btnNavPlayerPage = await this._driver.findElementByAutomationText(player);
await btnNavPlayerPage.tap();
Expand Down
6 changes: 6 additions & 0 deletions nativescript-angular/router/ns-location-strategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,7 @@ export class NSLocationStrategy extends LocationStrategy {
if (!lastState || !equalStateUrls) {
outlet.states.push(locationState);

// Update last state segmentGroup of parent Outlet.
if (this._modalNavigationDepth === 0 && !outlet.showingModal) {
this.updateParentsStates(outlet, currentSegmentGroup.parent);
}
Expand Down Expand Up @@ -566,6 +567,11 @@ export class NSLocationStrategy extends LocationStrategy {
newOutlet.parent = parent;
this.outlets.push(newOutlet);

// Update last state segmentGroup of parent Outlet.
if (this._modalNavigationDepth === 0 && !newOutlet.showingModal) {
this.updateParentsStates(newOutlet, segmentGroup.parent);
}

return newOutlet;
}

Expand Down