From 4feaf336dae242605543fb84d5c7b40aa5103470 Mon Sep 17 00:00:00 2001 From: Kazuaki Matsuo Date: Sat, 30 Sep 2023 22:41:18 -0700 Subject: [PATCH] fix: get bundleId for other apps before calling installation (#2054) --- lib/driver.js | 5 +++-- test/unit/driver-specs.js | 20 ++++++++++++++------ 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/lib/driver.js b/lib/driver.js index 62d781ad8..55d8186d7 100644 --- a/lib/driver.js +++ b/lib/driver.js @@ -1724,12 +1724,13 @@ class XCUITestDriver extends BaseDriver { /** @type {string[]} */ (appsList).map((app) => this.helpers.configureApp(app, '.app')), ); for (const otherApp of appPaths) { + const otherAppBundleId = await extractBundleId.bind(this)(otherApp); if (this.isRealDevice()) { await installToRealDevice( // @ts-expect-error - do not assign arbitrary properties to `this.opts` this.opts.device, otherApp, - undefined, + otherAppBundleId, { skipUninstall: true, // to make the behavior as same as UIA2 timeout: this.opts.appPushTimeout, @@ -1741,7 +1742,7 @@ class XCUITestDriver extends BaseDriver { // @ts-expect-error - do not assign arbitrary properties to `this.opts` this.opts.device, otherApp, - undefined, + otherAppBundleId, { newSimulator: this.lifecycleData.createSim, }, diff --git a/test/unit/driver-specs.js b/test/unit/driver-specs.js index a57d8f48b..7d5fd2ed2 100644 --- a/test/unit/driver-specs.js +++ b/test/unit/driver-specs.js @@ -275,6 +275,7 @@ describe('XCUITestDriver', function () { sandbox.stub(RealDeviceManagementModule, 'installToRealDevice'); sandbox.stub(driver, 'isRealDevice').returns(true); sandbox.stub(driver.helpers, 'configureApp').resolves('/path/to/iosApp.app'); + sandbox.stub(appUtils, 'extractBundleId').resolves('bundle-id'); // @ts-expect-error random stuff on opts driver.opts.device = 'some-device'; driver.lifecycleData = {createSim: false}; @@ -284,7 +285,7 @@ describe('XCUITestDriver', function () { expect(RealDeviceManagementModule.installToRealDevice).to.have.been.calledOnceWith( 'some-device', '/path/to/iosApp.app', - undefined, + 'bundle-id', {skipUninstall: true, timeout: undefined, strategy: undefined}, ); }); @@ -296,6 +297,9 @@ describe('XCUITestDriver', function () { const configureAppStub = sandbox.stub(driver.helpers, 'configureApp'); configureAppStub.onCall(0).resolves('/path/to/iosApp1.app'); configureAppStub.onCall(1).resolves('/path/to/iosApp2.app'); + sandbox.stub(appUtils, 'extractBundleId') + .onCall(0).resolves('bundle-id') + .onCall(1).resolves('bundle-id2'); // @ts-expect-error random stuff on opts driver.opts.device = 'some-device'; driver.lifecycleData = {createSim: false}; @@ -305,13 +309,13 @@ describe('XCUITestDriver', function () { expect(RealDeviceManagementModule.installToRealDevice).to.have.been.calledWith( 'some-device', '/path/to/iosApp1.app', - undefined, + 'bundle-id', {skipUninstall: true, timeout: undefined, strategy: undefined}, ); expect(RealDeviceManagementModule.installToRealDevice).to.have.been.calledWith( 'some-device', '/path/to/iosApp2.app', - undefined, + 'bundle-id2', {skipUninstall: true, timeout: undefined, strategy: undefined}, ); }); @@ -321,6 +325,7 @@ describe('XCUITestDriver', function () { sandbox.stub(SimulatorManagementModule, 'installToSimulator'); sandbox.stub(driver, 'isRealDevice').returns(false); sandbox.stub(driver.helpers, 'configureApp').resolves('/path/to/iosApp.app'); + sandbox.stub(appUtils, 'extractBundleId').resolves('bundle-id'); driver.opts.noReset = false; // @ts-expect-error random stuff on opts driver.opts.device = 'some-device'; @@ -331,7 +336,7 @@ describe('XCUITestDriver', function () { expect(SimulatorManagementModule.installToSimulator).to.have.been.calledOnceWith( 'some-device', '/path/to/iosApp.app', - undefined, + 'bundle-id', {newSimulator: false}, ); }); @@ -343,6 +348,9 @@ describe('XCUITestDriver', function () { const configureAppStub = sandbox.stub(driver.helpers, 'configureApp'); configureAppStub.onCall(0).resolves('/path/to/iosApp1.app'); configureAppStub.onCall(1).resolves('/path/to/iosApp2.app'); + sandbox.stub(appUtils, 'extractBundleId') + .onCall(0).resolves('bundle-id') + .onCall(1).resolves('bundle-id2'); driver.opts.noReset = false; // @ts-expect-error random stuff on opts driver.opts.device = 'some-device'; @@ -353,13 +361,13 @@ describe('XCUITestDriver', function () { expect(SimulatorManagementModule.installToSimulator).to.have.been.calledWith( 'some-device', '/path/to/iosApp1.app', - undefined, + 'bundle-id', {newSimulator: false}, ); expect(SimulatorManagementModule.installToSimulator).to.have.been.calledWith( 'some-device', '/path/to/iosApp2.app', - undefined, + 'bundle-id2', {newSimulator: false}, ); });