Skip to content

Commit 571b39f

Browse files
ADjenkovADjenkov
ADjenkov
authored and
ADjenkov
committed
tets: add tests for actionBarVisibility and lazy loaded named outlet
1 parent fb44f5a commit 571b39f

File tree

7 files changed

+100
-11
lines changed

7 files changed

+100
-11
lines changed

Diff for: e2e/renderer/app/app-routing.module.ts

+11-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { NgModule, NO_ERRORS_SCHEMA } from "@angular/core";
2-
import { NativeScriptRouterModule } from "nativescript-angular/router";
2+
import { NativeScriptRouterModule, NSEmptyOutletComponent } from "nativescript-angular/router";
33

44
import { ActionBarDynamicItemsComponent } from "./action-bar/action-bar-dynamic-items.component";
55
import { ActionBarExtensionComponent } from "./action-bar/action-bar-extension.component";
@@ -54,6 +54,16 @@ export const routes = [
5454
component: NestedPageComponent
5555
}]
5656
},
57+
{
58+
path: "action-bar-visibility-never-lazy",
59+
component: ActionBarVisibilityNeverComponent,
60+
children: [{
61+
path: "nested",
62+
outlet: "nested",
63+
component: NSEmptyOutletComponent,
64+
loadChildren:"~/page-router-outlet/nested-lazy-page.module#NestedLazyPageModule"
65+
}]
66+
},
5767
{
5868
path: "action-bar-dynamic",
5969
component: ActionBarDynamicItemsComponent,
@@ -111,7 +121,6 @@ export const navigatableComponents = [
111121
ActionBarVisibilityAlwaysComponent,
112122
ActionBarVisibilityNeverComponent,
113123
ActionBarVisibilityAutoComponent,
114-
NestedPageComponent,
115124

116125
TabItemBindingComponent,
117126

Diff for: e2e/renderer/app/app.module.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import { ItemsService } from "./items.service";
1111

1212
import { rendererTraceCategory, viewUtilCategory, bootstrapCategory } from "nativescript-angular/trace";
1313
import { addCategories, enable, categories } from "tns-core-modules/trace";
14+
import { SharedModule } from "./shared.module";
15+
1416
addCategories(bootstrapCategory);
1517
addCategories(rendererTraceCategory);
1618
addCategories(viewUtilCategory);
@@ -22,7 +24,7 @@ export class MyErrorHandler implements ErrorHandler {
2224
console.log("### ErrorHandler Error: " + error.toString());
2325
console.log("### ErrorHandler Stack: " + error.stack);
2426
}
25-
}
27+
}
2628

2729

2830
@NgModule({
@@ -38,6 +40,7 @@ export class MyErrorHandler implements ErrorHandler {
3840
imports: [
3941
NativeScriptModule,
4042
AppRoutingModule,
43+
SharedModule
4144
],
4245
schemas: [NO_ERRORS_SCHEMA],
4346
})

Diff for: e2e/renderer/app/list.component.ts

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { Component } from "@angular/core";
99
<Button text="ActionBarVisibility Always" [nsRouterLink]="['/action-bar-visibility-always']"></Button>
1010
<Button text="ActionBarVisibility Never" [nsRouterLink]="['/action-bar-visibility-never']"></Button>
1111
<Button text="ActionBarVisibility Auto" [nsRouterLink]="['/action-bar-visibility-auto']"></Button>
12+
<Button text="ActionBarVisibility Never Lazy" [nsRouterLink]="['/action-bar-visibility-never-lazy']"></Button>
1213
<Button text="TabItem Binding" [nsRouterLink]="['/tab-item-binding']"></Button>
1314
<Button text="NgFor" [nsRouterLink]="['/ngfor']"></Button>
1415
<Button text="NgForOf" [nsRouterLink]="['/ngforof']"></Button>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { NgModule, NO_ERRORS_SCHEMA } from "@angular/core";
2+
import { NativeScriptRouterModule } from "nativescript-angular/router";
3+
import { NativeScriptCommonModule } from "nativescript-angular/common";
4+
import { SharedModule } from "~/shared.module";
5+
import { NestedPageComponent } from "./nested-page.component";
6+
7+
@NgModule({
8+
imports: [
9+
SharedModule,
10+
NativeScriptCommonModule,
11+
NativeScriptRouterModule,
12+
NativeScriptRouterModule.forChild([
13+
{ path: "", component: NestedPageComponent }
14+
])
15+
],
16+
providers: [
17+
],
18+
schemas: [NO_ERRORS_SCHEMA]
19+
})
20+
export class NestedLazyPageModule { }

Diff for: e2e/renderer/app/shared.module.ts

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { NgModule, NO_ERRORS_SCHEMA } from "@angular/core";
2+
import { NativeScriptRouterModule } from "nativescript-angular/router";
3+
import { NativeScriptCommonModule } from "nativescript-angular/common";
4+
import { NestedPageComponent } from "./page-router-outlet/nested-page.component";
5+
6+
@NgModule({
7+
imports: [
8+
NativeScriptCommonModule,
9+
NativeScriptRouterModule
10+
],
11+
declarations:[NestedPageComponent],
12+
schemas: [NO_ERRORS_SCHEMA]
13+
})
14+
export class SharedModule { }

Diff for: e2e/renderer/e2e/page-router-outlet.e2e-spec.ts

+42
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,48 @@ describe("page-router-outlet-scenario", () => {
9393
});
9494
});
9595

96+
describe("actionBarVisibility 'never' doesn't show action bars in lazy module page", async () => {
97+
before(async () => {
98+
driver = await createDriver();
99+
await driver.driver.resetApp();
100+
});
101+
102+
afterEach(async function () {
103+
if (this.currentTest.state === "failed") {
104+
await driver.logTestArtifacts(this.currentTest.title);
105+
}
106+
});
107+
108+
it("should navigate to page", async () => {
109+
const navigationButton =
110+
await driver.findElementByAutomationText("ActionBarVisibility Never Lazy");
111+
await navigationButton.click();
112+
113+
await driver.findElementByAutomationText("ShowActionBar");
114+
});
115+
116+
it("should hide action bar by default", async () => {
117+
const screenMatches = await driver.compareScreen("actionBarVisibility-never-default", 5);
118+
assert(screenMatches);
119+
});
120+
121+
it("should not show action bar when shown by page", async () => {
122+
const showActionBarButton = await driver.findElementByAutomationText("ShowActionBar");
123+
showActionBarButton.click();
124+
125+
const screenMatches = await driver.compareScreen("actionBarVisibility-never-shown", 5);
126+
assert(screenMatches);
127+
});
128+
129+
it("should not do anything when hidden action bar by page", async () => {
130+
const hideActionBarButton = await driver.findElementByAutomationText("HideActionBar");
131+
hideActionBarButton.click();
132+
133+
const screenMatches = await driver.compareScreen("actionBarVisibility-never-hidden", 5);
134+
assert(screenMatches);
135+
});
136+
});
137+
96138
describe("actionBarVisibility 'auto' shows action bars based on page", async () => {
97139
before(async () => {
98140
driver = await createDriver();

Diff for: e2e/renderer/package.json

+8-8
Original file line numberDiff line numberDiff line change
@@ -24,25 +24,25 @@
2424
},
2525
"devDependencies": {
2626
"@angular/compiler-cli": "~7.0.0",
27-
"@types/chai": "^4.0.2",
28-
"@types/mocha": "^2.2.41",
29-
"@types/node": "^7.0.5",
27+
"@ngtools/webpack": "~7.0.0",
28+
"@types/chai": "~4.1.3",
29+
"@types/mocha": "~5.2.1",
30+
"@types/node": "10.11.4",
3031
"babel-traverse": "6.25.0",
3132
"babel-types": "6.25.0",
3233
"babylon": "6.17.4",
3334
"chai": "~4.1.1",
3435
"chai-as-promised": "~7.1.1",
3536
"colors": "^1.1.2",
3637
"lazy": "1.0.11",
37-
"mocha": "~3.5.0",
38-
"mocha-junit-reporter": "^1.13.0",
39-
"mocha-multi": "^0.11.0",
38+
"mocha": "~5.1.0",
39+
"mocha-junit-reporter": "~1.17.0",
40+
"mocha-multi": "~1.0.0",
4041
"nativescript-dev-appium": "next",
4142
"nativescript-dev-typescript": "~0.7.1",
4243
"nativescript-dev-webpack": "next",
4344
"tslib": "^1.7.1",
44-
"typescript": "~3.1.1",
45-
"@ngtools/webpack": "~7.0.0"
45+
"typescript": "~3.1.1"
4646
},
4747
"scripts": {
4848
"e2e": "tsc -p e2e && mocha --opts ../config/mocha.opts --recursive e2e --appiumCapsLocation ../config/appium.capabilities.json",

0 commit comments

Comments
 (0)