Files
zeekay 6c65e3e941 @hanzo/app 0.2.0: the app SDK, renamed from @hanzo/rooms
Every import, the catalog pin and the docs name @hanzo/app and
github.com/hanzoai/app. lib/rooms.ts is lib/app.ts and
components/rooms.tsx is components/app.tsx.
2026-10-22 19:07:20 -07:00

112 lines
3.1 KiB
TypeScript

import { test, expect } from '@playwright/test'
import {
COLUMNS,
PRIORITIES,
DEFAULT_CARDS,
board,
projects,
open,
edit,
claim,
type Card,
} from '@hanzo/app/lib/todo'
import type { AiClient } from '@hanzo/ai'
test.describe('todo board store unit tests', () => {
test('COLUMNS defines the platform closed set of states', () => {
const ids = COLUMNS.map((c) => c.id)
expect(ids).toContain('backlog')
expect(ids).toContain('todo')
expect(ids).toContain('in_progress')
expect(ids).toContain('done')
expect(ids).toContain('canceled')
})
test('PRIORITIES defines loudest to quietest priority ladder', () => {
expect(PRIORITIES).toEqual(['urgent', 'high', 'medium', 'low', 'none'])
})
test('DEFAULT_CARDS provides valid initial state cards', () => {
expect(DEFAULT_CARDS.length).toBeGreaterThan(0)
for (const card of DEFAULT_CARDS) {
expect(card.id).toBeDefined()
expect(card.title).toBeDefined()
expect(card.projectKey).toBeDefined()
}
})
test('board() falls back gracefully or reads from AiClient', async () => {
const mockCards: Card[] = [
{
id: 'prj-1',
identifier: 'PRJ#1',
projectKey: 'prj',
number: 1,
kind: 'task',
source: 'agent',
title: 'Mock Issue',
status: 'todo',
priority: 'high',
labels: ['test'],
createdAt: 100,
updatedAt: 100,
},
]
const mockClient = {
http: {
json: async () => ({ issues: mockCards }),
},
} as unknown as AiClient
const result = await board(mockClient)
expect(result.length).toBe(1)
expect(result[0].title).toBe('Mock Issue')
})
test('board() answers an empty org with no cards, not the local demo fixture', async () => {
const emptyClient = {
http: {
json: async () => ({ issues: [] }),
},
} as unknown as AiClient
const result = await board(emptyClient)
expect(result).toEqual([])
})
test('projects() falls back to standard projects if client omitted', async () => {
const list = await projects(null)
expect(list.length).toBe(4)
expect(list.map((p) => p.key)).toEqual(['hanzo', 'cloud', 'swarm', 'dev'])
})
test('open() creates a card and returns it', async () => {
const created = await open(null, 'test', {
title: 'New Unit Test Issue',
description: 'Issue description',
status: 'todo',
priority: 'high',
labels: ['qa'],
})
expect(created.title).toBe('New Unit Test Issue')
expect(created.projectKey).toBe('test')
expect(created.status).toBe('todo')
expect(created.priority).toBe('high')
})
test('edit() updates card fields', async () => {
const updated = await edit(null, 'test', 1, { status: 'done', priority: 'urgent' })
expect(updated).toBeDefined()
expect(updated.status).toBe('done')
expect(updated.priority).toBe('urgent')
})
test('claim() assigns card to caller', async () => {
const claimed = await claim(null, 'test', 1)
expect(claimed).toBeDefined()
expect(claimed.assignee).toBe('me')
})
})