diff --git a/vehicle-data-platform/apps/web/src/v2/productionEntry.test.ts b/vehicle-data-platform/apps/web/src/v2/productionEntry.test.ts index c9edf69c..30e084c2 100644 --- a/vehicle-data-platform/apps/web/src/v2/productionEntry.test.ts +++ b/vehicle-data-platform/apps/web/src/v2/productionEntry.test.ts @@ -346,6 +346,10 @@ describe('V2 production entry', () => { expect(corePageSources.OperationsPage).toContain(' { expect(corePageSources.StatisticsPage).toContain(' { - it('renders one primary outcome and supporting facts as accessible Semi cards', () => { - const view = render(); - - expect(view.container.querySelector('.test-rail.semi-card')).toHaveAttribute('aria-label', '查询统计'); - expect(view.container.querySelector('.test-card.is-primary .test-primary-value')).toHaveTextContent('1,024'); - expect(view.container.querySelector('.test-secondary.semi-card-group')).toBeInTheDocument(); - expect(view.container.querySelectorAll('.test-card.semi-card')).toHaveLength(3); - expect(screen.getByLabelText('车辆数:20;当前授权范围')).toHaveClass('is-vehicles'); - }); - - it('renders a list-first queue variant inside one Semi card', () => { + it('renders one accessible, list-first Semi metric rail', () => { const view = render( void; }; -type WorkspaceSummaryMetricRailProps = { - ariaLabel: string; - primary: WorkspaceMetricRailItem; - secondary: WorkspaceMetricRailItem[]; - className: string; - cardClassName: string; - secondaryClassName: string; - primaryValueClassName?: string; -}; - type WorkspaceQueueMetricRailProps = { variant: 'queue'; ariaLabel: string; @@ -37,73 +20,41 @@ type WorkspaceQueueMetricRailProps = { context?: ReactNode; }; -export function WorkspaceMetricRail(props: WorkspaceSummaryMetricRailProps | WorkspaceQueueMetricRailProps) { - if ('items' in props) { - const hasContext = props.context != null; - return -
- {props.items.map((item, index) => { - const toneClassName = `is-${item.tone ?? 'neutral'}`; - const emphasisClassName = `is-${item.emphasis ?? (index < 2 ? 'primary' : 'secondary')}`; - const classes = [ - toneClassName, - emphasisClassName !== toneClassName ? emphasisClassName : '', - item.onClick ? 'is-action' : '', - item.active ? 'is-active' : '' - ].filter(Boolean).join(' '); - const content = <> - {item.label} - {item.value} - {item.note ? {item.note} : null} - ; - return - {item.onClick ? : content} - ; - })} -
- {hasContext ?
{props.context}
: null} -
; - } - - const { - ariaLabel, - primary, - secondary, - className, - cardClassName, - secondaryClassName, - primaryValueClassName - } = props; - const cardClass = (item: WorkspaceMetricRailItem, primaryCard = false) => [ - cardClassName, - primaryCard ? 'is-primary' : '', - item.className ?? '' - ].filter(Boolean).join(' '); - - return - - {primary.label} - {primary.value} - {primary.note} - - - {secondary.map((item) => - {item.label} - {item.value} - {item.note} - )} - +export function WorkspaceMetricRail(props: WorkspaceQueueMetricRailProps) { + const hasContext = props.context != null; + return +
+ {props.items.map((item, index) => { + const toneClassName = `is-${item.tone ?? 'neutral'}`; + const emphasisClassName = `is-${item.emphasis ?? (index < 2 ? 'primary' : 'secondary')}`; + const classes = [ + toneClassName, + emphasisClassName !== toneClassName ? emphasisClassName : '', + item.onClick ? 'is-action' : '', + item.active ? 'is-active' : '' + ].filter(Boolean).join(' '); + const content = <> + {item.label} + {item.value} + {item.note ? {item.note} : null} + ; + return + {item.onClick ? : content} + ; + })} +
+ {hasContext ?
{props.context}
: null}
; }