import type { Meta, StoryObj } from '@storybook/nextjs-vite'; import { TestResultsSkeleton, TestRunResults, TestRunStatusStat, TimingStat } from '../components/ui/test-run'; const meta = { title: 'UI/TestRun', component: TestRunResults, parameters: { docs: { description: { component: 'Building blocks for live test-run panels ("run a query somewhere, stream tabular results back"): ' + 'timing stats, a one-row column skeleton, and a results table with always-visible headers and ' + 'horizontal scroll fades. Pair with useTestRunState, which wraps an app-owned campaign ' + '(e.g. a Fleet live query hook) with the run/stop/reset state machine.', }, }, }, } satisfies Meta; export default meta; type Story = StoryObj; const RESULT_ROWS = [ { 'host display name': 'workstation-01', pid: '1234', name: 'chrome', path: '/Applications/Google Chrome.app', state: 'R', uid: '501', 'resident size': '245760000', threads: '42', }, { 'host display name': 'workstation-01', pid: '5678', name: 'node', path: '/usr/local/bin/node', state: 'S', uid: '501', 'resident size': '98304000', threads: '12', }, ]; /** Finished run with rows: DataTable styling, headers on all breakpoints. */ export const WithResults: Story = { args: { isActive: false, displayRows: RESULT_ROWS, firstError: null, }, render: args => (
), }; /** Running: one-row skeleton with fixed 160px columns. */ export const Running: Story = { args: { isActive: true, displayRows: [], firstError: null, }, render: args => (
), }; /** Finished with zero rows: fixed-height empty state (no layout jump). */ export const EmptyResult: Story = { args: { isActive: false, displayRows: [], firstError: null, }, render: args => (
), }; /** Finished with an error: red banner with a copy action replaces the empty state. */ export const WithError: Story = { args: { isActive: false, displayRows: [], firstError: 'no such table: procesess (near "procesess": syntax error)', }, render: args => (
), }; /** Timing cells + standalone skeleton, as composed by app test panels. */ export const TimingAndSkeleton: Story = { args: { isActive: true, displayRows: [], firstError: null, }, render: () => (
), }; /** The four Status stat states: "-" before a run, then a colored tag. */ export const StatusStates: Story = { args: { isActive: false, displayRows: [], firstError: null, }, render: () => (
), };