appium-xcuitest-driver
Version:
Appium driver for iOS using XCUITest for backend
159 lines • 6.67 kB
JavaScript
;
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const sinon_1 = __importDefault(require("sinon"));
const lodash_1 = __importDefault(require("lodash"));
const driver_1 = require("../../lib/driver");
const chai_1 = __importStar(require("chai"));
const chai_as_promised_1 = __importDefault(require("chai-as-promised"));
chai_1.default.use(chai_as_promised_1.default);
describe('language and locale', function () {
const LANGUAGE = 'en';
const LOCALE = 'en_US';
const BUNDLE_ID = 'com.test.app';
const DEFAULT_CAPS = {
elementResponseFields: undefined,
disableAutomaticScreenshots: undefined,
shouldUseCompactResponses: undefined,
waitForIdleTimeout: undefined,
shouldWaitForQuiescence: true,
shouldUseTestManagerForVisibilityDetection: false,
maxTypingFrequency: 60,
shouldTerminateApp: true,
forceAppLaunch: true,
forceSimulatorSoftwareKeyboardPresence: true,
useNativeCachingStrategy: true,
shouldUseSingletonTestManager: true,
eventloopIdleDelaySec: 0,
appLaunchStateTimeoutSec: undefined,
environment: {},
};
let mockDriver;
afterEach(function () {
if (mockDriver) {
mockDriver.verify();
}
});
describe('send only language and locale', function () {
it('should send translated POST /session request with valid desired caps to WDA', async function () {
const expectedWDACapabilities = {
capabilities: {
firstMatch: [
{
...DEFAULT_CAPS,
bundleId: BUNDLE_ID,
arguments: [
'-AppleLanguages',
`(${LANGUAGE})`,
'-NSLanguages',
`(${LANGUAGE})`,
'-AppleLocale',
LOCALE,
],
},
],
alwaysMatch: {},
},
};
const desiredCapabilities = {
platformName: 'iOS',
platformVersion: '9.3',
deviceName: 'iPhone 6',
app: 'testapp.app',
language: LANGUAGE,
locale: LOCALE,
bundleId: BUNDLE_ID,
};
const driver = new driver_1.XCUITestDriver(desiredCapabilities);
mockDriver = sinon_1.default.mock(driver);
mockDriver.expects('proxyCommand').once().withExactArgs('/session', 'POST', expectedWDACapabilities);
driver.validateDesiredCaps(desiredCapabilities);
await driver.startWdaSession(desiredCapabilities.bundleId, desiredCapabilities.processArguments);
});
});
describe('send process args, language and locale json', function () {
it('should send translated POST /session request with valid desired caps to WDA', async function () {
const processArguments = {
args: ['a', 'b', 'c'],
env: { a: 'b', c: 'd' },
};
const augmentedProcessArgumentsWithLanguage = {
args: [
...processArguments.args,
'-AppleLanguages',
`(${LANGUAGE})`,
'-NSLanguages',
`(${LANGUAGE})`,
'-AppleLocale',
LOCALE,
],
env: processArguments.env,
};
const expectedProcessArguments = lodash_1.default.cloneDeep(processArguments);
const expectedWDACapabilities = {
capabilities: {
firstMatch: [
{ ...DEFAULT_CAPS,
bundleId: BUNDLE_ID,
arguments: augmentedProcessArgumentsWithLanguage.args,
environment: processArguments.env,
},
],
alwaysMatch: {},
},
};
const desiredCapabilities = {
platformName: 'iOS',
platformVersion: '9.3',
deviceName: 'iPhone 6',
app: 'testapp.app',
language: LANGUAGE,
locale: LOCALE,
bundleId: BUNDLE_ID,
processArguments,
};
const driver = new driver_1.XCUITestDriver(desiredCapabilities);
mockDriver = sinon_1.default.mock(driver);
mockDriver.expects('proxyCommand').once().withExactArgs('/session', 'POST', expectedWDACapabilities);
driver.validateDesiredCaps(desiredCapabilities);
await driver.startWdaSession(desiredCapabilities.bundleId, desiredCapabilities.processArguments);
(0, chai_1.expect)(desiredCapabilities.processArguments).to.eql(expectedProcessArguments);
});
});
});
//# sourceMappingURL=language-specs.js.map