Seed preview projects for local/preview work - #964
Conversation
Add an unowned Blocks template to test seeds so local and preview work can load Scratch content without auth.
Add an fr-FR row for excs-preview-starter so locale-aware preview loads can return translated name and instructions instead of falling back to English.
Test coverage92.3% line coverage reported by SimpleCov. |
Move the public Scratch preview seed helpers out of SeedsHelper so RuboCop Metrics/ModuleLength stays under the limit.
There was a problem hiding this comment.
Pull request overview
Adds a public (unowned) Scratch/Blocks “preview starter” template into the test seeding flow so classroom preview routes can load a stable project from editor-api without authentication, including a French locale variant to validate locale-aware loading.
Changes:
- Introduces
ProjectPreviewSeedsHelperto upsert/destroy an unownedcode_editor_scratchtemplate (excs-preview-starter) with seeded Scratch JSON and instruction steps (EN + FR). - Wires preview project create/destroy into
test_seeds:createandtest_seeds:destroy. - Extends
spec/lib/test_seeds_spec.rbto cover creation, destruction, and instruction updates, including thefr-FRrow.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| spec/lib/test_seeds_spec.rb | Adds specs asserting the preview template is created (EN/FR), updated, and removed via test seed tasks. |
| lib/tasks/test_seeds.rake | Hooks preview template lifecycle into the test reseed rake tasks. |
| lib/tasks/seeds_helper.rb | Pulls preview seeding helpers/constants into the existing seeding helper module. |
| lib/tasks/project_preview_seeds_helper.rb | Implements upsert/destroy logic for the public Scratch preview template and reads seed JSON from disk. |
| lib/tasks/seed_data/excs_preview_starter.json | Adds seeded Scratch project JSON payload for the preview template. |
| lib/tasks/seed_data/excs_preview_starter_instructions.json | Adds English instruction steps for the preview template. |
| lib/tasks/seed_data/excs_preview_starter_instructions_fr.json | Adds French instruction steps for the preview template. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 7 out of 7 changed files in this pull request and generated no new comments.
Suppressed comments (1)
lib/tasks/project_preview_seeds_helper.rb:44
- For an existing preview project, changing
project.scratch_component.contentis not persisted byproject.save!: thishas_oneassociation does not enable autosave, so Rails only saves a new associated record automatically. The current reseed therefore updates instructions but leaves stale Scratch JSON in the database; assigning a blankScratchComponent.newcan also save it beforecontentis set. Build missing components through the association and save the component explicitly.
project.scratch_component ||= ScratchComponent.new
project.scratch_component.content = public_scratch_preview_content
project.save!
Arises from issue: 1653
Summary
Adds unowned Blocks (
code_editor_scratch) templates to test seeds so Experience CS project previews can be loaded from editor-api without auth (and without waiting on ExCS content sync).Pairs with the classroom preview route work in editor-standalone - see this editor-standalone PR.
excs-preview-starteras a public Scratch template (user_id/school_idnil) with real Scratch JSON and instruction stepsfr-FRwith a French name and instructions, so locale-awareProjectLoaderrequests return translated project content instead of falling back to Englishtest_seeds:create/test_seeds:destroy(and thus/test/reseed)spec/lib/test_seeds_spec.rbWhy
#1653 needs a stable public Blocks project that classroom can open at a preview URL while logged out. Production templates will come from ExCS sync later; this seed unblocks local and PR testing.
How to try it
English and French project metadata should differ; Scratch content is shared.
Note: if the API process has been up a long time, restart it (or run
rake test_seeds:createin a freshdocker compose exec) so reseed picks up the new rake task code.