Skip to content

chore: merge release in master #1811

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 9, 2019
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
3 changes: 0 additions & 3 deletions e2e/modal-navigation-ng/e2e/modal.shared.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ describe("modal-shared:", async function () {
await screen[root]();
});

beforeEach(async function () {
});

afterEach(async function () {
if (this.currentTest.state === "failed") {
await driver.logTestArtifacts(this.currentTest.title);
Expand Down
12 changes: 6 additions & 6 deletions e2e/nested-router-tab-view/e2e/tab-view.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ describe("tab-view:", async function () {
let driver: AppiumDriver;
let screen: Screen;

before(async () => {
before(async function () {
nsCapabilities.testReporter.context = this;
driver = await createDriver();
screen = new Screen(driver);
});

after(async () => {
after(async function () {
await driver.quit();
console.log("Quit driver!");
});
Expand All @@ -28,14 +28,14 @@ describe("tab-view:", async function () {
}
});

it("loaded home component and lists", async () => {
it("loaded home component and lists", async function () {
await screen.navigateToHomePage();
await screen.loadedHome();
await screen.loadedPlayersList();
await screen.loadedTeamList();
});

it("loaded tabs component, Players List and Teams List pages", async () => {
it("loaded tabs component, Players List and Teams List pages", async function () {
await screen.navigateToTabsPage();
await screen.loadedTabs();
await screen.loadedPlayersList();
Expand All @@ -45,7 +45,7 @@ describe("tab-view:", async function () {
await screen.loadedPlayersList();
});

it("should navigate Player One/Team One then back separately", async () => {
it("should navigate Player One/Team One then back separately", async function () {
await testPlayerNavigated(screen, screen.playerOne);
await gotoTeamsTab(driver);
await testTeamNavigated(screen, screen.teamOne);
Expand All @@ -56,7 +56,7 @@ describe("tab-view:", async function () {
await screen.loadedPlayersList();
});

it("should navigate Player One/Team One then next Player/Team then back", async () => {
it("should navigate Player One/Team One then next Player/Team then back", async function () {
await testPlayerNavigated(screen, screen.playerOne);
await testPlayerNextNavigated(screen, screen.playerTwo);
await gotoTeamsTab(driver);
Expand Down
18 changes: 9 additions & 9 deletions e2e/renderer/e2e/action-bar.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ describe("Action Bar scenario", async function () {
let toggleFirstButton: UIElement;
let toggleSecondButton: UIElement;

before(async () => {
before(async function () {
nsCapabilities.testReporter.context = this;
driver = await createDriver();
await driver.driver.resetApp();
Expand Down Expand Up @@ -52,7 +52,7 @@ describe("Action Bar scenario", async function () {
});

it("should detach first element when its condition is false", done => {
(async () => {
(async function () {
await toggleFirst();

try {
Expand All @@ -69,7 +69,7 @@ describe("Action Bar scenario", async function () {
});

it("should detach second element when its condition is false", done => {
(async () => {
(async function () {
await toggleSecond();

try {
Expand All @@ -95,15 +95,15 @@ describe("Action Bar scenario", async function () {
await checkOrderIsCorrect();
});

const checkOrderIsCorrect = async () => {
const checkOrderIsCorrect = async function () {
await isOnTheLeft(firstActionItem, secondActionItem);
};

const toggleFirst = async () => {
const toggleFirst = async function () {
await toggleFirstButton.click();
};

const toggleSecond = async () => {
const toggleSecond = async function () {
await toggleSecondButton.click();
};

Expand All @@ -113,7 +113,7 @@ describe("Action Bar scenario", async function () {
let toggleButton: UIElement;
let conditional: UIElement;

before(async () => {
before(async function () {
nsCapabilities.testReporter.context = this;
driver = await createDriver();
await driver.driver.resetApp();
Expand Down Expand Up @@ -147,11 +147,11 @@ describe("Action Bar scenario", async function () {
await checkOrderIsCorrect();
});

const checkOrderIsCorrect = async () => {
const checkOrderIsCorrect = async function () {
await isOnTheLeft(toggleButton, conditional);
};

const toggle = async () => {
const toggle = async function () {
await toggleButton.click();
};
});
Expand Down
8 changes: 4 additions & 4 deletions e2e/renderer/e2e/ngfor.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ describe("ngFor scenario", async function () {
let elements: UIElement[] = [];
let lastAddedElementId = 0;

before(async () => {
before(async function () {
nsCapabilities.testReporter.context = this;
driver = await createDriver();
await driver.driver.resetApp();
Expand Down Expand Up @@ -79,7 +79,7 @@ describe("ngFor scenario", async function () {
await checkCorrectOrderAll();
});

const addElement = async () => {
const addElement = async function () {
await addButton.click();

lastAddedElementId += 1;
Expand All @@ -103,7 +103,7 @@ describe("ngFor scenario", async function () {
lastAddedElementId -= 1;
};

const checkAppendedCorrectly = async () => {
const checkAppendedCorrectly = async function () {
const lastAdded = await driver.findElementByAutomationText(
lastAddedElementId.toString());

Expand All @@ -112,7 +112,7 @@ describe("ngFor scenario", async function () {
await isAbove(addButton, removeButton);
};

const checkCorrectOrderAll = async () => {
const checkCorrectOrderAll = async function () {
for (let i = 0; i < elements.length - 1; i += 1) {
await isAbove(elements[i], elements[i + 1]);
}
Expand Down
8 changes: 4 additions & 4 deletions e2e/renderer/e2e/ngforof.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ describe("ngForOf scenario", function () {
let elements: ElementTuple[] = [];
let lastAddedElementId = 0;

before(async () => {
before(async function () {
nsCapabilities.testReporter.context = this;
driver = await createDriver();
await driver.driver.resetApp();
Expand Down Expand Up @@ -88,7 +88,7 @@ describe("ngForOf scenario", function () {
});


const addElement = async () => {
const addElement = async function () {
await addButton.click();

lastAddedElementId += 1;
Expand All @@ -114,15 +114,15 @@ describe("ngForOf scenario", function () {
lastAddedElementId -= 1;
};

const checkAppendedCorrectly = async () => {
const checkAppendedCorrectly = async function () {
const lastAdded = await getElement(lastAddedElementId);

await elementIsAbove(elements.slice(-2)[0], lastAdded);
await isAbove(lastAdded.button, addButton);
await isAbove(addButton, removeButton);
};

const checkCorrectOrderAll = async () => {
const checkCorrectOrderAll = async function () {
for (let i = 0; i < elements.length - 1; i += 1) {
await elementIsAbove(elements[i], elements[i + 1]);
}
Expand Down
6 changes: 3 additions & 3 deletions e2e/renderer/e2e/ngif.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { isAbove } from "./helpers/location";

import { assert } from "chai";

describe("ngIf scenario", () => {
describe("ngIf scenario", async function () {
let driver: AppiumDriver;
let toggleButton: UIElement;

Expand Down Expand Up @@ -376,7 +376,7 @@ describe("ngIf scenario", () => {

driver.findElementByAutomationText("first", 500)
.then(_ => { throw new Error("first label found!"); })
.catch(() => {
.catch(async function () {
driver.findElementByAutomationText("second", 500)
.then(_ => { throw new Error("second label found!"); })
.catch(() => done());
Expand All @@ -402,7 +402,7 @@ describe("ngIf scenario", () => {

driver.findElementByAutomationText("first", 500)
.then(_ => { throw new Error("first label found!"); })
.catch(() => {
.catch(async function () {
driver.findElementByAutomationText("second", 500)
.then(_ => { throw new Error("second label found!"); })
.catch(() => done());
Expand Down
13 changes: 13 additions & 0 deletions e2e/router/app/counter.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { Injectable } from "@angular/core";
import { BehaviorSubject } from "rxjs";

@Injectable({
providedIn: "root"
})
export class CounterService {
counter$ = new BehaviorSubject<number>(0);

tick() {
this.counter$.next(this.counter$.value + 1);
}
}
15 changes: 10 additions & 5 deletions e2e/router/app/first/first.component.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { Component, OnInit, OnDestroy, OnChanges, DoCheck } from "@angular/core";
import { ActivatedRoute, Router, Route } from "@angular/router";
import { Location } from "@angular/common";
import { RouterExtensions } from "nativescript-angular/router";

import { Page } from "tns-core-modules/ui/page";

import { CounterService } from "../counter.service";

@Component({
selector: "first",
template: `
Expand All @@ -21,12 +20,18 @@ import { Page } from "tns-core-modules/ui/page";
<Button text="RESET" automationText="RESET" (tap)="reset()"></Button>
<Label [text]="message"></Label>
<Label [text]="'CHECK: ' + doCheckCount"></Label>
<Label [text]="'COUNTER: ' + (service.counter$ | async)"></Label>
</StackLayout>`
})
export class FirstComponent implements OnInit, OnDestroy, DoCheck {
public message: string = "";
public doCheckCount: number = 0;
constructor(private routerExt: RouterExtensions, page: Page) {

constructor(
private routerExt: RouterExtensions,
public service: CounterService,
page: Page) {

console.log("FirstComponent - constructor() page: " + page);
}

Expand All @@ -42,7 +47,7 @@ export class FirstComponent implements OnInit, OnDestroy, DoCheck {
this.doCheckCount++;
console.log("FirstComponent - ngDoCheck(): " + this.doCheckCount);
}

reset() {
this.doCheckCount = 0;
}
Expand Down
11 changes: 9 additions & 2 deletions e2e/router/app/second/second.component.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { Component, OnInit, OnDestroy } from "@angular/core";
import { ActivatedRoute, Router, Route } from "@angular/router";
import { ActivatedRoute } from "@angular/router";

import { RouterExtensions } from "nativescript-angular/router";
import { Page } from "tns-core-modules/ui/page";
import { Observable } from "rxjs";
import { map } from "rxjs/operators";
import { CounterService } from "../counter.service";

@Component({
selector: "second",
Expand All @@ -19,6 +20,8 @@ import { map } from "rxjs/operators";
<Button text="LOAD NESTED NAMED OUTLET" (tap)="loadNestedNamedOutlet()"></Button>
<Button text="BACK" automationText="BACK" (tap)="goBack()"></Button>

<Button text="TICK" automationText="TICK" (tap)="service.tick()"></Button>

<GridLayout row="1" rows="*,*">
<GridLayout row="0" class="nested-outlet">
<router-outlet></router-outlet>
Expand All @@ -33,7 +36,11 @@ export class SecondComponent implements OnInit, OnDestroy {
public depth$: Observable<string>;
public nextDepth$: Observable<number>;

constructor(private routerExt: RouterExtensions, private route: ActivatedRoute, page: Page) {
constructor(
private routerExt: RouterExtensions,
private route: ActivatedRoute,
public service: CounterService,
page: Page) {
console.log("SecondComponent - constructor() page: " + page);
this.depth$ = route.params.pipe(map(r => r["depth"]));
this.nextDepth$ = route.params.pipe(map(r => +r["depth"] + 1));
Expand Down
40 changes: 40 additions & 0 deletions e2e/router/e2e/router.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,46 @@ describe("Simple navigate and back should trigger only one CD on FirstComponent"
});
});

describe("Simple navigate and back should trigger only one CD on FirstComponent even with 3 changes in service", () => {
let driver: AppiumDriver;

before(async () => {
driver = await createDriver();
await driver.resetApp();
});

it("should find First", async () => {
await assureFirstComponent(driver);
});

it("should reset counter", async () => {
await findAndClick(driver, "RESET");
await driver.waitForElement("CHECK: 1");
await driver.waitForElement("COUNTER: 0");
});

it("should navigate to Second(1)/master", async () => {
await findAndClick(driver, "GO TO SECOND");

await assureSecondComponent(driver, 1);
await assureNestedMasterComponent(driver);
});

it("should increase counter", async () => {
await findAndClick(driver, "TICK");
await findAndClick(driver, "TICK");
await findAndClick(driver, "TICK");
});

it("should navigate back to First", async () => {
await goBack(driver);
await assureFirstComponent(driver);
await driver.waitForElement("CHECK: 2");
await driver.waitForElement("COUNTER: 3");
});
});


async function assureFirstComponent(driver: AppiumDriver) {
await driver.findElementByAutomationText("FirstComponent");
}
Expand Down
2 changes: 1 addition & 1 deletion e2e/router/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"nativescript-dev-typescript": "next",
"nativescript-dev-webpack": "next",
"tslib": "^1.7.1",
"typescript": "^3.1.6"
"typescript": "~3.1.1"
},
"scripts": {
"e2e": "tsc -p e2e && mocha --opts ../config/mocha.opts --recursive e2e --appiumCapsLocation ../config/appium.capabilities.json",
Expand Down
1 change: 1 addition & 0 deletions nativescript-angular/router/page-router-outlet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ export class PageRouterOutlet implements OnDestroy { // tslint:disable-line:dire
this.activated = ref;

// reattach to ChangeDetection
this.activated.hostView.markForCheck();
this.activated.hostView.reattach();
this._activatedRoute = activatedRoute;
this.markActivatedRoute(activatedRoute);
Expand Down