@allurereport/web-commons 3.14.3 → 3.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,11 @@
1
1
  import { fetchReportAttachment } from "./data.js";
2
+ const PLAYWRIGHT_TRACE_CONTENT_TYPE = "application/vnd.allure.playwright-trace";
3
+ const PLAYWRIGHT_TRACE_DOWNLOAD_CONTENT_TYPE = "application/zip";
4
+ const downloadContentType = (contentType) => {
5
+ return contentType.split(";")[0].trim().toLowerCase() === PLAYWRIGHT_TRACE_CONTENT_TYPE
6
+ ? PLAYWRIGHT_TRACE_DOWNLOAD_CONTENT_TYPE
7
+ : contentType;
8
+ };
2
9
  export const fetchFromUrl = async ({ id, ext, contentType }) => {
3
10
  const fileName = `${id || "-"}${ext || ""}`;
4
11
  return fetchReportAttachment(`data/attachments/${fileName}?attachment`, contentType);
@@ -46,7 +53,7 @@ export const fetchAttachment = async (id, ext, contentType) => {
46
53
  }
47
54
  };
48
55
  export const blobAttachment = async (id, ext, contentType) => {
49
- const response = await fetchFromUrl({ id, ext, contentType });
56
+ const response = await fetchFromUrl({ id, ext, contentType: downloadContentType(contentType) });
50
57
  return await response.blob();
51
58
  };
52
59
  export const downloadAttachment = async (id, ext, contentType) => {
@@ -249,6 +256,7 @@ export const attachmentType = (type) => {
249
256
  case "application/x-bzip2":
250
257
  case "application/gzip":
251
258
  case "application/zip":
259
+ case PLAYWRIGHT_TRACE_CONTENT_TYPE:
252
260
  return "archive";
253
261
  case "application/vnd.allure.image.diff":
254
262
  return "image-diff";
@@ -33,6 +33,7 @@ export const generateStatusDynamicsChart = (props) => {
33
33
  }, { total: statistic.total }),
34
34
  id: point.uuid,
35
35
  timestamp: point.timestamp,
36
+ url: point.url,
36
37
  };
37
38
  });
38
39
  return {
@@ -25,6 +25,7 @@ export interface StatusDynamicsChartData {
25
25
  id: string;
26
26
  timestamp: number;
27
27
  name: string;
28
+ url?: string;
28
29
  }[];
29
30
  limit?: number;
30
31
  statuses?: TestStatus[];
@@ -1,2 +1,3 @@
1
1
  export declare const sanitize: (html: string, config?: Record<string, any>) => string;
2
2
  export declare const sanitizeIframeHtml: (html: string) => string;
3
+ export declare const sanitizeHtmlDocument: (html: string) => string;
package/dist/sanitize.js CHANGED
@@ -4,3 +4,14 @@ const IFRAME_SANITIZE_CONFIG = {
4
4
  USE_PROFILES: { html: true },
5
5
  };
6
6
  export const sanitizeIframeHtml = (html) => sanitize(html, IFRAME_SANITIZE_CONFIG);
7
+ const HTML_DOCUMENT_SANITIZE_CONFIG = {
8
+ WHOLE_DOCUMENT: true,
9
+ ADD_TAGS: ["meta", "link", "title"],
10
+ ADD_ATTR: ["charset", "http-equiv", "content", "name", "rel", "href", "media", "property"],
11
+ FORBID_TAGS: ["base"],
12
+ FORBID_ATTR: ["http-equiv"],
13
+ };
14
+ export const sanitizeHtmlDocument = (html) => {
15
+ const sanitized = sanitize(html, HTML_DOCUMENT_SANITIZE_CONFIG);
16
+ return sanitized ? `<!DOCTYPE html>${sanitized}` : sanitized;
17
+ };
@@ -32,13 +32,8 @@ export const isSameDocumentUrl = (url, currentHref = getCurrentUrl()) => {
32
32
  }
33
33
  };
34
34
  export const toSameDocumentHistoryUrl = (url) => {
35
- if (url.search) {
36
- return `${url.search}${url.hash}`;
37
- }
38
- if (url.hash) {
39
- return url.hash;
40
- }
41
- return url.pathname.split("/").pop() || ".";
35
+ const fileName = url.pathname.split("/").pop() || ".";
36
+ return `${fileName}${url.search}${url.hash}`;
42
37
  };
43
38
  export const getHistoryUrl = (to, currentHref = getCurrentUrl()) => {
44
39
  const url = getUrl(to);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@allurereport/web-commons",
3
- "version": "3.14.3",
3
+ "version": "3.16.0",
4
4
  "description": "Collection of utilities used across the web Allure reports",
5
5
  "keywords": [
6
6
  "allure",
@@ -26,10 +26,10 @@
26
26
  "lint:fix": "oxlint --import-plugin --fix src test features stories"
27
27
  },
28
28
  "dependencies": {
29
- "@allurereport/aql": "3.14.3",
30
- "@allurereport/charts-api": "3.14.3",
31
- "@allurereport/core-api": "3.14.3",
32
- "@allurereport/plugin-api": "3.14.3",
29
+ "@allurereport/aql": "3.16.0",
30
+ "@allurereport/charts-api": "3.16.0",
31
+ "@allurereport/core-api": "3.16.0",
32
+ "@allurereport/plugin-api": "3.16.0",
33
33
  "@preact/signals": "^2.6.1",
34
34
  "@preact/signals-core": "^1.12.2",
35
35
  "ansi-to-html": "^0.7.2",