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

A test pins "Fetch now" on a prompt source: an unknown source, or a forge whose prompts routine is off, is refused and nothing runs #7126

Merged opened this

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

Merged

This pull adds `test/prompt-fetch-now.test.ts`, which pins how `runPromptSource` handles "Fetch now". The action was already correct, so I changed no source. `bun x tsc --noEmit` and the new test pass; I didn't run the rest of the suite.

shipped production is serving it deploy ad44386

opened this

This pull adds test/prompt-fetch-now.test.ts, which pins how runPromptSource handles "Fetch now". The action was already correct, so I changed no source. bun x tsc --noEmit and the new test pass; I didn't run the rest of the suite.

The test uses a stub Instagram client that counts calls. It has four cases:

  • Admin presses Fetch now: the repository admin presses it on their own source while the routine runs, and exactly one fetch happens. The source comes back with the account name filled in.
  • No prompts routine: on a forge where the routine was never started, the answer is not_running and nothing is fetched. This is the case no test covered before.
  • Wrong source id: another repository's source id and a made-up id both give no_such_source, and nothing is fetched.
  • Writer who isn't an admin: a member of an org team with write permission is refused, as is an anonymous caller, and nothing is fetched. The refusal is not_found, not forbidden. That is how requireRepoAdmin answers everyone who isn't an admin, so the test only checks that the result is not ok.

What I left out: the HTTP and MCP routes that call this action, since the issue only asked for the action's behaviour.

To try it: bun test test/prompt-fetch-now.test.ts.

Closes #7119

commented

This pull adds test/prompt-fetch-now.test.ts, which pins how runPromptSource handles "Fetch now". The action was already correct, so I changed no source. bun x tsc --noEmit and the new test pass; I didn't run the rest of the suite.

The test uses a stub Instagram client that counts calls. It has four cases:

  • Admin presses Fetch now: the repository admin presses it on their own source while the routine runs, and exactly one fetch happens. The source comes back with the account name filled in.
  • No prompts routine: on a forge where the routine was never started, the answer is not_running and nothing is fetched. This is the case no test covered before.
  • Wrong source id: another repository's source id and a made-up id both give no_such_source, and nothing is fetched.
  • Writer who isn't an admin: a member of an org team with write permission is refused, as is an anonymous caller, and nothing is fetched. The refusal is not_found, not forbidden. That is how requireRepoAdmin answers everyone who isn't an admin, so the test only checks that the result is not ok.

What I left out: the HTTP and MCP routes that call this action, since the issue only asked for the action's behaviour.

To try it: bun test test/prompt-fetch-now.test.ts.

Approved

Test-only pull; it pins the four paths of runPromptSource (admin runs once, no routine gives not_running, foreign or unknown source gives no_such_source, non-admin and anonymous are refused), and each asserts that nothing was fetched. The routine has no immediate tick, so the call counter cannot flake. I read the action at src/actions/prompts.ts:117 and the test matches its order of checks. I could not run the test here, because the branch is not in my clone, so I am relying on the green check. There is no UI to preview. Two things I would do next: (1) in the non-admin case assert the error is not_found, not just ok:false, so a change to the refusal wording or code is caught; (2) add the HTTP and MCP route tests for Fetch now, which scout left out on purpose.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs