Skip to content

Consolidate main-action Jest mock and harness boilerplate - #11848

Merged
lpcox merged 2 commits into
mainfrom
copilot/duplicate-jest-mock-imports
Nov 20, 2026
Merged

lpcox merged 2 commits into
mainfrom
copilot/duplicate-jest-mock-imports

Conversation

@lpcox

@lpcox lpcox commented Nov 19, 2026 •

Copy link
Copy Markdown
Collaborator

Five main-action suites duplicate module mock registration, typed mock declarations, and platform/exit setup.

  • Shared mocks: Centralize registration in import-first setup modules, keeping enclave mocks opt-in and preserving the coverage-gaps suite’s smaller mock set.
  • Typed access: Add getMainActionMocks() and default dependency wiring for the existing harness.
  • Platform lifecycle: Add setupMainActionPlatformHarness() to manage Linux/root setup and restore platform state and spies.
import './main-action-enclave-mocks.test-utils';
import { createMainAction } from './main-action';
import { getMainActionMocks } from './main-action.test-utils';

const { mockedDockerManager } = getMainActionMocks();

@lpcox lpcox changed the title [WIP] Refactor duplicate jest mock boilerplate in main-action tests Consolidate main-action Jest mock and harness boilerplate Nov 19, 2026
@lpcox
lpcox marked this pull request as ready for review November 19, 2026 22:56
Copilot AI adaptive review requested due to automatic review settings November 19, 2026 22:56

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

Runtime validation is needed to confirm Jest module-loading order, hoisted mock registration, and nested lifecycle-hook cleanup preserve isolation across all affected suites.

No open issues 🎉

What changed in this PR

This PR consolidates duplicated Jest setup across the main-action test suites while preserving specialized enclave and coverage-gap mocking behavior.

Changes:

  • Centralizes common and enclave-specific mock registration.
  • Adds typed getMainActionMocks() access and default harness dependency wiring.
  • Adds reusable platform and process lifecycle harness setup with focused tests.
File Description
src/​commands/​main-action.test-utils.ts Provides typed mock access, default harness dependencies, and platform lifecycle setup.
src/​commands/​main-action-workflow.test.ts Replaces duplicated setup with shared mocks and platform lifecycle handling.
src/​commands/​main-action-mocks.test-utils.ts Registers common main-action module mocks.
src/​commands/​main-action-harness.test.ts Tests shared mock identity, default wiring, and platform harness behavior.
src/​commands/​main-action-enclave-mocks.test-utils.ts Adds opt-in enclave-related mocks on top of the common mocks.
src/​commands/​main-action-coverage-gaps.test.ts Uses common mocks while retaining the suite's smaller mock set.
src/​commands/​main-action-config-artifacts.test.ts Replaces duplicated setup with shared mocks and platform lifecycle handling.
src/​commands/​main-action-cleanup.test.ts Replaces duplicated setup with shared mocks and platform lifecycle handling.
src/​commands/​main-action-argument-parsing.test.ts Uses the shared mocks and platform harness for argument-parsing tests.

Review effort: Lite (adaptive)

@github-actions

Copy link
Copy Markdown
Contributor

✅ Copilot review passed with no inline comments.

@lpcox Add the ready-for-aw label to this PR to trigger agentic CI smoke tests.

@lpcox
lpcox merged commit ad96d76 into main Nov 20, 2026
45 of 48 checks passed
@lpcox
lpcox deleted the copilot/duplicate-jest-mock-imports branch November 20, 2026 00:13
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.

[Duplicate Code] Duplicate jest mock/import boilerplate across main-action test files

3 participants