import { type Statistic, capitalize, statusesList } from "@allurereport/core-api"; import { Loadable } from "@allurereport/web-components"; import { computed } from "@preact/signals"; import type { FunctionComponent } from "preact"; import MetadataItem, { type MetadataProps } from "@/components/ReportMetadata/MetadataItem"; import { MetadataTestType } from "@/components/ReportMetadata/MetadataTestType"; import { MetadataWithIcon } from "@/components/ReportMetadata/MetadataWithIcon"; import { statsStore } from "@/stores"; import { useI18n } from "@/stores/locale"; import * as styles from "@/components/ReportMetadata/styles.scss"; export const MetadataSummary: FunctionComponent = () => { const { t } = useI18n("statuses"); const { t: testSummary } = useI18n("testSummary"); return ( null} renderData={(stats) => { const allTest = computed(() => ({ title: capitalize(t("total")), type: "all", count: stats.total, })); const metaDataTests = ["flaky", "retry"] .map((key) => { if (!stats[key as keyof Statistic]) { return; } const title = testSummary(key); const props = { title, count: stats[key as keyof Statistic] || 0, type: key }; return (
); }) .filter(Boolean); const metadataStatuses = statusesList .map((status) => ({ status, value: stats[status] })) .filter(({ value }) => value) .map(({ status, value }) => { const title = capitalize(t(status) ?? status ?? ""); const props = { title, count: value, status, } as MetadataProps; return ( ); }); return (