Skip to content

zfa make crashes with 'Unknown method: toggle' — regression from #287 (test plugin default methods include toggle but test_builder_entity has no toggle case) #289

Description

@arrrrny

Context

Found while smoke-testing the zfa-only workflow (fresh zfa setup zikzak_r2 --flutterzfa entity create Product → canonical zfa make Product --preset=crud --with=vpc,state,di,test). Regression introduced by PR #287 (fix for #284).

What I ran

zfa setup zikzak_r2 --flutter --platforms=ios,macos
cd zikzak_r2
zfa entity create -n Product --field id:String --field name:String --field price:double
zfa make Product --preset=crud --with=vpc,state,di,test

Expected

zfa make generates the crud stack (per-method usecases + data repo impl + per-method DI + tests) and completes.

Actual

zfa make crashes immediately:

❌ Generation failed: Invalid argument(s): Unknown method: toggle

Root cause

PR #287 added entity-method defaults ['get', 'update', 'toggle'] to the test plugin (lib/src/plugins/test/test_plugin.dart:85-93) so entity configs route to generateForMethod. But the per-method test builder's method switch (lib/src/plugins/test/builders/test_builder_entity.dart:55-75) has no toggle case — only get, update, delete, watch, watchList. Any entity generated with the default methods (no explicit --methods) now crashes in the test plugin before anything is written.

Same pattern exists in other generators — need a sweep for toggle support:

  • lib/src/plugins/test/builders/test_builder_entity.dart:55-75 — NO toggle case → crash
  • lib/src/plugins/usecase/generators/entity_usecase_generator.dart:341 — has toggle? verify
  • lib/src/plugins/di/di_plugin.dart:1138 — HAS toggle (ok)
  • controller/presenter/view plugins — verify each has toggle in their method switches

Suggested fix

  1. Add toggle case to test_builder_entity.dart (class Toggle${entity}UseCase, per the usecase generator's toggle shape), OR
  2. Make the new defaults in DI/test plugins ['get', 'update'] only (drop toggle) until every generator's method switch supports it, OR
  3. Add a shared method-support registry so all plugins validate methods against the same set before generating.

Impact

Blocks the entire canonical zfa make flow — the #284 fix cannot be exercised because #287 introduced this regression. Fresh zfa-only apps cannot be generated at all right now.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions