Skip to content

Add test_seeds generator for automatic E2E seed data#1

Open
fez3d wants to merge 3 commits into
mainfrom
test-seeds-generator
Open

Add test_seeds generator for automatic E2E seed data#1
fez3d wants to merge 3 commits into
mainfrom
test-seeds-generator

Conversation

@fez3d
Copy link
Copy Markdown
Contributor

@fez3d fez3d commented Mar 6, 2026

Summary

  • Adds a new generator agent_e2e:test_seeds that reads all models and db/schema.rb, calls OpenAI to generate db/test_seeds.rb with realistic seed data for E2E testing
  • The QA user (qa@example.com / Password123!) is always created directly by the generator, independent of the AI response — with automatic detection of Devise, has_secure_password, and confirmable
  • Replaces the previous approach of relying on manually configured db/seeds.rb
  • bin/e2e now requires db/test_seeds.rb to exist; if missing, it stops and shows the user exactly what to do based on whether OPENAI_API_KEY is configured or not
  • The install generator delegates seed generation to the new test_seeds generator, keeping responsibilities separated

Changes

File What changed
test_seeds/test_seeds_generator.rb New generator — analyzes models, calls OpenAI (o3), generates db/test_seeds.rb
install/install_generator.rb Delegates to agent_e2e:test_seeds, removes manual seed instructions from next steps
install/templates/e2e Requires test_seeds.rb, exits with actionable instructions if missing
README.md Documents the new generator, SEED_AI_MODEL config, and troubleshooting

Test plan

  • Run bin/rails generate agent_e2e:install with OPENAI_API_KEY set — verify db/test_seeds.rb is generated with QA user and model data
  • Run bin/rails generate agent_e2e:install without API key — verify it skips seed generation gracefully and shows instructions
  • Run bin/rails generate agent_e2e:test_seeds independently — verify it generates/overwrites db/test_seeds.rb
  • Run bin/e2e without db/test_seeds.rb — verify it exits with correct instructions
  • Run bin/e2e with db/test_seeds.rb present — verify it seeds and runs tests normally
  • Test with a Devise app — verify password_confirmation and confirmed_at are included in QA user block

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant