test(matrix): make voice-detection tests hermetic against mention gating (#49946)

test_matrix_voice flaked in CI (6/7 failing on some shards, passing on
others and on main) depending on leaked MATRIX_REQUIRE_MENTION env state.

Root cause: the adapter defaults require_mention=True (falling back to the
MATRIX_REQUIRE_MENTION env var). These tests fire a group-room audio event
with no @mention, so _resolve_message_context drops it before dispatch
('No event was captured') whenever require_mention resolves True — which
happens in a clean shard, but an earlier test in another shard can leave
MATRIX_REQUIRE_MENTION=false in os.environ and mask it. The plugin
migration (#5600105478 adapter→bundled plugin) shifted shard composition
and exposed it.

Pin require_mention: False in the test adapter config so these media-TYPE
detection tests are no longer gated by the mention requirement, regardless
of ambient env. Verified: 7/7 pass with MATRIX_REQUIRE_MENTION=true (the
failing condition) AND with the env unset.
This commit is contained in:
Teknium 2026-06-20 21:22:11 -07:00 committed by GitHub
parent 4c349e85f8
commit 4b7f9a4d30
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 11 additions and 1 deletions

View File

@ -26,7 +26,16 @@ from gateway.platforms.base import MessageType
# ---------------------------------------------------------------------------
def _make_adapter():
"""Create a MatrixAdapter with mocked config."""
"""Create a MatrixAdapter with mocked config.
Pins ``require_mention: False`` so these media-detection tests are NOT
gated by the mention requirement. The adapter defaults require_mention to
True (falling back to the MATRIX_REQUIRE_MENTION env var), so without this
a group-room audio event with no @mention is dropped by
_resolve_message_context before dispatch making the tests pass or fail
depending on leaked env state from other tests in the same shard. These
tests exercise voice/audio TYPE detection, not mention gating.
"""
from plugins.platforms.matrix.adapter import MatrixAdapter
from gateway.config import PlatformConfig
@ -36,6 +45,7 @@ def _make_adapter():
extra={
"homeserver": "https://matrix.example.org",
"user_id": "@bot:example.org",
"require_mention": False,
},
)
adapter = MatrixAdapter(config)