Skip to content

Commit e539bb2

Browse files
Merge pull request #5 from NativeScript/svetoslavtsenov/e2e
tests: include smoke e2e tests
2 parents 63b1d55 + 2defebb commit e539bb2

File tree

92 files changed

+805
-15312
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+805
-15312
lines changed

Diff for: .gitignore

+7-1
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,14 @@ hooks
44
.vscode
55

66
app/**/*.js
7+
app/**/*.map
8+
9+
e2e/**/*.js
10+
e2e/**/*.map
711

812
# Webpack files
913
tsconfig.esm.json
1014
webpack.config.js
11-
15+
instruments*
16+
e2e/reports
17+
test-results.xml

Diff for: app/animate-child.component.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ import { Component } from "@angular/core";
1010

1111
@Component({
1212
template: `
13-
<StackLayout class="parent" width="500" height="500" [@parent]="parentVal">
14-
<StackLayout class="child" [@child]="childVal"></StackLayout>>
13+
<StackLayout class="parent" width="500" height="500" [@parent]="parentVal" automationText="parent">
14+
<StackLayout class="child" [@child]="childVal" automationText="child"></StackLayout>>
1515
</StackLayout>
1616
`,
1717
animations: [

Diff for: app/animation-builder.component.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { Component, ViewChild } from '@angular/core';
33

44
@Component({
55
template: `
6-
<Button #button (tap)="makeAnimation()" class="btn btn-primary" text="Tap to disappear!"></Button>
6+
<Button #button (tap)="makeAnimation()" class="btn btn-primary" automationText="tapToDisappear" text="Tap to disappear!"></Button>
77
`
88
})
99
export class AnimationBuilderComponent {

Diff for: app/animations-list.component.ts

+11-9
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
11
import { Component } from '@angular/core';
22

33
class Link {
4-
constructor(public title: string, public link: string) {}
4+
constructor(public title: string, public link: string, public id?: string) {
5+
this.id = this.id || this.link.replace("/", "");
6+
}
57
}
68

79
@Component({
810
template: `
9-
<ListView [items]="links">
10-
<ng-template let-item="item">
11-
<Button
12-
[text]="item.title"
13-
[nsRouterLink]="item.link"
14-
></Button>
15-
</ng-template>
16-
</ListView>
11+
<WrapLayout [items]="links">
12+
<Button
13+
*ngFor="let item of links"
14+
[text]="item.title"
15+
[nsRouterLink]="item.link"
16+
[automationText]="item.link.replace('/', '')">
17+
</Button>
18+
</WrapLayout>
1719
`
1820
})
1921
export class AnimationsListComponent {

Diff for: app/app.android.css

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Button {
2+
font-size: 8px;
3+
padding: 0px;
4+
margin: 0px;
5+
}
6+
7+
Label{
8+
font-size: 8px;
9+
}

Diff for: app/app.css

Whitespace-only changes.

Diff for: app/external-animation.component.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,20 @@ import { fadeAnimation } from "./animations";
99
<Button
1010
[@coolAnimation]="isVisible"
1111
text="Nice button."
12+
automationText="animatedBtn"
1213
></Button>
1314
1415
<Button
1516
(tap)="toggle()"
1617
text="Toggle"
18+
automationText="toggleAnimation"
1719
backgroundColor="green"
1820
color="white"
1921
></Button>
2022
</StackLayout>
2123
`,
2224
animations: [
2325
trigger("coolAnimation", [
24-
2526
transition("invisible => visible", [
2627
useAnimation(fadeAnimation, {
2728
params: {
@@ -37,7 +38,7 @@ import { fadeAnimation } from "./animations";
3738
params: {
3839
from: 1,
3940
to: 0,
40-
time: "0.4s",
41+
time: "1.0s",
4142
},
4243
})
4344
]),

Diff for: app/fade-in-out.component.ts

+2
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,15 @@ import { trigger, transition, style, animate } from "@angular/animations";
99
[@someCoolAnimation]="bindingVar"
1010
(tap)="hide()"
1111
backgroundColor="hotpink"
12+
automationText="animatedBtn"
1213
height="200"
1314
></Button>
1415
1516
<Button
1617
text="Toggle!"
1718
(tap)="toggle()"
1819
backgroundColor="red"
20+
automationText="toggleAnimation"
1921
></Button>
2022
</StackLayout>
2123
`,

Diff for: app/hero/hero-team-builder.component.html

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<FlexboxLayout flexDirection="column">
22
<FlexboxLayout>
3-
<Button (tap)="heroes.addInactive()" text="Add inactive" ></Button>
4-
<Button (tap)="heroes.addActive()" text="Add active"></Button>
5-
<Button (tap)="heroes.remove()" text="Remove"></Button>
6-
<Button (tap)="heroes.reset()" text="Reset"></Button>
3+
<Button (tap)="heroes.addInactive()" text="Add inactive" automationText="addInactive" ></Button>
4+
<Button (tap)="heroes.addActive()" text="Add active" automationText="addActive" ></Button>
5+
<Button (tap)="heroes.remove()" text="Remove" automationText="remove" ></Button>
6+
<Button (tap)="heroes.reset()" text="Reset" automationText="reset" ></Button>
77
</FlexboxLayout>
88

99
<FlexboxLayout flexDirection="column">

Diff for: app/options-default.component.ts

+5-3
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,26 @@ import {
99

1010
@Component({
1111
template: `
12-
<StackLayout>
12+
<StackLayout automationText="itemsContainer">
1313
<Button
1414
text="Add hero"
1515
(tap)="addNew()"
1616
[isEnabled]="extraHeroes.length > 0"
1717
[ngClass]="extraHeroes.length > 0 ? 'enabled' : 'disabled'"
18+
automationText="add"
1819
></Button>
1920
2021
2122
<Button
2223
*ngFor="let hero of heroes"
23-
[text]="hero"
24+
[text]="hero"
2425
[@flyInOut]="'in'"
2526
(tap)="flyOut(hero)"
2627
backgroundColor="hotpink"
28+
[automationText]="hero"
2729
height="75"
2830
></Button>
29-
31+
3032
</StackLayout>
3133
`,
3234
styles: [

Diff for: app/options.component.ts

+2
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,15 @@ import { Component } from "@angular/core";
77
<Button
88
*ngIf="animationData.value === 'active'"
99
[@someCoolAnimation]="animationData"
10+
automationText="animatedBtn"
1011
text="hello there"
1112
></Button>
1213
1314
<Button
1415
(tap)="fadeOut()"
1516
text="Remove above button"
1617
backgroundColor="green"
18+
automationText="toggleAnimation"
1719
color="white"
1820
></Button>
1921
</StackLayout>

Diff for: app/query-stagger.component.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import { Component } from "@angular/core";
2727
<StackLayout>
2828
<Button (tap)="add()" text="ADD" backgroundColor="hotpink"></Button>
2929
30-
<StackLayout [@listAnimation]="items.length">
30+
<StackLayout [@listAnimation]="items.length" automationText="container" >
3131
<Button *ngFor="let item of items" [text]="item" class="ani-button"></Button>
3232
</StackLayout>
3333
</StackLayout>

Diff for: app/selector-all.component.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,9 @@ import { Component } from "@angular/core";
2929
]),
3030
],
3131
template: `
32-
<FlexboxLayout flexDirection="column">
33-
<Button text="add" (tap)="items.push('random')"></Button>
32+
<FlexboxLayout flexDirection="column"
33+
automationText="itemsContainer">
34+
<Button text="add" automationText="add" (tap)="items.push('random')"></Button>
3435
3536
<FlexboxLayout
3637
flexDirection="column"

Diff for: e2e/config/appium.capabilities.json

+111
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
{
2+
"android19": {
3+
"platformName": "Android",
4+
"platformVersion": "4.4",
5+
"deviceName": "Emulator-Api19-Default",
6+
"avd": "Emulator-Api19-Default",
7+
"lt": 60000,
8+
"newCommandTimeout": 720,
9+
"noReset": true,
10+
"fullReset": false,
11+
"app": ""
12+
},
13+
"android21": {
14+
"platformName": "Android",
15+
"platformVersion": "5.0",
16+
"deviceName": "Emulator-Api21-Default",
17+
"avd": "Emulator-Api21-Default",
18+
"lt": 60000,
19+
"newCommandTimeout": 720,
20+
"noReset": true,
21+
"fullReset": false,
22+
"app": ""
23+
},
24+
"android23": {
25+
"platformName": "Android",
26+
"platformVersion": "6.0",
27+
"deviceName": "Emulator-Api23-Default",
28+
"avd": "Emulator-Api23-Default",
29+
"lt": 60000,
30+
"newCommandTimeout": 720,
31+
"noReset": true,
32+
"fullReset": false,
33+
"app": ""
34+
},
35+
"android24": {
36+
"platformName": "Android",
37+
"platformVersion": "7.0",
38+
"deviceName": "Emulator-Api24-Default",
39+
"avd": "Emulator-Api24-Default",
40+
"lt": 60000,
41+
"newCommandTimeout": 720,
42+
"noReset": true,
43+
"fullReset": false,
44+
"app": ""
45+
},
46+
"android25": {
47+
"platformName": "Android",
48+
"platformVersion": "7.1",
49+
"deviceName": "Emulator-Api25-Google",
50+
"avd": "Emulator-Api25-Google",
51+
"lt": 60000,
52+
"newCommandTimeout": 720,
53+
"noReset": true,
54+
"fullReset": false,
55+
"app": ""
56+
},
57+
"android26": {
58+
"platformName": "Android",
59+
"platformVersion": "8.0",
60+
"deviceName": "Emulator-Api26-Google",
61+
"avd": "Emulator-Api26-Google",
62+
"lt": 60000,
63+
"newCommandTimeout": 720,
64+
"noReset": true,
65+
"fullReset": false,
66+
"app": ""
67+
},
68+
"android27": {
69+
"platformName": "Android",
70+
"platformVersion": "27",
71+
"deviceName": "Emulator-Api27-Google",
72+
"avd": "Emulator-Api27-Google",
73+
"lt": 60000,
74+
"newCommandTimeout": 720,
75+
"noReset": true,
76+
"fullReset": false,
77+
"app": ""
78+
},
79+
"sim.iPhone7.100": {
80+
"platformName": "iOS",
81+
"platformVersion": "10.0",
82+
"deviceName": "iPhone 7",
83+
"noReset": true,
84+
"fullReset": false,
85+
"app": ""
86+
},
87+
"sim.iPhone7.110": {
88+
"platformName": "iOS",
89+
"platformVersion": "11.0",
90+
"deviceName": "iPhone 7 110",
91+
"noReset": true,
92+
"fullReset": false,
93+
"app": ""
94+
},
95+
"sim.iPhone8": {
96+
"platformName": "iOS",
97+
"platformVersion": "11.3",
98+
"deviceName": "iPhone 8",
99+
"noReset": true,
100+
"fullReset": false,
101+
"app": ""
102+
},
103+
"sim.iPhoneX": {
104+
"platformName": "iOS",
105+
"platformVersion": "11.3",
106+
"deviceName": "iPhone X",
107+
"noReset": true,
108+
"fullReset": false,
109+
"app": ""
110+
}
111+
}

Diff for: e2e/config/mocha.opts

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
--timeout 999999
2+
--recursive e2e
3+
--reporter mocha-multi
4+
--reporter-options spec=-,mocha-junit-reporter=test-results.xml
5+
--exit

Diff for: e2e/helper/utils.ts

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { UIElement } from "nativescript-dev-appium";
2+
3+
export const sort = async (array: Array<UIElement>) => {
4+
var done = false;
5+
while (!done) {
6+
done = true;
7+
for (var i = 1; i < array.length; i++) {
8+
if ((await (await array[i - 1]).location()).y > (await (await array[i]).location()).y) {
9+
done = false;
10+
var tmp = array[i - 1];
11+
array[i - 1] = array[i];
12+
array[i] = tmp;
13+
}
14+
}
15+
}
16+
17+
return array;
18+
}

Diff for: e2e/pages/animate-child-page.ts

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import { AppiumDriver, UIElement } from "nativescript-dev-appium";
2+
import { assert } from "chai";
3+
import { BasePage } from "./base-page";
4+
5+
export class AnimateChildPage extends BasePage {
6+
private _parent: UIElement;
7+
private _child: UIElement;
8+
constructor(_driver: AppiumDriver) {
9+
super(_driver)
10+
}
11+
12+
async enterExample() {
13+
const exampleBtn = await this._driver.findElementByAccessibilityId("animate-child");
14+
await exampleBtn.click();
15+
}
16+
17+
async waitParentToAppear() {
18+
this._parent = await this.awaitItemToAppear("parent");
19+
const startTime = Date.now();
20+
while ((await this._parent.location()).x !== 0 && Date.now() - startTime < 3000) { }
21+
}
22+
23+
async waitChildToAppear() {
24+
this._child = await this.awaitItemToAppear("child");
25+
const startTime = Date.now();
26+
while ((await this._child.location()).y !== (await this._parent.location()).y && Date.now() - startTime < 3000) { }
27+
}
28+
29+
async assertContainersPosition() {
30+
assert.isTrue((await this._parent.location()).x === 0);
31+
assert.isTrue((await this._parent.location()).y === (await this._child.location()).y);
32+
}
33+
34+
private async awaitItemToAppear(item: string, wait: number = 3000): Promise<UIElement> {
35+
const startTime = Date.now();
36+
const findBtn = async () => { return await this._driver.findElementByXPathIfExists(this._elementHelper.findByTextLocator("*", item, true)); };
37+
let btn = await findBtn();
38+
while (!btn || !(await btn.isDisplayed()) && Date.now() - startTime <= wait) {
39+
btn = await findBtn();
40+
}
41+
42+
return btn;
43+
}
44+
}

0 commit comments

Comments
 (0)