Skip to content

test(core): add unit tests for ci-check, rebase, and octokit service#3

Merged
mikais13 merged 8 commits intomainfrom
feat/setup-tests
Apr 8, 2026
Merged

test(core): add unit tests for ci-check, rebase, and octokit service#3
mikais13 merged 8 commits intomainfrom
feat/setup-tests

Conversation

@mikais13
Copy link
Copy Markdown
Owner

@mikais13 mikais13 commented Apr 8, 2026

Description

This PR adds a unit test suite for the core package, covering the shouldSkipCI, cascadeRebase, and startRebases application functions as well as the OctokitService.

  • adds ci-check.test.ts with full coverage of the shouldSkipCI function, asserting all early-return paths and the happy path (tree SHA match, before not an ancestor)
  • adds rebase.test.ts covering cascadeRebase and startRebases, including conflict file extraction, failure messages, and label-filtered PR queuing
  • adds octokit.service.test.ts asserting correct Octokit API calls for PR and commit retrieval
  • adds packages/core/src/test-config/preload.ts to mock the GitHub App module (github/auth) before any test imports it
  • adds bunfig.toml to the core package with preload and randomize = true to catch order-dependent test failures
  • adds a test job to .github/workflows/ci-pipeline.yaml that runs after setup and restores the node_modules cache before executing bun run test
  • adds test scripts to the root and core package.json files

How to test this change

Run the test suite locally from the repo root:

bun run test

All tests in packages/core should pass. The randomised order (randomize = true in bunfig.toml) means re-running a few times will confirm there are no order-dependent failures.

The new test CI job can be verified by inspecting the Actions run triggered by this PR — it should appear as a separate job after setup completes.

mikais13 added 8 commits April 8, 2026 12:05
…ebase tests

Pin the operator-facing error messages (conflict files, push failure,
GitHub API failure) via console.error spy assertions so refactors
cannot silently drop them.
Cover the webhook entry point: happy path, clone failure, and
cascadeRebase failure. Uses mock.module for getInstallationArtifacts
and spyOn for GitService/OctokitService prototype methods, following
the ci-check.test.ts pattern.
@mikais13 mikais13 merged commit 9fd2543 into main Apr 8, 2026
5 checks passed
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.

1 participant