api-catalog.client.spec.ts 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import { describe, expect, it } from 'vitest'
  2. import { EVENT_API, queryServiceApi, SERVICE_API } from '../src/client/api-catalog.ts'
  3. describe('Client Cordis inspect catalog', () => {
  4. it('publishes the split Workspace Controller and UI navigation services', () => {
  5. expect(SERVICE_API.find(service => service.key === 'workspaces')?.methods.map(method => method.signature))
  6. .toEqual([
  7. 'create(input: { path: string }): Promise<WorkspaceView>',
  8. 'rename(workspaceId: WorkspaceId, title: string): Promise<WorkspaceView>',
  9. 'delete(workspaceId: WorkspaceId): Promise<void>',
  10. 'archiveSession(sessionId: SessionId): Promise<void>',
  11. 'insertSessionBefore( workspaceId: WorkspaceId, sessionId: SessionId, beforeSessionId?: SessionId, ): Promise<WorkspaceView>',
  12. ])
  13. expect(SERVICE_API.find(service => service.key === 'uiWorkspace')?.methods.map(method => method.signature))
  14. .toEqual([
  15. 'connectWorkspace(workspaceId: WorkspaceId): Promise<SessionId>',
  16. 'startSession(workspaceId?: WorkspaceId): void',
  17. 'archiveSession(sessionId: SessionId): Promise<void>',
  18. 'pickDirectory(): Promise<string | null>',
  19. 'listDirectory(path?: string, signal?: AbortSignal): Promise<DirectoryListing>',
  20. 'createDirectory(path: string, name: string): Promise<string>',
  21. 'openPath(path: string): Promise<void>',
  22. ])
  23. })
  24. it('contains one entry per visible Client event', () => {
  25. const names = EVENT_API.map(event => event.name)
  26. expect(new Set(names).size).toBe(names.length)
  27. })
  28. it('includes the current referenced type closure for the Sessions service', () => {
  29. const result = queryServiceApi('sessions') as {
  30. referencedTypes: readonly { name: string }[]
  31. }
  32. expect(result.referencedTypes.length).toBeGreaterThan(0)
  33. expect(result.referencedTypes.map(type => type.name)).not.toEqual(expect.arrayContaining([
  34. 'ConversationSnapshot',
  35. 'PendingInteraction',
  36. 'PendingPayloads',
  37. 'PendingWait',
  38. ]))
  39. })
  40. })