Skip to content

Add POST /repos/<owner>/<repo>/tests (write_tests) for Gitea and GitHub - #6

Merged
yurivibes merged 2 commits into
masterfrom
feat/record-test
Dec 2, 2026
Merged

yurivibes merged 2 commits into
masterfrom
feat/record-test

Conversation

@yurivibes

@yurivibes yurivibes commented Dec 2, 2026 •

Copy link
Copy Markdown
Owner

Implements the build-plugin route from the record-test spec: POST /repos/<owner>/<repo>/tests (optional capability write_tests, contract_version stays 1), for both the Gitea and GitHub sources.

  • /health capabilities now ["logs", "cancel", "write_tests"]; same pairing-token auth.
  • Plugin-side validation: case ^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$, file ^[A-Za-z0-9][A-Za-z0-9_.-]{0,99}\.txt$ (not INSTRUCTION.txt), content non-empty UTF-8 ≤ 256 KiB, instruction required for new_case.
  • Preconditions on base: unknown_branch (404), unknown_case (404), case_exists (409), file_exists (409); refused write → forbidden (403) carrying the forge message.
  • Branch mt-record/<case>-<file stem>-<yyyymmddHHMMSS> (UTC), ONE commit (message = title), PR into base → 200 {"ok", "branch", "pr_url", "pr_number"}.
  • GitHub: git data API (tree with base_tree → commit → ref) + POST /pulls. Gitea: one POST /contents with new_branch (Gitea ≥ 1.20) + POST /pulls. If the PR fails, the new branch is deleted. No local clone.
  • api() helpers gained an optional JSON body.
  • Fake GitHub/Gitea accept the writes; tests/test_write_tests.py covers success (existing + new case), file_exists, case_exists, unknown_case, unknown_branch, bad names/content, 401 pairing token, 403 read-only forge token, PR failure cleanup — on both forges.
  • README (endpoint table + section, token scopes) and SECURITY.md updated. AGENTS.md Purpose/Tests updated.

Tests: python3 -m unittest discover -s tests → 143 tests OK.

…ea and GitHub

Opens a pull request adding a test recorded on the viewer's Devices page:
validates case/file/content, checks the case and file on base, then creates
mt-record/<case>-<stem>-<timestamp> with one commit (GitHub git data API,
Gitea POST contents with new_branch) and opens a PR into base. Errors:
unknown_branch, unknown_case, case_exists, file_exists, forbidden.
Fake forges accept the writes; README and SECURITY.md document the route.
yurivibes added a commit to yurivibes/MonkeyTester that referenced this pull request Dec 2, 2026
…PR via build plugin) (#33)

Devices page **Record test** (spec: vt-specs/record-test.md).

- Record test section under Apps: AI plugin dropdown (the configured
plugin for now), Start/Stop/Add check.
- Actions sent through the remote control are recorded server-side
(`recorder.py`) with a frame each.
- After Stop, one batch conversion: tap → `<NAME>: CLICK …`, text →
`<NAME>: INPUT <field> "<text>"`, check → `<NAME>: VERIFY …`, swipe →
`SWIPE: <dir>`; verbs come from the AI plugin's `/health` `commands`.
Back/Home/Recents/long-press → `#` comment + warning. Pauses > 2 s →
`WAIT: <rounded 0.5 s, max 10>`.
- Editable steps → project → branch → case (existing or new with
INSTRUCTION.txt) → file → Open PR through the build plugin's new `POST
/repos/<o>/<r>/tests` (capability `write_tests`, documented in
BUILD_PLUGIN_API.md). Existing file refused.
- Routes: `GET /api/record/plugins`, `GET /api/record/projects`, `POST
/api/record/start`, `/api/record/<id>/check`, `/api/record/<id>/stop`,
`/api/record/pr`.
- Tests: `tests/test_record_test.py` (29), full suite 829 OK; AGENTS.md
updated.

Companion PRs (deploy these first): yurivibes/MonkeyTester-Plugin-AI#8,
yurivibes/MonkeyTester-Plugin-Build-Local#6,
yurivibes/MonkeyTester-Plugin-Build-GitHub#3.
@yurivibes
yurivibes merged commit 0d4dabb into master Dec 2, 2026
1 check passed
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