Skip to content

[Test Improver] test: add unit tests for gc-root-store.js#17806

Draft
github-actions[bot] wants to merge 2 commits into
masterfrom
test-assist/gc-root-store-tests-7ffa24f6315d9718
Draft

[Test Improver] test: add unit tests for gc-root-store.js#17806
github-actions[bot] wants to merge 2 commits into
masterfrom
test-assist/gc-root-store-tests-7ffa24f6315d9718

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

🤖 Test Improver — automated AI assistant

Goal and Rationale

shell/utils/gc/gc-root-store.js had zero test coverage. It provides the Vuex getters and actions that coordinate garbage collection across all registered stores. While adjacent files (gc.ts, gc-interval.ts, gc-route-changed.ts) already have tests, the root store orchestration layer was untested.

Approach

  • gcGetters.gcStores — pure getter: 4 tests covering multi-store results, no-match, primitive state entries (skipped), and empty state.
  • gcActions.gcRouteChanged/gcStartIntervals/gcStopIntervals — delegation tests: verify each action calls the correct underlying module with the expected arguments.
  • gcActions.gcResetStores — 2 tests: dispatches per-store reset for each gc-enabled store, and dispatches nothing when no stores.
  • gcActions.garbageCollect — 3 tests: dispatches per-store gc when setting enabled, no dispatch when disabled, no dispatch when no stores.
  • gcActions.gcPreferencesUpdated — 3 tests: enables (start intervals), disables-was-on (reset stores), disables-was-off (only stop intervals).

All dependencies (gc, gc-interval, gc-route-changed) are mocked via jest.resetModules() + jest.mock() per the existing gc test pattern.

Coverage Impact

Metric Before After
Statements 0% 100%
Branches 0% 100%
Functions 0% 100%
Lines 0% 100%

Test Status

All 15 tests pass. ESLint reports no warnings.

node_modules/.bin/jest shell/utils/gc/__tests__/gc-root-store.test.ts

Trade-offs

Simple dispatch-mock tests. Minimal maintenance burden since they follow the same pattern as existing gc tests.

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 · ● 2.9M ·

Add 15 unit tests covering gcGetters.gcStores and all gcActions:
- gcPreferencesUpdated (3 cases: enabled, disabled-was-on, disabled-was-off)
- gcRouteChanged, gcStartIntervals, gcStopIntervals (delegation)
- gcResetStores (dispatch for each store, empty stores)
- garbageCollect (enabled/disabled setting, empty stores)

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