Skip to content

Commit

Permalink
us-east-1 dc is not mapped to headless env anymore
Browse files Browse the repository at this point in the history
  • Loading branch information
waggledans committed Aug 7, 2024
1 parent 47ab484 commit 945e1a9
Show file tree
Hide file tree
Showing 12 changed files with 16 additions and 46 deletions.
4 changes: 0 additions & 4 deletions scripts/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,6 @@ export interface SauceLabsOptions {
* - us-east-4 (short 'us-east')
*/
region?: ${regions};
/**
* If set to true you are accessing the headless Sauce instances (this discards the region option).
*/
headless?: boolean;
/**
* If you want to tunnel your API request through a proxy please provide your proxy URL.
*/
Expand Down
1 change: 0 additions & 1 deletion scripts/generate-typings.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ fs.readdir(path.join(__dirname, '../apis'), (err, files) => {
username: string;
region: string;
tld: string;
headless: boolean;
webdriverEndpoint: string;\n\n
${methods}
}
Expand Down
6 changes: 4 additions & 2 deletions src/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,20 @@ export const run = () => {
}
},
async (argv) => {
const {user, key, headless, region, proxy, tld} = Object.assign(
const {user, key, region, proxy, tld} = Object.assign(
{},
DEFAULT_OPTIONS,
argv
);
const api = new SauceLabs({user, key, headless, region, proxy, tld});
const api = new SauceLabs({user, key, region, proxy, tld});
const requiredParams = params
.filter((p) => p.required)
.map((p) => argv[p.name]);

try {
const result = await api[commandName](...requiredParams, argv);
console.log(commandName);
console.log(requiredParams);

if (typeof result === 'object') {
// eslint-disable-next-line no-console
Expand Down
8 changes: 2 additions & 6 deletions src/commands/sc.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,7 @@ export const builder = (yargs) => {
}
};
export const handler = async (argv) => {
const {user, key, headless, region, proxy} = Object.assign(
{},
DEFAULT_OPTIONS,
argv
);
const api = new SauceLabs({user, key, headless, region, proxy});
const {user, key, region, proxy} = Object.assign({}, DEFAULT_OPTIONS, argv);
const api = new SauceLabs({user, key, region, proxy});
return api.startSauceConnect(argv, true);
};
8 changes: 0 additions & 8 deletions src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ export const JOB_ASSET_NAMES = [
export const DEFAULT_OPTIONS = {
user: process.env.SAUCE_USERNAME,
key: process.env.SAUCE_ACCESS_KEY,
headless: false,
region: 'us',
proxy: process.env.HTTPS_PROXY || process.env.HTTP_PROXY,
headers: {'User-Agent': `saucelabs/v${version} (nodejs ${os.platform()})`},
Expand Down Expand Up @@ -137,13 +136,6 @@ export const CLI_PARAMS = [
description:
'your Sauce Labs datacenter region, the following regions are available: `us-west-1` (short `us`), `eu-central-1` (short `eu`)',
},
{
name: 'headless',
default: DEFAULT_OPTIONS.headless,
description:
'if set to true you are accessing the headless Sauce instances (this discards the `region` option)',
boolean: true,
},
{
alias: 'p',
name: 'proxy',
Expand Down
2 changes: 0 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ export default class SauceLabs {
*/
this.region = this._options.region;
this.tld = this._options.tld;
this.headless = this._options.headless;
this.webdriverEndpoint = `https://ondemand.${getRegionSubDomain(
options
)}.saucelabs.com/`;
Expand All @@ -84,7 +83,6 @@ export default class SauceLabs {
-6
)}`,
region: this._options.region,
headless: this._options.headless,
proxy: this._options.proxy,
webdriverEndpoint: this.webdriverEndpoint,
headers: this._options.headers,
Expand Down
1 change: 0 additions & 1 deletion src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ export function toString(scope) {
username: '${scope.username}',
key: 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXX${scope._accessKey.slice(-6)}',
region: '${scope._options.region}',
headless: ${scope._options.headless},
proxy: ${scope._options.proxy}
}`;
}
Expand Down
2 changes: 0 additions & 2 deletions tests/cli.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ test('should be able to execute a command', async () => {
const params = {
user: 'foobaruser',
key: 'barfookey',
headless: true,
region: 'anywhere',
username: 'username-param',
limit: 42,
Expand All @@ -62,7 +61,6 @@ test('should be able to execute a command', async () => {
expect(api.options).toEqual({
user: 'foobaruser',
key: 'barfookey',
headless: true,
region: 'anywhere',
});
expect(api.listJobs).toBeCalledWith('username-param', params);
Expand Down
8 changes: 1 addition & 7 deletions tests/commands/sc.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {builder, handler} from '../../src/commands/sc';
import {builder} from '../../src/commands/sc';

jest.mock('../../src/index', () => {
class SauceLabsMock {
Expand All @@ -19,9 +19,3 @@ test('builder', () => {
builder(yargs);
expect(yargs.option).toBeCalledWith('tunnel-name', expect.any(Object));
});

test('handler', async () => {
const api = await handler({headless: true});
expect(api.scStarted).toBe(true);
expect(api.startSauceConnect).toBeCalledWith({headless: true}, true);
});
17 changes: 8 additions & 9 deletions tests/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ test('should be inspectable', () => {
username: 'foo',
key: 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXbar',
region: 'us',
headless: false,
proxy: undefined`);
});

Expand Down Expand Up @@ -453,7 +452,7 @@ test('should contain custom headers', async () => {
describe('startSauceConnect', () => {
it('should start sauce connect with proper parsed args', async () => {
const logs = [];
const api = new SauceLabs({user: 'foo', key: 'bar', headless: true});
const api = new SauceLabs({user: 'foo', key: 'bar'});
setTimeout(
() =>
stdoutEmitter.emit(
Expand All @@ -479,7 +478,7 @@ describe('startSauceConnect', () => {

it('should start sauce connect with latest version if no version is specified in the args', async () => {
const logs = [];
const api = new SauceLabs({user: 'foo', key: 'bar', headless: true});
const api = new SauceLabs({user: 'foo', key: 'bar'});
got.mockReturnValue(
Promise.resolve({
body: {
Expand All @@ -506,7 +505,7 @@ describe('startSauceConnect', () => {

it('should start sauce connect with fallback default version in case the call to the API failed', async () => {
const logs = [];
const api = new SauceLabs({user: 'foo', key: 'bar', headless: true});
const api = new SauceLabs({user: 'foo', key: 'bar'});
got.mockImplementation(() => {
throw new Error('Endpoint not available!');
});
Expand All @@ -528,7 +527,7 @@ describe('startSauceConnect', () => {

it('should properly fail if connection could not be established', async () => {
const errMessage = 'Sauce Connect could not establish a connection';
const api = new SauceLabs({user: 'foo', key: 'bar', headless: true});
const api = new SauceLabs({user: 'foo', key: 'bar'});
setTimeout(() => stdoutEmitter.emit('data', errMessage), 50);
const err = await api
.startSauceConnect({
Expand All @@ -542,7 +541,7 @@ describe('startSauceConnect', () => {

it('should properly fail if user is not authorized', async () => {
const errMessage = 'Sauce Connect failed to start - 401 (Unauthorized).';
const api = new SauceLabs({user: 'foo', key: 'bar', headless: true});
const api = new SauceLabs({user: 'foo', key: 'bar'});
setTimeout(() => stdoutEmitter.emit('data', errMessage), 50);
const err = await api
.startSauceConnect({
Expand All @@ -555,7 +554,7 @@ describe('startSauceConnect', () => {
});

it('should close sauce connect', async () => {
const api = new SauceLabs({user: 'foo', key: 'bar', headless: true});
const api = new SauceLabs({user: 'foo', key: 'bar'});
setTimeout(
() =>
stdoutEmitter.emit(
Expand All @@ -577,7 +576,7 @@ describe('startSauceConnect', () => {
});

it('should fail if stderr is emitted', async () => {
const api = new SauceLabs({user: 'foo', key: 'bar', headless: true});
const api = new SauceLabs({user: 'foo', key: 'bar'});
setTimeout(() => stderrEmitter.emit('data', 'Uuups'), 50);
const res = await api
.startSauceConnect({tunnelIdentifier: 'my-tunnel'})
Expand All @@ -586,7 +585,7 @@ describe('startSauceConnect', () => {
});

it('should not fail if stderr is expected character', async () => {
const api = new SauceLabs({user: 'foo', key: 'bar', headless: true});
const api = new SauceLabs({user: 'foo', key: 'bar'});
setTimeout(() => stderrEmitter.emit('data', '\u001b[K'), 50);
setTimeout(
() =>
Expand Down
2 changes: 0 additions & 2 deletions tests/typings/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ const api = new SauceLabs({
user: 'foo',
key: 'foobar',
proxy: 'barfoo',
headless: false,
});

async function foobar() {
Expand All @@ -27,7 +26,6 @@ async function foobar() {
api.username.slice(1, 1);
api.region.slice(1, 1);
api.tld.slice(1, 1);
api.headless.valueOf();
api.webdriverEndpoint.slice(1, 1);
}

Expand Down
3 changes: 1 addition & 2 deletions tests/utils.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,12 @@ test('toString', () => {
toString({
username: 'foobar',
_accessKey: '50fc1a11-3231-4240-9707-8f34682b17b0',
_options: {region: 'us', headless: false},
_options: {region: 'us'},
})
).toBe(`SauceLabs API Client {
username: 'foobar',
key: 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXX2b17b0',
region: 'us',
headless: false,
proxy: undefined
}`);
});
Expand Down

0 comments on commit 945e1a9

Please sign in to comment.