Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 67 additions & 0 deletions demo-vue/e2e/config/appium.capabilities.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
{
"android23.local": {
"platformName": "Android",
"platformVersion": "6.0",
"deviceName": "Emulator_Api23_Default",
"avd": "Emulator_Api23_Default",
"noReset": true
},
"android23": {
"platformName": "Android",
"platformVersion": "6.0",
"deviceName": "Android Emulator",
"appium-version": "1.7.1",
"noReset": true
},
"android24": {
"platformName": "Android",
"platformVersion": "7.0",
"deviceName": "Android_GoogleAPI_Emulator",
"appiumVersion": "1.9.1",
"noReset": true
},
"android25": {
"platformName": "Android",
"platformVersion": "7.1",
"deviceName": "Android GoogleAPI Emulator",
"appium-version": "1.7.1",
"noReset": true
},
"sim11iPhone6": {
"platformName": "iOS",
"platformVersion": "11.0",
"deviceName": "iPhone 6",
"appium-version": "1.7.1",
"app": ""
},
"sim12iPhoneX": {
"platformName": "iOS",
"platformVersion": "12.1",
"deviceName": "iPhone X",
"appium-version": "1.9.1",
"app": ""
},
"sim103iPhone6": {
"browserName": "",
"appium-version": "1.7.1",
"platformName": "iOS",
"platformVersion": "10.3",
"deviceName": "iPhone 6",
"app": ""
},
"sim10iPhone6": {
"platformName": "iOS",
"platformVersion": "10.0",
"deviceName": "iPhone 6",
"appium-version": "1.7.1",
"app": ""
},
"sim_11.2_iPhone6": {
"browserName": "",
"appium-version": "1.7.1",
"platformName": "iOS",
"platformVersion": "11.2",
"deviceName": "iPhone 6",
"app": ""
}
}
3 changes: 3 additions & 0 deletions demo-vue/e2e/config/mocha.opts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
--timeout 800000
--recursive e2e
--exit
9 changes: 9 additions & 0 deletions demo-vue/e2e/setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { startServer, stopServer } from "nativescript-dev-appium";

before("start server", async () => {
await startServer();
});

after("stop server", async () => {
await stopServer();
});
121 changes: 121 additions & 0 deletions demo-vue/e2e/test.e2e.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
import {
AppiumDriver,
createDriver,
SearchOptions
} from "nativescript-dev-appium";
import { isSauceLab, runType } from "nativescript-dev-appium/lib/parser";
import { expect } from "chai";
import "mocha";

const isSauceRun = isSauceLab;
const isAndroid: boolean = runType.includes("android");

describe("Facebook tests", async function () {
const FACEBOOK_BUTTON = "fbLogin";
const USERNAME = "nativescript_gctpjih_user@tfbnw.net";
const PASSWORD = "P@ssw0rd";
const CUSTOM_LOGOUT_BUTTON = "customLogOut";
const USER_NAME = "Nativescript User";
let driver: AppiumDriver;

before(async () => {
driver = await createDriver();
driver.defaultWaitTime = 20000;
});

after(async () => {
if (isSauceRun) {
driver.sessionId().then(function (sessionId) {
console.log("Report: https://saucelabs.com/beta/tests/" + sessionId);
});
}
await driver.quit();
console.log("Driver successfully quit");
});

it("should log in via custom button", async function () {
if (isAndroid) {
var userNameLabelElement = "[@text='Nativescript User']";
} else {
var userNameLabelElement = "[@name='Nativescript User']";
}

const facebookButton = await driver.findElementByText("Custom", SearchOptions.contains);
await facebookButton.click();

if (isAndroid) {
const allFields = await driver.findElementsByClassName(driver.locators.getElementByName("textfield"));
const wd = driver.wd();
const action = new wd.TouchAction(driver.driver);
action
.press({ x: 52, y: 499 })
.moveTo({ x: -2, y: -294 })
.release();
await action.perform();
await driver.wait(1000);
await allFields[1].sendKeys(PASSWORD);
try {
await driver.driver.hideDeviceKeyboard();
} catch (error) { }
await driver.wait(1000);
await allFields[0].sendKeys(USERNAME);
} else {
const passField = await driver.findElementByClassName(driver.locators.getElementByName("securetextfield"));
await passField.click();
await passField.sendKeys(PASSWORD);
const usernameField = await driver.findElementByClassName(driver.locators.getElementByName("textfield"));
await usernameField.click();
await usernameField.sendKeys(USERNAME);
}
try {
await driver.driver.hideDeviceKeyboard("Done");
} catch (error) { }
if (isAndroid) {
const logInButton = await driver.findElementByClassName(driver.locators.button);
await logInButton.click();
const continueButton = await driver.findElementByText("Continue");
await continueButton.click();
} else {
const logInButton = await driver.findElementByText("Log In");
await logInButton.click();
const continueButton = await driver.findElementByText("Continue");
await continueButton.click();
}
const userNameLabel = await driver.findElementByXPath(
"//" + driver.locators.getElementByName("label") + userNameLabelElement
);
const userName = await userNameLabel.text();
expect(userName).to.equal(USER_NAME, "Not logged with the same user");
});

it("should log out via custom button", async function () {
const allButtons = await driver.findElementsByClassName(driver.locators.button);
await allButtons[1].click();
const facebookButton = await driver.findElementByText("Continue with Facebook", SearchOptions.exact);
expect(facebookButton).to.exist;
});

it("should share a link", async function () {
const shareLinkButton = await driver.findElementByText("Open Share dialog", SearchOptions.contains);
await shareLinkButton.click();
if (isAndroid) {
const allFields = await driver.findElementsByClassName(driver.locators.getElementByName("textfield"));
await allFields[1].sendKeys(PASSWORD);
await allFields[0].sendKeys(USERNAME);
const logInButton = await driver.findElementByClassName(driver.locators.button);
await logInButton.click();
} else {
const passField = await driver.findElementByClassName(driver.locators.getElementByName("securetextfield"));
await passField.click();
await passField.sendKeys(PASSWORD);
const usernameField = await driver.findElementByClassName(driver.locators.getElementByName("textfield"));
await usernameField.click();
await usernameField.sendKeys(USERNAME);
const logInButton = await driver.findElementByText("Log In");
await logInButton.click();
}

const postButton = await driver.findElementByText("Post");
expect(postButton).to.exist;
});
});
22 changes: 22 additions & 0 deletions demo-vue/e2e/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"importHelpers": false,
"sourceMap":true,
"types": [
"node",
"mocha",
"chai"
],
"lib": [
"dom",
"es2015.core",
"es2015.iterable",
"es2016.array.include",
"es2015"
]
}
}
68 changes: 39 additions & 29 deletions demo-vue/package.json
Original file line number Diff line number Diff line change
@@ -1,33 +1,43 @@
{
"nativescript": {
"id": "org.nativescript.demovue",
"tns-android": {
"version": "5.1.0"
},
"tns-ios": {
"version": "5.1.0"
}
"nativescript": {
"id": "org.nativescript.demovue",
"tns-android": {
"version": "5.1.0"
},
"description": "NativeScript Application",
"license": "SEE LICENSE IN <your-license-filename>",
"repository": "<fill-your-repository-here>",
"dependencies": {
"nativescript-facebook": "../src",
"nativescript-theme-core": "~1.0.4",
"nativescript-vue": "~2.0.0",
"tns-core-modules": "~5.1.0"
},
"devDependencies": {
"@babel/core": "~7.1.0",
"@babel/preset-env": "~7.1.0",
"babel-loader": "~8.0.0",
"nativescript-dev-typescript": "~0.7.0",
"nativescript-dev-webpack": "~0.19.0",
"nativescript-vue-template-compiler": "~2.0.2",
"node-sass": "~4.9.0",
"vue-loader": "~15.4.2"
},
"scripts": {
"build.plugin": "cd ../src && npm run build"
"tns-ios": {
"version": "5.1.0"
}
},
"description": "NativeScript Application",
"license": "SEE LICENSE IN <your-license-filename>",
"repository": "<fill-your-repository-here>",
"dependencies": {
"nativescript-facebook": "../src",
"nativescript-theme-core": "~1.0.4",
"nativescript-vue": "~2.0.0",
"tns-core-modules": "~5.1.0"
},
"devDependencies": {
"@types/chai": "^4.1.3",
"@types/mocha": "^5.2.0",
"@types/node": "^10.1.2",
"@babel/core": "~7.1.0",
"@babel/preset-env": "~7.1.0",
"chai": "~4.1.2",
"chai-as-promised": "~7.1.1",
"karma": "^2.0.2",
"karma-nativescript-launcher": "^0.4.0",
"mocha": "~5.2.0",
"babel-loader": "~8.0.0",
"nativescript-dev-appium": "^4.0.9",
"nativescript-dev-typescript": "~0.7.0",
"nativescript-dev-webpack": "~0.19.0",
"nativescript-vue-template-compiler": "~2.0.2",
"node-sass": "~4.9.0",
"vue-loader": "~15.4.2"
},
"scripts": {
"build.plugin": "cd ../src && npm run build",
"e2e": "tsc -p e2e && mocha --opts ./e2e/config/mocha.opts"
}
}