Skip to content

Commit 9b144a4

Browse files
Merge pull request #1811 from NativeScript/merge-release-in-master
chore: merge release in master
2 parents e59f8d4 + bef2227 commit 9b144a4

File tree

12 files changed

+100
-37
lines changed

12 files changed

+100
-37
lines changed

Diff for: e2e/modal-navigation-ng/e2e/modal.shared.e2e-spec.ts

-3
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@ describe("modal-shared:", async function () {
2424
await screen[root]();
2525
});
2626

27-
beforeEach(async function () {
28-
});
29-
3027
afterEach(async function () {
3128
if (this.currentTest.state === "failed") {
3229
await driver.logTestArtifacts(this.currentTest.title);

Diff for: e2e/nested-router-tab-view/e2e/tab-view.e2e-spec.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ describe("tab-view:", async function () {
1111
let driver: AppiumDriver;
1212
let screen: Screen;
1313

14-
before(async () => {
14+
before(async function () {
1515
nsCapabilities.testReporter.context = this;
1616
driver = await createDriver();
1717
screen = new Screen(driver);
1818
});
1919

20-
after(async () => {
20+
after(async function () {
2121
await driver.quit();
2222
console.log("Quit driver!");
2323
});
@@ -28,14 +28,14 @@ describe("tab-view:", async function () {
2828
}
2929
});
3030

31-
it("loaded home component and lists", async () => {
31+
it("loaded home component and lists", async function () {
3232
await screen.navigateToHomePage();
3333
await screen.loadedHome();
3434
await screen.loadedPlayersList();
3535
await screen.loadedTeamList();
3636
});
3737

38-
it("loaded tabs component, Players List and Teams List pages", async () => {
38+
it("loaded tabs component, Players List and Teams List pages", async function () {
3939
await screen.navigateToTabsPage();
4040
await screen.loadedTabs();
4141
await screen.loadedPlayersList();
@@ -45,7 +45,7 @@ describe("tab-view:", async function () {
4545
await screen.loadedPlayersList();
4646
});
4747

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

59-
it("should navigate Player One/Team One then next Player/Team then back", async () => {
59+
it("should navigate Player One/Team One then next Player/Team then back", async function () {
6060
await testPlayerNavigated(screen, screen.playerOne);
6161
await testPlayerNextNavigated(screen, screen.playerTwo);
6262
await gotoTeamsTab(driver);

Diff for: e2e/renderer/e2e/action-bar.e2e-spec.ts

+9-9
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ describe("Action Bar scenario", async function () {
1818
let toggleFirstButton: UIElement;
1919
let toggleSecondButton: UIElement;
2020

21-
before(async () => {
21+
before(async function () {
2222
nsCapabilities.testReporter.context = this;
2323
driver = await createDriver();
2424
await driver.driver.resetApp();
@@ -52,7 +52,7 @@ describe("Action Bar scenario", async function () {
5252
});
5353

5454
it("should detach first element when its condition is false", done => {
55-
(async () => {
55+
(async function () {
5656
await toggleFirst();
5757

5858
try {
@@ -69,7 +69,7 @@ describe("Action Bar scenario", async function () {
6969
});
7070

7171
it("should detach second element when its condition is false", done => {
72-
(async () => {
72+
(async function () {
7373
await toggleSecond();
7474

7575
try {
@@ -95,15 +95,15 @@ describe("Action Bar scenario", async function () {
9595
await checkOrderIsCorrect();
9696
});
9797

98-
const checkOrderIsCorrect = async () => {
98+
const checkOrderIsCorrect = async function () {
9999
await isOnTheLeft(firstActionItem, secondActionItem);
100100
};
101101

102-
const toggleFirst = async () => {
102+
const toggleFirst = async function () {
103103
await toggleFirstButton.click();
104104
};
105105

106-
const toggleSecond = async () => {
106+
const toggleSecond = async function () {
107107
await toggleSecondButton.click();
108108
};
109109

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

116-
before(async () => {
116+
before(async function () {
117117
nsCapabilities.testReporter.context = this;
118118
driver = await createDriver();
119119
await driver.driver.resetApp();
@@ -147,11 +147,11 @@ describe("Action Bar scenario", async function () {
147147
await checkOrderIsCorrect();
148148
});
149149

150-
const checkOrderIsCorrect = async () => {
150+
const checkOrderIsCorrect = async function () {
151151
await isOnTheLeft(toggleButton, conditional);
152152
};
153153

154-
const toggle = async () => {
154+
const toggle = async function () {
155155
await toggleButton.click();
156156
};
157157
});

Diff for: e2e/renderer/e2e/ngfor.e2e-spec.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ describe("ngFor scenario", async function () {
1515
let elements: UIElement[] = [];
1616
let lastAddedElementId = 0;
1717

18-
before(async () => {
18+
before(async function () {
1919
nsCapabilities.testReporter.context = this;
2020
driver = await createDriver();
2121
await driver.driver.resetApp();
@@ -79,7 +79,7 @@ describe("ngFor scenario", async function () {
7979
await checkCorrectOrderAll();
8080
});
8181

82-
const addElement = async () => {
82+
const addElement = async function () {
8383
await addButton.click();
8484

8585
lastAddedElementId += 1;
@@ -103,7 +103,7 @@ describe("ngFor scenario", async function () {
103103
lastAddedElementId -= 1;
104104
};
105105

106-
const checkAppendedCorrectly = async () => {
106+
const checkAppendedCorrectly = async function () {
107107
const lastAdded = await driver.findElementByAutomationText(
108108
lastAddedElementId.toString());
109109

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

115-
const checkCorrectOrderAll = async () => {
115+
const checkCorrectOrderAll = async function () {
116116
for (let i = 0; i < elements.length - 1; i += 1) {
117117
await isAbove(elements[i], elements[i + 1]);
118118
}

Diff for: e2e/renderer/e2e/ngforof.e2e-spec.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ describe("ngForOf scenario", function () {
2121
let elements: ElementTuple[] = [];
2222
let lastAddedElementId = 0;
2323

24-
before(async () => {
24+
before(async function () {
2525
nsCapabilities.testReporter.context = this;
2626
driver = await createDriver();
2727
await driver.driver.resetApp();
@@ -88,7 +88,7 @@ describe("ngForOf scenario", function () {
8888
});
8989

9090

91-
const addElement = async () => {
91+
const addElement = async function () {
9292
await addButton.click();
9393

9494
lastAddedElementId += 1;
@@ -114,15 +114,15 @@ describe("ngForOf scenario", function () {
114114
lastAddedElementId -= 1;
115115
};
116116

117-
const checkAppendedCorrectly = async () => {
117+
const checkAppendedCorrectly = async function () {
118118
const lastAdded = await getElement(lastAddedElementId);
119119

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

125-
const checkCorrectOrderAll = async () => {
125+
const checkCorrectOrderAll = async function () {
126126
for (let i = 0; i < elements.length - 1; i += 1) {
127127
await elementIsAbove(elements[i], elements[i + 1]);
128128
}

Diff for: e2e/renderer/e2e/ngif.e2e-spec.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { isAbove } from "./helpers/location";
1010

1111
import { assert } from "chai";
1212

13-
describe("ngIf scenario", () => {
13+
describe("ngIf scenario", async function () {
1414
let driver: AppiumDriver;
1515
let toggleButton: UIElement;
1616

@@ -376,7 +376,7 @@ describe("ngIf scenario", () => {
376376

377377
driver.findElementByAutomationText("first", 500)
378378
.then(_ => { throw new Error("first label found!"); })
379-
.catch(() => {
379+
.catch(async function () {
380380
driver.findElementByAutomationText("second", 500)
381381
.then(_ => { throw new Error("second label found!"); })
382382
.catch(() => done());
@@ -402,7 +402,7 @@ describe("ngIf scenario", () => {
402402

403403
driver.findElementByAutomationText("first", 500)
404404
.then(_ => { throw new Error("first label found!"); })
405-
.catch(() => {
405+
.catch(async function () {
406406
driver.findElementByAutomationText("second", 500)
407407
.then(_ => { throw new Error("second label found!"); })
408408
.catch(() => done());

Diff for: e2e/router/app/counter.service.ts

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { Injectable } from "@angular/core";
2+
import { BehaviorSubject } from "rxjs";
3+
4+
@Injectable({
5+
providedIn: "root"
6+
})
7+
export class CounterService {
8+
counter$ = new BehaviorSubject<number>(0);
9+
10+
tick() {
11+
this.counter$.next(this.counter$.value + 1);
12+
}
13+
}

Diff for: e2e/router/app/first/first.component.ts

+10-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import { Component, OnInit, OnDestroy, OnChanges, DoCheck } from "@angular/core";
2-
import { ActivatedRoute, Router, Route } from "@angular/router";
3-
import { Location } from "@angular/common";
42
import { RouterExtensions } from "nativescript-angular/router";
5-
63
import { Page } from "tns-core-modules/ui/page";
74

5+
import { CounterService } from "../counter.service";
6+
87
@Component({
98
selector: "first",
109
template: `
@@ -21,12 +20,18 @@ import { Page } from "tns-core-modules/ui/page";
2120
<Button text="RESET" automationText="RESET" (tap)="reset()"></Button>
2221
<Label [text]="message"></Label>
2322
<Label [text]="'CHECK: ' + doCheckCount"></Label>
23+
<Label [text]="'COUNTER: ' + (service.counter$ | async)"></Label>
2424
</StackLayout>`
2525
})
2626
export class FirstComponent implements OnInit, OnDestroy, DoCheck {
2727
public message: string = "";
2828
public doCheckCount: number = 0;
29-
constructor(private routerExt: RouterExtensions, page: Page) {
29+
30+
constructor(
31+
private routerExt: RouterExtensions,
32+
public service: CounterService,
33+
page: Page) {
34+
3035
console.log("FirstComponent - constructor() page: " + page);
3136
}
3237

@@ -42,7 +47,7 @@ export class FirstComponent implements OnInit, OnDestroy, DoCheck {
4247
this.doCheckCount++;
4348
console.log("FirstComponent - ngDoCheck(): " + this.doCheckCount);
4449
}
45-
50+
4651
reset() {
4752
this.doCheckCount = 0;
4853
}

Diff for: e2e/router/app/second/second.component.ts

+9-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import { Component, OnInit, OnDestroy } from "@angular/core";
2-
import { ActivatedRoute, Router, Route } from "@angular/router";
2+
import { ActivatedRoute } from "@angular/router";
33

44
import { RouterExtensions } from "nativescript-angular/router";
55
import { Page } from "tns-core-modules/ui/page";
66
import { Observable } from "rxjs";
77
import { map } from "rxjs/operators";
8+
import { CounterService } from "../counter.service";
89

910
@Component({
1011
selector: "second",
@@ -19,6 +20,8 @@ import { map } from "rxjs/operators";
1920
<Button text="LOAD NESTED NAMED OUTLET" (tap)="loadNestedNamedOutlet()"></Button>
2021
<Button text="BACK" automationText="BACK" (tap)="goBack()"></Button>
2122
23+
<Button text="TICK" automationText="TICK" (tap)="service.tick()"></Button>
24+
2225
<GridLayout row="1" rows="*,*">
2326
<GridLayout row="0" class="nested-outlet">
2427
<router-outlet></router-outlet>
@@ -33,7 +36,11 @@ export class SecondComponent implements OnInit, OnDestroy {
3336
public depth$: Observable<string>;
3437
public nextDepth$: Observable<number>;
3538

36-
constructor(private routerExt: RouterExtensions, private route: ActivatedRoute, page: Page) {
39+
constructor(
40+
private routerExt: RouterExtensions,
41+
private route: ActivatedRoute,
42+
public service: CounterService,
43+
page: Page) {
3744
console.log("SecondComponent - constructor() page: " + page);
3845
this.depth$ = route.params.pipe(map(r => r["depth"]));
3946
this.nextDepth$ = route.params.pipe(map(r => +r["depth"] + 1));

Diff for: e2e/router/e2e/router.e2e-spec.ts

+40
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,46 @@ describe("Simple navigate and back should trigger only one CD on FirstComponent"
449449
});
450450
});
451451

452+
describe("Simple navigate and back should trigger only one CD on FirstComponent even with 3 changes in service", () => {
453+
let driver: AppiumDriver;
454+
455+
before(async () => {
456+
driver = await createDriver();
457+
await driver.resetApp();
458+
});
459+
460+
it("should find First", async () => {
461+
await assureFirstComponent(driver);
462+
});
463+
464+
it("should reset counter", async () => {
465+
await findAndClick(driver, "RESET");
466+
await driver.waitForElement("CHECK: 1");
467+
await driver.waitForElement("COUNTER: 0");
468+
});
469+
470+
it("should navigate to Second(1)/master", async () => {
471+
await findAndClick(driver, "GO TO SECOND");
472+
473+
await assureSecondComponent(driver, 1);
474+
await assureNestedMasterComponent(driver);
475+
});
476+
477+
it("should increase counter", async () => {
478+
await findAndClick(driver, "TICK");
479+
await findAndClick(driver, "TICK");
480+
await findAndClick(driver, "TICK");
481+
});
482+
483+
it("should navigate back to First", async () => {
484+
await goBack(driver);
485+
await assureFirstComponent(driver);
486+
await driver.waitForElement("CHECK: 2");
487+
await driver.waitForElement("COUNTER: 3");
488+
});
489+
});
490+
491+
452492
async function assureFirstComponent(driver: AppiumDriver) {
453493
await driver.findElementByAutomationText("FirstComponent");
454494
}

Diff for: e2e/router/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
"nativescript-dev-typescript": "next",
4545
"nativescript-dev-webpack": "next",
4646
"tslib": "^1.7.1",
47-
"typescript": "^3.1.6"
47+
"typescript": "~3.1.1"
4848
},
4949
"scripts": {
5050
"e2e": "tsc -p e2e && mocha --opts ../config/mocha.opts --recursive e2e --appiumCapsLocation ../config/appium.capabilities.json",

Diff for: nativescript-angular/router/page-router-outlet.ts

+1
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,7 @@ export class PageRouterOutlet implements OnDestroy { // tslint:disable-line:dire
262262
this.activated = ref;
263263

264264
// reattach to ChangeDetection
265+
this.activated.hostView.markForCheck();
265266
this.activated.hostView.reattach();
266267
this._activatedRoute = activatedRoute;
267268
this.markActivatedRoute(activatedRoute);

0 commit comments

Comments
 (0)