Run the UTS through the per-side package factories - #2294
Conversation
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (6)
Disabled knowledge base sources:
WalkthroughThe UTS harness now selects core, device, or server client construction through ChangesPer-side UTS execution
Estimated code review effort: 3 (Moderate) | ~20 minutes Change: Other Suggested reviewers: ✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. A rabbit hops through core and device, Comment |
The UTS constructs every client through one seam (Ably.Rest /
Ably.Realtime in helpers.ts), previously hardwired to the core
constructors. Select the entry point with UTS_SIDE=core|device|server:
core keeps today's behavior (the entry shape of the existing ably
package), device routes realtime construction through
@ably/pubsub-device's createClient (REST stays on the package's
unstamped Rest re-export, as the package ships no HTTP factory), and
server routes both kinds through @ably/pubsub-server's factories. A
constructor-shaped wrapper keeps 'new Ably.Realtime(...)', instanceof
and statics (PresenceMessage, Crypto, ...) working unchanged at every
call site.
The factories are imported from packages/{device,server}/src with
@ably/pubsub-core mapped onto the core's Node.js source entry by a new
UTS tsconfig (pointed at by TSX_TSCONFIG_PATH), so the clients they
construct share the Platform singleton the mock installers patch. The
built wrapper dists cannot be used here: they resolve the core to
build/ably-node.js, a second module instance whose Platform the mocks
never touch.
side_modes.test.ts is a harness self-test, not a spec translation: it
asserts each mode's side-declaring agent stamp, so a broken seam or
paths mapping fails loudly instead of silently degrading the per-side
runs into duplicates of the core run.
This closes the remaining half of the rollout plan's conformance step
(suite and UTS run against the new layout for both packages); the
per-side agent wire assertions landed separately in
packages/core/test/unit/pubsub_side_agent.test.js.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Adds the side dimension to the Test NodeJS (UTS) matrix (2 node versions x 3 sides). Each leg runs the same unit and integration tiers with UTS_SIDE selecting the entry point; conformance must be identical on every leg because the factories only stamp the side-declaring agent entry, and side_modes.test.ts fails any leg whose stamp does not match its mode. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
f7c2a17 to
2d70f3f
Compare
ttypic
left a comment
There was a problem hiding this comment.
LGTM, weirdly github shows no indents for me, but locally in git everything looks good
Stacked on #2293 — closes the remaining half of the rollout plan's conformance step: "Test suite and UTS run against the new layout for both packages, plus an explicit assertion on the agent value per side". (The agent wire assertions landed on #2293 directly as
packages/core/test/unit/pubsub_side_agent.test.js; this PR makes the UTS itself run through the per-side entry points.)What
The UTS constructs every client through one seam —
Ably.Rest/Ably.Realtimeinhelpers.ts(~1,200 call sites across 135 files, all unchanged). This PR makes that seam selectable viaUTS_SIDE:core(default)ablypackage)deviceRestre-export (it ships no HTTP factory)@ably/pubsub-devicecreateClientserver@ably/pubsub-servercreateHttpClient@ably/pubsub-servercreateRealtimeClientA constructor-shaped wrapper keeps
new Ably.Realtime(...),instanceof, and statics (PresenceMessage,Crypto, …) working unchanged in every mode.How the factories reach the mocked core
The factories are imported from
packages/{device,server}/srcsource, with@ably/pubsub-coremapped onto the core's Node.js source entry by a new UTS tsconfig (packages/core/test/uts/tsconfig.json, viaTSX_TSCONFIG_PATH). This is load-bearing: the built wrapper dists resolve the core tobuild/ably-node.js, a second module instance whosePlatformsingleton the UTS mock installers never touch — pointing the suite at the dists would silently bypass every mock. (The dist artifacts stay covered end-to-end bytest:packageand the agent wire test on #2293.)side_modes.test.tsis a harness self-test guarding exactly that failure mode: it asserts each mode's side-declaring agent stamp, so a broken seam or paths mapping fails the leg loudly instead of degrading the per-side runs into duplicates of the core run.CI
The Test NodeJS (UTS) matrix gains the side dimension:
{18.x, 20.x} × {core, device, server}, same two tiers per leg.Verification
All three modes run locally with identical results: unit tier 1395 passing × 3, integration tier 244 passing × 3, plus the per-mode stamp self-tests.
tsc --noEmitover the typedoc project (which includestest/uts) compiles clean, and everything is prettier-formatted.🤖 Generated with Claude Code
Summary by CodeRabbit
Tests
Documentation