|
2 | 2 |
|
3 | 3 | import { describe, expect, it } from 'vitest'; |
4 | 4 |
|
| 5 | +import { FLOW_NODE_SIBLING_EXPRESSION_BLOCKS } from '../automation/flow-node-expression-paths.js'; |
5 | 6 | import { flowNodeValueTemplateRefusals } from '../automation/flow-value-slot-template.js'; |
6 | 7 | import { ObjectSchema } from '../data/object.zod.js'; |
7 | 8 | import { MIGRATIONS_BY_MAJOR } from '../migrations/registry.js'; |
@@ -66,6 +67,7 @@ describe('the refused-shape list — registered against the migration chain', () |
66 | 67 | 'cbp-master-relation-tiers-retired', |
67 | 68 | 'view-data-api-provider-retired', |
68 | 69 | 'flow-value-slot-template-dialect-refused', |
| 70 | + 'connector-action-input-value-slot-judged', |
69 | 71 | 'object-external-binding-managed-datasource-refused', |
70 | 72 | 'visibility-predicate-has-argument-refused', |
71 | 73 | 'object-duplicate-action-name-refused', |
@@ -364,6 +366,94 @@ describe('#23269 — a stored flow whose CRUD filter operand is a {…} token is |
364 | 366 | }); |
365 | 367 | }); |
366 | 368 |
|
| 369 | +// ── #28163 ──────────────────────────────────────────────────────────────── |
| 370 | + |
| 371 | +const connectorNode = (id: string, input: unknown) => ({ |
| 372 | + id, |
| 373 | + type: 'connector_action', |
| 374 | + label: id, |
| 375 | + connectorConfig: { connectorId: 'helpdesk', actionId: 'open_ticket', input }, |
| 376 | +}); |
| 377 | + |
| 378 | +describe('#28163 — a stored connector_action whose connectorConfig.input carries a {…} token is listed by flow and node', () => { |
| 379 | + it('one TODO under the connector input entry, at connectorConfig.input.<key>; the row is not rewritten', () => { |
| 380 | + const row = flowOf('fd_connector', [connectorNode('ticket', { text: '{record.name}', queue: 'support' })]); |
| 381 | + const before = JSON.stringify(row); |
| 382 | + const { item, todos } = storedTodos('flow', row); |
| 383 | + expect(JSON.stringify(item)).toBe(before); |
| 384 | + expect(todos).toHaveLength(1); |
| 385 | + const todo = todos[0]!; |
| 386 | + expect(todo.conversionId).toBe('connector-action-input-value-slot-judged'); |
| 387 | + expect(todo.path).toBe('flows[0].nodes[1].connectorConfig.input.text'); |
| 388 | + expect(todo.from).toBe(JSON.stringify('{record.name}')); |
| 389 | + expect(todo.reason).toContain( |
| 390 | + "Flow `fd_connector`, node 'ticket' (connector_action), connector_action input value at connectorConfig.input.text.", |
| 391 | + ); |
| 392 | + expect(todo.reason).toContain('registerFlow refuses the flow: it is not registered at boot and never runs'); |
| 393 | + expect(todo.reason).toContain("{ dialect: 'cel', source: 'record.name' }"); |
| 394 | + }); |
| 395 | + |
| 396 | + it('reaches a value nested in the input map, and a node inside a structured region', () => { |
| 397 | + const flow = flowOf('fd_connector_loop', [{ |
| 398 | + id: 'each', type: 'loop', label: 'Each', |
| 399 | + config: { |
| 400 | + collection: { dialect: 'cel', source: 'items' }, |
| 401 | + body: { nodes: [connectorNode('inner', { tags: ['ok', '{item.tag}'] })], edges: [] }, |
| 402 | + }, |
| 403 | + }]); |
| 404 | + const todos: ConversionTodoNotice[] = []; |
| 405 | + applyConversionsToFlow(flow, { includeRetired: true, onTodo: (t) => todos.push(t) }); |
| 406 | + expect(todos.map((t) => [t.conversionId, t.path])).toEqual([ |
| 407 | + ['connector-action-input-value-slot-judged', 'flows[0].nodes[1].config.body.nodes[0].connectorConfig.input.tags[1]'], |
| 408 | + ]); |
| 409 | + }); |
| 410 | + |
| 411 | + it('judges the row the conversions produced: a loose config.input the chain lifts is listed at connectorConfig', () => { |
| 412 | + const row = flowOf('fd_connector_loose', [{ |
| 413 | + id: 'loose', type: 'connector_action', label: 'Loose', |
| 414 | + config: { connectorId: 'helpdesk', actionId: 'open_ticket', input: { text: '{record.name}' } }, |
| 415 | + }]); |
| 416 | + const { todos } = storedTodos('flow', row); |
| 417 | + expect(todos.map((t) => [t.conversionId, t.path])).toEqual([ |
| 418 | + ['connector-action-input-value-slot-judged', 'flows[0].nodes[1].connectorConfig.input.text'], |
| 419 | + ]); |
| 420 | + }); |
| 421 | + |
| 422 | + it.each([ |
| 423 | + ['a CEL envelope', { text: { dialect: 'cel', source: 'record.name' } }], |
| 424 | + ['a literal', { text: 'Ticket', queue: 'support' }], |
| 425 | + ['no input', undefined], |
| 426 | + ])('a connector_action already on protocol (%s) is not listed', (_label, input) => { |
| 427 | + const flow = flowOf('fd_connector_ok', [connectorNode('ticket', input)]); |
| 428 | + const todos: ConversionTodoNotice[] = []; |
| 429 | + applyConversionsToFlow(flow, { includeRetired: true, onTodo: (t) => todos.push(t) }); |
| 430 | + expect(todos).toEqual([]); |
| 431 | + }); |
| 432 | + |
| 433 | + it('agrees with the refusing door: each site is one the value-slot judge refuses when handed the node, and no other', () => { |
| 434 | + const nodes: Array<Record<string, any>> = [ |
| 435 | + connectorNode('a', { text: '{record.name}', id: { dialect: 'cel', source: 'record.id' } }), |
| 436 | + crudNode('b', 'get_record', { id: '{record.id}' }), |
| 437 | + connectorNode('c', { note: 'plain' }), |
| 438 | + ]; |
| 439 | + const { todos } = todosOf({ flows: [flowOf('fd_connector_mixed', nodes)] }); |
| 440 | + // The door's own call — `registerFlow` and `objectstack validate` hand the node. |
| 441 | + const judged = nodes.flatMap((n, i) => |
| 442 | + flowNodeValueTemplateRefusals(n.type, n.config, n).map((r) => `flows[0].nodes[${i + 1}].${r.block}.${r.path}`)); |
| 443 | + // Report order is detector order, so the two are compared as sets. |
| 444 | + expect(todos.map((t) => t.path).sort()).toEqual([...judged].sort()); |
| 445 | + expect(todos.map((t) => [t.conversionId, t.path])).toEqual([ |
| 446 | + ['flow-value-slot-template-dialect-refused', 'flows[0].nodes[2].config.filter.id'], |
| 447 | + ['connector-action-input-value-slot-judged', 'flows[0].nodes[1].connectorConfig.input.text'], |
| 448 | + ]); |
| 449 | + }); |
| 450 | + |
| 451 | + it('the two flow detectors cover every block the ledger roots a value slot in', () => { |
| 452 | + // A new sibling block needs a detector here (and its D3 entry) before its refusals can be listed. |
| 453 | + expect(['config', ...Object.keys(FLOW_NODE_SIBLING_EXPRESSION_BLOCKS)]).toEqual(['config', 'connectorConfig']); |
| 454 | + }); |
| 455 | +}); |
| 456 | + |
367 | 457 | // ── #23317 ──────────────────────────────────────────────────────────────── |
368 | 458 |
|
369 | 459 | describe('#23317 — a stored page whose component binds the retired API source in its `data` prop is listed by page and component', () => { |
|
0 commit comments