Import the client, server, skills, tests, and build scripts as the starting point for the rebuild, then trim the surfaces this project does not ship: Electron desktop packaging, the marketing website, and the ESP32 firmware tree. CI keeps the web build, e2e, lockfile, release, and Docker workflows. Rename the package and CLI entry points to hermes-ui, drop the prepare hook so npm ci no longer triggers a build, and drop the removed tsconfig and nodemon references. Rewrite AGENTS.md, ARCHITECTURE.md, DEVELOPMENT.md, and the READMEs so the documented package map and hard rules match this repository. reference_code/ is ignored: it is a read-only snapshot, not an input to the build.
101 lines
3.0 KiB
TypeScript
101 lines
3.0 KiB
TypeScript
// @vitest-environment jsdom
|
|
import { describe, expect, it, vi } from 'vitest'
|
|
import { mount } from '@vue/test-utils'
|
|
|
|
const mockUsageStore = vi.hoisted(() => ({
|
|
dailyUsage: [
|
|
{
|
|
date: '2026-05-12',
|
|
input_tokens: 100,
|
|
output_tokens: 50,
|
|
cache_read_tokens: 75,
|
|
cache_write_tokens: 10,
|
|
sessions: 2,
|
|
errors: 0,
|
|
cost: 0.02,
|
|
visualTokens: 225,
|
|
inputPercent: 44.444,
|
|
outputPercent: 22.222,
|
|
cachePercent: 33.333,
|
|
},
|
|
],
|
|
modelUsage: [
|
|
{
|
|
model: 'gpt-5',
|
|
inputTokens: 100,
|
|
outputTokens: 50,
|
|
cacheTokens: 75,
|
|
cacheWriteTokens: 10,
|
|
totalTokens: 150,
|
|
visualTokens: 225,
|
|
sessions: 2,
|
|
color: '#4fd1c5',
|
|
inputPercent: 44.444,
|
|
outputPercent: 22.222,
|
|
cachePercent: 33.333,
|
|
},
|
|
],
|
|
agentUsage: [
|
|
{
|
|
agent: 'hermes',
|
|
inputTokens: 100,
|
|
outputTokens: 50,
|
|
cacheTokens: 75,
|
|
cacheWriteTokens: 10,
|
|
totalTokens: 150,
|
|
visualTokens: 225,
|
|
sessions: 2,
|
|
color: '#63b3ed',
|
|
inputPercent: 44.444,
|
|
outputPercent: 22.222,
|
|
cachePercent: 33.333,
|
|
},
|
|
],
|
|
}))
|
|
|
|
vi.mock('@/stores/hermes/usage', () => ({
|
|
useUsageStore: () => mockUsageStore,
|
|
}))
|
|
|
|
vi.mock('vue-i18n', () => ({
|
|
useI18n: () => ({
|
|
t: (key: string) => key,
|
|
}),
|
|
}))
|
|
|
|
import DailyTrend from '@/components/hermes/usage/DailyTrend.vue'
|
|
import ModelBreakdown from '@/components/hermes/usage/ModelBreakdown.vue'
|
|
import AgentBreakdown from '@/components/hermes/usage/AgentBreakdown.vue'
|
|
|
|
describe('usage cache visualizations', () => {
|
|
it('renders cache-read as a visible segment in the daily usage bars', () => {
|
|
const wrapper = mount(DailyTrend)
|
|
|
|
const cacheSegment = wrapper.find('.bar-segment.cache')
|
|
expect(cacheSegment.exists()).toBe(true)
|
|
expect(cacheSegment.attributes('style')).toContain('height: 33.333%')
|
|
expect(wrapper.text()).toContain('usage.cacheRead')
|
|
})
|
|
|
|
it('renders model breakdown as input/output/cache stacked segments', () => {
|
|
const wrapper = mount(ModelBreakdown)
|
|
|
|
expect(wrapper.find('.model-swatch').attributes('style')).toContain('background: rgb(79, 209, 197)')
|
|
expect(wrapper.find('.model-bar-segment.input').exists()).toBe(true)
|
|
expect(wrapper.find('.model-bar-segment.output').exists()).toBe(true)
|
|
const cacheSegment = wrapper.find('.model-bar-segment.cache')
|
|
expect(cacheSegment.exists()).toBe(true)
|
|
expect(cacheSegment.attributes('style')).toContain('width: 33.333%')
|
|
})
|
|
|
|
it('renders agent breakdown as input/output/cache stacked segments', () => {
|
|
const wrapper = mount(AgentBreakdown)
|
|
|
|
expect(wrapper.text()).toContain('usage.agents.hermes')
|
|
expect(wrapper.find('.agent-swatch').attributes('style')).toContain('background: rgb(99, 179, 237)')
|
|
expect(wrapper.find('.agent-bar-segment.input').exists()).toBe(true)
|
|
expect(wrapper.find('.agent-bar-segment.output').exists()).toBe(true)
|
|
expect(wrapper.find('.agent-bar-segment.cache').attributes('style')).toContain('width: 33.333%')
|
|
})
|
|
})
|