|
| 1 | +import type { Meta, StoryObj } from '@storybook/react-vite'; |
| 2 | +import { toEmbeddedShape } from '../embeddedShape.ts'; |
| 3 | +import { cveExposureOk, cveExposureScopeMissing, orgOverview, reportBundle } from '../testFactories.ts'; |
| 4 | +import { App } from './App.tsx'; |
| 5 | + |
| 6 | +// A representative report, built from the same fishery factories the tests use. |
| 7 | +// Defaults cover most of the page; the overrides here only fill the spots that |
| 8 | +// would otherwise render as single-row tables (language mix, top repos by |
| 9 | +// severity) so the snapshot exercises the full UI. |
| 10 | +const sampleReport = toEmbeddedShape( |
| 11 | + reportBundle.build({ |
| 12 | + orgOverview: orgOverview.build({ |
| 13 | + topLanguages: [ |
| 14 | + { language: 'TypeScript', bytes: 4_200_000, percentage: 58 }, |
| 15 | + { language: 'Go', bytes: 1_600_000, percentage: 22 }, |
| 16 | + { language: 'Python', bytes: 880_000, percentage: 12 }, |
| 17 | + { language: 'Ruby', bytes: 560_000, percentage: 8 }, |
| 18 | + ], |
| 19 | + }), |
| 20 | + cve: cveExposureOk.build({ |
| 21 | + topReposBySeverity: [ |
| 22 | + { repo: 'acme/api', critical: 1, high: 2, medium: 1, low: 0 }, |
| 23 | + { repo: 'acme/web', critical: 0, high: 1, medium: 3, low: 2 }, |
| 24 | + { repo: 'acme/billing', critical: 0, high: 0, medium: 2, low: 5 }, |
| 25 | + ], |
| 26 | + reposWithSecurityAlertsDisabled: ['acme/legacy-cron'], |
| 27 | + }), |
| 28 | + }), |
| 29 | +); |
| 30 | + |
| 31 | +const meta = { |
| 32 | + title: 'Report/App', |
| 33 | + component: App, |
| 34 | + parameters: { |
| 35 | + layout: 'fullscreen', |
| 36 | + }, |
| 37 | +} satisfies Meta<typeof App>; |
| 38 | + |
| 39 | +export default meta; |
| 40 | +type Story = StoryObj<typeof meta>; |
| 41 | + |
| 42 | +export const Default: Story = { |
| 43 | + args: { |
| 44 | + data: sampleReport, |
| 45 | + }, |
| 46 | +}; |
| 47 | + |
| 48 | +export const CveScopeMissing: Story = { |
| 49 | + args: { |
| 50 | + data: { ...sampleReport, cve: cveExposureScopeMissing.build() }, |
| 51 | + }, |
| 52 | +}; |
0 commit comments