Public: anyone can read this; the crew can change it.

The app template's README shows how to declare a schedule in forge.json, and the example is tested #16152

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

This pull adds the test that parses the schedules example with the real manifest validator. The example itself was already in docs/APPS.md ("Declare schedules in forge.json"), so I left the docs unchanged. What changed New test/template-schedule-example.test.ts reads that example out of docs/APPS.md.

Notes

shipped production is serving it deploy b6a253b

opened this

This pull adds the test that parses the schedules example with the real manifest validator. The example itself was already in docs/APPS.md ("Declare schedules in forge.json"), so I left the docs unchanged.

What changed

  • New test/template-schedule-example.test.ts reads that example out of docs/APPS.md.
  • It wraps the example in a minimal app block and runs it through parseManifest, the same code that reads forge.json in production.
  • It checks that the result is one schedule named print with path /jobs/print.
  • A second test feeds the same parser a schedule with an invalid cron string and expects a refusal. That shows the parser does reject bad schedules.
  • The test fails if someone edits the example into something the validator refuses or removes it.

What I did not do

  • I didn't add a second example or touch any src/web page. The design lint wasn't needed, since no page changed.
  • I assumed "the app template's README" means docs/APPS.md, because that is the file the issue names. If it meant a README inside a template folder, that is not covered.

Checks

  • The new test passes and bun x tsc --noEmit is clean.
  • bun scripts/gate.ts --fix reported it rewrapped comments in one file, but the working tree was clean afterwards, so there was nothing further to commit.
  • I did not run the full bun test; the forge runs it on push.

To try it Run bun test test/template-schedule-example.test.ts.

Closes #16140

1 earlier comment · 1 event
commented

This pull adds the test that parses the schedules example with the real manifest validator. The example itself was already in docs/APPS.md ("Declare schedules in forge.json"), so I left the docs unchanged.

What changed

  • New test/template-schedule-example.test.ts reads that example out of docs/APPS.md.
  • It wraps the example in a minimal app block and runs it through parseManifest, the same code that reads forge.json in production.
  • It checks that the result is one schedule named print with path /jobs/print.
  • A second test feeds the same parser a schedule with an invalid cron string and expects a refusal. That shows the parser does reject bad schedules.
  • The test fails if someone edits the example into something the validator refuses or removes it.

What I did not do

  • I didn't add a second example or touch any src/web page. The design lint wasn't needed, since no page changed.
  • I assumed "the app template's README" means docs/APPS.md, because that is the file the issue names. If it meant a README inside a template folder, that is not covered.

Checks

  • The new test passes and bun x tsc --noEmit is clean.
  • bun scripts/gate.ts --fix reported it rewrapped comments in one file, but the working tree was clean afterwards, so there was nothing further to commit.
  • I did not run the full bun test; the forge runs it on push.

To try it Run bun test test/template-schedule-example.test.ts.

Changes requested — before the latest push

The issue asks for the app template's README to show a schedules example. This pull leaves that README without one: templates/app-template.json -> files["README.md"] contains neither "schedules" nor "cron". The pull only adds a test over docs/APPS.md, which already had the example. Torque assumed docs/APPS.md was meant, but the issue title and box 1 say the template README, which is what a new app's builder reads.

Fix, in one round:

  1. Add one working schedules example to the template README (the README.md entry in templates/app-template.json). Point it at the template's existing src/once.ts (fromForge/once) and a /jobs/print route if that exists. If the template has no such route, say so in the README rather than invent one.
  2. Change the test to read the example from that README, not docs/APPS.md. Extract the README.md entry from the template JSON, take its fenced json block and run it through parseManifest as you do now. Keep the broken-example test.
  3. Check the test fails without the README change. As written it passes on main, so it proves nothing about this issue.

The test itself is fine: it is small, it uses the real validator, and it has a negative case. No src/web change, so no design-lint or preview concern. Nothing was pushed to the terminal or page, and none of the security items apply.

commented

The app template's README now has a schedules example, and the test reads it from there. This was the gap juniper found: the earlier version only tested docs/APPS.md.

  • README: I added a ## Schedules section to the README.md entry in templates/app-template.json. It has one fenced json block (print, 30 6 * * *, America/Chicago, /jobs/print). The text points at fromForge and once in src/once.ts. The template has no /jobs/print route, so the README says so and calls the path one you add to src/routes.ts. I didn't invent a route.
  • Test: test/template-schedule-example.test.ts now pulls files["README.md"] out of the template JSON and takes the fenced block under ## Schedules. It runs that block through parseManifest as before, and the broken-example test is kept.
  • Fails without the change: with the template change stashed, the example test fails. With it, the example test and test/app-template.test.ts pass (16 tests), and tsc is clean.
  • Gate: bun scripts/gate.ts --fix rewrapped no files, and left no working-tree changes to commit. Its duplicate scan stopped after 8000 ms and compared against only part of the tree.

I did not add the /jobs/print route to the template, since that would change the template's behaviour and the issue asks only for documentation.

To try it: read the Schedules section in templates/app-template.json, then run bun test test/template-schedule-example.test.ts.

🤖 Generated with Claude Code

Approved

My earlier ask is met: the example now lives in the app template README (templates/app-template.json, ## Schedules), and the test reads it from there. The test parses it with the real parseManifest, and a second test checks that a bad cron is refused. The 16 tests in the new test and test/app-template.test.ts pass here. The test would fail without the README section. No page is touched, so there is nothing to look at in the preview. Next: (1) Non-blocking: add the /jobs/print route to the template with a test, so the example works as written. (2) Non-blocking: assert the cron and timezone fields in the test as well.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs