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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ demo-angular/platforms/
!demo-vue/app/app.js
/src/platforms/android/nativescript_facebook.aar
/src/*.tgz
/publish/package/*.tgz
/publish/package/*.tgz
/publish/package/**/*
196 changes: 105 additions & 91 deletions demo/e2e/test.e2e.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {
AppiumDriver,
createDriver,
SearchOptions
AppiumDriver,
createDriver,
SearchOptions
} from "nativescript-dev-appium";
import { isSauceLab, runType } from "nativescript-dev-appium/lib/parser";
import { expect } from "chai";
Expand All @@ -10,98 +10,112 @@ 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;
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;
});
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");
});
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']";
}
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();
const facebookButton = await driver.findElementByText("Custom", SearchOptions.contains);
await facebookButton.click();

if (isAndroid) {
const allFields = await driver.driver.waitForElementsByClassName(
driver.locators.getElementByName("textfield"),
10000
);
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.driver.waitForElementByClassName(
driver.locators.getElementByName("securetextfield"),
10000
);
await passField.click().sendKeys(PASSWORD);
const usernameField = await driver.driver.waitForElementByClassName(
driver.locators.getElementByName("textfield"),
10000
);
await usernameField.click().sendKeys(USERNAME);
}
try {
await driver.driver.hideDeviceKeyboard("Done");
} catch (error) {}
if (isAndroid) {
const logInButton = await driver.findElementByClassName(driver.locators.button);
await logInButton.click();
const okButton = await driver.findElementByClassName(driver.locators.button);
await okButton.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");
});
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.findElementByAccessibilityId(FACEBOOK_BUTTON);
expect(facebookButton).to.exist;
});
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.findElementByAccessibilityId(FACEBOOK_BUTTON);
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;
});
});
2 changes: 1 addition & 1 deletion src/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nativescript-facebook",
"version": "2.2.4",
"version": "2.3.0",
"description": "NativeScript plugin, wrapper of native Facebook SDK for Adroid and iOS.",
"nativescript": {
"platforms": {
Expand Down