Skip to content

refactor(store): dedupe node-type maps, cover resolveParentEntityType#78

Open
bburda wants to merge 1 commit into
mainfrom
chore/parent-entity-type-test-polish
Open

refactor(store): dedupe node-type maps, cover resolveParentEntityType#78
bburda wants to merge 1 commit into
mainfrom
chore/parent-entity-type-test-polish

Conversation

@bburda
Copy link
Copy Markdown
Contributor

@bburda bburda commented May 15, 2026

Pull Request

Summary

Follow-up polish on the parent entity-type resolution used by the topic data fallback (#77). No user-facing behavior change beyond dropping a latent invalid type cast.

  • Export resolveParentEntityType and add unit tests covering the runtime_only function/app hierarchy (the scenario behind the topic data 400), operations/configurations/faults resource segments, and the not-in-tree and unknown-type fallbacks.
  • Hoist NODE_TYPE_TO_RESOURCE and resolveParentEntityType next to findNode so the /** Fallback: fetch entity details ... */ comment documents fetchEntityFromApi again.
  • Replace the duplicate type maps in handleTopicSelection and refreshSelectedEntity with the shared NODE_TYPE_TO_RESOURCE, dropping the invalid ${type}s cast for sub-area/sub-component node types.
  • Fix a JSDoc typo and a split comment fragment.

Issue

Link the related issue (required):


Type

  • Bug fix
  • New feature
  • Breaking change
  • Documentation only

Testing

  • npx vitest run - 412 tests pass (16 files), including 9 new resolveParentEntityType cases in store-helpers.test.ts.
  • npm run typecheck, npm run lint, npm run format:check - clean.
  • npm run build - succeeds.

Checklist

  • Breaking changes are clearly described (and announced in docs / changelog if needed)
  • Linting passes (npm run lint)
  • Build succeeds (npm run build)
  • Docs were updated if behavior or public API changed

Follow-up polish on the parent entity-type resolution used by the topic
data fallback.

- Export resolveParentEntityType and add unit tests covering the
  runtime_only function/app hierarchy (the scenario behind the topic
  data 400), operations/configurations/faults segments, and the
  not-in-tree and unknown-type fallbacks.
- Hoist NODE_TYPE_TO_RESOURCE and resolveParentEntityType next to
  findNode so the "Fallback: fetch entity details" comment documents
  fetchEntityFromApi again.
- Replace the duplicate type maps in handleTopicSelection and
  refreshSelectedEntity with the shared NODE_TYPE_TO_RESOURCE, dropping
  the invalid `${type}s` cast for sub-area/sub-component node types.
- Fix a JSDoc typo and a split comment fragment.

Closes #77
Copilot AI review requested due to automatic review settings May 15, 2026 10:53
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Refactors and hardens the “parent entity-type resolution” logic in the Zustand store to avoid duplicated node-type → API-resource mappings, and adds unit tests to prevent regressions in runtime_only (function/app) hierarchy scenarios tied to #77.

Changes:

  • Hoisted/deduplicated the node-type → API resource mapping into a single NODE_TYPE_TO_RESOURCE constant and reused it in topic selection + refresh logic.
  • Exported resolveParentEntityType and added focused unit tests covering runtime_only depth pitfalls, supported resource segments, and safe fallbacks.
  • Minor comment/JSDoc cleanup so the fallback documentation again applies to fetchEntityFromApi.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/lib/store.ts Centralizes node-type→resource mapping, exports resolveParentEntityType, and replaces ad-hoc casts/maps in topic selection and refresh logic.
src/lib/store-helpers.test.ts Adds unit coverage for resolveParentEntityType (runtime_only hierarchy, resource segments, unknown/missing parent fallbacks).

@bburda bburda self-assigned this May 15, 2026
@bburda bburda requested a review from mfaferek93 May 15, 2026 11:34
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.

Polish follow-up: regression test + comment cleanup for parent entity-type resolution

2 participants