From d0ba75b995f775bc4057724c6b8d8a2762c90ca8 Mon Sep 17 00:00:00 2001 From: pyr0ball Date: Sat, 2 May 2026 18:03:13 -0700 Subject: [PATCH] feat: extract CompareView at /eval/compare; remove Compare tab from BenchmarkView --- web/src/views/BenchmarkView.test.ts | 48 +++++++++++++++++++++++++++++ web/src/views/BenchmarkView.vue | 11 ++----- web/src/views/CompareView.test.ts | 31 +++++++++++++++++++ web/src/views/CompareView.vue | 34 +++++++++++++++++--- 4 files changed, 111 insertions(+), 13 deletions(-) create mode 100644 web/src/views/BenchmarkView.test.ts create mode 100644 web/src/views/CompareView.test.ts diff --git a/web/src/views/BenchmarkView.test.ts b/web/src/views/BenchmarkView.test.ts new file mode 100644 index 0000000..32c7cff --- /dev/null +++ b/web/src/views/BenchmarkView.test.ts @@ -0,0 +1,48 @@ +import { mount } from '@vue/test-utils' +import { describe, it, expect, vi, beforeEach } from 'vitest' +import BenchmarkView from './BenchmarkView.vue' + +beforeEach(() => { + vi.stubGlobal('fetch', vi.fn().mockResolvedValue({ + ok: true, + // Return a shape that satisfies all child tab API calls: + // - ClassifierTab expects { models: {}, ... } from /api/benchmark/results + // - ClassifierTab expects ModelCategoriesResponse from /api/benchmark/models + // - LlmEvalTab, StyleTab, CompareTab have their own calls but also use models/tasks + json: async () => ({ models: {}, categories: {}, tasks: [], types: [], results: [] }), + text: async () => '', + })) + vi.stubGlobal('EventSource', class { + onmessage = null + onerror = null + close() {} + }) +}) + +describe('BenchmarkView', () => { + it('renders page title "Benchmark"', () => { + const w = mount(BenchmarkView) + expect(w.text()).toContain('Benchmark') + }) + + it('has mode buttons: Classifier, LLM Eval, Writing Style', () => { + const w = mount(BenchmarkView) + const text = w.text() + expect(text).toContain('Classifier') + expect(text).toContain('LLM Eval') + expect(text).toContain('Writing Style') + }) + + it('does NOT have a Compare mode button', () => { + const w = mount(BenchmarkView) + const buttons = w.findAll('.mode-btn') + const labels = buttons.map(b => b.text()) + expect(labels.every(l => !l.includes('Compare'))).toBe(true) + }) + + it('shows Classifier tab by default', () => { + const w = mount(BenchmarkView) + // ClassifierTab has a .classifier-tab root + expect(w.find('.classifier-tab').exists()).toBe(true) + }) +}) diff --git a/web/src/views/BenchmarkView.vue b/web/src/views/BenchmarkView.vue index 667cde1..a4ae4ea 100644 --- a/web/src/views/BenchmarkView.vue +++ b/web/src/views/BenchmarkView.vue @@ -16,11 +16,6 @@ :class="{ active: benchMode === 'llm' }" @click="benchMode = 'llm'" >🤖 LLM Eval -