Skip to content

[WC-3452] Pusher module refine#2323

Open
r0b1n wants to merge 7 commits into
mainfrom
feat/pusher-module-refine
Open

[WC-3452] Pusher module refine#2323
r0b1n wants to merge 7 commits into
mainfrom
feat/pusher-module-refine

Conversation

@r0b1n

@r0b1n r0b1n commented Jul 14, 2026

Copy link
Copy Markdown
Collaborator

No description provided.

@r0b1n r0b1n requested a review from a team as a code owner July 14, 2026 09:49
@github-actions

This comment has been minimized.

r0b1n added 6 commits July 14, 2026 14:46
SubscriptionConfig.onError was never set by any caller after handleError
was removed from Pusher.tsx. Drop the interface field, private field,
call site, and cleanup assignment to avoid misleading future readers.
…herConfig

Cover the previously untested upper layers: widget subscription building
logic in Pusher.tsx, channel name derivation, and config fetch error paths.
@r0b1n r0b1n force-pushed the feat/pusher-module-refine branch from c87f303 to 8366a69 Compare July 14, 2026 14:57
@github-actions

This comment has been minimized.

@github-actions

Copy link
Copy Markdown
Contributor

AI Code Review

🔶 Changes requested — one or more medium-severity items must be addressed


What was reviewed

File Change
automation/utils/src/steps.ts Extracted insertWidgetsIntoMpk helper; added addTestProjectWidgetsToMpk export
packages/modules/pusher/scripts/release.ts Uses new addTestProjectWidgetsToMpk to bundle legacy Pusher.mpk
packages/pluggableWidgets/pusher-web/src/Pusher.tsx Removed handleError / useCallback; removed onError from subscription config
packages/pluggableWidgets/pusher-web/src/hooks/usePusherSubscribe.ts Removed cleanup return from subscription effect; renamed instancelistenerInstance
packages/pluggableWidgets/pusher-web/src/utils/PusherListener.ts Removed onError callback, removed handleStateChange debug handler
packages/pluggableWidgets/pusher-web/src/__tests__/Pusher.spec.tsx Replaced TODO placeholder with real tests
packages/pluggableWidgets/pusher-web/src/__tests__/PusherListener.spec.ts New file — full lifecycle coverage
packages/pluggableWidgets/pusher-web/src/__tests__/fetchPusherConfig.spec.ts New file — fetch + error paths
packages/pluggableWidgets/pusher-web/src/__tests__/getChannelName.spec.ts New file — channel name derivation
packages/pluggableWidgets/pusher-web/src/__tests__/usePusherSubscribe.spec.ts New file — hook subscribe/unsubscribe/destroy lifecycle

Skipped (out of scope): dist/, pnpm-lock.yaml

CI checks: could not retrieve (command requires approval) — please verify before merging.


Findings

🔶 Medium — Missing CHANGELOG entries for behavioral changes in pusher-web

File: packages/pluggableWidgets/pusher-web/CHANGELOG.md
Problem: The [Unreleased] section only contains "Initial widget scaffolding". This PR removes the onError callback from SubscriptionConfig (a public API change), removes the state_change connection binding, and removes console.debug logging for events and auth errors — all observable behavior changes that belong in the changelog.
Fix: Add a ### Changed entry under [Unreleased]:

### Changed

- Removed `onError` callback from subscription config; errors are now logged directly by `PusherListener`.
- Removed debug-level state change and event-received logging to reduce console noise.

🔶 Medium — Missing CHANGELOG entry for module bundle change in pusher module

File: packages/modules/pusher/CHANGELOG.md
Problem: The PR intentionally bundles the legacy Pusher.mpk alongside the new widget to ease migration, as noted in the release script comment. This is a meaningful behavioral change to the published module artifact that users upgrading need to know about.
Fix: Add a ### Changed entry under [Unreleased]:

### Changed

- Module now bundles the legacy `Pusher.mpk` alongside the new `com.mendix.widget.web.Pusher.mpk` to support gradual migration.

⚠️ Low — getChannelName.spec.ts brittle symbol-based object construction

File: packages/pluggableWidgets/pusher-web/src/__tests__/getChannelName.spec.ts line 9–16
Note: makeObjectItem manually attaches a symbol key with a getEntity stub, relying on the internal convention that getChannelName / extractEntityName reads the first own symbol property of an ObjectItem. This couples the test to an undocumented implementation detail. If the ObjectItem internal structure changes (e.g. the symbol key is renamed or iterated differently), the tests silently pass but exercise dead code paths. Consider using the obj() builder from @mendix/widget-plugin-test-utils if it supports entity metadata, or document the invariant explicitly with a comment referencing the Mendix runtime source.


⚠️ Low — PusherListener.destroy() unbinds all connection events, not just the registered handler

File: packages/pluggableWidgets/pusher-web/src/utils/PusherListener.ts line 106
Note: this.pusher.connection.unbind() with no arguments removes every binding on the connection object, not only the handleConnectionError handler registered in the constructor. This is harmless today because no other handler is registered, but it is imprecise and could cause hard-to-debug issues if a second handler is added later.
Fix:

this.pusher.connection.unbind("error", this.handleConnectionError);

Positives

  • Replaced the placeholder TODO test with five well-structured spec files covering all key paths: happy path, no-op on same channel, channel change, handler update, destroy idempotency, network errors, and aborted signals.
  • insertWidgetsIntoMpk extraction eliminates the duplication between addWidgetsToMpk and addTestProjectWidgetsToMpk cleanly; the additionalFiles optional param is a minimal extension with no overhead when not used.
  • PusherListener.subscribe() correctly separates channel resubscription (channel-name change) from handler-map updates (same channel), avoiding unnecessary Pusher reconnects on every React render.
  • PusherListener.destroy() guards with this.destroyed flag — idempotency verified in tests.
  • actionValue() builder from @mendix/widget-plugin-test-utils is used correctly in Pusher.spec.tsx — no manual mock objects.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant