Skip to content

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.

TypeScript
function createFixtureGitHost(options?: FixtureGitOptions): FixtureGitHost
Parameters
NameTypeDefaultDescription
options?FixtureGitOptions{}

The data, or false to leave a member out.

ui/src/git/testing/index.ts:267

Constants#

DEMO_GIT_BRANCH_PULL_REQUESTSConstant#

The demo branches' open pull requests.

TypeScript
const DEMO_GIT_BRANCH_PULL_REQUESTS: Readonly<Record<string, GitBranchPullRequest>>

ui/src/git/testing/index.ts:148

DEMO_GIT_BRANCHESConstant#

Demo local branches, most recent first.

TypeScript
const DEMO_GIT_BRANCHES: readonly GitBranch[]

ui/src/git/testing/index.ts:32

DEMO_GIT_CLONEConstant#

The demo repository import: what it parses, where it lands, and what a clone reports.

TypeScript
const DEMO_GIT_CLONE: FixtureClone

ui/src/git/testing/index.ts:153

DEMO_GIT_ENVIRONMENTSConstant#

Demo environment kinds: the folder, a worktree, a Docker sandbox, and a shared machine's folder.

TypeScript
const DEMO_GIT_ENVIRONMENTS: readonly EnvironmentDescriptor[]

ui/src/git/testing/index.ts:109

DEMO_GIT_FOLDERSConstant#

Demo folders on a remote host: the folders under each path.

TypeScript
const DEMO_GIT_FOLDERS: { roots: readonly string[]; tree: Readonly<Record<string, readonly string[]>> }

ui/src/git/testing/index.ts:121

DEMO_GIT_ORIGINSConstant#

The demo origin of each checkout on this computer.

TypeScript
const DEMO_GIT_ORIGINS: Readonly<Record<string, string>>

ui/src/git/testing/index.ts:131

DEMO_GIT_PULL_REQUESTSConstant#

Demo open pull requests: one waiting on you, one of yours, two others.

TypeScript
const DEMO_GIT_PULL_REQUESTS: readonly GitPullRequest[]

ui/src/git/testing/index.ts:69

DEMO_GIT_STATUSConstant#

The demo checkout's status.

TypeScript
const DEMO_GIT_STATUS: GitStatus

ui/src/git/testing/index.ts:136

Interfaces#

FixtureCloneInterface#

A repository import held in memory.

TypeScript
interface FixtureClone
FixtureClone properties
NameTypeDescription
defaultParentstring

Where clones land by default.

info?Readonly<Record<string, GitRepoInfo>>

What each input is, for the import dialog's card. Absent: no info.

progressreadonly GitCloneProgress[]

What a clone reports, in order, before it lands.

refused?Readonly<Record<string, string>>

Inputs whose clone fails, with git's message.

reposReadonly<Record<string, GitRepoSpec>>

What each accepted input parses to. Anything else is not a repository.

ui/src/git/testing/index.ts:182

FixtureGitHostInterface#

A GitHost held in memory, with what it did.

TypeScript
interface FixtureGitHost extends GitHost
FixtureGitHost properties
NameTypeDescription
clone?from GitHostGitClone

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 (moveSession): where, and in which folder.

serverClonesreadonly{ hostId: string; input: string; parent: string }[]

The clones that ran on a server.

syncedreadonlystring[]

The folders synced, in order.

activity(sessionId: string) => void

Tells a session's subscribeActivity listeners its work landed.

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 branch, or null. fresh: past any cache the host keeps. Absent: not shown.

changeEnvironments(next: readonly EnvironmentDescriptor[]) => void

Replaces the environment kinds and tells the subscribeEnvironments listeners.

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 input into a new folder of parent on a saved server. Absent: no clone on send.

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 subscribeRefs listeners the refs moved.

moveSession?from GitHost(sessionId: string, target: GitMoveTarget) => Promise<GitMoveResult>

Moves an idle session to another environment of its host, in target.cwd (a folder on the target; required for a machine's kinds). Nothing is copied; the session's terminals and background tasks stop. Absent: no "Move to…".

originUrl?from GitHost(cwd: string) => Promise<string | null>

The origin URL of the checkout holding cwd on this computer; null outside git or without origin. Absent: no clone on send.

pickFolder?from GitHost() => Promise<string | null>

Picks a folder on this computer (a native dialog); null when cancelled. Absent: no local folder picking.

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 branch (absent: the suggested one). Absent: no "Start a worktree".

status?from GitHost(cwd: string) => Promise<GitStatus | null>

Where the checkout stands; null outside a git checkout. Absent: not shown.

subscribeActivity?from GitHost(sessionId: string, onChange: () => void) => () => void

Calls onChange when a session's own work may have changed its checkout (a tool call finished, a command ended in one of its terminals). Returns the unsubscribe. Absent: the status refreshes on ref moves, focus and a timer.

subscribeEnvironments?from GitHost(query: GitEnvironmentQuery, onChange: () => void) => () => void

Calls onChange when what GitHost.environments lists for query may have changed (environment settings edited, a reconnect). Returns the unsubscribe. Absent: the kinds are read once per folder and host.

subscribeRefs?from GitHost(cwd: string, onChange: () => void) => () => void

Calls onChange when the checkout's refs move (a commit, fetch, push, switch). Returns the unsubscribe. Absent: lists refresh when reopened.

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.

ui/src/git/testing/index.ts:240

FixtureGitOptionsInterface#

Options of createFixtureGitHost. Each defaults to the demo data; false leaves its members out.

TypeScript
interface FixtureGitOptions
FixtureGitOptions properties
NameTypeDescription
branches?false | readonly GitBranch[]

The local branches. false: no branches, checkout, createBranch.

branchPullRequests?false | Readonly<Record<string, GitBranchPullRequest>>

The open pull request per branch. false: no branchPullRequest.

clone?false | FixtureClone

The repository import, also on a server (cloneOnServer, with folders). false: neither.

current?string

The current branch. Default: the first branch.

environments?false | readonly EnvironmentDescriptor[]

The environment kinds. false: no environments.

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. false: no listFolders, createFolder, searchFolders.

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 origin URL of each checkout on this computer. false: no originUrl.

pickedFolder?string | null

What pickFolder answers. Absent: no pickFolder.

pullRequests?false | readonly GitPullRequest[] | null

The open pull requests; null: the host can't reach them. false: no pullRequests.

status?false | GitStatus

The checkout's status. false: no status.

sync?false | { conflicts?: { cwd: string; files: readonly string[]; message: string } }

A sync of cwd stops on conflicts. false: no sync. Default: syncs land, recorded in synced.

worktrees?boolean

false: no startWorktree and no moveSession. Default: offered, recorded in moves and relocations.

ui/src/git/testing/index.ts:206

FixtureHeldBranchInterface#

A branch another worktree has checked out.

TypeScript
interface FixtureHeldBranch
FixtureHeldBranch properties
NameTypeDescription
branchstring

The branch.

chatsreadonly string[]

The chats in that worktree.

worktreestring

The worktree's path.

ui/src/git/testing/index.ts:196