Skip to content

Commit eccc63f

Browse files
Dimitar TodorovDimitar Todorov
authored andcommitted
Add ui tests in demo-angular
1 parent 653ccd1 commit eccc63f

24 files changed

+527
-10
lines changed
Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
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": false,
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": false,
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": false,
32+
"fullReset": false,
33+
"app": ""
34+
},
35+
"android24": {
36+
"platformName": "Android",
37+
"platformVersion": "7.0",
38+
"deviceName": "Android_GoogleAPI_Emulator",
39+
"avd": "Android_GoogleAPI_Emulator",
40+
"lt": 60000,
41+
"newCommandTimeout": 720,
42+
"noReset": false,
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": false,
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": false,
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": false,
76+
"fullReset": false,
77+
"app": ""
78+
},
79+
"android28": {
80+
"platformName": "Android",
81+
"platformVersion": "28",
82+
"deviceName": "Emulator-Api28-Google",
83+
"avd": "Emulator-Api28-Google",
84+
"lt": 60000,
85+
"newCommandTimeout": 720,
86+
"noReset": false,
87+
"fullReset": false,
88+
"app": ""
89+
},
90+
"sim.iPhone7": {
91+
"platformName": "iOS",
92+
"platformVersion": "/12.*/",
93+
"deviceName": "iPhone 7",
94+
"noReset": false,
95+
"fullReset": false,
96+
"app": ""
97+
},
98+
"sim.iPhone8": {
99+
"platformName": "iOS",
100+
"platformVersion": "/12*/",
101+
"deviceName": "iPhone 8",
102+
"noReset": false,
103+
"fullReset": false,
104+
"app": ""
105+
},
106+
"sim.iPhoneX": {
107+
"platformName": "iOS",
108+
"platformVersion": "/12*/",
109+
"deviceName": "iPhone X",
110+
"noReset": false,
111+
"fullReset": false,
112+
"app": ""
113+
},
114+
"sim.iPhoneXS": {
115+
"platformName": "ios",
116+
"platformVersion": "/12*/",
117+
"deviceName": "iPhone XS",
118+
"noReset": false,
119+
"fullReset": false,
120+
"app": ""
121+
}
122+
}

demo-angular/e2e/config/mocha.opts

Lines changed: 5 additions & 0 deletions
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 mochawesome=-,mocha-junit-reporter=test-results.xml
5+
--exit

demo-angular/e2e/helper.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import { AppiumDriver, SearchOptions, Direction, UIElement } from "nativescript-dev-appium";
2+
import { runType } from "nativescript-dev-appium/lib/parser";
3+
4+
const isAndroid: boolean = runType.includes("android");
5+
const optionsText = "Options";
6+
const moreOptionsID = "More options";
7+
8+
9+
export function getDateString() {
10+
const date = new Date();
11+
let year = date.getFullYear().toString();
12+
let month = date.toLocaleString('en-us', { month: 'short' });
13+
let day = date.getDate().toString();
14+
if (date.getDate() < 10) {
15+
day = "0" + date.getDay().toString();
16+
}
17+
const dateString = month + " " + day + ", " + year;
18+
return dateString;
19+
}
20+
21+
export function getTimeString() {
22+
const date = new Date();
23+
let timeString = date.toLocaleString("en-US", {
24+
hour: "numeric",
25+
minute: "numeric",
26+
hour12: true
27+
});
28+
29+
return timeString;
30+
}
Loading
Loading
326 KB
Loading

demo-angular/e2e/setup.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { startServer, stopServer } from "nativescript-dev-appium";
2+
3+
before("start server", async () => {
4+
await startServer();
5+
});
6+
7+
after("stop server", async () => {
8+
await stopServer();
9+
});

demo-angular/e2e/tests.e2e.ts

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
import { AppiumDriver, createDriver, SearchOptions } from "nativescript-dev-appium";
2+
import { isSauceLab, runType } from "nativescript-dev-appium/lib/parser";
3+
import { expect } from "chai";
4+
import { ok } from "assert";
5+
import { getDateString, getTimeString } from "./helper";
6+
const fs = require('fs');
7+
const addContext = require('mochawesome/addContext');
8+
const rimraf = require('rimraf');
9+
const isSauceRun = isSauceLab;
10+
const isAndroid: boolean = runType.includes("android");
11+
12+
describe("DateTimePicker", () => {
13+
const defaultWaitTime = 5000;
14+
let driver: AppiumDriver;
15+
16+
before(async () => {
17+
driver = await createDriver();
18+
driver.defaultWaitTime = 15000;
19+
let dir = "mochawesome-report";
20+
if (!fs.existsSync(dir)) {
21+
fs.mkdirSync(dir);
22+
}
23+
rimraf('mochawesome-report/*', function () { });
24+
});
25+
26+
after(async () => {
27+
if (isSauceRun) {
28+
driver.sessionId().then(function (sessionId) {
29+
console.log("Report https://saucelabs.com/beta/tests/" + sessionId);
30+
});
31+
}
32+
await driver.quit();
33+
console.log("Quit driver!");
34+
});
35+
36+
afterEach(async function () {
37+
if (this.currentTest.state && this.currentTest.state === "failed") {
38+
let png = await driver.logScreenshot(this.currentTest.title);
39+
fs.copyFile(png, './mochawesome-report/' + this.currentTest.title + '.png', function (err) {
40+
if (err) {
41+
throw err;
42+
}
43+
console.log('Screenshot saved.');
44+
});
45+
addContext(this, './' + this.currentTest.title + '.png');
46+
}
47+
});
48+
49+
it("Should verify demo title", async () => {
50+
const title = await driver.findElementByText("DateTimePicker Demo NG", SearchOptions.exact);
51+
expect(title).to.exist;
52+
});
53+
54+
it("Should select date and verify value of picker field", async () => {
55+
const selectDateField = await driver.findElementByText("select date", SearchOptions.contains);
56+
await selectDateField.click();
57+
const okBtn = await driver.findElementByText("OK", SearchOptions.exact);
58+
await okBtn.click();
59+
const date = getDateString();
60+
console.log(date);
61+
const dateSelected = await driver.findElementByText(date);
62+
expect(dateSelected).to.exist;
63+
});
64+
65+
it("Should select time and verify value of picker field", async () => {
66+
const selectTimeField = await driver.findElementByText("select time", SearchOptions.contains);
67+
await selectTimeField.click();
68+
const okBtn = await driver.findElementByText("OK", SearchOptions.exact);
69+
await okBtn.click();
70+
const timeString = getTimeString();
71+
console.log(timeString);
72+
const timeSelected = await driver.findElementByText(timeString);
73+
expect(timeSelected).to.exist;
74+
})
75+
76+
});

demo-angular/e2e/tsconfig.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"compilerOptions": {
3+
"module": "commonjs",
4+
"target": "es6",
5+
"experimentalDecorators": true,
6+
"emitDecoratorMetadata": true,
7+
"importHelpers": false,
8+
"types": [
9+
"mocha",
10+
"chai"
11+
],
12+
"lib": [
13+
"es2015",
14+
"dom"
15+
],
16+
"baseUrl": "."
17+
}
18+
}
Binary file not shown.

0 commit comments

Comments
 (0)