import assert from 'node:assert/strict' import { readFile } from 'node:fs/promises' import test from 'node:test' const proxyView = await readFile(new URL('../src/views/Proxy.vue', import.meta.url), 'utf8') const modeSwitch = await readFile( new URL('../src/components/proxy/ProxyModeSwitch.vue', import.meta.url), 'utf8' ) const outboundInventory = await readFile( new URL('../src/components/proxy/ProxyOutboundInventory.vue', import.meta.url), 'utf8' ) const upstreamInventory = await readFile( new URL('../src/components/proxy/ProxyUpstreamInventory.vue', import.meta.url), 'utf8' ) const inventoryShell = await readFile( new URL('../src/components/proxy/ProxyInventoryShell.vue', import.meta.url), 'utf8' ) const emptyState = await readFile( new URL('../src/components/EmptyState.vue', import.meta.url), 'utf8' ) test('proxy page uses the compact production inventory workspace', () => { assert.match(proxyView, / { assert.match(proxyView, /transition: transform 180ms[^;]+, opacity 180ms/) assert.match(proxyView, /transition: transform 120ms[^;]+, opacity 120ms/) assert.match(proxyView, /@media \(prefers-reduced-motion: reduce\)/) assert.match(proxyView, /transition-property: opacity/) assert.match(proxyView, /transform: none/) assert.doesNotMatch(proxyView, /transition:\s*all/) }) test('proxy controls retain real runtime facts and accessible actions', () => { assert.match(modeSwitch, /aria-current/) assert.match(modeSwitch, /min-height: 58px/) assert.match(outboundInventory, /row\.lastError/) assert.match(outboundInventory, /:disabled="!row\.enabled"/) for (const action of ['启动', '停止', '重启', '编辑', '删除']) { assert.ok(outboundInventory.includes(`aria-label="\`${action}`)) } }) test('both proxy modes share one compact inventory shell', () => { assert.match(upstreamInventory, / { const fetchIndex = proxyView.indexOf('await proxyStore.fetchInstance(inst.id)') const rejectIndex = proxyView.indexOf('if (!result.ok) throw result.error', fetchIndex) const openIndex = proxyView.indexOf('drawerOpen.value = true', rejectIndex) assert.ok(fetchIndex >= 0) assert.ok(rejectIndex > fetchIndex) assert.ok(openIndex > rejectIndex) assert.doesNotMatch(proxyView, /已使用概览数据/) assert.match(proxyView, /ElMessage\.error\(err\.message \|\| '读取完整实例配置失败'\)/) })