Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions packages/cli/test/build-json-failure-warnings.e2e.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,16 @@ const PLANTED_KEY = 'zzzUndeclaredProbeKey';

/**
* A stack raising ONE advisory of each of the four classes while parsing
* cleanly: a bare `unique: true` index (authoring-RULE advisory), an unknown
* `requires` token (#3366 capability hint), an undeclared key inside
* cleanly: `title` unique twice — per organization on the field, `'global'` on
* a declared index (authoring-RULE advisory, `unique/double-declaration`), an
* unknown `requires` token (#3366 capability hint), an undeclared key inside
* `visibleWhen` (#3786 finding), plus — via `plantDocs` — a doc whose `tags:`
* scalar the reader cannot parse (ADR-0046 doc advisory).
*
* The rule advisory was a bare declared `unique: true` until protocol 18 refused
* that spelling at the parse (ADR-0120 D7, PR #22103), which then stopped every
* run at step 3, before the gate under test.
*
* The key sits inside `visibleWhen` rather than on the object or field itself:
* an undeclared key in either of those positions has been a hard PARSE error
* since #4001, which would stop the run at 3 and never reach the gate under
Expand All @@ -162,11 +167,12 @@ export default defineStack({
name: '${ns}_ticket',
label: 'Ticket',
sharingModel: 'private',
indexes: [{ name: '${ns}_title_idx', fields: ['title'], unique: true }],
indexes: [{ name: '${ns}_title_idx', fields: ['title'], unique: 'global' }],
fields: {
title: {
type: 'text',
label: 'Title',
unique: true,
visibleWhen: { dialect: 'cel', source: 'true', ${PLANTED_KEY}: 1 },
},
},
Expand Down Expand Up @@ -289,16 +295,16 @@ export default defineStack({
`);

// 3b — an author-time rule ERROR (a `record.<field>` that does not resolve),
// raised alongside the bare-`unique` advisory.
// raised alongside the `unique/double-declaration` advisory.
make('rulefail', `
import { defineStack } from '@objectstack/spec';

export default defineStack({
manifest: { id: 'com.example.rfail', name: 'rfail', version: '1.0.0', type: 'app', namespace: 'rfail' },
requires: ['${PLANTED_TOKEN}'],
objects: [{ name: 'rf_ticket', label: 'Ticket', sharingModel: 'private',
indexes: [{ name: 'rf_title_idx', fields: ['title'], unique: true }],
fields: { title: { type: 'text', label: 'Title',
indexes: [{ name: 'rf_title_idx', fields: ['title'], unique: 'global' }],
fields: { title: { type: 'text', label: 'Title', unique: true,
visibleWhen: { dialect: 'cel', source: 'record.zzz_no_such_field' } } } }],
}, { strict: false });
`);
Expand Down
16 changes: 11 additions & 5 deletions packages/cli/test/validate-json-failure-warnings.e2e.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,12 +166,17 @@ function payloadOf(run: Run, label: string): Record<string, unknown> {
}

/**
* A stack raising ONE advisory of each class while parsing cleanly: a bare
* `unique: true` index (authoring-RULE advisory), an unknown `requires` token
* (#3366 capability hint), an undeclared key inside `visibleWhen` (#3786
* A stack raising ONE advisory of each class while parsing cleanly: `title`
* unique twice — per organization on the field, `'global'` on a declared index
* (authoring-RULE advisory, `unique/double-declaration`), an unknown `requires`
* token (#3366 capability hint), an undeclared key inside `visibleWhen` (#3786
* finding), and — by declaring neither `apps` nor `plugins` — the structural
* advisory that must NOT appear on any failure exit.
*
* The rule advisory was a bare declared `unique: true` until protocol 18 refused
* that spelling at the parse (ADR-0120 D7, PR #22103), which then stopped every
* run at the parse gate, before the gate under test.
*
* The key sits inside `visibleWhen` rather than on the object or field itself:
* an undeclared key in either of those positions has been a hard PARSE error
* since #4001, which would stop the run at the parse gate and never reach the
Expand All @@ -189,11 +194,12 @@ export default defineStack({
name: '${ns}_ticket',
label: 'Ticket',
sharingModel: 'private',
indexes: [{ name: '${ns}_title_idx', fields: ['title'], unique: true }],
indexes: [{ name: '${ns}_title_idx', fields: ['title'], unique: 'global' }],
fields: {
title: {
type: 'text',
label: 'Title',
unique: true,
visibleWhen: { dialect: 'cel', source: 'true', ${PLANTED_KEY}: 1 },
},${extraFields}
},
Expand Down Expand Up @@ -293,7 +299,7 @@ beforeAll(() => {
broken: { type: 'this_is_not_a_field_type', label: 'Broken' },`));

// rule errors — an expression naming a field that does not resolve, raised
// alongside the bare-`unique` advisory.
// alongside the `unique/double-declaration` advisory.
make('rulefail', stack('rfail', [PLANTED_TOKEN], `
subject: { type: 'text', label: 'Subject', visibleWhen: { dialect: 'cel', source: 'record.zzz_no_such_field' } },`));

Expand Down
Loading