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

#988 change filter capabity from host to filterByHost #989

Merged
merged 4 commits into from
Feb 5, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion docs/capabilities.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ title: Capabilities
| appium:platformVersion | This capability is used to filter devices/simulators based on SDK. Only devices/simulators that are an exact match with the platformVerson would be considered for test run. `appium:platformVersion` is optional argument. ex: `'appium:platformVersion': 16.1.1` |
| appium:minSDK | This capability is used to filter devices/simulators based on SDK. Devices/Simulators with SDK greater then or equal to minSDK would only be considered for test run. `appium:minSDK` is optional argument. ex: `'appium:minSDK': 15` |
| appium:maxSDK | This capability is used to filter devices/simulators based on SDK. Devices/Simulators with SDK less then or equal to maxSDK would only be considered for test run. `appium:maxSDK` is optional argument. ex: `'appium:maxSDK': 15` |
| host | This capability is used to filter devices/simulators based on node IP. This will only consider devices from specific node. `host` is optional argument. ex: `'host': '192.168.0.226',` |
| appium:filterByHost | This capability is used to filter devices/simulators based on node IP. This will only consider devices from specific node. `host` is optional argument. ex: `'host': '192.168.0.226',` |
15 changes: 13 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "appium-device-farm",
"version": "8.4.7-rc.6",
"version": "8.4.7-rc.7",
"description": "An appium 2.0 plugin that manages and create driver session on available devices",
"main": "./lib/src/index.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion server-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"port": 31337,
"plugin": {
"device-farm": {
"platform": "ios",
"platform": "android",
"skipChromeDownload": true
}
}
Expand Down
5 changes: 2 additions & 3 deletions src/data-service/device-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,8 @@ export async function getDevices(filterOptions: IDeviceFilterOptions): Promise<I
case 'session_id':
filter.session_id = filterOptions.session_id;
break;
case 'host':
filter.host = { $contains: filterOptions.host };
case 'filterByHost':
filter.host = { $contains: filterOptions.filterByHost };
break;
case 'minSDK':
if (semver.coerce(filterOptions.minSDK)) {
Expand Down Expand Up @@ -204,7 +204,6 @@ export async function getDevices(filterOptions: IDeviceFilterOptions): Promise<I
// if (filterOptions.deviceType === 'simulator') {
// filter.state = 'Booted'; // Needs a fix
// }

const matchingDevices = results.find(filter).data();
// use the following debugging tools to debug this function
/*
Expand Down
4 changes: 2 additions & 2 deletions src/device-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ const customCapability = {
udids: 'appium:udids',
minSDK: 'appium:minSDK',
maxSDK: 'appium:maxSDK',
filterByHost: 'appium:filterByHost',
};

let timer: any;
Expand Down Expand Up @@ -281,7 +282,6 @@ export function getDeviceFiltersFromCapability(
} else if (capability[customCapability.iphoneOnly]) {
name = 'iPhone';
}

let caps = {
platform,
platformVersion: capability['appium:platformVersion']
Expand All @@ -292,7 +292,7 @@ export function getDeviceFiltersFromCapability(
udid: udids?.length ? udids : capability['appium:udid'],
busy: false,
userBlocked: false,
host: capability['host'],
filterByHost: capability[customCapability.filterByHost],
minSDK: capability[customCapability.minSDK] ? capability[customCapability.minSDK] : undefined,
maxSDK: capability[customCapability.maxSDK] ? capability[customCapability.maxSDK] : undefined,
};
Expand Down
2 changes: 1 addition & 1 deletion src/interfaces/IDeviceFilterOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ export interface IDeviceFilterOptions {
minSDK?: string;
maxSDK?: string;
session_id?: string;
host?: string;
filterByHost?: string;
}
4 changes: 2 additions & 2 deletions test/unit/device-utils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ describe('Device Utils', () => {
'appium:app': '/Downloads/VodQA.apk',
'appium:deviceAvailabilityTimeout': 1800,
'appium:deviceRetryInterval': 100,
host: '192.168.0.226',
'appium:filterByHost': '192.168.0.226',
},
firstMatch: [{}],
};
Expand Down Expand Up @@ -144,7 +144,7 @@ describe('Device Utils', () => {
.to.be.an('error')
.with.property(
'message',
'Device is busy or blocked.. Device request: {"platform":"android","udid":"emulator-5555","host":"192.168.0.226"}',
'Device is busy or blocked.. Device request: {"platform":"android","udid":"emulator-5555","filterByHost":"192.168.0.226"}',
),
);
});
Expand Down
6 changes: 3 additions & 3 deletions test/unit/plugin.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ describe('Device filter tests', () => {
udid: '21112-1111-1111-111',
minSDK: undefined,
maxSDK: undefined,
host: undefined,
filterByHost: undefined,
busy: false,
userBlocked: false,
});
Expand Down Expand Up @@ -64,7 +64,7 @@ describe('Device filter tests', () => {
platform: 'ios',
platformVersion: '14.0',
name: 'iPhone',
host: undefined,
filterByHost: undefined,
deviceType: 'simulator',
udid: undefined,
minSDK: undefined,
Expand All @@ -88,7 +88,7 @@ describe('Device filter tests', () => {
const filter = getDeviceFiltersFromCapability(firstMatch, pluginArgs);
expect(filter).to.deep.equal({
platform: 'ios',
host: undefined,
filterByHost: undefined,
platformVersion: undefined,
name: 'iPhone',
deviceType: 'simulator',
Expand Down
Loading