zidane-ui/ git/ testing
import { … } from 'zidane-ui/git/testing'ui/src/git/testing/index.ts
Functions#
createFixtureGitHostFunction#
Creates a GitHost held in memory. Switching and starting branches change its current
branch; a branch in held is refused with its worktree.
function createFixtureGitHost(options?: FixtureGitOptions): FixtureGitHostParameters
| Name | Type | Default | Description |
|---|---|---|---|
| options? | FixtureGitOptions | {} | The data, or |
Returns
Constants#
DEMO_GIT_BRANCH_PULL_REQUESTSConstant#
The demo branches' open pull requests.
const DEMO_GIT_BRANCH_PULL_REQUESTS: Readonly<Record<string, GitBranchPullRequest>>DEMO_GIT_BRANCHESConstant#
Demo local branches, most recent first.
const DEMO_GIT_BRANCHES: readonly GitBranch[]DEMO_GIT_CLONEConstant#
The demo repository import: what it parses, where it lands, and what a clone reports.
const DEMO_GIT_CLONE: FixtureCloneDEMO_GIT_ENVIRONMENTSConstant#
Demo environment kinds: the folder, a worktree, a Docker sandbox, and a shared machine's folder.
const DEMO_GIT_ENVIRONMENTS: readonly EnvironmentDescriptor[]DEMO_GIT_FOLDERSConstant#
Demo folders on a remote host: the folders under each path.
const DEMO_GIT_FOLDERS: { roots: readonly string[]; tree: Readonly<Record<string, readonly string[]>> }DEMO_GIT_ORIGINSConstant#
The demo origin of each checkout on this computer.
const DEMO_GIT_ORIGINS: Readonly<Record<string, string>>DEMO_GIT_PULL_REQUESTSConstant#
Demo open pull requests: one waiting on you, one of yours, two others.
const DEMO_GIT_PULL_REQUESTS: readonly GitPullRequest[]DEMO_GIT_STATUSConstant#
The demo checkout's status.
const DEMO_GIT_STATUS: GitStatusInterfaces#
FixtureCloneInterface#
A repository import held in memory.
interface FixtureCloneProperties
| Name | Type | Description |
|---|---|---|
| defaultParent | string | Where clones land by default. |
| info? | Readonly<Record<string, GitRepoInfo>> | What each input is, for the import dialog's card. Absent: no |
| progress | readonly GitCloneProgress[] | What a clone reports, in order, before it lands. |
| refused? | Readonly<Record<string, string>> | Inputs whose clone fails, with git's message. |
| repos | Readonly<Record<string, GitRepoSpec>> | What each accepted input parses to. Anything else is not a repository. |
FixtureGitHostInterface#
A GitHost held in memory, with what it did.
interface FixtureGitHost extends GitHostProperties
| Name | Type | Description |
|---|---|---|
clone?from GitHost | GitClone | Clones a repository into a new folder. Absent: no repository import. |
| clonedreadonly | { input: string; parent: string }[] | The clones that ran. |
| movesreadonly | { branch?: string; sessionId: string }[] | The sessions moved into worktrees, and on which branch. |
| relocationsreadonly | { branch?: string; cwd?: string; kind: string; sessionId: string }[] | The sessions moved anywhere ( |
| serverClonesreadonly | { hostId: string; input: string; parent: string }[] | The clones that ran on a server. |
| syncedreadonly | string[] | The folders synced, in order. |
| activity | (sessionId: string) => void | Tells a session's |
branches?from GitHost | (cwd: string) => Promise<readonly GitBranch[]> | Local branches, most recently committed first. Absent: no branch menu. |
branchPullRequest?from GitHost | (cwd: string, branch: string, fresh?: boolean) => Promise<GitBranchPullRequest | null> | The open pull request of |
| changeEnvironments | (next: readonly EnvironmentDescriptor[]) => void | Replaces the environment kinds and tells the |
checkout?from GitHost | (cwd: string, target: GitCheckoutTarget, sessionId?: string | null) => Promise<GitCheckoutResult> | Switches the checkout. Never forced: git's refusal comes back as the error. Absent: no branch menu. |
cloneOnServer?from GitHost | (hostId: string, input: string, parent: string) => Promise<GitCloneResult> | Clones |
createBranch?from GitHost | (cwd: string, name: string, sessionId?: string | null) => Promise<GitCheckoutResult> | Starts a branch from the current checkout and switches to it. Absent: a typed name is not offered to start. |
createFolder?from GitHost | (query: GitCreateFolderQuery) => Promise<GitCreateFolderResult> | Creates a folder on a remote host (not on a shared machine). Absent: no "New folder" in the folder picker. |
| current | () => string | The current branch. |
environments?from GitHost | (query: GitEnvironmentQuery) => Promise<readonly EnvironmentDescriptor[]> | The environment kinds a new session can run in. Absent: the app supplies them itself. |
listFolders?from GitHost | (query: GitFolderQuery) => Promise<GitFolderResult> | The folders of a remote host. Absent: no remote folder picker. |
| moveRefs | () => void | Tells the |
moveSession?from GitHost | (sessionId: string, target: GitMoveTarget) => Promise<GitMoveResult> | Moves an idle session to another environment of its host, in |
originUrl?from GitHost | (cwd: string) => Promise<string | null> | The |
pickFolder?from GitHost | () => Promise<string | null> | Picks a folder on this computer (a native dialog); |
pullRequests?from GitHost | (query: GitPullRequestQuery) => Promise<GitPullRequestList> | Open pull requests: waiting on you, yours, then recent others. Absent: the branch menu lists branches only. |
searchFolders?from GitHost | (query: GitFolderSearchQuery) => Promise<GitFolderSearchResult> | Searches a remote host's folders by name (not a shared machine's). Absent: the folder picker filters the folder it shows only. |
startWorktree?from GitHost | (sessionId: string, branch?: string) => Promise<GitActionResult> | Moves a local session into a new git worktree on |
status?from GitHost | (cwd: string) => Promise<GitStatus | null> | Where the checkout stands; |
subscribeActivity?from GitHost | (sessionId: string, onChange: () => void) => () => void | Calls |
subscribeEnvironments?from GitHost | (query: GitEnvironmentQuery, onChange: () => void) => () => void | Calls |
subscribeRefs?from GitHost | (cwd: string, onChange: () => void) => () => void | Calls |
sync?from GitHost | (cwd: string, sessionId?: string | null) => Promise<GitSyncResult> | Pulls (merging) then pushes the current branch, or publishes it when it has no upstream. Absent: no sync. |
FixtureGitOptionsInterface#
Options of createFixtureGitHost. Each defaults to the demo data; false leaves its members out.
interface FixtureGitOptionsProperties
| Name | Type | Description |
|---|---|---|
| branches? | false | readonly GitBranch[] | The local branches. |
| branchPullRequests? | false | Readonly<Record<string, GitBranchPullRequest>> | The open pull request per branch. |
| clone? | false | FixtureClone | The repository import, also on a server ( |
| current? | string | The current branch. Default: the first branch. |
| environments? | false | readonly EnvironmentDescriptor[] | The environment kinds. |
| folderAllows? | GitFolderAllows | What the remote host lets clients do in its folders. Default: everything. |
| folders? | false | { roots: readonly string[]; tree: Readonly<Record<string, readonly string[]>> } | Remote folders: the roots and the folders under each path. |
| held? | readonly FixtureHeldBranch[] | Branches other worktrees hold: switching to one is refused, naming the worktree. |
| latencyMs? | number | Milliseconds each answer takes. Default: 0. |
| origins? | false | Readonly<Record<string, string>> | The |
| pickedFolder? | string | null | What |
| pullRequests? | false | readonly GitPullRequest[] | null | The open pull requests; |
| status? | false | GitStatus | The checkout's status. |
| sync? | false | { conflicts?: { cwd: string; files: readonly string[]; message: string } } | A sync of |
| worktrees? | boolean |
|
FixtureHeldBranchInterface#
A branch another worktree has checked out.
interface FixtureHeldBranchProperties
| Name | Type | Description |
|---|---|---|
| branch | string | The branch. |
| chats | readonly string[] | The chats in that worktree. |
| worktree | string | The worktree's path. |