import { formatDuration } from "@allurereport/core-api"; import { Counter, Heading, Text, TooltipWrapper } from "@allurereport/web-components"; import type { FunctionalComponent } from "preact"; import type { ClassicTestResult } from "types"; import { TestResultInfoStatuses } from "@/components/TestResult/TestResultInfo/TestResultInfoStatuses"; import { TestResultNavigation } from "@/components/TestResult/TestResultNavigation"; import { TestResultPrevStatuses } from "@/components/TestResult/TestResultPrevStatuses"; import { TestResultSeverity } from "@/components/TestResult/TestResultSeverity"; import { TestResultStatus } from "@/components/TestResult/TestResultStatus"; import { TestResultTab, TestResultTabsList } from "@/components/TestResult/TestResultTabs"; import { useI18n } from "@/stores/locale"; import { timestampToDate } from "@/utils/time"; import * as styles from "./styles.scss"; export type TestResultInfoProps = { testResult?: ClassicTestResult; }; export const TestResultInfo: FunctionalComponent = ({ testResult }) => { const { name, status, muted, flaky, known, duration, labels, history, retries, attachments, stop } = testResult ?? {}; const formattedDuration = formatDuration(duration as number); const fullDate = stop && timestampToDate(stop); const severity = labels?.find((label) => label.name === "severity")?.value ?? "normal"; const { t } = useI18n("ui"); const statuses = Object.entries({ flaky, muted, known }).filter(([, value]) => value); const Content = () => { return ( <> {name && ( {name} )}
{Boolean(status) && } {Boolean(history?.length) && } {Boolean(statuses.length) && } {formattedDuration}
{t("overview")}
{t("history")} {Boolean(history?.length) && }
{t("retries")} {Boolean(retries?.length) && }
{t("attachments")} {Boolean(attachments?.length) && }
); }; return (
{testResult && }
); };