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

Add support to run tests with sauce credentials Vslt/vslt 1243 #120

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Change Log

## 0.21
- Add support to run tests with sauce credentials

## 0.20.3
- Add `disableDiffOnError` option

Expand Down
7 changes: 6 additions & 1 deletion src/validate.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ var browserStackSchema = require('screener-runner/src/validate').browserStackSch

exports.storybookConfig = function(value) {
var schema = Joi.object().keys({
apiKey: Joi.string().required(),
apiKey: Joi.string(),
username: Joi.string(),
accessKey: Joi.string(),
projectRepo: Joi.string().max(100).required(),
storybookConfigDir: Joi.string().required(),
storybookStaticDir: Joi.string(),
Expand Down Expand Up @@ -74,6 +76,9 @@ exports.storybookConfig = function(value) {
})
.without('resolutions', ['resolution'])
.without('sauce', ['browserStack'])
.xor('username', 'apiKey')
.and('username', 'accessKey')
.xor('accessKey', 'apiKey')
.with('storybookBinPath', ['storybookVersion'])
.with('useNewerBaseBranch', ['baseBranch'])
.with('alwaysAcceptBaseBranch', ['baseBranch'])
Expand Down
20 changes: 17 additions & 3 deletions test/unit/validate.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,24 @@ describe('screener-storybook/src/validate', function() {
});
});

it('should throw error when no apiKey', function() {
return validate.storybookConfig({})
it('should throw error when no apiKey or username', function() {
luisVelasquezSauce marked this conversation as resolved.
Show resolved Hide resolved
return validate.storybookConfig({ projectRepo: 'repo', storybookConfigDir: '.storybook', storybookPort: 6006, storybookPreview: '/preview.html', storybook: []})
.catch(function(err) {
expect(err.message).to.equal('child "apiKey" fails because ["apiKey" is required]');
expect(err.message).to.equal('"value" must contain at least one of [username, apiKey]');
});
});

it('should throw error when no accessKey if username', function() {
return validate.storybookConfig({ username: 'username', projectRepo: 'repo', storybookConfigDir: '.storybook', storybookPort: 6006, storybookPreview: '/preview.html', storybook: []})
.catch(function(err) {
expect(err.message).to.equal('"value" contains [username] without its required peers [accessKey]');
});
});

it('should throw error when no usrname and apiKey are defined at the same time', function() {
return validate.storybookConfig({ apiKey:'test', username: 'username', projectRepo: 'repo', storybookConfigDir: '.storybook', storybookPort: 6006, storybookPreview: '/preview.html', storybook: []})
.catch(function(err) {
expect(err.message).to.equal('"value" contains a conflict between exclusive peers [username, apiKey]');
});
});

Expand Down