test(core): add unit tests for ci-check, rebase, and octokit service#3
Merged
test(core): add unit tests for ci-check, rebase, and octokit service#3
Conversation
…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.
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.
Description
This PR adds a unit test suite for the
corepackage, covering theshouldSkipCI,cascadeRebase, andstartRebasesapplication functions as well as theOctokitService.ci-check.test.tswith full coverage of theshouldSkipCIfunction, asserting all early-return paths and the happy path (tree SHA match, before not an ancestor)rebase.test.tscoveringcascadeRebaseandstartRebases, including conflict file extraction, failure messages, and label-filtered PR queuingoctokit.service.test.tsasserting correct Octokit API calls for PR and commit retrievalpackages/core/src/test-config/preload.tsto mock the GitHub App module (github/auth) before any test imports itbunfig.tomlto thecorepackage withpreloadandrandomize = trueto catch order-dependent test failurestestjob to.github/workflows/ci-pipeline.yamlthat runs after setup and restores thenode_modulescache before executingbun run testtestscripts to the root andcorepackage.jsonfilesHow to test this change
Run the test suite locally from the repo root:
All tests in
packages/coreshould pass. The randomised order (randomize = trueinbunfig.toml) means re-running a few times will confirm there are no order-dependent failures.The new
testCI job can be verified by inspecting the Actions run triggered by this PR — it should appear as a separate job aftersetupcompletes.