Skip to content

Commit e1a1d64

Browse files
author
Vasil Chimev
authored
test(e2e): add modal-navigation app tests (NativeScript#5445)
* test(e2e): modal-navigation app webpack support * test(e2e): add modal-navigation app smoke test * chore(e2e): tslint disable next line * chore(e2e): modal-navigation app compilation * refactor(e2e): modal-nabivation app pages * test(e2e): add app root modal frame tests * test(e2e): add app root modal frame background tests * refactor(e2e): app root modal frame tests * test(e2e): add tab root modal frame tests * refactor(e2e): modal frame tests * test(e2e): add modal page tests * docs(e2e): add scenarios * refactor(e2e): modal-navigation app tests * test(e2e): turn on/off "Don't keep activities" * test(e2e): delete no background tests * test(e2e): add modal tab tests * refactor(e2e): quit driver after all tests * refactor(e2e): config files * fix(e2e): tab root tests * refactor(e2e): skip tab root tests until fix app * chore(e2e): config files
1 parent 1cbb1e8 commit e1a1d64

30 files changed

+1108
-53
lines changed

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,11 @@ apps/hooks/
5252
apps/node_modules/
5353

5454
e2e/**/platforms
55+
!e2e/**/webpack.config.js
56+
e2e/**/reports/
57+
e2e/**/*.trace/
58+
e2e/**/test-results.xml
5559

5660
package-lock.json
5761

58-
.nsbuildinfo
62+
.nsbuildinfo

DevelopmentWorkflow.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ Managing dependencies:
2020
- `tns-platform-declarations`
2121
- `tns-core-modules`
2222
- `e2e` depends on:
23-
- `tns-platform-declarations`
2423
- `tns-core-modules`
2524
- `tests` depends on:
2625
- `tns-platform-declarations`
@@ -43,7 +42,7 @@ Install devDependencies:
4342
npm install
4443
```
4544

46-
Run `setup` script. This will [`npm link`](https://docs.npmjs.com/cli/link) the `tns-core-modules` and `tns-core-modules-declarations` dependencies inside the `tests`, `apps` and `e2e` projects.
45+
Run `setup` script. This will [`npm link`](https://docs.npmjs.com/cli/link) the `tns-core-modules` and `tns-core-modules-declarations` dependencies inside the `tests` and `apps` projects.
4746

4847
```bash
4948
npm run setup
@@ -69,7 +68,7 @@ The modules have `typescript` as a devDependency so you should also be able to u
6968
./node_modules/.bin/tsc
7069
```
7170

72-
You can compile the TypeScript files in the `tns-core-modules`, `tns-platform-declarations`, `apps`, `e2e` and `tests` at once at the root of the repo:
71+
You can compile the TypeScript files in the `tns-core-modules`, `tns-platform-declarations`, `apps` and `tests` at once at the root of the repo:
7372

7473
```bash
7574
npm run tsc

e2e/modal-navigation/.vscode/launch.json

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,48 @@
44
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
55
"version": "0.2.0",
66
"configurations": [
7-
7+
{
8+
"type": "node",
9+
"request": "launch",
10+
"name": "Launch Tests on Android",
11+
"program": "${workspaceFolder}/node_modules/mocha/bin/_mocha",
12+
"args": [
13+
"-u",
14+
"tdd",
15+
"--timeout",
16+
"999999",
17+
"--colors",
18+
// "${workspaceFolder}/test",
19+
"--opts",
20+
"./e2e/config/mocha.opts",
21+
"--runType",
22+
"android23",
23+
"--reuseDevice",
24+
"--verbose"
25+
],
26+
"internalConsoleOptions": "openOnSessionStart"
27+
},
28+
{
29+
"type": "node",
30+
"request": "launch",
31+
"name": "Launch Tests on iOS",
32+
"program": "${workspaceFolder}/node_modules/mocha/bin/_mocha",
33+
"args": [
34+
"-u",
35+
"tdd",
36+
"--timeout",
37+
"999999",
38+
"--colors",
39+
// "${workspaceFolder}/test",
40+
"--opts",
41+
"./e2e/config/mocha.opts",
42+
"--runType",
43+
"sim.iPhoneX.iOS112",
44+
"--reuseDevice",
45+
"--verbose"
46+
],
47+
"internalConsoleOptions": "openOnSessionStart"
48+
},
849
{
950
"name": "Launch on iOS",
1051
"type": "nativescript",
@@ -25,7 +66,6 @@
2566
"platform": "ios",
2667
"appRoot": "${workspaceRoot}",
2768
"sourceMaps": true,
28-
"stopOnEntry": true,
2969
"tnsArgs": [
3070
"--syncAllFiles"
3171
],
@@ -51,7 +91,6 @@
5191
"platform": "android",
5292
"appRoot": "${workspaceRoot}",
5393
"sourceMaps": true,
54-
"stopOnEntry": true,
5594
"tnsArgs": [
5695
"--syncAllFiles"
5796
],

e2e/modal-navigation/README.md

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
Execute Tests
2+
=============
3+
4+
Android:
5+
6+
```
7+
npm run e2e -- --runType android23 --reuseDevice
8+
```
9+
10+
iOS:
11+
12+
```
13+
npm run e2e -- --runType sim.iPhoneX.iOS112 --reuseDevice
14+
```
15+
16+
Scenarios
17+
=============
18+
19+
ROOT FRAME:
20+
21+
1. [Done] Show modal dialog with frame
22+
1. Navigate to modal second page within modal dialog
23+
1. Go back
24+
2. Show nested modal dialog
25+
2. Close nested modal dialog
26+
3. Show nested modal dialog with frame
27+
3. Close nested modal dialog
28+
4. Close modal dialog
29+
2. [Done] Show modal dialog
30+
1. Show nested modal dialog
31+
1. Close nested modal dialog
32+
2. Show nested modal dialog with frame
33+
2. Close nested modal dialog
34+
3. Close modal dialog
35+
3. [Done] Show modal tabview
36+
1. Navigate to second page within tab item frame
37+
1. Go back
38+
2. Show nested modal dialog
39+
2. Close nested modal dialog
40+
3. Show nested modal dialog with frame
41+
3. Close nested modal dialog
42+
4. Close modal dialog
43+
4. Navigate to second page within root frame
44+
1. Show modal dialog with frame
45+
1. Navigate to second page within modal dialog
46+
1. Go back
47+
2. Show nested modal dialog
48+
2. Close nested modal dialog
49+
3. Show nested modal dialog with frame
50+
3. Close nested modal dialog
51+
4. Close modal dialog
52+
2. Show modal dialog
53+
1. Show nested modal dialog
54+
1. Close nested modal dialog
55+
2. Show nested modal dialog with frame
56+
2. Close nested modal dialog
57+
3. Close modal dialog
58+
3. Go back
59+
60+
ROOT TABVIEW:
61+
62+
[Same as above]

e2e/modal-navigation/app/app.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import "./bundle-config";
12
import * as application from "tns-core-modules/application";
23

34
application.run({ moduleName: "app-root" });
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
if ((<any>global).TNS_WEBPACK) {
2+
// Register tns-core-modules UI framework modules
3+
require("bundle-entry-points");
4+
5+
// Register application modules
6+
// This will register each `root`, `page`, `fragment` postfixed xml, css, js, ts, scss file in the app/ folder
7+
const context = (<any>require).context("~/", true, /(root|page|fragment)\.(xml|css|js|ts|scss|less|sass)$/);
8+
global.registerWebpackModules(context);
9+
}

e2e/modal-navigation/app/home/home-page.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,6 @@ export function onNavigate(args: EventData) {
5656
}
5757

5858
export function onRootViewChange() {
59-
let rootView: View = application.getRootView();
60-
rootView.typeName === "Frame" ? application._resetRootView({moduleName: "tab-root"}) : application._resetRootView({moduleName: "app-root"});
59+
let rootView = application.getRootView();
60+
rootView instanceof Frame ? application._resetRootView({moduleName: "tab-root"}) : application._resetRootView({moduleName: "app-root"});
6161
}

e2e/modal-navigation/app/modal-nested/modal-nested-page.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
navigatedFrom="onNavigatedFrom">
66

77
<ActionBar class="action-bar">
8-
<Label class="action-bar-title" text="Nested Modal"></Label>
8+
<Label class="action-bar-title" text="Modal Nested"></Label>
99
</ActionBar>
1010

1111
<StackLayout backgroundColor="darkBlue">
12-
<Button text="Close Modal" tap="closeModal" />
12+
<Button text="Close Modal Nested" tap="closeModal" />
1313
</StackLayout>
1414
</Page>

e2e/modal-navigation/app/modal/modal-page.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,6 @@ export function closeModal(args: EventData) {
3939
(args.object as View).closeModal();
4040
}
4141

42-
export function showNestedModalPage(args: EventData) {
43-
const view = args.object as View;
44-
45-
view.showModal("modal-nested/modal-nested-page",
46-
"nested-context",
47-
() => console.log("modal page nested closed"),
48-
false);
49-
}
50-
5142
export function showNestedModalFrame(args: EventData) {
5243
const view = args.object as View;
5344

@@ -60,6 +51,15 @@ export function showNestedModalFrame(args: EventData) {
6051
false);
6152
}
6253

54+
export function showNestedModalPage(args: EventData) {
55+
const view = args.object as View;
56+
57+
view.showModal("modal-nested/modal-nested-page",
58+
"nested-context",
59+
() => console.log("modal page nested closed"),
60+
false);
61+
}
62+
6363
export function onNavigate(args: EventData) {
6464
const view = args.object as View;
6565
const page = view.page as Page;

e2e/modal-navigation/app/modal/modal-page.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010

1111
<StackLayout backgroundColor="maroon">
1212
<Button text="Navigate To Second Page" tap="onNavigate" visibility="{{ navigationVisibility }}" />
13-
<Button text="Show Nested Modal Page" tap="showNestedModalPage" />
1413
<Button text="Show Nested Modal Page With Frame" tap="showNestedModalFrame" />
14+
<Button text="Show Nested Modal Page" tap="showNestedModalPage" />
1515
<Button text="Close Modal" tap="closeModal" />
1616
</StackLayout>
1717
</Page>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
require("application");
2+
if (!global["__snapshot"]) {
3+
// In case snapshot generation is enabled these modules will get into the bundle
4+
// but will not be required/evaluated.
5+
// The snapshot webpack plugin will add them to the tns-java-classes.js bundle file.
6+
// This way, they will be evaluated on app start as early as possible.
7+
require("ui/frame");
8+
require("ui/frame/activity");
9+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// There is a bug in angular: https://github.com/angular/angular-cli/pull/8589/files
2+
// Legendary stuff, its webpack plugin pretty much doesn't work with empty TypeScript files in v1.8.3
3+
// tslint:disable-next-line:no-unused-expression
4+
void 0;

e2e/modal-navigation/app/vendor.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// Snapshot the ~/app.css and the theme
2+
const application = require("application");
3+
require("ui/styling/style-scope");
4+
const appCssContext = require.context("~/", false, /^\.\/app\.(css|scss|less|sass)$/);
5+
global.registerWebpackModules(appCssContext);
6+
application.loadAppCss();
7+
8+
require("./vendor-platform");
9+
10+
require("bundle-entry-points");
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
{
2+
"android19": {
3+
"platformName": "Android",
4+
"platformVersion": "4.4",
5+
"deviceName": "Emulator-Api19-Default",
6+
"avd": "Emulator-Api19-Default",
7+
"lt": 60000,
8+
"appActivity": "com.tns.NativeScriptActivity",
9+
"newCommandTimeout": 720,
10+
"noReset": true,
11+
"fullReset": false,
12+
"app": ""
13+
},
14+
"android21": {
15+
"platformName": "Android",
16+
"platformVersion": "5.0",
17+
"deviceName": "Emulator-Api21-Default",
18+
"avd": "Emulator-Api21-Default",
19+
"lt": 60000,
20+
"appActivity": "com.tns.NativeScriptActivity",
21+
"newCommandTimeout": 720,
22+
"noReset": true,
23+
"fullReset": false,
24+
"app": ""
25+
},
26+
"android23": {
27+
"platformName": "Android",
28+
"platformVersion": "6.0",
29+
"deviceName": "Emulator-Api23-Default",
30+
"avd": "Emulator-Api23-Default",
31+
"lt": 60000,
32+
"appActivity": "com.tns.NativeScriptActivity",
33+
"newCommandTimeout": 720,
34+
"noReset": true,
35+
"fullReset": false,
36+
"app": ""
37+
},
38+
"android24": {
39+
"platformName": "Android",
40+
"platformVersion": "7.0",
41+
"deviceName": "Emulator-Api24-Default",
42+
"avd": "Emulator-Api24-Default",
43+
"lt": 60000,
44+
"appActivity": "com.tns.NativeScriptActivity",
45+
"newCommandTimeout": 720,
46+
"noReset": true,
47+
"fullReset": false,
48+
"app": ""
49+
},
50+
"android25": {
51+
"platformName": "Android",
52+
"platformVersion": "7.1",
53+
"deviceName": "Emulator-Api25-Google",
54+
"avd": "Emulator-Api25-Google",
55+
"lt": 60000,
56+
"appActivity": "com.tns.NativeScriptActivity",
57+
"newCommandTimeout": 720,
58+
"noReset": true,
59+
"fullReset": false,
60+
"app": ""
61+
},
62+
"android26": {
63+
"platformName": "Android",
64+
"platformVersion": "8.0",
65+
"deviceName": "Emulator-Api26-Google",
66+
"avd": "Emulator-Api26-Google",
67+
"lt": 60000,
68+
"appActivity": "com.tns.NativeScriptActivity",
69+
"newCommandTimeout": 720,
70+
"noReset": true,
71+
"fullReset": false,
72+
"app": ""
73+
},
74+
"android27": {
75+
"platformName": "Android",
76+
"platformVersion": "8.1",
77+
"deviceName": "Emulator-Api27-Google",
78+
"avd": "Emulator-Api27-Google",
79+
"lt": 60000,
80+
"appActivity": "com.tns.NativeScriptActivity",
81+
"newCommandTimeout": 720,
82+
"noReset": true,
83+
"fullReset": false,
84+
"app": ""
85+
},
86+
"sim.iPhone7.iOS110": {
87+
"platformName": "iOS",
88+
"platformVersion": "11.2",
89+
"deviceName": "iPhone 7 110",
90+
"noReset": true,
91+
"fullReset": false,
92+
"app": ""
93+
},
94+
"sim.iPhone8.iOS110": {
95+
"platformName": "iOS",
96+
"platformVersion": "11.0",
97+
"deviceName": "iPhone 8 110",
98+
"noReset": true,
99+
"fullReset": false,
100+
"app": ""
101+
},
102+
"sim.iPhoneX.iOS110": {
103+
"platformName": "iOS",
104+
"platformVersion": "11.0",
105+
"deviceName": "iPhone X",
106+
"noReset": true,
107+
"fullReset": false,
108+
"app": ""
109+
},
110+
"sim.iPhoneX.iOS112": {
111+
"platformName": "iOS",
112+
"platformVersion": "11.2",
113+
"deviceName": "iPhone X",
114+
"noReset": true,
115+
"fullReset": false,
116+
"app": ""
117+
}
118+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
--timeout 80000
2+
--recursive e2e
3+
--reporter mocha-multi
4+
--reporter-options spec=-,mocha-junit-reporter=test-results.xml

0 commit comments

Comments
 (0)