import { type TestResult, formatDuration } from "@allurereport/core-api"; import { IconButton, Text, allureIcons } from "@allurereport/web-components"; import { type FunctionalComponent } from "preact"; import { useState } from "preact/hooks"; import { ArrowButton } from "@/components/ArrowButton"; import { TestResultError } from "@/components/TestResult/TestResultError"; import TreeItemIcon from "@/components/Tree/TreeItemIcon"; import { useI18n } from "@/stores"; import { navigateTo } from "@/utils/navigate"; import { timestampToDate } from "@/utils/time"; import * as styles from "@/components/TestResult/TestResultRetriesView/styles.scss"; export type TrRetriesItemProps = { testResultItem: TestResult; attempt: number; totalAttempts: number; }; export const TestResultRetriesItem: FunctionalComponent = ({ testResultItem, attempt, totalAttempts, }) => { const { id, status, message, trace, stop, duration } = testResultItem; const [isOpened, setIsOpen] = useState(false); const { t } = useI18n("ui"); const retryTitlePrefix = t("attempt", { attempt, total: totalAttempts }); const convertedStop = stop ? timestampToDate(stop) : undefined; const retryTitle = convertedStop ? `${retryTitlePrefix} – ${convertedStop}` : retryTitlePrefix; const formattedDuration = typeof duration === "number" ? formatDuration(duration) : undefined; const navigateUrl = `testresult/${id}`; return (
setIsOpen(!isOpened)}> {Boolean(message) && }
{retryTitle}
{Boolean(formattedDuration) && ( {formattedDuration} )} navigateTo(navigateUrl)} />
{isOpened && message && (
)}
); };