Skip to content

[Test Improver] Add unit tests for action-menu store - #81

Draft
github-actions[bot] wants to merge 1 commit into
masterfrom
test-assist/action-menu-store-e9970a22c9567d42
Draft

[Test Improver] Add unit tests for action-menu store#81
github-actions[bot] wants to merge 1 commit into
masterfrom
test-assist/action-menu-store-e9970a22c9567d42

Conversation

@github-actions

Copy link
Copy Markdown

🤖 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/action-menu.js. This store manages the context-menu/action-menu UI state and contains non-trivial logic that was completely untested:

  • optionsArray getter — builds a merged action list from multiple selected resources, tracking per-action available/total counts to compute the final enabled state
  • togglePromptModal mutation — three distinct code paths (clear, performCallback, show-modal)
  • execute action — dispatches to per-resource action functions, supports altAction/altResource substitution
  • Other mutations with conditional normalisation (togglePromptRemove, togglePromptRestore, SET_RESOURCE)

Approach

  1. Import state, getters, mutations, and actions directly from the module for isolated unit testing (no Vuex runtime)
  2. Drive optionsArray through resources shapes to verify the _add/_filter helper logic indirectly
  3. Use plain Jest mock functions for resource action callbacks

Coverage Impact

Metric Before After
Tests added 34
Test file none shell/store/__tests__/action-menu.test.ts

Trade-offs

  • Tests cover the public surface (state, getters, mutations, actions). The private _add/_filter/_execute helpers are exercised indirectly through optionsArray and execute.
  • Tests document one subtle behaviour: actions absent on a resource are not counted against it (only resources that declare the action participate in the available/total comparison).

Reproducibility

YARN_IGNORE_ENGINES=true NODE_OPTIONS=--max_old_space_size=8192 yarn test:ci --testPathPattern="shell/store/__tests__/action-menu"

Test Status

✅ All 34 tests pass. No linting warnings.

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • download.cypress.io

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "download.cypress.io"

See Network Configuration for more information.

Generated by Daily Test Improver · ● 3.7M ·

Add 34 unit tests for shell/store/action-menu.js covering:
- State factory default values
- optionsArray getter: empty/null resources, single resource, multi-resource
  action merging, enabled/disabled logic, deduplification, anyEnabled filtering
- show/hide mutations including single-to-array normalization
- togglePromptRemove / togglePromptRestore mutations
- togglePromptModal: falsy clear path, performCallback path, showModal path
- updateModalData key/value merge
- clearCallbackData and SET_RESOURCE mutations
- execute action: per-resource dispatch, skip missing, altAction/altResource path
- setResource and clearCallbackData actions

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.

0 participants