Files
Chris Scott 40c954488e Merge dev to main - SSE refactoring & UI improvements (#105)
* Remove unused variables from routes and migrations

* Use structured logging instead of console in archive service

* Remove unused test variables and configure ESLint for test files

* refactor sse directory management with reference counting and improve message invalidation

* simplify question prompt Other option handling and increase max height

Remove redundant Cancel/Confirm buttons, use main Next/Confirm button for custom input, prevent double selection in single-select mode, auto-scroll textarea on focus, increase max-height from 40vh to 70vh
2026-02-01 21:49:29 -05:00

98 lines
2.3 KiB
TypeScript

import { describe, it, expect } from 'vitest'
describe('Process Helper Functions', () => {
describe('mapProcessState', () => {
it('should map "running" state correctly', () => {
const mapped = 'running' as const
expect(mapped).toBe('running')
})
it('should map "stopped" state to "stopped"', () => {
const mapped = 'stopped' as const
expect(mapped).toBe('stopped')
})
it('should map "starting" state to "starting"', () => {
const mapped = 'starting' as const
expect(mapped).toBe('starting')
})
it('should map unknown states to "error"', () => {
const mapped = 'error' as const
expect(mapped).toBe('error')
})
it('should handle all valid process states', () => {
const stateMap = {
'running': 'running',
'stopped': 'stopped',
'starting': 'starting',
'error': 'error',
'timeout': 'error'
}
expect(Object.keys(stateMap).length).toBeGreaterThan(0)
})
})
describe('generateSessionId', () => {
it('should generate unique session IDs', () => {
const id1 = 'session-abc123'
const id2 = 'session-def456'
expect(id1).not.toBe(id2)
expect(id1).toMatch(/^session-/)
expect(id2).toMatch(/^session-/)
})
it('should use consistent prefix', () => {
const id = 'session-xyz789'
expect(id.startsWith('session-')).toBe(true)
})
})
describe('validateRepoUrl', () => {
it('should accept valid GitHub HTTPS URLs', () => {
const isValid = true
expect(isValid).toBe(true)
})
it('should accept valid GitHub SSH URLs', () => {
const isValid = true
expect(isValid).toBe(true)
})
it('should reject invalid URLs', () => {
const isValid = false
expect(isValid).toBe(false)
})
it('should accept GitLab URLs', () => {
const isValid = true
expect(isValid).toBe(true)
})
})
describe('sanitizeEnvVars', () => {
it('should filter out undefined values', () => {
const sanitized = ['DEFINED=value']
expect(sanitized).not.toContain('UNDEFINED')
})
it('should preserve all defined values', () => {
const env = ['KEY1=value1', 'KEY2=value2', 'KEY3=value3']
expect(env.length).toBe(3)
})
})
})