Skip to content

refactor(test): replace logic-bearing vi.mock factories with real modules and boundary fakes - #120063

Merged
steipete merged 3 commits into
mainfrom
steipete/loc2-mock-factories-5a7c
Aug 6, 2026
Merged

steipete merged 3 commits into
mainfrom
steipete/loc2-mock-factories-5a7c

Conversation

@steipete

@steipete steipete commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

What Problem This Solves

Two test suites carried logic-bearing module factories that either copied production policy or let assertions pass without reaching the real implementation. The embedded-agent suite duplicated Codex native-search activation and payload injection, while the Slack slash suite duplicated command lookup, parsing, formatting, menu eligibility, and choice resolution.

Why This Change Was Made

The embedded-agent suite now uses the real Codex native-search module. Its duplicate-tool case was also corrected to route through the real OpenAI wrapper with a valid OAuth profile; the previous gateway route bypassed the behavior under test.

The Slack slash suite now imports the real command runtime and keeps only a narrow, data-only adapter for synthetic Slack-limit cases that no production command can express. Real built-ins cover login, tools, TTS, usage, think, and status behavior. The former internal mock-call assertion for dynamic think choices is now an observable assertion over encoded Block Kit menu values.

Per-file results:

  • src/agents/embedded-agent-runner-extraparams.test.ts: 139 -> 139 tests. Boundary: provider stream request/payload handoff. Deleted tests/assertions: none.
  • extensions/slack/src/monitor/slash.test.ts: 56 -> 56 tests. Boundaries: Bolt/Slack response transport, model catalog loading, and plugin command discovery. Deleted tests: none. Deleted assertion: the resolveCommandArgMenu mock-call inspection, replaced by observable runtime-specific menu values.

Three requested files were intentionally not changed:

  • Browser hot-reload: premise mismatch. The current file already imports the real refresh/lifecycle modules and contains only narrow config-source, process, MCP, and Playwright boundary fakes; the claimed 567-line logic factory is not present.
  • Doctor config flow: skipped after two honest attempts. The real preflight/plugin path exceeded 180 seconds for the full file and a single-test probe hit the bounded 300-second no-output limit while compiling/discovering plugins. The attempted rewrite was reverted cleanly.
  • Slack dispatch preview fallback: skipped after two honest attempts. The full real-kernel attempt took 225 seconds and failed broadly; after correcting the missing real reply-payload exports, a single ordinary preview test still timed out. The attempted rewrite was reverted cleanly.

User Impact

No production behavior changes. The retained tests now cover production Codex search and Slack command/menu behavior instead of local reimplementations, while preserving all successful test cases.

Evidence

Passed:

  • node scripts/run-vitest.mjs src/agents/embedded-agent-runner-extraparams.test.ts — 139 passed
  • node scripts/run-vitest.mjs src/agents/codex-native-web-search.test.ts — 21 passed
  • node scripts/run-vitest.mjs src/llm/providers/stream-wrappers/openai.test.ts — 32 passed
  • node scripts/run-vitest.mjs extensions/slack/src/monitor/slash.test.ts — 56 passed
  • node scripts/run-vitest.mjs src/auto-reply/commands-registry.test.ts — 37 passed
  • node scripts/run-vitest.mjs src/agents/thinking-runtime.test.ts — 12 passed
  • node scripts/run-vitest.mjs extensions/slack/src/monitor/external-arg-menu-store.test.ts — 4 passed
  • node scripts/run-oxlint.mjs src/agents/embedded-agent-runner-extraparams.test.ts extensions/slack/src/monitor/slash.test.ts
  • node scripts/run-tsgo.mjs -p test/tsconfig/tsconfig.extensions.test.json --incremental --tsBuildInfoFile .artifacts/tsgo-cache/extensions-test.tsbuildinfo
  • git diff --check
  • .agents/skills/autoreview/scripts/autoreview --mode branch --base origin/main — clean, no accepted/actionable findings

Changed-gate note: node scripts/check-changed.mjs could not acquire any remote provider. The trusted local fallback passed all guards, formatting, and lint before core-test typechecking stopped on pre-existing Control UI E2E errors in ui/src/e2e/appearance-settings-defaults.e2e.test.ts (browser/server are undefined). The independent extension-test typecheck passed.

Production LOC delta: +0 / -0.

Test LOC delta from git diff origin/main...HEAD --numstat: +175 / -385 (net -210) across two test files.

@steipete
steipete marked this pull request as ready for review August 6, 2026 23:25
@steipete

steipete commented Aug 6, 2026

Copy link
Copy Markdown
Contributor Author

Incident-mode landing note (operator-directed). GitHub's Actions incident blocked core CI and ClawSweeper; the operator directed landing. Gates satisfied: coordinator diff review (the vi.mock factories that reimplemented resolveCodexNativeSearchActivation/patchCodexNativeWebSearchPayload and the Slack slash runtime are deleted; the real modules now run under the same assertions — 139/139 and 56/56 retained); Codex contract verified against ../codex source (hosted_spec.rs, config_types.rs); structured Codex autoreview clean (0.99); lint/types/diff checks green. Three of five targeted files were honestly skipped (premise gone, or de-stubbing required production refactors — out of scope). Test LOC −210, production 0, and the surviving tests now prove the system rather than the stubs. Landed via operator-authorized admin merge at the verified head.

@steipete
steipete merged commit bfd47df into main Aug 6, 2026
62 checks passed
@steipete
steipete deleted the steipete/loc2-mock-factories-5a7c branch August 6, 2026 23:32
@openclaw-barnacle openclaw-barnacle Bot added channel: slack Channel integration: slack agents Agent runtime and tooling size: L maintainer Maintainer-authored PR labels Aug 6, 2026
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 7, 2026
…ules and boundary fakes (openclaw#120063)

* refactor(test): use real Codex search module

* refactor(test): use real Slack slash command runtime

* test: satisfy Slack slash fixture lint
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling channel: slack Channel integration: slack maintainer Maintainer-authored PR size: L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant