Skip to content

[WC-3452] Pusher module refine#2323

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

[WC-3452] Pusher module refine#2323
r0b1n wants to merge 6 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

Copy link
Copy Markdown
Contributor

AI Code Review

⚠️ Approved with suggestions — low-to-medium items only, safe to merge after addressing the ActionValue mock


What was reviewed

File Change
automation/utils/src/steps.ts Extracted insertWidgetsIntoMpk helper; added addTestProjectWidgetsToMpk export
packages/modules/pusher/scripts/release.ts Added step to bundle legacy Pusher.mpk alongside new widget
packages/pluggableWidgets/pusher-web/src/Pusher.tsx Removed onError callback and useCallback wrapper
packages/pluggableWidgets/pusher-web/src/hooks/usePusherSubscribe.ts Removed subscription effect cleanup (unsubscribe-on-rerender)
packages/pluggableWidgets/pusher-web/src/utils/PusherListener.ts Removed onError, state_change handler, related fields
packages/pluggableWidgets/pusher-web/src/__tests__/Pusher.spec.tsx Replaced placeholder with real tests
packages/pluggableWidgets/pusher-web/src/__tests__/PusherListener.spec.ts New — full class coverage
packages/pluggableWidgets/pusher-web/src/__tests__/fetchPusherConfig.spec.ts New — covers all response/abort branches
packages/pluggableWidgets/pusher-web/src/__tests__/getChannelName.spec.ts New — covers all edge cases
packages/pluggableWidgets/pusher-web/src/__tests__/usePusherSubscribe.spec.ts New — hook lifecycle coverage

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


Findings

🔶 Medium — Manual ActionValue mock instead of actionValue() builder

File: packages/pluggableWidgets/pusher-web/src/__tests__/Pusher.spec.tsx lines 18–20
Problem: makeAction builds a raw object literal cast to ActionValue. This misses the status, validation, readOnly, and other fields present on a real ActionValue, making the mock brittle and inconsistent with the rest of the repo's test conventions (actionValue() from @mendix/widget-plugin-test-utils).
Fix:

import { actionValue } from "@mendix/widget-plugin-test-utils";

// Replace makeAction with:
const action = actionValue(); // already a jest.fn()-backed ActionValue
// If you need canExecute=false: actionValue(false)

Then remove the makeAction helper entirely and inline actionValue() / actionValue(false) at call sites.


⚠️ Low — Grammar nit in release script comment

File: packages/modules/pusher/scripts/release.ts line 27
Note: "New widgets has different filename" → "New widget has a different filename". Minor polish before this pattern gets copy-pasted.


Positives

  • Correct fix for double-unsubscribe: Removing the cleanup callback from the subscription effect is the right call. The old code called listener.unsubscribe() in the cleanup AND PusherListener.subscribe() calls unsubscribe() internally on channel change — two consecutive unsubscribes for every config update. The new code relies on PusherListener managing its own channel lifecycle, which is exactly where that logic belongs.
  • insertWidgetsIntoMpk extraction is clean: The refactor correctly uses distinct tmpDir names (tmp vs tmp_local_widgets) so sequential calls can't race on the same temp path. The additionalFiles optional param keeps the API minimal.
  • Test coverage is genuinely comprehensive: The five new spec files cover the full lifecycle — config fetch (including abort/missing-fields), channel name derivation, listener subscribe/resubscribe/handler-hot-swap/destroy idempotency, hook mount/unmount/undefined-subscription, and component-level subscription wiring. This goes well beyond a placeholder.
  • PusherListener.spec.ts handler-hot-swap test is particularly well-designed: it verifies that the bind_global callback always dispatches to the current handler map, not a stale closure — the exact correctness property that matters for Mendix re-render cycles.

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