import { describe, it, expect } from 'vitest'; import { pullerKindRule } from '@beehexa/hexasync-template-validate'; import { ValidationContext } from '@beehexa/hexasync-template-validate'; const ctx = (tokenForm: any): ValidationContext => ({ tokenForm }) as ValidationContext; const run = (tf: any) => pullerKindRule.run(ctx(tf)); describe('pullerKindRule — PLK', () => { it('PLK-1: flags a legacy (old-kind) puller as a migration NOTICE', () => { const tf = { pullers: [ { id: 'P', pullSteps: [{ key: 'A' }], responseFilters: { hasNextPage: '{{x}}' }, }, ], }; const issues = run(tf).filter((i) => i.ruleId === 'PLK-1'); expect(issues).toHaveLength(1); /** * `very-low`, because an old-kind puller WORKS (Jazz, 2026-08-11). It was `low`, which put a migration nudge among * findings that mean the profile is misconfigured; on a project with many legacy pullers those drowned. `PLK-2` — * a puller declaring BOTH shapes — stays `high`, because that one is genuinely ambiguous at runtime, and the * contrast is the point of the pair. */ expect(issues[0].severity).toBe('very-low'); expect(issues[0].idOrKey).toBe('P'); }); it('PLK-2: flags a new-kind puller carrying legacy fields as HIGH', () => { const tf = { pullers: [ { id: 'P', steps: [{ key: 'A' }], responseFilters: { hasNextPage: '{{x}}' }, // legacy field on a new-kind puller pullSteps: [{ key: 'B' }], }, ], }; const issues = run(tf).filter((i) => i.ruleId === 'PLK-2'); expect(issues).toHaveLength(1); expect(issues[0].severity).toBe('high'); expect(issues[0].message).toContain('responseFilters'); expect(issues[0].message).toContain('pullSteps'); }); it('clean new-kind puller (steps only) produces no PLK issue', () => { const tf = { pullers: [ { id: 'P', steps: [{ key: 'A' }], onErrorSteps: [{ key: 'E' }] }, ], }; expect(run(tf)).toHaveLength(0); }); it('clean legacy puller still nudges (PLK-1) — one issue, LOW', () => { const tf = { pullers: [{ id: 'P', pullSteps: [{ key: 'A' }] }] }; const issues = run(tf); expect(issues).toHaveLength(1); expect(issues[0].ruleId).toBe('PLK-1'); }); });