UNPKG

appium-xcuitest-driver

Version:

Appium driver for iOS using XCUITest for backend

111 lines 5.53 kB
"use strict"; 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 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('alert commands', function () { const driver = new driver_1.XCUITestDriver({}); const proxySpy = sinon_1.default.stub(driver, 'proxyCommand'); afterEach(function () { proxySpy.reset(); }); describe('getAlertText', function () { it('should send translated GET request to WDA', async function () { await driver.getAlertText(); (0, chai_1.expect)(proxySpy.calledOnce).to.be.true; (0, chai_1.expect)(proxySpy.firstCall.args[0]).to.eql('/alert/text'); (0, chai_1.expect)(proxySpy.firstCall.args[1]).to.eql('GET'); }); }); describe('setAlertText', function () { it('should send translated POST request to WDA', async function () { await driver.setAlertText('some text'); (0, chai_1.expect)(proxySpy.calledOnceWithExactly('/alert/text', 'POST', { value: 'some text' })).to.be.true; }); }); describe('postAcceptAlert', function () { it('should send translated POST request to WDA', async function () { await driver.postAcceptAlert(); (0, chai_1.expect)(proxySpy.calledOnce).to.be.true; (0, chai_1.expect)(proxySpy.firstCall.args[0]).to.eql('/alert/accept'); (0, chai_1.expect)(proxySpy.firstCall.args[1]).to.eql('POST'); }); }); describe('postDismissAlert', function () { it('should send translated POST request to WDA', async function () { await driver.postDismissAlert(); (0, chai_1.expect)(proxySpy.calledOnce).to.be.true; (0, chai_1.expect)(proxySpy.firstCall.args[0]).to.eql('/alert/dismiss'); (0, chai_1.expect)(proxySpy.firstCall.args[1]).to.eql('POST'); }); }); describe('mobile: alert', function () { const commandName = 'alert'; it('should reject request to WDA if action parameter is not supported', async function () { await (0, chai_1.expect)(driver.execute(`mobile: ${commandName}`, { action: 'blabla' })).to.be.rejectedWith(/should be either/); }); it('should send accept alert request to WDA with encoded button label', async function () { const buttonLabel = 'some label'; await driver.execute(`mobile: ${commandName}`, { action: 'accept', buttonLabel }); (0, chai_1.expect)(proxySpy.calledOnceWithExactly('/alert/accept', 'POST', { name: buttonLabel })).to.be.true; }); it('should send dimsiss alert request to WDA if button label is not provided', async function () { await driver.execute(`mobile: ${commandName}`, { action: 'dismiss' }); (0, chai_1.expect)(proxySpy.calledOnce).to.be.true; (0, chai_1.expect)(proxySpy.firstCall.args[0]).to.eql(`/alert/dismiss`); (0, chai_1.expect)(proxySpy.firstCall.args[1]).to.eql('POST'); }); it('should send get alert buttons request to WDA', async function () { const buttonLabel = 'OK'; proxySpy.resolves({ value: [buttonLabel], sessionId: '05869B62-C559-43AD-A343-BAACAAE00CBB', status: 0, }); const response = /** @type { {value: string[]} } */ (await driver.execute(`mobile: ${commandName}`, { action: 'getButtons' })); (0, chai_1.expect)(proxySpy.calledOnce).to.be.true; (0, chai_1.expect)(proxySpy.firstCall.args[0]).to.eql('/wda/alert/buttons'); (0, chai_1.expect)(proxySpy.firstCall.args[1]).to.eql('GET'); (0, chai_1.expect)(response.value[0]).to.eq(buttonLabel); }); }); }); //# sourceMappingURL=alert-specs.js.map