Skip to content

test(core): add unit tests for the Grok playbook loader (fixes #448) - #460

Merged
dmae97 merged 1 commit into
dmae97:mainfrom
anhnt256:test/grok-playbook
Nov 17, 2026
Merged

dmae97 merged 1 commit into
dmae97:mainfrom
anhnt256:test/grok-playbook

Conversation

@anhnt256

Copy link
Copy Markdown
Contributor

Fixes #448.

Test-only PR, no source changes. Adds packages/coding-agent/test/grok-playbook.test.ts (9 vitest cases) for the Grok playbook loader in core/grok-playbook.ts:

  • grokPlaybookAppendForProvider returns undefined for anthropic and undefined even when grok.md exists, and the file text for xai
  • loadGrokPlaybookAppend returns undefined when the file is missing, whitespace-only, or a directory (read error swallowed)
  • trims " hello \n" to "hello"
  • a file at exactly GROK_PLAYBOOK_MAX_APPEND_CHARS (24,000) is returned unchanged
  • one char over the cap truncates to the first 24,000 chars plus the [... grok.md truncated for system prompt; full file: <path>] suffix

Tests write only inside a temp dir and restore ENV_AGENT_DIR (OMK_CODING_AGENT_DIR) in afterEach.

Verification: all 9 tests pass locally; bite-check (changing the truncation guard from > to >=) fails exactly 1 test. Biome check clean on the new file; tsgo --noEmit shows only 2 pre-existing errors in untouched files. Local npm run check stops at check:dep-tree, a pre-existing environment artifact; CI is the real gate.

dmae97 commented Nov 16, 2026

Copy link
Copy Markdown
Owner

Reviewed head eaa799fa2470f61af72c49b60b4ebf0f2e9a8154 against main 94ed867a0342ee9f158a144eb80b0dc58c2ba57f.

The 83-line test-only diff covers #448's provider gating, missing/blank/directory inputs, whitespace trimming, and exact/over-cap boundaries. I compared the assertions with grok-playbook.ts; writes remain in a fresh temporary directory, and afterEach restores or deletes ENV_AGENT_DIR before removing that directory. No source, dependency, workflow, or network changes are introduced; no blocking defect found in this narrow diff.

Verification: all five reported checks passed. I inspected build-check-test job 133225735185, including the new file's 9 passing tests and the successful check job. This is implementation/diff and CI-log review, not an independent local rerun; I did not reproduce the reported mutation test or local environment/type errors. No other submitted review or unresolved review thread was present.

Automated merge remains withheld because branch-protection detail reads return 403 to this integration, so required merge policy cannot be fully verified. No rerun or merge was initiated.

@dmae97
dmae97 merged commit 4412759 into dmae97:main Nov 17, 2026
5 checks 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.

test: add unit tests for the Grok playbook loader in core/grok-playbook.ts

2 participants