Milestone 0: import zappier billing, Verae middleware, and Zapier research
Compose-ready workspace: packages/zappier (rate card, portal, Stripe), packages/verae-zapier-middleware (timestamp + NATS), packages/verae-zapier (CLI app), vendor/zapier-platform, and research/zapier vendor corpus. Gate 0 structure checks pass. Product code and research are not yet wired.
This commit is contained in:
commit
b4150c8250
1364 changed files with 6814366 additions and 0 deletions
154
vendor/zapier-platform/packages/schema/test/readability.js
vendored
Normal file
154
vendor/zapier-platform/packages/schema/test/readability.js
vendored
Normal file
|
|
@ -0,0 +1,154 @@
|
|||
'use strict';
|
||||
|
||||
const should = require('should');
|
||||
|
||||
const AuthenticationSchema = require('../lib/schemas/AuthenticationSchema');
|
||||
const CreateSchema = require('../lib/schemas/CreateSchema');
|
||||
const TriggerSchema = require('../lib/schemas/TriggerSchema');
|
||||
|
||||
describe('readability', () => {
|
||||
it('should have decent messages for anyOf mismatches', () => {
|
||||
const results = AuthenticationSchema.validate({
|
||||
type: 'oauth2',
|
||||
test: 'whateverfake!',
|
||||
});
|
||||
results.errors.should.have.length(1);
|
||||
results.errors[0].stack.should.eql('instance is not of a type(s) object');
|
||||
should(results.errors[0].property.endsWith('instance')).be.false();
|
||||
});
|
||||
|
||||
it('should have decent messages for minimum length not met', () => {
|
||||
const results = TriggerSchema.validate({
|
||||
key: 'recipe',
|
||||
noun: 'Recipe',
|
||||
display: {
|
||||
label: '',
|
||||
description: 'Creates a new recipe.',
|
||||
},
|
||||
operation: {
|
||||
perform: '$func$2$f$',
|
||||
sample: { id: 1 },
|
||||
},
|
||||
});
|
||||
results.errors.should.have.length(1);
|
||||
should(results.errors[0].property.endsWith('instance')).be.false();
|
||||
results.errors[0].stack.should.eql(
|
||||
'instance.display.label does not meet minimum length of 2',
|
||||
);
|
||||
});
|
||||
|
||||
it('should have decent messages for value type mismatch', () => {
|
||||
const results = CreateSchema.validate({
|
||||
key: 'recipe',
|
||||
noun: 'Recipe',
|
||||
display: {
|
||||
label: 'Create Recipe',
|
||||
description: 'Creates a new recipe.',
|
||||
},
|
||||
operation: {
|
||||
perform: '$func$2$f$',
|
||||
sample: { id: 1 },
|
||||
inputFields: [123],
|
||||
},
|
||||
});
|
||||
results.errors.should.have.length(1);
|
||||
should(results.errors[0].property.endsWith('instance')).be.false();
|
||||
results.errors[0].stack.should.eql('instance is not of a type(s) object');
|
||||
});
|
||||
|
||||
it('should handle falsy values for objects', () => {
|
||||
const results = CreateSchema.validate({
|
||||
key: 'recipe',
|
||||
noun: 'Recipe',
|
||||
display: {
|
||||
label: 'Create Recipe',
|
||||
description: 'Creates a new recipe.',
|
||||
},
|
||||
operation: {
|
||||
perform: '$func$2$f$',
|
||||
sample: { id: 1 },
|
||||
inputFields: [0],
|
||||
},
|
||||
});
|
||||
results.errors.should.have.length(1);
|
||||
should(results.errors[0].property.endsWith('instance')).be.false();
|
||||
results.errors[0].stack.should.eql('instance is not of a type(s) object');
|
||||
});
|
||||
|
||||
it('should surface deep issues', () => {
|
||||
const results = CreateSchema.validate({
|
||||
key: 'recipe',
|
||||
noun: 'Recipe',
|
||||
display: {
|
||||
label: 'Create Recipe',
|
||||
description: 'Creates a new recipe.',
|
||||
},
|
||||
operation: {
|
||||
perform: '$func$2$f$',
|
||||
sample: { id: 1 },
|
||||
inputFields: [{ key: 'field', type: 'string', default: '' }],
|
||||
},
|
||||
});
|
||||
results.errors.should.have.length(1);
|
||||
should(results.errors[0].property.endsWith('instance')).be.false();
|
||||
results.errors[0].property.should.eql(
|
||||
'instance.operation.inputFields[0].default',
|
||||
);
|
||||
results.errors[0].message.should.eql('does not meet minimum length of 1');
|
||||
});
|
||||
|
||||
it('should correctly surface subschema types', () => {
|
||||
const results = CreateSchema.validate({
|
||||
key: 'recipe',
|
||||
noun: 'Recipe',
|
||||
display: {
|
||||
label: 'Create Recipe',
|
||||
description: 'Creates a new recipe.',
|
||||
},
|
||||
operation: {
|
||||
perform: {
|
||||
url: 'https://example.com',
|
||||
body: 123,
|
||||
},
|
||||
sample: { id: 1 },
|
||||
},
|
||||
});
|
||||
results.errors.should.have.length(1);
|
||||
results.errors[0].property.should.eql('instance.operation.perform.body');
|
||||
should(
|
||||
results.errors[0].message.includes('null,string,object,array'),
|
||||
).be.true();
|
||||
should(results.errors[0].property.endsWith('instance')).be.false();
|
||||
results.errors[0].docLinks.length.should.eql(0);
|
||||
});
|
||||
|
||||
it('should be helpful for fieldChoices', () => {
|
||||
const results = CreateSchema.validate({
|
||||
key: 'recipe',
|
||||
noun: 'Recipe',
|
||||
display: {
|
||||
label: 'Create Recipe',
|
||||
description: 'Creates a new recipe.',
|
||||
},
|
||||
operation: {
|
||||
perform: '$func$2$f$',
|
||||
sample: { id: 1 },
|
||||
inputFields: [
|
||||
{
|
||||
key: 'adsf',
|
||||
// schema says these should be strings
|
||||
choices: [1, 2, 3],
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
results.errors.should.have.length(1);
|
||||
results.errors[0].property.should.eql(
|
||||
'instance.operation.inputFields[0].choices',
|
||||
);
|
||||
should(
|
||||
results.errors[0].docLinks[0].includes('schema.md#fieldchoicesschema'),
|
||||
).be.true();
|
||||
should(results.errors[0].property.endsWith('instance')).be.false();
|
||||
});
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue