Skip to content

Commit

Permalink
Fix headless endpoint (#3876)
Browse files Browse the repository at this point in the history
* fix headless endpoint

* fix unit test

* fix unit test
  • Loading branch information
christian-bromann authored and abjerstedt committed Apr 26, 2019
1 parent 9c84d06 commit a4a568f
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 20 deletions.
19 changes: 4 additions & 15 deletions packages/wdio-config/src/utils.js
Expand Up @@ -6,18 +6,16 @@ const REGION_MAPPING = {
'us': '', // default endpoint
'eu': 'eu-central-1.',
'eu-central-1': 'eu-central-1.',
'us-east-1': 'us-east1.'
'us-east-1': 'us-east-1.'
}

export function getSauceEndpoint (region, isRDC, isHeadless) {
export function getSauceEndpoint (region, isRDC) {
const shortRegion = REGION_MAPPING[region] ? region : 'us'
const product = isHeadless ? 'headless.' : ''

if (isRDC){
return `${shortRegion}1.appium.testobject.com`
}

return `ondemand.${REGION_MAPPING[shortRegion]}${product}saucelabs.com`
return `ondemand.${REGION_MAPPING[shortRegion]}saucelabs.com`
}

/**
Expand Down Expand Up @@ -62,18 +60,9 @@ export function detectBackend (options = {}, isRDC = false) {
// Sauce headless is currently only in us-east-1
const sauceRegion = headless ? 'us-east-1' : region

/**
* headless runs not over SSL which might change soon
* see https://wiki.saucelabs.com/display/DOCS/Sauce+Headless+Beta
*/
if (headless) {
protocol = 'http'
port = 4444
}

return {
protocol: protocol || 'https',
hostname: hostname || getSauceEndpoint(sauceRegion, isRDC, headless),
hostname: hostname || getSauceEndpoint(sauceRegion, isRDC),
port: port || 443
}
}
Expand Down
6 changes: 3 additions & 3 deletions packages/wdio-config/tests/detectBackend.test.js
Expand Up @@ -133,9 +133,9 @@ describe('detectBackend', () => {
region: 'eu',
headless: true
})
expect(caps.hostname).toBe('ondemand.us-east1.headless.saucelabs.com')
expect(caps.port).toBe(4444)
expect(caps.protocol).toBe('http')
expect(caps.hostname).toBe('ondemand.us-east-1.saucelabs.com')
expect(caps.port).toBe(443)
expect(caps.protocol).toBe('https')
})

it('should throw if user and key are given but can not be connected to a cloud', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/wdio-spec-reporter/src/index.js
Expand Up @@ -97,7 +97,7 @@ class SpecReporter extends WDIOReporter {
getTestLink ({ config, sessionId }) {
if (config.hostname.includes('saucelabs')) {
const dc = config.headless
? '.us-east1.headless'
? '.us-east-1'
: ['eu', 'eu-central-1'].includes(config.region) ? '.eu-central-1' : ''
return ['', `Check out job at https://app${dc}.saucelabs.com/tests/${sessionId}`]
}
Expand Down
2 changes: 1 addition & 1 deletion packages/wdio-spec-reporter/tests/__fixtures__/testdata.js
Expand Up @@ -180,5 +180,5 @@ export const SAUCELABS_EU_REPORT = REPORT + `[loremipsum #0-0]
`

export const SAUCELABS_HEADLESS_REPORT = REPORT + `[loremipsum #0-0]
[loremipsum #0-0] Check out job at https://app.us-east1.headless.saucelabs.com/tests/ba86cbcb70774ef8a0757c1702c3bdf9
[loremipsum #0-0] Check out job at https://app.us-east-1.saucelabs.com/tests/ba86cbcb70774ef8a0757c1702c3bdf9
`

0 comments on commit a4a568f

Please sign in to comment.