appium-xcuitest-driver
Version:
Appium driver for iOS using XCUITest for backend
101 lines • 4.47 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 app_infos_cache_1 = require("../../lib/app-infos-cache");
const support_1 = require("appium/support");
const node_path_1 = __importDefault(require("node:path"));
const logger_1 = require("../../lib/logger");
const setup_1 = require("../setup");
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('AppInfosCache', function () {
describe('retrives info from different types of apps', function () {
let ipaPath;
let appPath;
/** @type {AppInfosCache} */
let cache;
before(async function () {
// Download the UIKitCatalog app dynamically
appPath = await (0, setup_1.getUIKitCatalogPath)();
const tmpDir = await support_1.tempDir.openDir();
try {
const destDir = node_path_1.default.join(tmpDir, 'Payload', 'UIKitCatalog-iphonesimulator.app');
await support_1.fs.mkdirp(destDir);
await support_1.fs.copyFile(appPath, destDir);
ipaPath = await support_1.tempDir.path({
prefix: 'foo',
suffix: '.ipa',
});
await support_1.zip.toArchive(ipaPath, {
cwd: tmpDir,
});
}
finally {
await support_1.fs.rimraf(tmpDir);
}
});
after(async function () {
if (ipaPath && await support_1.fs.exists(ipaPath)) {
await support_1.fs.rimraf(ipaPath);
ipaPath = undefined;
}
});
beforeEach(function () {
cache = new app_infos_cache_1.AppInfosCache(logger_1.log);
});
it('should cache ipa', async function () {
const info = await cache.put(ipaPath);
(0, chai_1.expect)(info.CFBundleIdentifier).to.eql(setup_1.UICATALOG_BUNDLE_ID);
const info2 = await cache.put(ipaPath);
(0, chai_1.expect)(info).to.equal(info2);
});
it('should cache app', async function () {
const info = await cache.put(appPath);
(0, chai_1.expect)(info.CFBundleIdentifier).to.eql(setup_1.UICATALOG_BUNDLE_ID);
const info2 = await cache.put(appPath);
(0, chai_1.expect)(info).to.equal(info2);
});
it('should extract cached info', async function () {
await (0, chai_1.expect)(cache.extractAppPlatforms(appPath)).to.eventually.eql(['iPhoneSimulator']);
await (0, chai_1.expect)(cache.extractBundleId(ipaPath)).to.eventually.eql(setup_1.UICATALOG_BUNDLE_ID);
await (0, chai_1.expect)(cache.extractExecutableName(ipaPath)).to.eventually.eql('UIKitCatalog');
});
});
});
//# sourceMappingURL=app-infos-cache-specs.js.map