Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add updatedWDABundleIdSuffix to handle bundle id for updatedWDABundleId with usePreinstalledWDA #871

Merged
merged 8 commits into from
Mar 26, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions lib/webdriveragent.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ class WebDriverAgent {
this.wdaLaunchTimeout = args.wdaLaunchTimeout || WDA_LAUNCH_TIMEOUT;
this.usePreinstalledWDA = args.usePreinstalledWDA;
this.xctestApiClient = null;
this.doNotAddXctrunnerSuffix = args.doNotAddXctrunnerSuffix;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about changing this cap to updatedWDABundleIdSuffix and have it equal to .xctrunner by default?
this way it would clearly be visible to where this capability belongs

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, it sounds good idea


this.xcodebuild = this.canSkipXcodebuild
? null
Expand Down Expand Up @@ -111,11 +112,17 @@ class WebDriverAgent {
}

/**
* Return bundle id for WebDriverAgent to launch the WDA.
* The primary usage is with 'this.usePreinstalledWDA'.
* It adds `.xctrunner` as suffix by default but 'this.doNotAddXctrunnerSuffix'
* lets skip it.
*
* @returns {string} Bundle ID for Xctest.
*/
get bundleIdForXctest () {
return this.updatedWDABundleId ? `${this.updatedWDABundleId}.xctrunner` : WDA_RUNNER_BUNDLE_ID_FOR_XCTEST;
mykola-mokhnach marked this conversation as resolved.
Show resolved Hide resolved
return this.updatedWDABundleId ?
`${this.updatedWDABundleId}${this.doNotAddXctrunnerSuffix ? '' : '.xctrunner'}`

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not quite sure we need to completely skip adding the suffix. There is a convention that xctest apps should have bundle ids ending with xctrunner. Perhaps it would be just enough to check if the id already ends with and then skip adding the suffix

Copy link
Member Author

@KazuCocoa KazuCocoa Mar 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bundle id can be non- .xctrunner when the bundle id in info.plist updated after wda build like downloading packages from https://github.com/appium/WebDriverAgent/releases and signed properly. XCTest session also can start with it.

: `${this.doNotAddXctrunnerSuffix ? WDA_RUNNER_BUNDLE_ID : WDA_RUNNER_BUNDLE_ID_FOR_XCTEST}`;
}

setWDAPaths (bootstrapPath, agentPath) {
Expand Down Expand Up @@ -449,7 +456,7 @@ class WebDriverAgent {
const {wdaBundleId, testBundleId} = await this.prepareWDA();
const env = {
USE_PORT: this.wdaRemotePort,
WDA_PRODUCT_BUNDLE_IDENTIFIER: this.updatedWDABundleId,
WDA_PRODUCT_BUNDLE_IDENTIFIER: this.bundleIdForXctest,
};
if (this.mjpegServerPort) {
env.MJPEG_SERVER_PORT = this.mjpegServerPort;
Expand Down
33 changes: 33 additions & 0 deletions test/unit/webdriveragent-specs.js
Original file line number Diff line number Diff line change
Expand Up @@ -340,3 +340,36 @@ describe('setupCaching()', function () {
});
});
});


describe('usePreinstalledWDA related functions', function () {
describe('bundleIdForXctest', function () {
it('should have xctrunner automatically', function () {
const args = Object.assign({}, fakeConstructorArgs);
args.updatedWDABundleId = 'io.appium.wda';
const agent = new WebDriverAgent({}, args);
agent.bundleIdForXctest.should.equal('io.appium.wda.xctrunner');
});

it('should have xctrunner automatically with default bundle id', function () {
const args = Object.assign({}, fakeConstructorArgs);
const agent = new WebDriverAgent({}, args);
agent.bundleIdForXctest.should.equal('com.facebook.WebDriverAgentRunner.xctrunner');
});

it('should not have xctrunner suffix', function () {
const args = Object.assign({}, fakeConstructorArgs);
args.updatedWDABundleId = 'io.appium.wda';
args.doNotAddXctrunnerSuffix = true;
const agent = new WebDriverAgent({}, args);
agent.bundleIdForXctest.should.equal('io.appium.wda');
});

it('should have xctrunner automatically with default bundle id', function () {
const args = Object.assign({}, fakeConstructorArgs);
args.doNotAddXctrunnerSuffix = true;
const agent = new WebDriverAgent({}, args);
agent.bundleIdForXctest.should.equal('com.facebook.WebDriverAgentRunner');
});
});
});
Loading