Skip to content

Chore: Expand test suite to cover all redux functionality#1613

Merged
jumpinjackie merged 3 commits intomasterfrom
copilot/expand-test-suite-redux-functionality
Mar 15, 2026
Merged

Chore: Expand test suite to cover all redux functionality#1613
jumpinjackie merged 3 commits intomasterfrom
copilot/expand-test-suite-redux-functionality

Conversation

Copy link
Contributor

Copilot AI commented Mar 14, 2026

Expands redux test coverage to ensure all reducers, action creators, and store utilities are adequately tested — a prerequisite for a clean migration to Redux Toolkit.

New tests by area

test/reducers/viewer.spec.ts

  • MAP_ENABLE_SELECT_DRAGPANselectCanDragPan state toggling

test/reducers/toolbar.spec.ts

  • COMPONENT_CLOSE — closes component flyout; guards against unregistered context menu
  • FUSION_SET_ELEMENT_STATE — closes task menu when taskPaneVisible=false
  • FUSION_SET_TASK_PANE_VISIBILITY — closes task menu flyout on false

test/reducers/config.spec.ts

  • SET_LOCALE — locale update
  • MAP_ENABLE_SELECT_DRAGPANselectCanDragPan update

test/reducers/map-state.spec.ts

Previously untested layer management actions: MAP_REFRESH, MAP_SET_LAYER_TRANSPARENCY, MAP_SHOW_SELECTED_FEATURE, EXTERNAL_LAYERS_READY, LAYER_ADDED (with/without default style), REMOVE_LAYER, SET_LAYER_VISIBILITY, SET_LAYER_OPACITY, SET_HEATMAP_LAYER_BLUR, SET_HEATMAP_LAYER_RADIUS, SET_LAYER_INDEX, SET_LAYER_VECTOR_STYLE, ADD_LAYER_BUSY_WORKER, REMOVE_LAYER_BUSY_WORKER

test/actions/map.spec.ts

  • setMapSwipeMode / updateMapSwipePosition action creators
  • setCurrentView thunk — dispatches MAP_SET_VIEW only when the view meaningfully differs from the current state
// Deduplication guard: same view → no dispatch
const thunk = setCurrentView({ ...currentView });
thunk(dispatch, getState); // dispatched.length === 0

// Different view → dispatches MAP_SET_VIEW
const thunk2 = setCurrentView({ x: -87.50, y: 43.50, scale: 50000 });
thunk2(dispatch, getState); // dispatched[0].type === ActionType.MAP_SET_VIEW

test/store/configure-store.spec.ts (new)

  • Store creation with all root reducers present
  • Extra reducer composition via extraReducers
  • Action dispatch end-to-end through the store
  • Hydration from provided initial state

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • storybook.js.org
    • Triggering command: /opt/hostedtoolcache/node/24.14.0/x64/bin/node /opt/hostedtoolcache/node/24.14.0/x64/bin/node /home/REDACTED/work/mapguide-react-layout/mapguide-react-layout/node_modules/.bin/storybook build -c .storybook (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>Chore: Expand test suite to cover all redux functionality</issue_title>
<issue_description>To make the eventual migration to redux toolkit more seamless. Expand the current test suite to ensure all redux functionality (dispatchers, reducers, etc) are adequately covered by tests.</issue_description>

Comments on the Issue (you are @copilot in this section)


📱 Kick off Copilot coding agent tasks wherever you are with GitHub Mobile, available on iOS and Android.

@coveralls
Copy link

coveralls commented Mar 14, 2026

Coverage Status

coverage: 40.349% (+0.9%) from 39.489%
when pulling a385d4d on copilot/expand-test-suite-redux-functionality
into 18ef117 on master.

Co-authored-by: jumpinjackie <563860+jumpinjackie@users.noreply.github.com>
Copilot AI changed the title [WIP] [Chore] Expand test suite to cover all redux functionality Chore: Expand test suite to cover all redux functionality Mar 14, 2026
Copilot AI requested a review from jumpinjackie March 14, 2026 18:08
@jumpinjackie
Copy link
Owner

@copilot Build errors. Pls fix.

ERROR in /home/runner/work/mapguide-react-layout/mapguide-react-layout/test/reducers/map-state.spec.ts
503:50-56
[tsl] ERROR in /home/runner/work/mapguide-react-layout/mapguide-react-layout/test/reducers/map-state.spec.ts(503,51)
      TS2345: Argument of type '{ type: ActionType; payload: { mapName: string; }; }' is not assignable to parameter of type 'ViewerAction'.
  Type '{ type: ActionType; payload: { mapName: string; }; }' is not assignable to type 'ICloseContextMenuAction | IAcknowledgeStartupWarningsAction | ITaskPaneBackAction | ... 5 more ... | IClearClientSelectionAction'.
    Type '{ type: ActionType; payload: { mapName: string; }; }' is not assignable to type 'IClearClientSelectionAction'.
      Types of property 'type' are incompatible.
        Type 'ActionType' is not assignable to type 'ActionType.MAP_CLEAR_CLIENT_SELECTION'.

ERROR in /home/runner/work/mapguide-react-layout/mapguide-react-layout/test/reducers/viewer.spec.ts
66:25-41
[tsl] ERROR in /home/runner/work/mapguide-react-layout/mapguide-react-layout/test/reducers/viewer.spec.ts(66,26)
      TS2339: Property 'selectCanDragPan' does not exist on type 'IViewerReducerState | { size: number[]; busyCount: number; tool: ActiveMapTool; featureTooltipsEnabled: boolean; }'.
  Property 'selectCanDragPan' does not exist on type 'IViewerReducerState'.

ERROR in /home/runner/work/mapguide-react-layout/mapguide-react-layout/test/reducers/viewer.spec.ts
72:25-41
[tsl] ERROR in /home/runner/work/mapguide-react-layout/mapguide-react-layout/test/reducers/viewer.spec.ts(72,26)
      TS2339: Property 'selectCanDragPan' does not exist on type 'IViewerReducerState | { size: number[]; busyCount: number; tool: ActiveMapTool; featureTooltipsEnabled: boolean; }'.
  Property 'selectCanDragPan' does not exist on type 'IViewerReducerState'.

ERROR in /home/runner/work/mapguide-react-layout/mapguide-react-layout/test/store/configure-store.spec.ts
35:33-56
[tsl] ERROR in /home/runner/work/mapguide-react-layout/mapguide-react-layout/test/store/configure-store.spec.ts(35,34)
      TS2571: Object is of type 'unknown'.

ERROR in /home/runner/work/mapguide-react-layout/mapguide-react-layout/test/store/configure-store.spec.ts
42:23-29
[tsl] ERROR in /home/runner/work/mapguide-react-layout/mapguide-react-layout/test/store/configure-store.spec.ts(42,24)
      TS2345: Argument of type 'IMapSetBusyCountAction' is not assignable to parameter of type 'never'.

ERROR in /home/runner/work/mapguide-react-layout/mapguide-react-layout/test/store/configure-store.spec.ts
44:15-38
[tsl] ERROR in /home/runner/work/mapguide-react-layout/mapguide-react-layout/test/store/configure-store.spec.ts(44,16)
      TS2571: Object is of type 'unknown'.

ERROR in /home/runner/work/mapguide-react-layout/mapguide-react-layout/test/store/configure-store.spec.ts
57:15-38
[tsl] ERROR in /home/runner/work/mapguide-react-layout/mapguide-react-layout/test/store/configure-store.spec.ts(57,16)
      TS2571: Object is of type 'unknown'.

ERROR in /home/runner/work/mapguide-react-layout/mapguide-react-layout/test/store/configure-store.spec.ts
58:15-38
[tsl] ERROR in /home/runner/work/mapguide-react-layout/mapguide-react-layout/test/store/configure-store.spec.ts(58,16)
      TS2571: Object is of type 'unknown'.

Co-authored-by: jumpinjackie <563860+jumpinjackie@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Mar 14, 2026

@copilot Build errors. Pls fix.

...

Fixed in a385d4d. Three issues addressed:

  1. viewer.spec.ts — Removed MAP_ENABLE_SELECT_DRAGPAN tests that accessed state.selectCanDragPan: this property is on IConfigurationReducerState, not IViewerReducerState, so accessing it was a type error. Coverage for this action is still provided by config.spec.ts.

  2. map-state.spec.ts — Cast externalLayersReady() result to IExternalLayersReadyAction. The function lacks an explicit return type so TypeScript widens the type field to ActionType (the whole enum) instead of ActionType.EXTERNAL_LAYERS_READY, which fails the ViewerAction union check.

  3. configure-store.spec.ts — Added as unknown as AppStore casts everywhere. configureStore uses compose() which loses Redux type generics at compile time, causing TypeScript to infer Store<EmptyObject, never> instead of the real app state/action types.

@jumpinjackie jumpinjackie marked this pull request as ready for review March 15, 2026 00:00
@jumpinjackie jumpinjackie merged commit 3885f9d into master Mar 15, 2026
4 checks passed
@jumpinjackie jumpinjackie deleted the copilot/expand-test-suite-redux-functionality branch March 15, 2026 00:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Chore: Expand test suite to cover all redux functionality

3 participants