Skip to content

test: add unit tests for device manager functionality#1507

Closed
sawirricardo wants to merge 6 commits into
responsively-org:mainfrom
sawirricardo:add-device-manager-unit-tests
Closed

test: add unit tests for device manager functionality#1507
sawirricardo wants to merge 6 commits into
responsively-org:mainfrom
sawirricardo:add-device-manager-unit-tests

Conversation

@sawirricardo

Copy link
Copy Markdown

Summary

Adds comprehensive unit tests for the device manager Redux slice and the sanitizeSuites utility, addressing issue #934.

Device manager slice tests (index.test.ts)

  • setDevices — replaces device list, handles empty array
  • setActiveSuite — updates active suite id
  • addSuite — appends suite and makes it active
  • addSuites — merge logic with name collision (incoming wins)
  • setSuiteDevices — updates devices for existing suite, no-op for missing suite
  • deleteSuite — removes suite and resets activeSuite, no-op for missing id
  • deleteAllSuites — resets to default single suite
  • selectActiveSuite selector — returns matching suite, falls back to first

sanitizeSuites tests (utils.test.ts)

  • Creates default suite when stored suites are null or empty
  • Removes invalid device IDs from suites
  • Does not write to store when all IDs are valid (no dirty state)
  • Handles multiple suites, only writes when dirty

All 17 tests pass with vitest run.

Fixes #934

Add comprehensive unit tests for the device manager Redux slice and
sanitizeSuites utility function.

Covers:
- setDevices, setActiveSuite, addSuite, addSuites (merge logic)
- setSuiteDevices, deleteSuite, deleteAllSuites
- selectActiveSuite selector with fallback behavior
- sanitizeSuites: null/empty suites, invalid device ID filtering,
  dirty vs clean state

Fixes responsively-org#934
@CLAassistant

CLAassistant commented Jun 12, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

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.

Add unit tests for the device manager functionality

2 participants