zidane-ui/ git/ testing/ contract
import { … } from 'zidane-ui/git/testing/contract'ui/src/git/testing/contract.ts
Functions#
describeGitHostContractFunction#
Declares the shared GitHost suite for one implementation.
function describeGitHostContract(
name: string,
makeHarness: GitHostHarnessFactory,
capabilities: readonly GitHostCapability[],
): voidParameters
| Name | Type | Description |
|---|---|---|
| name | string | The implementation's name, shown in the suite title. |
| makeHarness | GitHostHarnessFactory | Builds a fresh host over a backend that does what it is given, once per test. |
| capabilities | readonly GitHostCapability[] | The optional members the host offers. Every other optional member must be undefined. |
Interfaces#
GitHostContractBackendInterface#
What the backend behind the host holds, and what it does with each action.
interface GitHostContractBackendProperties
| Name | Type | Description |
|---|---|---|
| branches | GitBranch[] | Local branches, most recent first. The first is checked out. |
| branchPullRequests | Record<string, GitBranchPullRequest> | The open pull request per branch. Branches left out have none. |
| cloned | { input: string; parent: string }[] | Clones that ran: what was cloned, and where. |
| current | string | The current branch. Switches and new branches land here. |
| cwd | string | The checkout's folder. |
| environments | EnvironmentDescriptor[] | The environment kinds for |
| existsMessage | string | Creating a branch that exists fails with this message. |
| folders | { existsMessage: string; outsideMessage: string; roots: string[]; tree: Record<string, string[]> } | The remote host's folders: its roots, and the folders under each path. A path outside the roots is refused with
|
| held | { branch: string; chats: string[]; message: string; worktree: string } | A branch another worktree has checked out: switching to it is refused with git's message, the worktree and its chats. |
| hostId | string | The saved server whose folders |
| moves | { branch?: string; sessionId: string }[] | Sessions moved into worktrees land here. |
| origins | Record<string, string> | The |
| pickedFolder | string | What the native folder dialog answers. |
| pullRequests | GitPullRequest[] | Open pull requests. A search answers the ones |
| relocations | { branch?: string; cwd?: string; kind: string; sessionId: string }[] | Sessions moved anywhere ( |
| repo | { defaultParent: string; info: GitRepoInfo; input: string; progress: GitCloneProgress[]; refusedInput: string; refusedMessage: string; spec: GitRepoSpec } | The repository import: what |
| serverClones | { hostId: string; input: string; parent: string }[] | Clones that ran on a server: which server, what, and where. |
| sessionId | string | A session in that folder. |
| status | GitStatus | The checkout's status. |
| sync | { conflictCwd: string; conflictMessage: string; conflicts: string[] } | What a sync does: it pulls |
| synced | string[] | Syncs that ran, by folder. |
GitHostHarnessInterface#
A host built over a backend, and what the suite drives on it.
interface GitHostHarnessProperties
| Name | Type | Description |
|---|---|---|
| host | GitHost | The host under test. |
| activity? | (sessionId: string) => void | Has the backend report work by a session that may have moved its checkout (needed for |
| changeEnvironments? | () => void | Has the backend announce that the environment kinds may have changed (needed for |
| dispose? | () => void | Closes connections and timers after each test. |
| moveRefs? | () => void | Has the backend announce that the checkout's refs moved (needed for |
Types#
GitHostCapabilityType#
An optional GitHost member.
type GitHostCapability =
| 'branches'
| 'pullRequests'
| 'checkout'
| 'createBranch'
| 'startWorktree'
| 'moveSession'
| 'environments'
| 'subscribeEnvironments'
| 'status'
| 'subscribeRefs'
| 'listFolders'
| 'pickFolder'
| 'subscribeActivity'
| 'branchPullRequest'
| 'sync'
| 'clone'
| 'createFolder'
| 'searchFolders'
| 'originUrl'
| 'cloneOnServer'GitHostHarnessFactoryType#
Builds a fresh host (and its backend) for one test.
type GitHostHarnessFactory = (backend: GitHostContractBackend) => GitHostHarness | Promise<GitHostHarness>