mirror of
https://github.com/stablyai/orca.git
synced 2026-11-01 01:27:35 +00:00
56 lines
1.7 KiB
TypeScript
56 lines
1.7 KiB
TypeScript
import { describe, expect, it, vi } from 'vitest'
|
|
|
|
// The desktop's server-list feed loads react-native; its timer never runs without a subscriber.
|
|
vi.mock('react-native', () => ({}))
|
|
import type { MobileRelayHost } from '../../../src/shared/mobile-relay-hosts-contract'
|
|
import { applyServerWorkspaces, NO_SERVER_WORKSPACES } from './server-workspaces'
|
|
import type { Worktree } from './workspace-list-types'
|
|
|
|
const host: MobileRelayHost = {
|
|
hostId: 'runtime:env-1',
|
|
label: 'Box',
|
|
health: 'available',
|
|
relay: 'ready'
|
|
}
|
|
|
|
function row(worktreeId: string): Worktree {
|
|
return {
|
|
worktreeId,
|
|
repoId: 'repo-1',
|
|
hostId: host.hostId,
|
|
repo: 'orca',
|
|
branch: 'main',
|
|
displayName: worktreeId,
|
|
path: `/srv/${worktreeId}`,
|
|
liveTerminalCount: 0,
|
|
hasAttachedPty: false,
|
|
unread: false,
|
|
isPinned: false,
|
|
linkedPR: null
|
|
}
|
|
}
|
|
|
|
describe('applyServerWorkspaces', () => {
|
|
it('keeps the same hosts list when only the rows change', () => {
|
|
const first = applyServerWorkspaces(NO_SERVER_WORKSPACES, { hosts: [host], rows: [[row('a')]] })
|
|
const next = applyServerWorkspaces(first, {
|
|
hosts: [{ ...host }],
|
|
rows: [[row('a'), row('b')]]
|
|
})
|
|
expect(next.worktrees.map((worktree) => worktree.worktreeId)).toEqual(['a', 'b'])
|
|
expect(next.hosts).toBe(first.hosts)
|
|
const relabeled = applyServerWorkspaces(next, {
|
|
hosts: [{ ...host, relay: 'unavailable' }],
|
|
rows: [null]
|
|
})
|
|
expect(relabeled.hosts).not.toBe(first.hosts)
|
|
expect(relabeled.worktrees).toEqual(next.worktrees)
|
|
expect(
|
|
applyServerWorkspaces(next, {
|
|
hosts: [{ ...host }],
|
|
rows: [[row('a'), row('b')]]
|
|
})
|
|
).toBe(next)
|
|
})
|
|
})
|