[Test Improver] Add unit tests for ui-context store - #61
Draft
github-actions[bot] wants to merge 1 commit into
Draft
[Test Improver] Add unit tests for ui-context store#61github-actions[bot] wants to merge 1 commit into
github-actions[bot] wants to merge 1 commit into
Conversation
22 tests covering state factory, getters.all (sorting by tag, edge cases), mutations (add, update no-op for missing id, remove), and actions (add validation for invalid context, sequential id generation, idCounter increments; update/remove throw for missing elements and call correct commits). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
26 tasks
21 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖 This PR was created by Test Improver, an automated AI assistant focused on improving test coverage.
Goal and Rationale
Add unit tests for
shell/store/ui-context.ts. This store manages UI context elements (tag-based overlays/annotations). It had zero test coverage despite containing meaningful validation logic in its actions.Key testable logic:
actions.add: throws on invalid context (undefinedvalue, falsytag, null), auto-incrementsidCounter, generates sequentialctx-Nidsactions.update/remove: throw when element id not found in stategetters.all: sorts contexts alphabetically by tag (empty tags sort first)mutations.update: silently no-ops for missing element idApproach
state()factory, all 3 mutations, thegetters.allgetter, and all 3 actionsit.eachwith named-object entries for the 4 invalid-context throw casesCoverage Impact
shell/store/ui-context.tsTrade-offs
as anycasts in a few places because theElement.idTypeScript interface saysnumberbut the runtime code assigns string values ('ctx-0'). The type discrepancy is in the source, not the tests.Reproducibility
Test Status
✅ 22 tests passing, 0 failing
✅ ESLint: no warnings or errors
Warning
Firewall blocked 1 domain
The following domain was blocked by the firewall during workflow execution:
download.cypress.ioSee Network Configuration for more information.