-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathsmoke.tests.js
91 lines (78 loc) · 2.41 KB
/
smoke.tests.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
const assert = require("chai").assert;
const nsAppium = require("nativescript-dev-appium");
let driver;
before("reate driver", async () => {
driver = await nsAppium.createDriver();
});
afterEach(`navigate back to main page after test`, async () => {
await driver.navBack();
});
after('quit driver', async () => {
await driver.quit();
console.log('Buh-Bye...');
});
describe("components", async () => {
const components = [
'ActivityIndicator',
'Button',
'DatePicker',
'HtmlView',
'Image',
'Label',
'ListPicker',
'ListView',
'Progress',
'ScrollView',
'SearchBar',
'SegmentedBar',
'Slider',
'Switch',
'TabView',
'TextField',
'TextView',
'TimePicker',
'WebView',
];
for (let component of components) {
it(`load ${component}`, async () => {
await loadComponent(component);
const result = await driver.compareScreen(component, 10, 0.1);
assert.isTrue(result, "Image comparisson has failed!");
if (component === 'SearchBar' && driver.isAndroid) {
await driver.navBack();
}
});
};
});
describe("dialogs", async () => {
const dialogs = [
'ActionDialog',
'AlertDialog',
'ConfirmDialog',
'LoginDialog',
'PromptDialog',
];
for (let dialog of dialogs) {
it(`load ${dialog}`, async () => {
await loadComponent(dialog);
const result = await driver.compareScreen(dialog, 10, 0.1);
if (driver.isIOS) {
const button = dialog === "ActionDialog" ? "cancel" : "OK";
const dialogItem = await driver.findElementByTextIfExists(button, nsAppium.SearchOptions.contains);
if (dialogItem) {
await dialogItem.click();
} else {
console.error(`Could not find ${button} to dismiss the dialog!`);
}
} else {
await driver.navBack();
}
assert.isTrue(result, "Image comparisson has failed!");
});
};
});
const loadComponent = async (component) => {
const listItem = await driver.findElementByText(component);
await listItem.click();
await driver.findElementByTextIfExists(component, nsAppium.SearchOptions.contains);
};