Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: a lot of small fixes and improvements #50

Merged
merged 3 commits into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions packages/web-awesome/src/assets/svg/line-alerts-alert-circle.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions packages/web-awesome/src/assets/svg/line-general-eye.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions packages/web-awesome/src/assets/svg/line-icon-bomb-2.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
background: transparent;
border: none;
padding: 8px 4px;
border-radius: 4px;
color: var(--on-icon-secondary);

&:hover {
background: var(--bg-control-flat-medium);
color: var(--on-icon-primary);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import type { Statistic } from "@allurereport/core-api";
import { statusesList } from "@allurereport/core-api";
import { computed } from "@preact/signals";
import { FunctionComponent } from "preact";
import MetadataItem, { MetadataProps } from "@/components/app/ReportMetadata/MetadataItem";
import type { FunctionComponent } from "preact";
import type { MetadataProps } from "@/components/app/ReportMetadata/MetadataItem";
import MetadataItem from "@/components/app/ReportMetadata/MetadataItem";
import { MetadataTestType } from "@/components/app/ReportMetadata/MetadataTestType";
import { MetadataWithIcon } from "@/components/app/ReportMetadata/MetadataWithIcon";
import * as styles from "@/components/app/ReportMetadata/styles.scss";
Expand All @@ -12,6 +14,7 @@ import { capitalize } from "@/utils/capitalize";

export const MetadataSummary: FunctionComponent = () => {
const { t } = useI18n("statuses");
const { t: testSummary } = useI18n("testSummary");

return (
<Loadable
Expand All @@ -23,20 +26,21 @@ export const MetadataSummary: FunctionComponent = () => {
type: "all",
count: stats.total,
}));
// TODO: https://github.com/qameta/allure3/issues/178
// const metadataStatsKeys: (keyof Statistic)[] = ["flakyTests", "retryTests", "newTests"];
// const metaDataTests = metadataStatsKeys
// .filter((key) => stats[key])
// .map((key) => {
// const title = t[key];
// const props = { title, count: stats[key], type: key };
//
// return (
// <>
// <MetadataItem key={key} props={props} renderComponent={MetadataWithIcon} />
// </>
// );
// });
const metaDataTests = ["flaky", "retry"]
.map((key) => {
if (!stats[key]) {
return;
}
const title = testSummary(key);
const props = { title, count: stats[key] || 0, type: key };

return (
<div key={key}>
<MetadataItem key={key} props={props} renderComponent={MetadataWithIcon} />
</div>
);
})
.filter(Boolean);

const metadataStatuses = statusesList
.map((status) => ({ status, value: stats[status] }))
Expand Down Expand Up @@ -67,8 +71,8 @@ export const MetadataSummary: FunctionComponent = () => {
props={allTest.value}
renderComponent={MetadataWithIcon}
/>
{/*<div className={styles["report-metadata-separator"]}></div>*/}
{/*{metaDataTests}*/}
{Boolean(metaDataTests.length) && <div className={styles["report-metadata-separator"]} />}
{metaDataTests}
</div>
<div className={styles["report-metadata-status"]}>{metadataStatuses}</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { FunctionComponent, h } from "preact";
import type { FunctionComponent } from "preact";
import notifications from "@/assets/svg/line-alerts-notification-box.svg";
import refresh from "@/assets/svg/line-arrows-refresh-ccw-1.svg";
import lineGeneralZap from "@/assets/svg/line-general-zap.svg";
import { MetadataProps } from "@/components/app/ReportMetadata/MetadataItem";
import type { MetadataProps } from "@/components/app/ReportMetadata/MetadataItem";
import { SvgIcon } from "@/components/commons/SvgIcon";
import { Text } from "@/components/commons/Typography";
import * as styles from "./styles.scss";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { useState } from "preact/hooks";
import LineGeneralCopy3 from "@/assets/svg/line-general-copy-3.svg";
import { IconButton } from "@/components/commons/Button";
import { TooltipWrapper } from "@/components/commons/Tooltip";
import { Code, Text } from "@/components/commons/Typography";
import { useI18n } from "@/stores/locale";
import { copyToClipboard } from "@/utils/copyToClipboard";
Expand All @@ -19,28 +20,26 @@ const TestResultErrorTrace = ({ trace }) => {
export const TestResultError = ({ message, trace }) => {
const [isOpen, setIsOpen] = useState(false);
const { t } = useI18n("ui");
const { t: tooltip } = useI18n("controls");

return (
<div data-testid="test-result-error" className={styles["test-result-error"]}>
<div
data-testid="test-result-error-header"
className={styles["test-result-error-header"]}
onClick={() => setIsOpen(!isOpen)}
>
<div data-testid="test-result-error-header" className={styles["test-result-error-header"]}>
<Text tag={"p"} size={"m"} bold className={styles["test-result-error-text"]}>
{t("error")}
</Text>
<IconButton
style={"ghost"}
size={"s"}
icon={LineGeneralCopy3.id}
onClick={(e) => {
e.stopPropagation();
copyToClipboard(message);
}}
/>
<TooltipWrapper tooltipText={tooltip("clipboard")} tooltipTextAfterClick={tooltip("clipboardSuccess")}>
<IconButton
style={"ghost"}
size={"s"}
icon={LineGeneralCopy3.id}
onClick={() => {
copyToClipboard(message);
}}
/>
</TooltipWrapper>
</div>
<div onClick={() => setIsOpen(!isOpen)}>
<div className={styles["test-result-error-message"]} onClick={() => setIsOpen(!isOpen)}>
<Code data-testid="test-result-error-message" size={"s"}>
{message}
</Code>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
.test-result-error {
padding: 8px 8px 12px 24px;
padding: 8px 8px 12px 16px;
background-color: var(--bg-alpha-capella);
border-radius: 8px;
position: relative;
overflow: hidden;
cursor: pointer;

&:before {
content: "";
Expand All @@ -26,15 +25,27 @@

.test-result-error-text {
margin-bottom: 8px;
padding-left: 8px;
color: var(--on-support-capella);
}

.test-result-error-trace {
margin-top: 8px;
padding-left: 8px;

pre {
overflow-wrap: break-word;
word-wrap: break-word;
white-space: pre-wrap;
overflow: scroll;
padding-bottom: 24px;
}
}

.test-result-error-message {
padding: 8px;
border-radius: 8px;
cursor: pointer;
transition: background-color 300ms;

&:hover {
background: var(--bg-alpha-capella);
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import clsx from "clsx";
import { FunctionalComponent } from "preact";
import { AllureAwesomeTestResult } from "types";
import type { FunctionalComponent } from "preact";
import type { AllureAwesomeTestResult } from "types";
import LineArrowsChevronDown from "@/assets/svg/line-arrows-chevron-down.svg";
import LineGeneralHomeLine from "@/assets/svg/line-general-home-line.svg";
import { LanguagePicker } from "@/components/app/LanguagePicker";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,18 @@ import TreeItemIcon from "@/components/app/Tree/TreeItemIcon";
import { IconButton } from "@/components/commons/Button";
import { TooltipWrapper } from "@/components/commons/Tooltip";
import { Text } from "@/components/commons/Typography";
import { navigateTo } from "@/index";
import { openInNewTab } from "@/index";
import { useI18n } from "@/stores";
import { timestampToDate } from "@/utils/time";

export const TestResultHistoryItem = ({ testResultItem }) => {
const { status, message, trace, stop, duration, id, uuid } = testResultItem;
const { status, message, trace, stop, duration, id } = testResultItem;
const [isOpened, setIsOpen] = useState(false);
const convertedStop = timestampToDate(stop);
const formattedDuration = formatDuration(duration);
const formattedDuration = formatDuration(duration as number);
const { t } = useI18n("controls");

const navigateUrl = `/${uuid}/${id}`;
const navigateUrl = `/testresult/${id}`;

return (
<div>
Expand All @@ -31,16 +33,15 @@ export const TestResultHistoryItem = ({ testResultItem }) => {
<Text type="ui" size={"s"} className={styles["item-time"]}>
{formattedDuration}
</Text>

<TooltipWrapper tooltipText={"Go to error"}>
<TooltipWrapper tooltipText={t("openInNewTab")}>
<IconButton
icon={LineGeneralLinkExternal.id}
style={"ghost"}
size={"s"}
className={styles["test-result-history-item-link"]}
onClick={(e) => {
e.stopPropagation();
navigateTo(navigateUrl);
openInNewTab(navigateUrl);
}}
/>
</TooltipWrapper>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import lineAlertsAlertCircle from "@/assets/svg/line-alerts-alert-circle.svg";
import lineGeneralEye from "@/assets/svg/line-general-eye.svg";
import lineIconBomb2 from "@/assets/svg/line-icon-bomb-2.svg";
import { SvgIcon } from "@/components/commons/SvgIcon";
import { useI18n } from "@/stores";
import { capitalize } from "@/utils/capitalize";
import * as styles from "./styles.scss";

const icons = {
flaky: lineIconBomb2.id,
known: lineAlertsAlertCircle.id,
muted: lineGeneralEye.id,
};

export const TestResultInfoStatuses = ({ statuses }) => {
const { t } = useI18n("filters");
return (
<div className={styles["test-result-info-statuses"]}>
{statuses.map(([status], key: number) => {
const title = t(status);

return (
<div key={key} className={styles["test-result-info-status"]}>
<SvgIcon className={styles["metadata-icon"]} id={icons[status]} size={"s"} />
{capitalize(title)}
</div>
);
})}
</div>
);
};
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { formatDuration } from "@allurereport/core-api";
import * as test from "node:test";
import { FunctionalComponent } from "preact";
import { AllureAwesomeTestResult } from "types";
import type { FunctionalComponent } from "preact";
import type { AllureAwesomeTestResult } from "types";
import { TestResultInfoStatuses } from "@/components/app/TestResult/TestResultInfo/TestResultInfoStatuses";
import { TestResultNavigation } from "@/components/app/TestResult/TestResultNavigation";
import { TestResultPrevStatuses } from "@/components/app/TestResult/TestResultPrevStatuses";
import { TestResultSeverity } from "@/components/app/TestResult/TestResultSeverity";
Expand All @@ -19,11 +19,12 @@ export type TestResultInfoProps = {
};

export const TestResultInfo: FunctionalComponent<TestResultInfoProps> = ({ testResult }) => {
const { name, status, duration, labels, history, retries, attachments, stop } = testResult ?? {};
const { name, status, muted, flaky, known, duration, labels, history, retries, attachments, stop } = testResult ?? {};
const formattedDuration = formatDuration(duration);
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 (
Expand All @@ -37,6 +38,7 @@ export const TestResultInfo: FunctionalComponent<TestResultInfoProps> = ({ testR
{Boolean(status) && <TestResultStatus status={status} />}
{Boolean(history?.length) && <TestResultPrevStatuses history={history} />}
<TestResultSeverity severity={severity} />
{Boolean(statuses.length) && <TestResultInfoStatuses statuses={statuses} />}
<TooltipWrapper tooltipText={fullDate}>
<Text tag={"div"} size={"s"} bold className={styles["test-result-duration"]}>
{formattedDuration}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,20 @@
gap: 4px;
align-items: center;
}

.test-result-info-statuses {
display: flex;
align-items: center;
gap: 8px;
}

.test-result-info-status {
display: flex;
align-items: center;
gap: 2px;
}

.metadata-icon {
margin-right: 8px;
color: var(--on-icon-secondary);
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,10 @@ export const TestResultNavigation: FunctionalComponent<TestResultNavigationProps
source={testResultNavStore}
renderData={(data) => {
const currentIndex = data.indexOf(id) + 1;

return (
<div className={styles["test-result-nav"]}>
{fullName && <FullName />}
{data && (
{data && !testResult?.hidden && (
<div className={styles["test-result-navigator"]}>
<TooltipWrapper tooltipText={tooltip("prevTR")} isTriggerActive={currentIndex > 1}>
<IconButton
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { autoUpdate, computePosition, flip, offset, shift } from "@floating-ui/dom";
import { FunctionalComponent } from "preact";
import { useEffect, useRef, useState } from "preact/hooks";
import { AllureAwesomeTestResult } from "types";
import type { FunctionalComponent } from "preact";
import type { AllureAwesomeTestResult } from "types";
import LineShapesDotCircle from "@/assets/svg/line-shapes-dot-circle.svg";
import { useTestResultTabsContext } from "@/components/app/TestResult/TestResultTabs";
import { SvgIcon } from "@/components/commons/SvgIcon";
import { TooltipWrapper } from "@/components/commons/Tooltip";
import { Text } from "@/components/commons/Typography";
Expand All @@ -12,8 +11,9 @@ import { timestampToDate } from "@/utils/time";
import * as styles from "./styles.scss";

const TestResultPrevStatus = ({ item }) => {
const { setCurrentTab } = useTestResultTabsContext();
return (
<div className={styles["test-result-prev-status"]}>
<div className={styles["test-result-prev-status"]} onClick={() => setCurrentTab("history")}>
<SvgIcon id={LineShapesDotCircle.id} className={styles[`status-${item?.status}`]} />
</div>
);
Expand Down Expand Up @@ -41,7 +41,7 @@ export const TestResultPrevStatuses: FunctionalComponent<TestResultPrevStatusesP
return (
<div className={styles["test-result-prev-statuses"]}>
{history?.slice(0, 6).map((item, key) => (
<div className={styles["test-result-prev-status"]}>
<div key={key} className={styles["test-result-prev-status"]}>
<TooltipWrapper key={key} tooltipComponent={<TestResultPrevStatusTooltip item={item} />}>
<TestResultPrevStatus item={item} />
</TooltipWrapper>
Expand Down
Loading
Loading