webdriverio-automation
Version:
WebdriverIO-Automation android ios project
182 lines (158 loc) • 10.8 kB
text/typescript
import { HomePageActions } from "@kount/yodalib_ui_webdriverio/dist/sdk/action/android/HomePageActions";
import { CollectWithLocationPage } from "@kount/yodalib_ui_webdriverio/dist/sdk/pages/android/CollectWithLocationPage";
import { CollectWithoutLocationPage } from "@kount/yodalib_ui_webdriverio/dist/sdk/pages/android/CollectWithoutLocationPage";
import { HomePage } from "@kount/yodalib_ui_webdriverio/dist/sdk/pages/android/HomePage";
import { FetchRequestAdapter } from "@kount/yodalib_requestor_fetch/dist/fetchRequestAdapter";
import { CollectorRestApi } from "@kount/yodalib/dist/device/collector/collectorRestApi";
import { expect } from "chai";
import * as LocationData from "../../../fixtures/LocationConstants.json";
import { Utils } from "@kount/yodalib/dist/device/utils";
import { TestHelper } from "../../../src/TestHelper";
import { DeviceUtils } from "../../../src/DeviceUtils";
import { parse } from "query-string";
describe("Deny Location Android Mobile App Test Cases", () => {
let collector: CollectorRestApi;
let env: any;
let utils: Utils;
let testHelper: TestHelper;
let host: string;
let protocol: string;
let envURL: string;
const homePageActions = new HomePageActions();
const collectWithLocationPage = new CollectWithLocationPage();
const collectWithoutLocationPage = new CollectWithoutLocationPage();
const homePage = new HomePage();
beforeEach(() => {
utils = new Utils();
env = new DeviceUtils().getEnvironment();
host = env.services.device.collectorApi.host;
protocol = env.services.device.collectorApi.protocol;
envURL = protocol.concat("://").concat(host.toString());
collector = CollectorRestApi.init(env, FetchRequestAdapter);
testHelper = new TestHelper();
});
it("To make a collection with location and location services turned off", async () => {
homePageActions.denyLocationInApp();
// Run app on desired environment
homePageActions.clickURL();
homePageActions.sendTextToElement(homePage.editURLTextBox, envURL);
homePageActions.clickOkButton();
// Modify Merchant ID in App
homePageActions.clickMerchantIdTextBox();
homePageActions.sendTextToElement(homePage.editURLTextBox, env.vars.merchantId);
homePageActions.clickOkButton();
homePageActions.clickCollectWithLocationButton();
homePageActions.waitForElementContainsText(collectWithLocationPage.denyUIElement, "elapsed");
const collectionText = homePageActions.getElementText(collectWithLocationPage.denyUIElement);
const params = parse(collectionText);
const session: string = params.s as string;
expect(collectionText).to.contain(LocationData.WithLocation.m);
expect(collectionText).to.contain(LocationData.WithLocation.s);
expect(collectionText).to.contain(LocationData.WithLocation.dc_et);
expect(collectionText).to.contain(LocationData.WithLocation.dmm);
expect(collectionText).to.contain(LocationData.WithLocation.dmm_et);
expect(collectionText).to.contain(LocationData.WithLocation.e);
expect(collectionText).to.contain(LocationData.WithLocation.e_et);
expect(collectionText).to.contain(LocationData.WithLocation.elapsed);
expect(collectionText).to.contain(LocationData.WithLocation.fingerprint_et);
expect(collectionText).to.contain(LocationData.WithLocation.ln);
expect(collectionText).to.contain(LocationData.WithLocation.ln_et);
expect(collectionText).to.contain(LocationData.WithLocation.mdl);
expect(collectionText).to.contain(LocationData.WithLocation.mdl_et);
expect(collectionText).to.contain(LocationData.WithLocation.odc_et);
expect(collectionText).to.contain(LocationData.WithLocation.os);
expect(collectionText).to.contain(LocationData.WithLocation.os_et);
expect(collectionText).to.contain(LocationData.WithLocation.sa);
expect(collectionText).to.contain(LocationData.WithLocation.sa_et);
expect(collectionText).to.contain(LocationData.WithLocation.st);
expect(collectionText).to.contain(LocationData.WithLocation.sv);
expect(collectionText).to.contain(LocationData.WithLocation.system_et);
expect(collectionText).to.contain(LocationData.WithLocation.t0);
expect(collectionText).to.contain(LocationData.WithLocation.t0_et);
expect(collectionText).to.contain(LocationData.WithLocation.ta);
expect(collectionText).to.contain(LocationData.WithLocation.ta_et);
expect(collectionText).to.contain(LocationData.WithLocation.tf);
expect(collectionText).to.contain(LocationData.WithLocation.tf_et);
expect(collectionText).to.not.contain(LocationData.WithLocation.lat);
expect(collectionText).to.not.contain(LocationData.WithLocation.lon);
expect(collectionText).to.not.contain(LocationData.WithLocation.location_et);
expect(collectionText).to.not.contain(LocationData.WithLocation.ltm);
expect(collectionText).to.not.contain(LocationData.WithLocation.city);
expect(collectionText).to.not.contain(LocationData.WithLocation.country);
expect(collectionText).to.not.contain(LocationData.WithLocation.iso);
expect(collectionText).to.not.contain(LocationData.WithLocation.region);
expect(collectionText).to.not.contain(LocationData.WithLocation.street);
expect(collectionText).to.not.contain(LocationData.WithLocation.postal_code);
// make a getdeviceid call
if (env.vars.internalOnly === true) {
const deviceData = await testHelper.getDeviceId(session);
console.log("mobile body: " + JSON.stringify(deviceData));
expect(deviceData.osSignature, "osSignature should not be empty, if it is then p0f is not working")
.to.not.be.empty;
expect(deviceData.browser, "browser should be NONE").to.eq("NONE");
expect(deviceData.mobile, "this should be marked as a mobile collection").to.be.true;
}
});
it("To make a collection without location and location services turned off", async () => {
homePageActions.denyLocationInApp();
// Run app on desired environment
homePageActions.clickURL();
homePageActions.sendTextToElement(homePage.editURLTextBox, envURL);
homePageActions.clickOkButton();
// Modify Merchant ID in App
homePageActions.clickMerchantIdTextBox();
homePageActions.sendTextToElement(homePage.editURLTextBox, env.vars.merchantId);
homePageActions.clickOkButton();
homePageActions.clickCollectWithoutLocationButton();
homePageActions.waitForElementContainsText(collectWithoutLocationPage.locationElement, "elapsed");
const collectionText = homePageActions.getElementText(collectWithoutLocationPage.locationElement);
const params = parse(collectionText);
const session: string = params.s as string;
expect(collectionText).to.contain(LocationData.WithoutLocation.s);
expect(collectionText).to.contain(LocationData.WithoutLocation.dc);
expect(collectionText).to.contain(LocationData.WithoutLocation.dc_et);
expect(collectionText).to.contain(LocationData.WithoutLocation.dmm);
expect(collectionText).to.contain(LocationData.WithoutLocation.dmm_et);
expect(collectionText).to.contain(LocationData.WithoutLocation.e);
expect(collectionText).to.contain(LocationData.WithoutLocation.e_et);
expect(collectionText).to.contain(LocationData.WithoutLocation.elapsed);
expect(collectionText).to.contain(LocationData.WithoutLocation.fingerprint_et);
expect(collectionText).to.contain(LocationData.WithoutLocation.ln);
expect(collectionText).to.contain(LocationData.WithoutLocation.ln_et);
expect(collectionText).to.contain(LocationData.WithoutLocation.mdl);
expect(collectionText).to.contain(LocationData.WithoutLocation.mdl_et);
expect(collectionText).to.contain(LocationData.WithoutLocation.odc_et);
expect(collectionText).to.contain(LocationData.WithoutLocation.os);
expect(collectionText).to.contain(LocationData.WithoutLocation.os_et);
expect(collectionText).to.contain(LocationData.WithoutLocation.sa);
expect(collectionText).to.contain(LocationData.WithoutLocation.sa_et);
expect(collectionText).to.contain(LocationData.WithoutLocation.st);
expect(collectionText).to.contain(LocationData.WithoutLocation.sv);
expect(collectionText).to.contain(LocationData.WithoutLocation.system_et);
expect(collectionText).to.contain(LocationData.WithoutLocation.t0);
expect(collectionText).to.contain(LocationData.WithoutLocation.t0_et);
expect(collectionText).to.contain(LocationData.WithoutLocation.ta);
expect(collectionText).to.contain(LocationData.WithoutLocation.ta_et);
expect(collectionText).to.contain(LocationData.WithoutLocation.tf);
expect(collectionText).to.contain(LocationData.WithoutLocation.tf_et);
expect(collectionText).to.not.contain(LocationData.WithLocation.lat);
expect(collectionText).to.not.contain(LocationData.WithLocation.lon);
expect(collectionText).to.not.contain(LocationData.WithLocation.location_et);
expect(collectionText).to.not.contain(LocationData.WithLocation.ltm);
expect(collectionText).to.not.contain(LocationData.WithLocation.city);
expect(collectionText).to.not.contain(LocationData.WithLocation.country);
expect(collectionText).to.not.contain(LocationData.WithLocation.iso);
expect(collectionText).to.not.contain(LocationData.WithLocation.region);
expect(collectionText).to.not.contain(LocationData.WithLocation.street);
expect(collectionText).to.not.contain(LocationData.WithLocation.postal_code);
// make a getdeviceid call
if (env.vars.internalOnly === true) {
const deviceData = await testHelper.getDeviceId(session);
console.log("mobile body: " + JSON.stringify(deviceData));
expect(deviceData.osSignature, "osSignature should not be empty, if it is then p0f is not working")
.to.not.be.empty;
expect(deviceData.browser, "browser should be NONE").to.eq("NONE");
expect(deviceData.mobile, "this should be marked as a mobile collection").to.be.true;
}
});
});