@allurereport/plugin-awesome 3.14.2 → 3.15.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,5 +1,5 @@
1
1
  import { type AttachmentLink, type EnvironmentIdentity, type EnvironmentItem, type Statistic, type TestEnvGroup, type TestResult } from "@allurereport/core-api";
2
- import type { AllureStore, ExitCode, PluginContext, PluginGlobalAttachment, PluginGlobalError, QualityGateValidationResult, ReportFiles, ResultFile } from "@allurereport/plugin-api";
2
+ import type { AllureStore, GlobalAttachmentLink, ExitCode, PluginContext, PluginGlobalError, QualityGateValidationResult, ReportFiles, ResultFile } from "@allurereport/plugin-api";
3
3
  import type { AwesomeExecutorInfo, AwesomeRunSummary, AwesomeTestResult } from "@allurereport/web-awesome";
4
4
  import type { AwesomeOptions, TemplateManifest } from "./model.js";
5
5
  import type { AwesomeDataWriter, ReportFile } from "./writer.js";
@@ -27,13 +27,17 @@ export declare const generateAttachmentsFiles: (writer: AwesomeDataWriter, attac
27
27
  export declare const generateHistoryDataPoints: (writer: AwesomeDataWriter, store: AllureStore) => Promise<Map<string, string>>;
28
28
  export declare const generateGlobals: (writer: AwesomeDataWriter, payload: {
29
29
  globalExitCode?: ExitCode;
30
- globalAttachments?: PluginGlobalAttachment[];
31
- globalAttachmentsByEnv?: Record<string, PluginGlobalAttachment[]>;
30
+ globalAttachments?: GlobalAttachmentLink[];
31
+ globalAttachmentsByEnv?: Record<string, GlobalAttachmentLink[]>;
32
32
  globalErrors?: PluginGlobalError[];
33
33
  globalErrorsByEnv?: Record<string, PluginGlobalError[]>;
34
34
  contentFunction: (id: string) => Promise<ResultFile | undefined>;
35
35
  }) => Promise<void>;
36
- export declare const generateQualityGateResults: (writer: AwesomeDataWriter, qualityGateResults?: Record<string, QualityGateValidationResult[]>) => Promise<void>;
36
+ export declare const generateQualityGateResults: (writer: AwesomeDataWriter, qualityGateResults?: Record<string, QualityGateValidationResult[]>, options?: {
37
+ tests?: AwesomeTestResult[];
38
+ labels?: string[];
39
+ appendTitlePath?: boolean;
40
+ }) => Promise<void>;
37
41
  export declare const generateStaticFiles: (payload: AwesomeOptions & {
38
42
  id: string;
39
43
  allureVersion: string;
@@ -3,7 +3,7 @@ import { readFile, readdir } from "node:fs/promises";
3
3
  import { createRequire } from "node:module";
4
4
  import { basename, dirname, join } from "node:path";
5
5
  import { defaultChartsConfig } from "@allurereport/charts-api";
6
- import { compareBy, createBaseUrlScript, createFontLinkTag, createReportDataScript, stringifyForInlineScript, createScriptTag, createStylesLinkTag, incrementStatistic, joinPosixPath, nullsLast, ordinal, } from "@allurereport/core-api";
6
+ import { appLoaderFaviconDataUri, appLoaderStyles, compareBy, createAppLoaderMarkup, createBaseUrlScript, createFaviconLinkTag, createFontLinkTag, createReportDataScript, stringifyForInlineScript, createScriptTag, createStylesLinkTag, incrementStatistic, joinPosixPath, nullsLast, ordinal, } from "@allurereport/core-api";
7
7
  import { collapseTreeGroups, createTreeByLabels, createTreeByLabelsAndTitlePath, createTreeByTitlePath, preciseTreeLabels, processTree, } from "@allurereport/plugin-api";
8
8
  import { generateCharts, getPieChartValues } from "@allurereport/web-commons";
9
9
  import Handlebars from "handlebars";
@@ -14,13 +14,15 @@ const template = `<!DOCTYPE html>
14
14
  <head>
15
15
  <meta charset="utf-8">
16
16
  <title> {{ reportName }} </title>
17
- <link rel="icon" href="data:image/svg+xml,%3Csvg width='32' height='32' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M22.232 4.662a3.6 3.6 0 0 1 5.09.035c2.855 2.894 4.662 6.885 4.662 11.295a3.6 3.6 0 0 1-7.2 0c0-2.406-.981-4.61-2.587-6.24a3.6 3.6 0 0 1 .035-5.09Z' fill='url(%23a)'/%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M12.392 3.6a3.6 3.6 0 0 1 3.6-3.6c4.41 0 8.401 1.807 11.296 4.662a3.6 3.6 0 1 1-5.056 5.126C20.602 8.18 18.398 7.2 15.992 7.2a3.6 3.6 0 0 1-3.6-3.6Z' fill='url(%23b)'/%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M0 15.992C0 7.157 7.157 0 15.992 0a3.6 3.6 0 0 1 0 7.2A8.789 8.789 0 0 0 7.2 15.992c0 2.406.981 4.61 2.588 6.24a3.6 3.6 0 0 1-5.126 5.056C1.807 24.393 0 20.402 0 15.992Z' fill='url(%23c)'/%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M4.661 22.232a3.6 3.6 0 0 1 5.091-.035c1.63 1.606 3.834 2.587 6.24 2.587a3.6 3.6 0 0 1 0 7.2c-4.41 0-8.401-1.807-11.295-4.661a3.6 3.6 0 0 1-.036-5.091Z' fill='url(%23d)'/%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M28.384 12.392a3.6 3.6 0 0 1 3.6 3.6c0 8.835-7.157 15.992-15.992 15.992a3.6 3.6 0 0 1 0-7.2 8.789 8.789 0 0 0 8.792-8.792 3.6 3.6 0 0 1 3.6-3.6Z' fill='url(%23e)'/%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M28.385 12.392a3.6 3.6 0 0 1 3.6 3.6v12.392a3.6 3.6 0 0 1-7.2 0V15.992a3.6 3.6 0 0 1 3.6-3.6Z' fill='url(%23f)'/%3E%3Cg clip-path='url(%23g)'%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M22.232 4.662a3.6 3.6 0 0 1 5.091.035c2.855 2.894 4.662 6.885 4.662 11.295a3.6 3.6 0 0 1-7.2 0c0-2.406-.982-4.61-2.588-6.24a3.6 3.6 0 0 1 .035-5.09Z' fill='url(%23h)'/%3E%3C/g%3E%3Cdefs%3E%3ClinearGradient id='a' x1='26.4' y1='9.6' x2='28.8' y2='15' gradientUnits='userSpaceOnUse'%3E%3Cstop stop-color='%237E22CE'/%3E%3Cstop offset='1' stop-color='%238B5CF6'/%3E%3C/linearGradient%3E%3ClinearGradient id='b' x1='26.8' y1='9.4' x2='17.8' y2='3.6' gradientUnits='userSpaceOnUse'%3E%3Cstop stop-color='%23EF4444'/%3E%3Cstop offset='1' stop-color='%23DC2626'/%3E%3C/linearGradient%3E%3ClinearGradient id='c' x1='3.6' y1='14' x2='5.4' y2='24.8' gradientUnits='userSpaceOnUse'%3E%3Cstop stop-color='%2322C55E'/%3E%3Cstop offset='1' stop-color='%2315803D'/%3E%3C/linearGradient%3E%3ClinearGradient id='d' x1='4.8' y1='22.2' x2='14.4' y2='29.2' gradientUnits='userSpaceOnUse'%3E%3Cstop stop-color='%2394A3B8'/%3E%3Cstop offset='.958' stop-color='%2364748B'/%3E%3Cstop offset='1' stop-color='%2364748B'/%3E%3C/linearGradient%3E%3ClinearGradient id='e' x1='28.4' y1='22.173' x2='22.188' y2='28.384' gradientUnits='userSpaceOnUse'%3E%3Cstop stop-color='%23D97706'/%3E%3Cstop offset='1' stop-color='%23FBBF24'/%3E%3C/linearGradient%3E%3ClinearGradient id='f' x1='29.2' y1='54.4' x2='30.626' y2='54.256' gradientUnits='userSpaceOnUse'%3E%3Cstop stop-color='%23FBBF24'/%3E%3Cstop offset='1' stop-color='%23FBBF24'/%3E%3C/linearGradient%3E%3ClinearGradient id='h' x1='26.4' y1='9.6' x2='28.8' y2='15' gradientUnits='userSpaceOnUse'%3E%3Cstop stop-color='%237E22CE'/%3E%3Cstop offset='1' stop-color='%238B5CF6'/%3E%3C/linearGradient%3E%3CclipPath id='g'%3E%3Cpath fill='%23fff' transform='translate(24.8 12)' d='M0 0h7.2v8H0z'/%3E%3C/clipPath%3E%3C/defs%3E%3C/svg%3E" />
17
+ ${createFaviconLinkTag(appLoaderFaviconDataUri)}
18
+ ${appLoaderStyles}
18
19
  {{{ headTags }}}
19
20
  <script>
20
21
  window.allureReportOptions = {{{ reportOptions }}}
21
22
  </script>
22
23
  </head>
23
24
  <body>
25
+ ${createAppLoaderMarkup()}
24
26
  <div id="app"></div>
25
27
  ${createBaseUrlScript()}
26
28
  <script>
@@ -84,7 +86,9 @@ export const generateTestResults = async (_writer, store, trs, options = {}) =>
84
86
  const related = await store.relatedByTestResultIds(trs.map(({ id }) => id));
85
87
  for (const tr of trs) {
86
88
  const trFixtures = related.fixturesByTrId.get(tr.id) ?? [];
87
- const convertedTrFixtures = trFixtures.map(convertFixtureResult);
89
+ const convertedTrFixtures = [...trFixtures]
90
+ .sort(nullsLast(compareBy("start", ordinal())))
91
+ .map(convertFixtureResult);
88
92
  const convertedTr = convertTestResult(tr, {
89
93
  hideLabels: options.hideLabels,
90
94
  });
@@ -186,6 +190,10 @@ export const getRunSummary = (testResults) => {
186
190
  : undefined;
187
191
  };
188
192
  export const generateTree = async (writer, treeFilename, labels, tests, options) => {
193
+ const tree = generateTreeData(labels, tests, options);
194
+ await writer.writeWidget(treeFilename, tree);
195
+ };
196
+ const generateTreeData = (labels, tests, options) => {
189
197
  const visibleTests = tests.filter((test) => !test.isRetry);
190
198
  const { appendTitlePath } = options || {};
191
199
  let tree;
@@ -202,7 +210,7 @@ export const generateTree = async (writer, treeFilename, labels, tests, options)
202
210
  sort: nullsLast(compareBy("start", ordinal())),
203
211
  transform: (leaf, idx) => ({ ...leaf, groupOrder: idx + 1 }),
204
212
  });
205
- await writer.writeWidget(treeFilename, tree);
213
+ return tree;
206
214
  };
207
215
  const buildTreeByLabels = (tests, labels) => {
208
216
  return createTreeByLabels(tests, labels, leafFactory, undefined, (group, leaf) => {
@@ -371,8 +379,25 @@ export const generateGlobals = async (writer, payload) => {
371
379
  }
372
380
  await writer.writeWidget("globals.json", globals);
373
381
  };
374
- export const generateQualityGateResults = async (writer, qualityGateResults = {}) => {
375
- await writer.writeWidget("quality-gate.json", qualityGateResults);
382
+ export const generateQualityGateResults = async (writer, qualityGateResults = {}, options = {}) => {
383
+ const { tests = [], labels = [], appendTitlePath } = options;
384
+ const testsById = new Map(tests.map((test) => [test.id, test]));
385
+ const resultsWithTrees = Object.fromEntries(Object.entries(qualityGateResults).map(([environment, results]) => [
386
+ environment,
387
+ results.map((result) => {
388
+ const relatedTests = [...new Set(result.testResults ?? [])]
389
+ .map((testResultId) => testsById.get(testResultId))
390
+ .filter((test) => Boolean(test));
391
+ if (relatedTests.length === 0) {
392
+ return result;
393
+ }
394
+ return {
395
+ ...result,
396
+ testResultsTree: generateTreeData(labels, relatedTests, { appendTitlePath }),
397
+ };
398
+ }),
399
+ ]));
400
+ await writer.writeWidget("quality-gate.json", resultsWithTrees);
376
401
  };
377
402
  export const generateStaticFiles = async (payload) => {
378
403
  const { id, reportName = "Allure Report", reportLanguage = "en", singleFile, logo = "", theme = "auto", groupBy, reportFiles, reportDataFiles, reportUuid, allureVersion, layout = "base", defaultSection = "", ci, executor, runSummary, stepTreeExpansion, defaultSortBy, } = payload;
package/dist/plugin.js CHANGED
@@ -68,9 +68,22 @@ export class AwesomePlugin {
68
68
  }
69
69
  envIdByTrId.set(tr.id, environmentId);
70
70
  }));
71
+ const trsByEnvId = new Map();
72
+ for (const tr of allTrs) {
73
+ const environmentId = envIdByTrId.get(tr.id);
74
+ if (!environmentId) {
75
+ continue;
76
+ }
77
+ const group = trsByEnvId.get(environmentId);
78
+ if (group) {
79
+ group.push(tr);
80
+ }
81
+ else {
82
+ trsByEnvId.set(environmentId, [tr]);
83
+ }
84
+ }
71
85
  await Promise.all(environments.map(async ({ id }) => {
72
- const envTrs = await store.testResultsByEnvironmentId(id, { includeRetries: true });
73
- envStatistics.set(id, await statisticByTestResults(store, envTrs));
86
+ envStatistics.set(id, await statisticByTestResults(store, trsByEnvId.get(id) ?? []));
74
87
  }));
75
88
  await generateStatistic(__classPrivateFieldGet(this, _AwesomePlugin_writer, "f"), {
76
89
  stats: statistics,
@@ -126,7 +139,11 @@ export class AwesomePlugin {
126
139
  if (attachments?.length) {
127
140
  await generateAttachmentsFiles(__classPrivateFieldGet(this, _AwesomePlugin_writer, "f"), attachments, (id) => store.attachmentContentById(id));
128
141
  }
129
- await generateQualityGateResults(__classPrivateFieldGet(this, _AwesomePlugin_writer, "f"), qualityGateResults);
142
+ await generateQualityGateResults(__classPrivateFieldGet(this, _AwesomePlugin_writer, "f"), qualityGateResults, {
143
+ tests: convertedTrs,
144
+ labels: treeLabels,
145
+ appendTitlePath,
146
+ });
130
147
  await generateGlobals(__classPrivateFieldGet(this, _AwesomePlugin_writer, "f"), {
131
148
  globalAttachments,
132
149
  globalAttachmentsByEnv,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@allurereport/plugin-awesome",
3
- "version": "3.14.2",
3
+ "version": "3.15.0",
4
4
  "description": "Allure Awesome Plugin – brand new HTML report with modern design and new features",
5
5
  "keywords": [
6
6
  "allure",
@@ -30,11 +30,11 @@
30
30
  "lint:fix": "oxlint --import-plugin --fix src test features stories"
31
31
  },
32
32
  "dependencies": {
33
- "@allurereport/charts-api": "3.14.2",
34
- "@allurereport/core-api": "3.14.2",
35
- "@allurereport/plugin-api": "3.14.2",
36
- "@allurereport/web-awesome": "3.14.2",
37
- "@allurereport/web-commons": "3.14.2",
33
+ "@allurereport/charts-api": "3.15.0",
34
+ "@allurereport/core-api": "3.15.0",
35
+ "@allurereport/plugin-api": "3.15.0",
36
+ "@allurereport/web-awesome": "3.15.0",
37
+ "@allurereport/web-commons": "3.15.0",
38
38
  "d3-shape": "^3.2.0",
39
39
  "handlebars": "^4.7.9",
40
40
  "markdown-it": "^14.2.0"