Skip to content

Commit

Permalink
fix: get bundleId for other apps before calling installation (#2054)
Browse files Browse the repository at this point in the history
  • Loading branch information
KazuCocoa authored Oct 1, 2023
1 parent 91ec8bf commit 4feaf33
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
5 changes: 3 additions & 2 deletions lib/driver.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
},
Expand Down
20 changes: 14 additions & 6 deletions test/unit/driver-specs.js
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand All @@ -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},
);
});
Expand All @@ -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};
Expand All @@ -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},
);
});
Expand All @@ -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';
Expand All @@ -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},
);
});
Expand All @@ -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';
Expand All @@ -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},
);
});
Expand Down

0 comments on commit 4feaf33

Please sign in to comment.