Skip to content

Commit

Permalink
fix: a lot of small fixes and improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
todti committed Jan 6, 2025
1 parent 2b5328d commit b696fd0
Show file tree
Hide file tree
Showing 33 changed files with 132 additions and 85 deletions.
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
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
@@ -1,7 +1,6 @@
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 { TestResultNavigation } from "@/components/app/TestResult/TestResultNavigation";
import { TestResultPrevStatuses } from "@/components/app/TestResult/TestResultPrevStatuses";
import { TestResultSeverity } from "@/components/app/TestResult/TestResultSeverity";
Expand Down
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
4 changes: 3 additions & 1 deletion packages/web-awesome/src/components/app/Tree/TreeItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ export const TreeItem: FunctionComponent<TreeItemProps> = ({ name, groupOrder, s
return (
<div {...rest} className={styles["tree-item"]} onClick={() => navigateTo(id)}>
<TreeItemIcon status={status} />
<span data-testid="tree-leaf-order" class={styles.order}>#{groupOrder}</span>
<span data-testid="tree-leaf-order" class={styles.order}>
{groupOrder}
</span>
<Text data-testid="tree-leaf-title" className={styles["item-title"]}>
{name}
</Text>
Expand Down
8 changes: 7 additions & 1 deletion packages/web-awesome/src/components/app/Tree/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
padding: 6px 8px 6px 6px;
transition: background-color 300ms;
gap: 4px;
align-items: center;
cursor: pointer;
position: relative;

Expand Down Expand Up @@ -173,4 +172,11 @@

.order {
user-select: none;
color: var(--on-text-hint);
min-width: 16px;
text-align: center;
box-sizing: content-box;
padding-top: 2px;
line-height: 16px;
width: 24px;
}
10 changes: 6 additions & 4 deletions packages/web-awesome/src/components/commons/Button/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,12 @@

&:hover {
--allure-btn-bg-color: var(--bg-control-flat-medium);

.contentIcon,
.leadingIcon,
.dropdownIcon {
color: var(--allure-btn-icon-color);
}
}

&:active,
Expand Down Expand Up @@ -520,10 +526,6 @@
transition: color var(--color-change-transition-duration);
user-select: none;

&:hover {
color: var(--allure-btn-icon-color);
}

&:focus {
outline: none;
}
Expand Down
4 changes: 2 additions & 2 deletions packages/web-awesome/src/i18n/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ export const LANG_LOCALE: Record<
},
am: {
short: "Am",
full: "አማርኛ",
iso: "am-ET",
full: "Հայերեն",
iso: "hy-AM",
},
az: {
short: "Az",
Expand Down
3 changes: 2 additions & 1 deletion packages/web-awesome/src/i18n/locales/am.json
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@
"collapse": "Կծկել",
"expand": "Ընդլայնել",
"fullscreen": "Լրիվ էկրան",
"language": "Փոխել լեզուն"
"language": "Փոխել լեզուն",
"openInNewTab": "Բացել նոր ներդիրում"
},
"errors": {
"missedAttachment": "Կցորդը չի գտնվել"
Expand Down
3 changes: 2 additions & 1 deletion packages/web-awesome/src/i18n/locales/az.json
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@
"collapse": "Daralt",
"expand": "Genişləndir",
"fullscreen": "Tam ekran",
"language": "Dili dəyiş"
"language": "Dili dəyiş",
"openInNewTab": "Yeni tabda aç"
},
"errors": {
"missedAttachment": "Əlavə tapılmadı"
Expand Down
3 changes: 2 additions & 1 deletion packages/web-awesome/src/i18n/locales/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@
"collapse": "Einklappen",
"expand": "Ausklappen",
"fullscreen": "Vollbild",
"language": "Sprache ändern"
"language": "Sprache ändern",
"openInNewTab": "In neuem Tab öffnen"
},
"errors": {
"missedAttachment": "Anhang nicht gefunden"
Expand Down
3 changes: 2 additions & 1 deletion packages/web-awesome/src/i18n/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@
"collapse": "Collapse",
"expand": "Expand",
"fullscreen": "Full screen",
"language": "Change language"
"language": "Change language",
"openInNewTab": "Open in new tab"
},
"errors": {
"missedAttachment": "Attachment not found"
Expand Down
3 changes: 2 additions & 1 deletion packages/web-awesome/src/i18n/locales/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@
"collapse": "Colapsar",
"expand": "Expandir",
"fullscreen": "Pantalla completa",
"language": "Cambiar idioma"
"language": "Cambiar idioma",
"openInNewTab": "Abrir en nueva pestaña"
},
"errors": {
"missedAttachment": "Adjunto no encontrado"
Expand Down
Loading

0 comments on commit b696fd0

Please sign in to comment.