Repository navigation
test(hooks): align cursor smoke expectations with native flat handlers - #3198
Mohammed Alkindi (MohammedAlkindi) wants to merge 2 commits into
Conversation
microsoft#3149 renders Cursor hooks under camelCase native events with flat handlers, but two integration tests still expected the old shape and have kept the scheduled smoke red since: - the root source drift test read the ownership sidecar under PreToolUse instead of preToolUse, and seeded a nested user hook that Cursor's strict validator now rejects on reinstall; - the audit contract test expected a nested group in .cursor/hooks.json to be silently not-applicable, while audit now reports it as incomplete coverage because Cursor does not load nested handlers. Refs microsoft#3166
There was a problem hiding this comment.
🟡 Changes recommended
The updated tests can miss user-hook mutation and still use a non-native Cursor event in the audit fixture.
2 open findings
What changed in this PR
Updates Cursor integration tests to match native camel-case events and flat handlers.
Changes:
- Uses
preToolUseand flat user hooks for Cursor drift tests. - Updates audit expectations for nested Cursor handlers.
| File | Description |
|---|---|
tests/integration/test_hook_root_source_drift_e2e.py |
Aligns Cursor drift fixtures with flat handlers. |
tests/integration/test_audit_primitive_contract.py |
Expects nested Cursor handlers to be incomplete. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| if target == "cursor" and nested: | ||
| # Cursor loads only flat handlers, so a nested group is reported, not read. | ||
| assert [(entry.pointer, entry.diagnostic) for entry in result.incomplete] == [ | ||
| ("/hooks/PreToolUse/0", "native hook event requires flat handlers") |
| and isinstance(e["hooks"][0], dict) | ||
| and e["hooks"][0].get("command") == "echo user-owned" | ||
| ] | ||
| user_owned = [e for e in entries if _is_user_owned(e)] |
|
One or more custom setup steps configured for this repository failed during this Copilot code review run: Setup steps run before each review. If the review above is missing context, or no review was posted at all, the failing step above may be the cause. See the workflow run for failure details, fix your setup steps configuration, and re-request a review. Note You can configure setup steps for Copilot code review separately from Copilot cloud agent with a |

Description
Daily smoke has failed since #3149 moved Cursor to
preToolUsewith flat handlers. Two cursor tests still expected the old shape. The drift test now readspreToolUseand seeds a flat user hook. The audit test expects a nested Cursor group reported incomplete (native hook event requires flat handlers). Tests only.Issue and approved scope
Issue: #3166
Human scope-approval comment: none; #3166 is the bot-filed smoke tracker.
Does this PR complete the issue, or what remains? Should clear the smoke.
Type of change
Testing
Spec conformance (OpenAPM v0.1)
docs/src/content/docs/specs/openapm-v0.1.mdupdateddocs/src/content/docs/specs/manifests/openapm-v0.1.requirements.ymlupdated.@pytest.mark.req("req-XXX")test undertests/spec_conformance/added or extended.CONFORMANCE.{md,json}regenerated viauv run --extra dev python -m tests.spec_conformance.gen_statementand committed.