/**
 * D6 regression: project_id uses Date.now() instead of UUID
 * Bug: Date.now() causes collisions for rapid inits.
 * Fix: crypto.randomUUID()
 */

import { describe, it, expect } from 'bun:test'
import { readFileSync } from 'fs'
import { join } from 'path'

describe('D6: project_id UUID generation', () => {
  const src = readFileSync(
    join(import.meta.dir, '..', '..', '..', 'cli', 'src', 'commands', 'init.ts'),
    'utf-8'
  )

  it('imports randomUUID from crypto', () => {
    expect(src).toContain("randomUUID")
    expect(src).toContain("'crypto'")
  })

  it('does not use Date.now() for project_id', () => {
    expect(src).not.toMatch(/Date\.now\(\)\.toString/)
  })

  it('project_id pattern uses randomUUID', () => {
    expect(src).toMatch(/proj_\$\{randomUUID/)
  })
})
