Files
orca/src/shared/source-control-commit-eligibility.test.ts
T
Kelvin Amoaba c903d30283 fix(mobile): build the Source Control action sheet from desktop's menu rows (#34047)
* fix(mobile): build the Source Control action sheet from desktop's menu rows

Adds Force Push and desktop's order, enable rules and hints.

* fix(mobile): rebase from desktop's effective base and keep the Force Push warning in the action sheet

* fix(mobile): keep the rebase row's base when the branch compare fails

* fix(mobile): keep upstream compares working when the default base lookup fails

* fix(mobile): keep the rebase target apart from the branch compare so failed or unsupported compares keep it

* fix(mobile): leave force pushes to desktop when the linked review has its own push target

* refactor(mobile): rebase onto the shown base and share the force-push block with the primary action
2026-10-27 13:13:25 +00:00

38 lines
1.3 KiB
TypeScript

import { describe, expect, it } from 'vitest'
import {
canSubmitCommit,
isCommitMessageFieldDisabled,
resolveCommitDisabledReason
} from './source-control-commit-eligibility'
function baseInputs(
overrides: Partial<Parameters<typeof canSubmitCommit>[0]> = {}
): Parameters<typeof canSubmitCommit>[0] {
return {
stagedCount: 1,
hasPartiallyStagedChanges: false,
hasMessage: true,
hasUnresolvedConflicts: false,
isCommitting: false,
isRemoteOperationActive: false,
...overrides
}
}
describe('source-control-commit-eligibility', () => {
it('allows committing the staged index when files are partially staged', () => {
const inputs = baseInputs({ hasPartiallyStagedChanges: true })
expect(resolveCommitDisabledReason(inputs)).toBeNull()
expect(canSubmitCommit(inputs)).toBe(true)
expect(isCommitMessageFieldDisabled(inputs)).toBe(false)
})
it('disables the message field while commit or remote work is in flight', () => {
expect(isCommitMessageFieldDisabled(baseInputs({ isCommitting: true }))).toBe(true)
expect(isCommitMessageFieldDisabled(baseInputs({ isRemoteOperationActive: true }))).toBe(true)
expect(isCommitMessageFieldDisabled(baseInputs({ isPullRequestOperationActive: true }))).toBe(
true
)
})
})