import assert from 'node:assert/strict'
import { readFileSync } from 'node:fs'
import test from 'node:test'
import { fileURLToPath } from 'node:url'

const overviewTemplate = readFileSync(
  fileURLToPath(new URL('../src/views/OverviewView.vue', import.meta.url)),
  'utf8'
)
const overviewStyles = readFileSync(
  fileURLToPath(new URL('../src/assets/styles/views/overview-view.css', import.meta.url)),
  'utf8'
)

test('finance dashboard merges budget execution gauge into budget metrics card', () => {
  assert.match(overviewTemplate, /<h3>预算指标/)
  assert.match(overviewTemplate, /budget-metrics-content/)
  assert.match(overviewTemplate, /budget-gauge-block/)
  assert.match(overviewTemplate, /<GaugeChart/)
  assert.match(overviewTemplate, /budgetSummary\.ratio/)
  assert.match(overviewTemplate, /top-claim-panel[\s\S]*budget-metrics-panel/)
  assert.match(overviewStyles, /\.budget-metrics-panel\s*\{\s*grid-column:\s*span 6;/)
  assert.match(overviewStyles, /@media \(max-width: 1320px\)[\s\S]*\.budget-metrics-panel\s*\{\s*grid-column:\s*span 12;/)
  assert.match(overviewStyles, /\.budget-metrics-content/)
  assert.match(overviewStyles, /\.budget-gauge-block/)
  assert.match(overviewStyles, /grid-template-columns:\s*repeat\(2, minmax\(0, 1fr\)\)/)
  assert.doesNotMatch(overviewTemplate, /预算执行率（本月）/)
  assert.doesNotMatch(overviewTemplate, /dashboard-card budget-panel/)
  assert.doesNotMatch(overviewStyles, /\.budget-panel/)
})
