Skip to content

armgit / orca

Public Imported from GitHub
0

Orca is the place for working with a fleet of agents (e.g. Grok Bot, Claude Code). Run any coding agent with your own subscription. Available on desktop, mobile and remote runtime.

1.8 KB
Raw Blame
import { execFileSync } from 'node:child_process'
import { mkdtempSync, rmSync, writeFileSync } from 'node:fs'
import { tmpdir } from 'node:os'
import { join } from 'node:path'
import { afterEach, describe, expect, it } from 'vitest'

const scriptPath = 'config/scripts/summarize-terminal-perf-report.mjs'
const tempDirs = []

function writeReport() {
  const dir = mkdtempSync(join(tmpdir(), 'orca-terminal-perf-summary-'))
  tempDirs.push(dir)
  const reportPath = join(dir, 'report.json')
  writeFileSync(
    reportPath,
    JSON.stringify({
      suites: [
        {
          specs: [
            {
              tests: [
                {
                  annotations: [
                    {
                      type: 'opencode-scale',
                      description: 'panes=50 frames=60 median=12.3ms rendererQueuedChars=1000'
                    },
                    {
                      type: 'browser-unrelated',
                      description: 'panes=1 median=999.0ms'
                    }
                  ]
                }
              ]
            }
          ]
        }
      ]
    })
  )
  return reportPath
}

afterEach(() => {
  while (tempDirs.length > 0) {
    rmSync(tempDirs.pop(), { force: true, recursive: true })
  }
})

describe('summarize-terminal-perf-report', () => {
  it('prints only OpenCode terminal perf annotation rows', () => {
    const output = execFileSync(process.execPath, [scriptPath, writeReport()], {
      cwd: process.cwd(),
      encoding: 'utf8'
    })

    expect(output).toContain('| Source | Scenario | Panes | Frames | Median |')
    expect(output).toContain('| report.json | opencode-scale | 50 | 60 | 12.3ms |')
    expect(output).toContain('1000')
    expect(output).not.toContain('browser-unrelated')
    expect(output).not.toContain('999.0ms')
  })
})