test-workflow-section-constraints.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  1. #!/usr/bin/env node
  2. import fs from 'fs';
  3. import assert from 'assert';
  4. const files = [
  5. './.vl-code/workflows/parallel-codegen.json',
  6. './public/seed-workflows/parallel-codegen.json',
  7. './.vl-code/workflows/3-file-codegen.json',
  8. './public/seed-workflows/3-file-codegen.json',
  9. './.vl-code/workflows/meta-direct-codegen.json',
  10. './public/seed-workflows/meta-direct-codegen.json',
  11. './.vl-code/workflows/add-page.json',
  12. './public/seed-workflows/add-page.json',
  13. ];
  14. function includesConstraint(workflow, needle) {
  15. const raw = JSON.stringify(workflow);
  16. return raw.includes(needle);
  17. }
  18. function main() {
  19. console.log('\n── Workflow Section Constraints ──');
  20. for (const file of files) {
  21. const workflow = JSON.parse(fs.readFileSync(file, 'utf-8'));
  22. assert.ok(includesConstraint(workflow, 'NEVER bind events directly on <For-*> nodes'), `${file} missing For event constraint`);
  23. assert.ok(includesConstraint(workflow, 'NEVER emit deprecated <StateStyle-*> trigger:\\"hover\\" blocks'), `${file} missing hover StateStyle constraint`);
  24. console.log(`PASS ${file}`);
  25. }
  26. console.log('PASS test-workflow-section-constraints.js');
  27. }
  28. main();