Repository navigation
improve(test): speed up Mattermost send suite - #124114
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 15, 2026, 4:52 AM ET / 08:52 UTC. ClawSweeper reviewWhat this changesThe PR imports the mocked Mattermost send and target-resolution owners once per file instead of once per test, while assigning each default-account test a distinct cache token. Merge readinessKeep open for normal maintainer handling. The test-only refactor aligns isolation with the real token-keyed cache boundary and has no actionable correctness finding; rebase it onto current main and confirm exact-head checks before merge. Priority: P3 Review scores
Verification
How this fits togetherMattermost sends resolve an account and target, use token-keyed caches for user/channel lookups, then send through the plugin runtime. The changed test suite mocks transport boundaries while exercising those real resolution and cache owners. flowchart LR
A[Test mocks] --> B[File-scoped owner import]
B --> C[Account resolution]
C --> D[Token-keyed caches]
D --> E[Send and target logic]
E --> F[Mock transport assertions]
Decision needed
Why: The author association and Before merge
Agent review detailsSecurityNone. PR surfaceTests +4. Total +4 across 1 file. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep the file-scoped import and production-keyed test namespaces, then merge after a clean rebase confirms the focused Mattermost suite and normal exact-head checks. Do we have a high-confidence way to reproduce the issue? Not applicable: this PR optimizes test-suite execution rather than repairing a user-facing defect; the body supplies focused before/after Testbox evidence. Is this the best way to solve the issue? Yes: using unique values at the real base-URL-plus-token cache key is cleaner than retaining repeated module resets or adding a test-only cache-reset API. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 4fc375654d34. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
Patch-identical after rebase; stable patch id remains Fresh exact-head landing proof for
The controlled same-Testbox A/B remains patch-identical: wall -18.4%, Vitest -22.7%, test body -89.3%, CPU user -20.1%, and peak RSS -41.6% (about 971 MiB). Native review artifacts validate as |
|
ClawSweeper’s merge notes are addressed:
No actionable Rank-up move or finding remains for the merge coordinator. |
|
Merged via squash.
|
What Problem This Solves
Resolves avoidable runtime and memory overhead in the Mattermost send test suite. The suite retained per-test
vi.resetModules()and dynamic owner imports after its old test-only cache reset was removed, so every test rebuilt the real send and target-resolution module graph.Why This Change Was Made
The test file now imports the real send and target-resolution owners once, after mocks are installed, while preserving every test and assertion. Default-account tests use a unique
botTokennamespace per test because the production caches are keyed by base URL and token; cache-bound tests keep their explicit independent tokens. This exercises real production isolation without adding a production seam, clearing caches, weakening assertions, or using timing shortcuts.The one-time import is deliberately file-scoped. An earlier candidate put
beforeAllinside the first describe block, which made a filtered run of the later cache-bound suite fail withsendMessageMattermost is not a function; moving the hook to file scope fixed that filtered path.User Impact
No product behavior changes. Mattermost's test suite keeps the same 49 tests and production composition while running with materially lower body time, CPU, and peak memory.
Evidence
tbx_01m0286f8cx9x8rgrjj1yn93k0, run 31874291639, stopped):channel-secondclassification; restoring unique production cache keys returned the file to green.extension-import-boundariesandextension-test-boundary.tbx_01m0297956c23rpb7g2vbc2x9a, run 31875025720, stopped.git diff --checkpassed. Fresh committed-branch autoreview reported no actionable findings.