Skip to content

Commit 04df826

Browse files
Merge pull request #149 from NativeScript/dtodorov/add-vue-tests
Add tests for vueJs Demo
2 parents dd78f97 + a36e576 commit 04df826

File tree

6 files changed

+261
-29
lines changed

6 files changed

+261
-29
lines changed
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
{
2+
"android23.local": {
3+
"platformName": "Android",
4+
"platformVersion": "6.0",
5+
"deviceName": "Emulator_Api23_Default",
6+
"avd": "Emulator_Api23_Default",
7+
"noReset": true
8+
},
9+
"android23": {
10+
"platformName": "Android",
11+
"platformVersion": "6.0",
12+
"deviceName": "Android Emulator",
13+
"appium-version": "1.7.1",
14+
"noReset": true
15+
},
16+
"android24": {
17+
"platformName": "Android",
18+
"platformVersion": "7.0",
19+
"deviceName": "Android_GoogleAPI_Emulator",
20+
"appiumVersion": "1.9.1",
21+
"noReset": true
22+
},
23+
"android25": {
24+
"platformName": "Android",
25+
"platformVersion": "7.1",
26+
"deviceName": "Android GoogleAPI Emulator",
27+
"appium-version": "1.7.1",
28+
"noReset": true
29+
},
30+
"sim11iPhone6": {
31+
"platformName": "iOS",
32+
"platformVersion": "11.0",
33+
"deviceName": "iPhone 6",
34+
"appium-version": "1.7.1",
35+
"app": ""
36+
},
37+
"sim12iPhoneX": {
38+
"platformName": "iOS",
39+
"platformVersion": "12.1",
40+
"deviceName": "iPhone X",
41+
"appium-version": "1.9.1",
42+
"app": ""
43+
},
44+
"sim103iPhone6": {
45+
"browserName": "",
46+
"appium-version": "1.7.1",
47+
"platformName": "iOS",
48+
"platformVersion": "10.3",
49+
"deviceName": "iPhone 6",
50+
"app": ""
51+
},
52+
"sim10iPhone6": {
53+
"platformName": "iOS",
54+
"platformVersion": "10.0",
55+
"deviceName": "iPhone 6",
56+
"appium-version": "1.7.1",
57+
"app": ""
58+
},
59+
"sim_11.2_iPhone6": {
60+
"browserName": "",
61+
"appium-version": "1.7.1",
62+
"platformName": "iOS",
63+
"platformVersion": "11.2",
64+
"deviceName": "iPhone 6",
65+
"app": ""
66+
}
67+
}

demo-vue/e2e/config/mocha.opts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
--timeout 800000
2+
--recursive e2e
3+
--exit

demo-vue/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-vue/e2e/test.e2e.ts

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
import {
2+
AppiumDriver,
3+
createDriver,
4+
SearchOptions
5+
} from "nativescript-dev-appium";
6+
import { isSauceLab, runType } from "nativescript-dev-appium/lib/parser";
7+
import { expect } from "chai";
8+
import "mocha";
9+
10+
const isSauceRun = isSauceLab;
11+
const isAndroid: boolean = runType.includes("android");
12+
13+
describe("Facebook tests", async function () {
14+
const FACEBOOK_BUTTON = "fbLogin";
15+
const USERNAME = "nativescript_gctpjih_user@tfbnw.net";
16+
const PASSWORD = "P@ssw0rd";
17+
const CUSTOM_LOGOUT_BUTTON = "customLogOut";
18+
const USER_NAME = "Nativescript User";
19+
let driver: AppiumDriver;
20+
21+
before(async () => {
22+
driver = await createDriver();
23+
driver.defaultWaitTime = 20000;
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("Driver successfully quit");
34+
});
35+
36+
it("should log in via custom button", async function () {
37+
if (isAndroid) {
38+
var userNameLabelElement = "[@text='Nativescript User']";
39+
} else {
40+
var userNameLabelElement = "[@name='Nativescript User']";
41+
}
42+
43+
const facebookButton = await driver.findElementByText("Custom", SearchOptions.contains);
44+
await facebookButton.click();
45+
46+
if (isAndroid) {
47+
const allFields = await driver.findElementsByClassName(driver.locators.getElementByName("textfield"));
48+
const wd = driver.wd();
49+
const action = new wd.TouchAction(driver.driver);
50+
action
51+
.press({ x: 52, y: 499 })
52+
.moveTo({ x: -2, y: -294 })
53+
.release();
54+
await action.perform();
55+
await driver.wait(1000);
56+
await allFields[1].sendKeys(PASSWORD);
57+
try {
58+
await driver.driver.hideDeviceKeyboard();
59+
} catch (error) { }
60+
await driver.wait(1000);
61+
await allFields[0].sendKeys(USERNAME);
62+
} else {
63+
const passField = await driver.findElementByClassName(driver.locators.getElementByName("securetextfield"));
64+
await passField.click();
65+
await passField.sendKeys(PASSWORD);
66+
const usernameField = await driver.findElementByClassName(driver.locators.getElementByName("textfield"));
67+
await usernameField.click();
68+
await usernameField.sendKeys(USERNAME);
69+
}
70+
try {
71+
await driver.driver.hideDeviceKeyboard("Done");
72+
} catch (error) { }
73+
if (isAndroid) {
74+
const logInButton = await driver.findElementByClassName(driver.locators.button);
75+
await logInButton.click();
76+
const continueButton = await driver.findElementByText("Continue");
77+
await continueButton.click();
78+
} else {
79+
const logInButton = await driver.findElementByText("Log In");
80+
await logInButton.click();
81+
const continueButton = await driver.findElementByText("Continue");
82+
await continueButton.click();
83+
}
84+
const userNameLabel = await driver.findElementByXPath(
85+
"//" + driver.locators.getElementByName("label") + userNameLabelElement
86+
);
87+
const userName = await userNameLabel.text();
88+
expect(userName).to.equal(USER_NAME, "Not logged with the same user");
89+
});
90+
91+
it("should log out via custom button", async function () {
92+
const allButtons = await driver.findElementsByClassName(driver.locators.button);
93+
await allButtons[1].click();
94+
const facebookButton = await driver.findElementByText("Continue with Facebook", SearchOptions.exact);
95+
expect(facebookButton).to.exist;
96+
});
97+
98+
it("should share a link", async function () {
99+
const shareLinkButton = await driver.findElementByText("Open Share dialog", SearchOptions.contains);
100+
await shareLinkButton.click();
101+
if (isAndroid) {
102+
const allFields = await driver.findElementsByClassName(driver.locators.getElementByName("textfield"));
103+
await allFields[1].sendKeys(PASSWORD);
104+
await allFields[0].sendKeys(USERNAME);
105+
const logInButton = await driver.findElementByClassName(driver.locators.button);
106+
await logInButton.click();
107+
} else {
108+
const passField = await driver.findElementByClassName(driver.locators.getElementByName("securetextfield"));
109+
await passField.click();
110+
await passField.sendKeys(PASSWORD);
111+
const usernameField = await driver.findElementByClassName(driver.locators.getElementByName("textfield"));
112+
await usernameField.click();
113+
await usernameField.sendKeys(USERNAME);
114+
const logInButton = await driver.findElementByText("Log In");
115+
await logInButton.click();
116+
}
117+
118+
const postButton = await driver.findElementByText("Post");
119+
expect(postButton).to.exist;
120+
});
121+
});

demo-vue/e2e/tsconfig.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"compilerOptions": {
3+
"module": "commonjs",
4+
"target": "es6",
5+
"experimentalDecorators": true,
6+
"emitDecoratorMetadata": true,
7+
"importHelpers": false,
8+
"sourceMap":true,
9+
"types": [
10+
"node",
11+
"mocha",
12+
"chai"
13+
],
14+
"lib": [
15+
"dom",
16+
"es2015.core",
17+
"es2015.iterable",
18+
"es2016.array.include",
19+
"es2015"
20+
]
21+
}
22+
}

demo-vue/package.json

Lines changed: 39 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,43 @@
11
{
2-
"nativescript": {
3-
"id": "org.nativescript.demovue",
4-
"tns-android": {
5-
"version": "5.1.0"
6-
},
7-
"tns-ios": {
8-
"version": "5.1.0"
9-
}
2+
"nativescript": {
3+
"id": "org.nativescript.demovue",
4+
"tns-android": {
5+
"version": "5.1.0"
106
},
11-
"description": "NativeScript Application",
12-
"license": "SEE LICENSE IN <your-license-filename>",
13-
"repository": "<fill-your-repository-here>",
14-
"dependencies": {
15-
"nativescript-facebook": "../src",
16-
"nativescript-theme-core": "~1.0.4",
17-
"nativescript-vue": "~2.0.0",
18-
"tns-core-modules": "~5.1.0"
19-
},
20-
"devDependencies": {
21-
"@babel/core": "~7.1.0",
22-
"@babel/preset-env": "~7.1.0",
23-
"babel-loader": "~8.0.0",
24-
"nativescript-dev-typescript": "~0.7.0",
25-
"nativescript-dev-webpack": "~0.19.0",
26-
"nativescript-vue-template-compiler": "~2.0.2",
27-
"node-sass": "~4.9.0",
28-
"vue-loader": "~15.4.2"
29-
},
30-
"scripts": {
31-
"build.plugin": "cd ../src && npm run build"
7+
"tns-ios": {
8+
"version": "5.1.0"
329
}
10+
},
11+
"description": "NativeScript Application",
12+
"license": "SEE LICENSE IN <your-license-filename>",
13+
"repository": "<fill-your-repository-here>",
14+
"dependencies": {
15+
"nativescript-facebook": "../src",
16+
"nativescript-theme-core": "~1.0.4",
17+
"nativescript-vue": "~2.0.0",
18+
"tns-core-modules": "~5.1.0"
19+
},
20+
"devDependencies": {
21+
"@types/chai": "^4.1.3",
22+
"@types/mocha": "^5.2.0",
23+
"@types/node": "^10.1.2",
24+
"@babel/core": "~7.1.0",
25+
"@babel/preset-env": "~7.1.0",
26+
"chai": "~4.1.2",
27+
"chai-as-promised": "~7.1.1",
28+
"karma": "^2.0.2",
29+
"karma-nativescript-launcher": "^0.4.0",
30+
"mocha": "~5.2.0",
31+
"babel-loader": "~8.0.0",
32+
"nativescript-dev-appium": "^4.0.9",
33+
"nativescript-dev-typescript": "~0.7.0",
34+
"nativescript-dev-webpack": "~0.19.0",
35+
"nativescript-vue-template-compiler": "~2.0.2",
36+
"node-sass": "~4.9.0",
37+
"vue-loader": "~15.4.2"
38+
},
39+
"scripts": {
40+
"build.plugin": "cd ../src && npm run build",
41+
"e2e": "tsc -p e2e && mocha --opts ./e2e/config/mocha.opts"
42+
}
3343
}

0 commit comments

Comments
 (0)