master-zapier-plan-draft/vendor/zapier-platform/packages/schema/test/functional-constraints/deepNestedFields.js
George Lambert b4150c8250 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.
2026-09-09 02:37:36 -04:00

82 lines
2.1 KiB
JavaScript

'use strict';
require('should');
const schema = require('../../schema');
describe('deepNestedFields', () => {
it('should not error on fields nested one level deep', () => {
const definition = {
version: '1.0.0',
platformVersion: '1.0.0',
creates: {
foo: {
key: 'foo',
noun: 'Foo',
display: {
label: 'Create Foo',
description: 'Creates a...',
},
operation: {
perform: '$func$2$f$',
sample: { id: 1 },
inputFields: [
{ key: 'orderId', type: 'number' },
{
key: 'line_items',
children: [
{
key: 'product',
type: 'string',
},
],
},
],
},
},
},
};
const results = schema.validateAppDefinition(definition);
results.errors.should.have.length(0);
});
it('should error on fields nested more than one level deep', () => {
const definition = {
version: '1.0.0',
platformVersion: '1.0.0',
creates: {
foo: {
key: 'foo',
noun: 'Foo',
display: {
label: 'Create Foo',
description: 'Creates a...',
},
operation: {
perform: '$func$2$f$',
sample: { id: 1 },
inputFields: [
{ key: 'orderId', type: 'number' },
{
key: 'line_items',
children: [
{ key: 'some do not have children' },
{
key: 'product',
children: [{ key: 'name', type: 'string' }],
},
],
},
],
},
},
},
};
const results = schema.validateAppDefinition(definition);
results.errors.should.have.length(1);
results.errors[0].stack.should.eql(
'instance.creates.foo.inputFields[1] must not contain deeply nested child fields. One level max.',
);
});
});