Skip to content

Commit

Permalink
fix: after review
Browse files Browse the repository at this point in the history
  • Loading branch information
todti committed Jan 9, 2025
1 parent d014ca9 commit b273219
Show file tree
Hide file tree
Showing 10 changed files with 66 additions and 8 deletions.
23 changes: 22 additions & 1 deletion .pnp.cjs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { sanitizeHtml } from "@allurereport/web-commons";
import { useState } from "preact/hooks";
import LineGeneralCopy3 from "@/assets/svg/line-general-copy-3.svg";
import { IconButton } from "@/components/commons/Button";
Expand All @@ -8,10 +9,12 @@ import { copyToClipboard } from "@/utils/copyToClipboard";
import * as styles from "./styles.scss";

const TestResultErrorTrace = ({ trace }) => {
const sanitizedTrace = sanitizeHtml(trace);

return (
<div data-testid="test-result-error-trace" className={styles["test-result-error-trace"]}>
<Code size={"s"} type={"ui"}>
<pre>{trace}</pre>
<pre dangerouslySetInnerHTML={{ __html: sanitizedTrace }} />
</Code>
</div>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ 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 { openInNewTab } from "@/index";
import { navigateTo, openInNewTab } from "@/index";
import { useI18n } from "@/stores";
import { timestampToDate } from "@/utils/time";

Expand All @@ -34,7 +34,7 @@ export const TestResultHistoryItem = ({ testResultItem }) => {
className={styles["test-result-history-item-wrap"]}
onClick={(e) => {
e.stopPropagation();
openInNewTab(navigateUrl);
navigateTo(navigateUrl);
}}
>
<TreeItemIcon status={status} className={styles["test-result-history-item-status"]} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ import { useTestResultTabsContext } from "@/components/app/TestResult/TestResult
import { SvgIcon } from "@/components/commons/SvgIcon";
import { TooltipWrapper } from "@/components/commons/Tooltip";
import { Text } from "@/components/commons/Typography";
import { openInNewTab } from "@/index";
import { navigateTo, openInNewTab } from "@/index";
import { useI18n } from "@/stores";
import { capitalize } from "@/utils/capitalize";
import { timestampToDate } from "@/utils/time";
import * as styles from "./styles.scss";

const TestResultPrevStatus = ({ item }) => {
return (
<div className={styles["test-result-prev-status"]} onClick={() => openInNewTab(`testresult/${item.id}`)}>
<div className={styles["test-result-prev-status"]} onClick={() => navigateTo(`testresult/${item.id}`)}>
<SvgIcon id={LineShapesDotCircle.id} className={styles[`status-${item?.status}`]} />
</div>
);
Expand Down
3 changes: 2 additions & 1 deletion packages/web-commons/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
"rimraf": "^6.0.1",
"tslib": "^2.7.0",
"typescript": "^5.6.3",
"vitest": "^2.1.8"
"vitest": "^2.1.8",
"xss": "^1.0.15"
}
}
1 change: 1 addition & 0 deletions packages/web-commons/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export * from "./data.js";
export * from "./static.js";
export * from "./sanitizeHtml.js";
12 changes: 12 additions & 0 deletions packages/web-commons/src/sanitizeHtml.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import xss from "xss";

export const sanitizeHtml = (html: string) => {
return xss(html, {
stripIgnoreTagBody: ["script"],
whiteList: {
div: ["style"],
span: ["style"],
},
css: true,
});
};
22 changes: 21 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -665,6 +665,7 @@ __metadata:
tslib: "npm:^2.7.0"
typescript: "npm:^5.6.3"
vitest: "npm:^2.1.8"
xss: "npm:^1.0.15"
languageName: unknown
linkType: soft

Expand Down Expand Up @@ -6112,7 +6113,7 @@ __metadata:
languageName: node
linkType: hard

"commander@npm:^2.20.0":
"commander@npm:^2.20.0, commander@npm:^2.20.3":
version: 2.20.3
resolution: "commander@npm:2.20.3"
checksum: 10/90c5b6898610cd075984c58c4f88418a4fb44af08c1b1415e9854c03171bec31b336b7f3e4cefe33de994b3f12b03c5e2d638da4316df83593b9e82554e7e95b
Expand Down Expand Up @@ -6434,6 +6435,13 @@ __metadata:
languageName: node
linkType: hard

"cssfilter@npm:0.0.10":
version: 0.0.10
resolution: "cssfilter@npm:0.0.10"
checksum: 10/1e45182f42de848f092f50a313113c28a88e4ac98333bf1603ee1c3b200384a3bc83c12e35cd61135e3b0f218295f600d51120ca1f926b7958b2d3262d711214
languageName: node
linkType: hard

"cssnano-preset-default@npm:^6.1.2":
version: 6.1.2
resolution: "cssnano-preset-default@npm:6.1.2"
Expand Down Expand Up @@ -15209,6 +15217,18 @@ __metadata:
languageName: node
linkType: hard

"xss@npm:^1.0.15":
version: 1.0.15
resolution: "xss@npm:1.0.15"
dependencies:
commander: "npm:^2.20.3"
cssfilter: "npm:0.0.10"
bin:
xss: bin/xss
checksum: 10/074ad54babac9dd5107466dbf30d3b871dbedae1f8e7b8f4e3b76d60da8b92bd0f66f18ccd26b8524545444ef784b78c526cee089a907aa904f83c8b8d7958f6
languageName: node
linkType: hard

"yallist@npm:^3.0.2":
version: 3.1.1
resolution: "yallist@npm:3.1.1"
Expand Down

0 comments on commit b273219

Please sign in to comment.