appium-xcuitest-driver
Version:
Appium driver for iOS using XCUITest for backend
131 lines • 5.46 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_utils_1 = require("../../lib/app-utils");
const support_1 = require("appium/support");
const node_path_1 = __importDefault(require("node:path"));
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('app-utils', function () {
let uiCatalogAppPath;
before(async function () {
// Download the UIKitCatalog app dynamically
uiCatalogAppPath = await (0, setup_1.getUIKitCatalogPath)();
});
describe('unzipStream', function () {
it('should unzip from stream', async function () {
try {
await support_1.fs.which('bsdtar');
}
catch {
return;
}
const tmpDir = await support_1.tempDir.openDir();
let appRoot;
let srcStream;
try {
const tmpSrc = node_path_1.default.join(tmpDir, 'temp.zip');
await support_1.zip.toArchive(tmpSrc, {
cwd: uiCatalogAppPath,
});
srcStream = support_1.fs.createReadStream(tmpSrc);
({ rootDir: appRoot } = await (0, app_utils_1.unzipStream)(srcStream));
await (0, chai_1.expect)(support_1.fs.exists(node_path_1.default.resolve(appRoot, 'Info.plist'))).to.eventually.be.true;
}
finally {
await support_1.fs.rimraf(tmpDir);
if (appRoot) {
await support_1.fs.rimraf(appRoot);
}
}
});
it('should fail for invalid archives', async function () {
try {
await support_1.fs.which('bsdtar');
}
catch {
return;
}
const tmpDir = await support_1.tempDir.openDir();
let srcStream;
try {
const tmpSrc = node_path_1.default.join(tmpDir, 'Info.plist');
await support_1.fs.copyFile(node_path_1.default.join(uiCatalogAppPath, 'Info.plist'), tmpSrc);
srcStream = support_1.fs.createReadStream(tmpSrc);
await (0, chai_1.expect)((0, app_utils_1.unzipStream)(srcStream)).to.be.rejected;
}
finally {
await support_1.fs.rimraf(tmpDir);
}
});
});
describe('unzipFile', function () {
it('should unzip from file', async function () {
const tmpDir = await support_1.tempDir.openDir();
let appRoot;
try {
const tmpSrc = node_path_1.default.join(tmpDir, 'temp.zip');
await support_1.zip.toArchive(tmpSrc, {
cwd: uiCatalogAppPath,
});
({ rootDir: appRoot } = await (0, app_utils_1.unzipFile)(tmpSrc));
await (0, chai_1.expect)(support_1.fs.exists(node_path_1.default.resolve(appRoot, 'Info.plist'))).to.eventually.be.true;
}
finally {
await support_1.fs.rimraf(tmpDir);
if (appRoot) {
await support_1.fs.rimraf(appRoot);
}
}
});
it('should fail for invalid archives', async function () {
const tmpDir = await support_1.tempDir.openDir();
try {
const tmpSrc = node_path_1.default.join(tmpDir, 'Info.plist');
await support_1.fs.copyFile(node_path_1.default.join(uiCatalogAppPath, 'Info.plist'), tmpSrc);
await (0, chai_1.expect)((0, app_utils_1.unzipFile)(tmpSrc)).to.be.rejected;
}
finally {
await support_1.fs.rimraf(tmpDir);
}
});
});
});
//# sourceMappingURL=app-utils-specs.js.map