Skip to content

Commit 2c0dd63

Browse files
streamline geocountrycode option
1 parent a10ab78 commit 2c0dd63

File tree

9 files changed

+41
-38
lines changed

9 files changed

+41
-38
lines changed

src/cli.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ const espressoCommand = program
111111
)
112112
// Geolocation
113113
.option(
114-
'--geo-location <code>',
114+
'--geo-country-code <code>',
115115
'Geographic IP location (ISO country code, e.g., "US", "DE").',
116116
)
117117
// Network throttling
@@ -193,7 +193,7 @@ const espressoCommand = program
193193
language: args.language,
194194
locale: args.locale,
195195
timeZone: args.timezone,
196-
geoLocation: args.geoLocation,
196+
geoCountryCode: args.geoCountryCode,
197197
throttleNetwork: args.throttleNetwork,
198198
quiet: args.quiet,
199199
async: args.async,
@@ -501,7 +501,7 @@ const xcuitestCommand = program
501501
)
502502
// Geolocation
503503
.option(
504-
'--geo-location <code>',
504+
'--geo-country-code <code>',
505505
'Geographic IP location (ISO country code, e.g., "US", "DE").',
506506
)
507507
// Network throttling
@@ -576,7 +576,7 @@ const xcuitestCommand = program
576576
language: args.language,
577577
locale: args.locale,
578578
timeZone: args.timezone,
579-
geoLocation: args.geoLocation,
579+
geoCountryCode: args.geoCountryCode,
580580
throttleNetwork: args.throttleNetwork,
581581
quiet: args.quiet,
582582
async: args.async,

src/models/espresso_options.ts

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export interface EspressoCapabilities {
2727
phoneOnly?: boolean;
2828
name?: string;
2929
build?: string;
30+
'testingbot.geoCountryCode'?: string;
3031
}
3132

3233
export interface EspressoRunOptions {
@@ -42,8 +43,6 @@ export interface EspressoRunOptions {
4243
language?: string;
4344
locale?: string;
4445
timeZone?: string;
45-
// Geolocation
46-
geoLocation?: string;
4746
// Network throttling
4847
throttle_network?: ThrottleNetwork | CustomNetworkProfile;
4948
}
@@ -72,7 +71,7 @@ export default class EspressoOptions {
7271
private _locale?: string;
7372
private _timeZone?: string;
7473
// Geolocation
75-
private _geoLocation?: string;
74+
private _geoCountryCode?: string;
7675
// Network throttling
7776
private _throttleNetwork?: ThrottleNetwork | CustomNetworkProfile;
7877
// Execution mode
@@ -106,7 +105,7 @@ export default class EspressoOptions {
106105
language?: string;
107106
locale?: string;
108107
timeZone?: string;
109-
geoLocation?: string;
108+
geoCountryCode?: string;
110109
throttleNetwork?: ThrottleNetwork | CustomNetworkProfile;
111110
quiet?: boolean;
112111
async?: boolean;
@@ -144,7 +143,7 @@ export default class EspressoOptions {
144143
this._language = options?.language;
145144
this._locale = options?.locale;
146145
this._timeZone = options?.timeZone;
147-
this._geoLocation = options?.geoLocation;
146+
this._geoCountryCode = options?.geoCountryCode;
148147
this._throttleNetwork = options?.throttleNetwork;
149148
this._quiet = options?.quiet ?? false;
150149
this._async = options?.async ?? false;
@@ -234,8 +233,8 @@ export default class EspressoOptions {
234233
return this._timeZone;
235234
}
236235

237-
public get geoLocation(): string | undefined {
238-
return this._geoLocation;
236+
public get geoCountryCode(): string | undefined {
237+
return this._geoCountryCode;
239238
}
240239

241240
public get throttleNetwork():
@@ -281,6 +280,8 @@ export default class EspressoOptions {
281280
if (this._phoneOnly) caps.phoneOnly = true;
282281
if (this._name) caps.name = this._name;
283282
if (this._build) caps.build = this._build;
283+
if (this._geoCountryCode)
284+
caps['testingbot.geoCountryCode'] = this._geoCountryCode;
284285

285286
return caps;
286287
}
@@ -304,8 +305,6 @@ export default class EspressoOptions {
304305
if (this._language) opts.language = this._language;
305306
if (this._locale) opts.locale = this._locale;
306307
if (this._timeZone) opts.timeZone = this._timeZone;
307-
// Geolocation
308-
if (this._geoLocation) opts.geoLocation = this._geoLocation;
309308
// Network throttling
310309
if (this._throttleNetwork) opts.throttle_network = this._throttleNetwork;
311310

src/models/maestro_options.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export interface MaestroCapabilities {
2626
locale?: string;
2727
timeZone?: string;
2828
throttleNetwork?: ThrottleNetwork;
29-
geoCountryCode?: string;
29+
'testingbot.geoCountryCode'?: string;
3030
realDevice?: string;
3131
}
3232

@@ -290,7 +290,8 @@ export default class MaestroOptions {
290290
if (this._locale) caps.locale = this._locale;
291291
if (this._timeZone) caps.timeZone = this._timeZone;
292292
if (this._throttleNetwork) caps.throttleNetwork = this._throttleNetwork;
293-
if (this._geoCountryCode) caps.geoCountryCode = this._geoCountryCode;
293+
if (this._geoCountryCode)
294+
caps['testingbot.geoCountryCode'] = this._geoCountryCode;
294295
if (this._realDevice) caps.realDevice = 'true';
295296

296297
return caps;

src/models/xcuitest_options.ts

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export interface XCUITestCapabilities {
2727
phoneOnly?: boolean;
2828
name?: string;
2929
build?: string;
30+
'testingbot.geoCountryCode'?: string;
3031
}
3132

3233
export interface XCUITestRunOptions {
@@ -36,8 +37,6 @@ export interface XCUITestRunOptions {
3637
language?: string;
3738
locale?: string;
3839
timeZone?: string;
39-
// Geolocation
40-
geoLocation?: string;
4140
// Network throttling
4241
throttle_network?: ThrottleNetwork | CustomNetworkProfile;
4342
}
@@ -59,7 +58,7 @@ export default class XCUITestOptions {
5958
private _locale?: string;
6059
private _timeZone?: string;
6160
// Geolocation
62-
private _geoLocation?: string;
61+
private _geoCountryCode?: string;
6362
// Network throttling
6463
private _throttleNetwork?: ThrottleNetwork | CustomNetworkProfile;
6564
// Execution mode
@@ -86,7 +85,7 @@ export default class XCUITestOptions {
8685
language?: string;
8786
locale?: string;
8887
timeZone?: string;
89-
geoLocation?: string;
88+
geoCountryCode?: string;
9089
throttleNetwork?: ThrottleNetwork | CustomNetworkProfile;
9190
quiet?: boolean;
9291
async?: boolean;
@@ -117,7 +116,7 @@ export default class XCUITestOptions {
117116
this._language = options?.language;
118117
this._locale = options?.locale;
119118
this._timeZone = options?.timeZone;
120-
this._geoLocation = options?.geoLocation;
119+
this._geoCountryCode = options?.geoCountryCode;
121120
this._throttleNetwork = options?.throttleNetwork;
122121
this._quiet = options?.quiet ?? false;
123122
this._async = options?.async ?? false;
@@ -179,8 +178,8 @@ export default class XCUITestOptions {
179178
return this._timeZone;
180179
}
181180

182-
public get geoLocation(): string | undefined {
183-
return this._geoLocation;
181+
public get geoCountryCode(): string | undefined {
182+
return this._geoCountryCode;
184183
}
185184

186185
public get throttleNetwork():
@@ -226,6 +225,8 @@ export default class XCUITestOptions {
226225
if (this._phoneOnly) caps.phoneOnly = true;
227226
if (this._name) caps.name = this._name;
228227
if (this._build) caps.build = this._build;
228+
if (this._geoCountryCode)
229+
caps['testingbot.geoCountryCode'] = this._geoCountryCode;
229230

230231
return caps;
231232
}
@@ -239,8 +240,6 @@ export default class XCUITestOptions {
239240
if (this._language) opts.language = this._language;
240241
if (this._locale) opts.locale = this._locale;
241242
if (this._timeZone) opts.timeZone = this._timeZone;
242-
// Geolocation
243-
if (this._geoLocation) opts.geoLocation = this._geoLocation;
244243
// Network throttling
245244
if (this._throttleNetwork) opts.throttle_network = this._throttleNetwork;
246245

tests/cli.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ describe('TestingBotCTL CLI', () => {
115115
'test-app.apk',
116116
'--device',
117117
'Pixel 6',
118-
'--geo-location',
118+
'--geo-country-code',
119119
'DE',
120120
'--throttle-network',
121121
'3G',

tests/models/maestro_options.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ describe('MaestroOptions', () => {
196196
locale: 'en_GB',
197197
timeZone: 'Europe/London',
198198
throttleNetwork: 'Edge',
199-
geoCountryCode: 'GB',
199+
'testingbot.geoCountryCode': 'GB',
200200
realDevice: 'true', // IPA files require real devices
201201
});
202202
});
@@ -219,7 +219,7 @@ describe('MaestroOptions', () => {
219219
expect(caps).not.toHaveProperty('locale');
220220
expect(caps).not.toHaveProperty('timeZone');
221221
expect(caps).not.toHaveProperty('throttleNetwork');
222-
expect(caps).not.toHaveProperty('geoCountryCode');
222+
expect(caps).not.toHaveProperty('testingbot.geoCountryCode');
223223
});
224224

225225
it('should not include includeTags and excludeTags in capabilities', () => {

tests/providers/espresso.test.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -370,13 +370,13 @@ describe('Espresso', () => {
370370
);
371371
});
372372

373-
it('should send geolocation option when provided', async () => {
373+
it('should send geolocation as capability when provided', async () => {
374374
const optionsWithGeo = new EspressoOptions(
375375
'path/to/app.apk',
376376
'path/to/testApp.apk',
377377
'Pixel 6',
378378
{
379-
geoLocation: 'DE',
379+
geoCountryCode: 'DE',
380380
},
381381
);
382382
const espressoWithGeo = new Espresso(mockCredentials, optionsWithGeo);
@@ -390,9 +390,11 @@ describe('Espresso', () => {
390390
expect(axios.post).toHaveBeenCalledWith(
391391
expect.any(String),
392392
expect.objectContaining({
393-
espressoOptions: {
394-
geoLocation: 'DE',
395-
},
393+
capabilities: [
394+
expect.objectContaining({
395+
'testingbot.geoCountryCode': 'DE',
396+
}),
397+
],
396398
}),
397399
expect.any(Object),
398400
);

tests/providers/maestro.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ describe('Maestro', () => {
391391
locale: 'en_US',
392392
timeZone: 'America/New_York',
393393
throttleNetwork: '4G',
394-
geoCountryCode: 'US',
394+
'testingbot.geoCountryCode': 'US',
395395
},
396396
],
397397
}),

tests/providers/xcuitest.test.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -366,13 +366,13 @@ describe('XCUITest', () => {
366366
);
367367
});
368368

369-
it('should send geolocation option when provided', async () => {
369+
it('should send geolocation as capability when provided', async () => {
370370
const optionsWithGeo = new XCUITestOptions(
371371
'path/to/app.ipa',
372372
'path/to/testApp.zip',
373373
'iPhone 15',
374374
{
375-
geoLocation: 'DE',
375+
geoCountryCode: 'DE',
376376
},
377377
);
378378
const xcuiTestWithGeo = new XCUITest(mockCredentials, optionsWithGeo);
@@ -386,9 +386,11 @@ describe('XCUITest', () => {
386386
expect(axios.post).toHaveBeenCalledWith(
387387
expect.any(String),
388388
expect.objectContaining({
389-
options: {
390-
geoLocation: 'DE',
391-
},
389+
capabilities: [
390+
expect.objectContaining({
391+
'testingbot.geoCountryCode': 'DE',
392+
}),
393+
],
392394
}),
393395
expect.any(Object),
394396
);

0 commit comments

Comments
 (0)