Skip to content

Commit

Permalink
Revert "us-east-1 is not supported (#243)" (#247)
Browse files Browse the repository at this point in the history
This reverts commit e436faa.
  • Loading branch information
waggledans authored Aug 8, 2024
1 parent e436faa commit f2d65fa
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 11 deletions.
2 changes: 1 addition & 1 deletion apis/builds.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"region": {
"default": "us-west-1",
"description": "region of datacenter",
"enum": ["us-west-1", "us-east-4", "eu-central-1", "staging"]
"enum": ["us-west-1", "us-east-1", "eu-central-1", "staging"]
},
"tld": {
"default": "com",
Expand Down
2 changes: 1 addition & 1 deletion apis/sauce.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"region": {
"default": "us-west-1",
"description": "region of datacenter",
"enum": ["us-west-1", "us-east-4", "eu-central-1", "staging"]
"enum": ["us-west-1", "us-east-1", "eu-central-1", "staging"]
},
"tld": {
"default": "com",
Expand Down
2 changes: 1 addition & 1 deletion apis/teamManagement.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"region": {
"default": "us-west-1",
"description": "region of datacenter",
"enum": ["us-west-1", "us-east-4", "eu-central-1", "staging"]
"enum": ["us-west-1", "us-east-1", "eu-central-1", "staging"]
},
"tld": {
"default": "com",
Expand Down
2 changes: 1 addition & 1 deletion scripts/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export interface SauceLabsOptions {
*
* - us-west-1 (short 'us')
* - eu-central-1 (short 'eu')
* - us-east-4
* - us-east-1 (headless)
*/
region?: ${regions};
/**
Expand Down
2 changes: 1 addition & 1 deletion src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export const ASSET_REGION_MAPPING = {
us: '',
eu: 'eu-central-1.',
'us-west-1': '',
'us-east-4': 'us-east-4.',
'us-east-1': 'us-east-1.',
'eu-central-1': 'eu-central-1.',
staging: 'staging.',
};
Expand Down
9 changes: 7 additions & 2 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export function getRegionSubDomain(options = {}) {

if (options.region === 'us') region = 'us-west-1';
if (options.region === 'eu') region = 'eu-central-1';
if (options.headless) region = 'us-east-1';
return region;
}

Expand All @@ -45,7 +46,7 @@ export function getRegionSubDomain(options = {}) {
* @param {string} servers OpenAPI spec servers property
* @param {string} basePath OpenAPI spec base path
* @param {object} options client options
* @return {string} endpoint base url (e.g. `https://api.us-east-4.saucelabs.com`)
* @return {string} endpoint base url (e.g. `https://us-east1.headless.saucelabs.com`)
*/
export function getAPIHost(servers, basePath, options) {
/**
Expand Down Expand Up @@ -85,10 +86,14 @@ export function getAPIHost(servers, basePath, options) {
* helper to generate host for assets, like:
* https://assets.saucelabs.com/jobs/<jobId>/selenium-server.log
* https://assets.eu-central-1.saucelabs.com/jobs/<jobId>/log.json
* https://assets.us-east-4.saucelabs.com/jobs/<jobId>/log.json
* https://assets.us-east-1.saucelabs.com/jobs/<jobId>/log.json
* https://assets.staging.saucelabs.net/jobs/<jobId>/log.json
*/
export function getAssetHost(options) {
if (options.headless) {
options.region = 'us-east-1';
}

if (options.region === 'staging') {
options.tld = options.tld || 'net';
}
Expand Down
10 changes: 10 additions & 0 deletions tests/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,16 @@ test('should expose a webdriverEndpoint', () => {
'https://ondemand.eu-central-1.saucelabs.com/'
);

const api3 = new SauceLabs({
user: 'foo',
key: 'bar',
region: 'eu',
headless: true,
});
expect(api3.webdriverEndpoint).toBe(
'https://ondemand.us-east-1.saucelabs.com/'
);

const api4 = new SauceLabs({user: 'foo', key: 'bar', region: 'us-central-3'});
expect(api4.webdriverEndpoint).toBe(
'https://ondemand.us-central-3.saucelabs.com/'
Expand Down
17 changes: 13 additions & 4 deletions tests/utils.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,14 @@ test('getAPIHost', () => {
getAPIHost(sauceAPI.servers, sauceAPI.basePath, {region: 'us-west-1'})
).toBe('https://api.us-west-1.saucelabs.com/rest');
expect(
getAPIHost(sauceAPI.servers, sauceAPI.basePath, {region: 'us-east-4'})
).toBe('https://api.us-east-4.saucelabs.com/rest');
getAPIHost(sauceAPI.servers, sauceAPI.basePath, {region: 'us-east-1'})
).toBe('https://api.us-east-1.saucelabs.com/rest');
expect(
getAPIHost(sauceAPI.servers, sauceAPI.basePath, {
region: 'us-west-1',
headless: true,
})
).toBe('https://api.us-east-1.saucelabs.com/rest');
expect(
getAPIHost(sauceAPI.servers, sauceAPI.basePath, {host: 'http://foobar.com'})
).toBe('http://foobar.com/rest');
Expand Down Expand Up @@ -85,8 +91,11 @@ test('getAssetHost', () => {
expect(getAssetHost({region: 'eu-central-1'})).toBe(
'https://assets.eu-central-1.saucelabs.com'
);
expect(getAssetHost({region: 'us-east-4'})).toBe(
'https://assets.us-east-4.saucelabs.com'
expect(getAssetHost({headless: true})).toBe(
'https://assets.us-east-1.saucelabs.com'
);
expect(getAssetHost({headless: true, region: 'eu'})).toBe(
'https://assets.us-east-1.saucelabs.com'
);
expect(getAssetHost({region: 'staging'})).toBe(
'https://assets.staging.saucelabs.net'
Expand Down

0 comments on commit f2d65fa

Please sign in to comment.