@allurereport/plugin-api
Advanced tools
+3
-2
@@ -1,2 +0,2 @@ | ||
| import type { DefaultLabelsConfig, EnvironmentsConfig, ReportVariables } from "@allurereport/core-api"; | ||
| import type { CategoriesConfig, DefaultLabelsConfig, EnvironmentsConfig, ReportVariables } from "@allurereport/core-api"; | ||
| import type { PluginDescriptor } from "./plugin.js"; | ||
@@ -13,3 +13,3 @@ import type { QualityGateConfig } from "./qualityGate.js"; | ||
| defaultLabels?: DefaultLabelsConfig; | ||
| stage?: string; | ||
| dump?: string; | ||
| environment?: string; | ||
@@ -24,3 +24,4 @@ environments?: EnvironmentsConfig; | ||
| }; | ||
| categories?: CategoriesConfig; | ||
| } | ||
| export declare const defineConfig: (allureConfig: Config) => Config; |
+3
-1
@@ -1,2 +0,2 @@ | ||
| import type { AttachmentLink, CiDescriptor, Statistic, TestError, TestResult, TestStatus } from "@allurereport/core-api"; | ||
| import type { AllureHistory, AttachmentLink, CategoryDefinition, CiDescriptor, Statistic, TestError, TestResult, TestStatus } from "@allurereport/core-api"; | ||
| import type { QualityGateValidationResult } from "./qualityGate.js"; | ||
@@ -29,2 +29,4 @@ import type { ResultFile } from "./resultFile.js"; | ||
| ci?: CiDescriptor; | ||
| categories?: CategoryDefinition[]; | ||
| history?: AllureHistory; | ||
| } | ||
@@ -31,0 +33,0 @@ export type SummaryTestResult = Pick<TestResult, "name" | "id" | "status" | "duration">; |
+1
-1
@@ -18,3 +18,3 @@ import type { AttachmentLink, HistoryDataPoint, HistoryTestResult, KnownTestFailure, ReportVariables, Statistic, TestCase, TestEnvGroup, TestError, TestFixtureResult, TestResult } from "@allurereport/core-api"; | ||
| allKnownIssues: () => Promise<KnownTestFailure[]>; | ||
| allNewTestResults: (filter?: TestResultFilter) => Promise<TestResult[]>; | ||
| allNewTestResults: (filter?: TestResultFilter, history?: HistoryDataPoint[]) => Promise<TestResult[]>; | ||
| qualityGateResults: () => Promise<QualityGateValidationResult[]>; | ||
@@ -21,0 +21,0 @@ qualityGateResultsByEnv: () => Promise<Record<string, QualityGateValidationResult[]>>; |
@@ -1,3 +0,13 @@ | ||
| import type { TestResult } from "@allurereport/core-api"; | ||
| import type { SummaryTestResult } from "../plugin.js"; | ||
| import { type AllureHistory, type CiDescriptor, type TestResult } from "@allurereport/core-api"; | ||
| import type { PluginSummary, SummaryTestResult } from "../plugin.js"; | ||
| import type { AllureStore } from "../store.js"; | ||
| export declare const convertToSummaryTestResult: (tr: TestResult) => SummaryTestResult; | ||
| export declare const createPluginSummary: (params: { | ||
| filter?: (testResult: TestResult) => boolean; | ||
| name: string; | ||
| plugin: string; | ||
| store: AllureStore; | ||
| history?: AllureHistory; | ||
| ci?: CiDescriptor; | ||
| meta: Record<string, any>; | ||
| }) => Promise<PluginSummary>; |
@@ -0,1 +1,2 @@ | ||
| import { getWorstStatus } from "@allurereport/core-api"; | ||
| export const convertToSummaryTestResult = (tr) => ({ | ||
@@ -7,1 +8,25 @@ id: tr.id, | ||
| }); | ||
| export const createPluginSummary = async (params) => { | ||
| const { name, filter, plugin, store, history, meta } = params; | ||
| const allTrs = await store.allTestResults({ filter }); | ||
| const mainBranchHistory = (await history?.readHistory?.({ branch: "" })) ?? []; | ||
| const newTrs = await store.allNewTestResults(filter, mainBranchHistory); | ||
| const retryTrs = allTrs.filter((tr) => !!tr?.retries?.length); | ||
| const flakyTrs = allTrs.filter((tr) => !!tr?.flaky); | ||
| const duration = allTrs.reduce((acc, { duration: trDuration = 0 }) => acc + trDuration, 0); | ||
| const worstStatus = getWorstStatus(allTrs.map(({ status }) => status)); | ||
| const createdAt = allTrs.reduce((acc, { stop }) => Math.max(acc, stop || 0), 0); | ||
| const summary = { | ||
| stats: await store.testsStatistic(filter), | ||
| status: worstStatus ?? "passed", | ||
| newTests: newTrs.map(convertToSummaryTestResult), | ||
| flakyTests: flakyTrs.map(convertToSummaryTestResult), | ||
| retryTests: retryTrs.map(convertToSummaryTestResult), | ||
| name, | ||
| duration, | ||
| createdAt, | ||
| plugin, | ||
| meta, | ||
| }; | ||
| return summary; | ||
| }; |
+24
-9
@@ -1,2 +0,2 @@ | ||
| import { findByLabelName, } from "@allurereport/core-api"; | ||
| import { createDictionary, findByLabelName, } from "@allurereport/core-api"; | ||
| import { emptyStatistic } from "@allurereport/core-api"; | ||
@@ -23,3 +23,3 @@ import { md5 } from "./misc.js"; | ||
| const createTree = (data, classifier, leafFactory, groupFactory, addLeafToGroup = () => { }) => { | ||
| const groupsByClassifier = {}; | ||
| const groupsByClassifier = createDictionary(); | ||
| const leavesById = {}; | ||
@@ -38,10 +38,12 @@ const groupsById = {}; | ||
| parentGroups = layer.flatMap((group) => { | ||
| return parentGroups.map((parentGroup) => { | ||
| return parentGroups.flatMap((parentGroup) => { | ||
| const parentId = "nodeId" in parentGroup ? parentGroup.nodeId : ""; | ||
| if (groupsByClassifier[parentId] === undefined) { | ||
| groupsByClassifier[parentId] = {}; | ||
| groupsByClassifier[parentId] = createDictionary(); | ||
| } | ||
| if (groupsByClassifier[parentId][group] === undefined || | ||
| typeof groupsByClassifier[parentId][group] === "function") { | ||
| if (groupsByClassifier[parentId][group] === undefined) { | ||
| const newGroup = groupFactory(parentId, group); | ||
| if (!newGroup || typeof newGroup !== "object" || typeof newGroup.nodeId !== "string") { | ||
| return []; | ||
| } | ||
| groupsByClassifier[parentId][group] = newGroup; | ||
@@ -51,5 +53,8 @@ groupsById[newGroup.nodeId] = newGroup; | ||
| const currentGroup = groupsByClassifier[parentId][group]; | ||
| if (!currentGroup || typeof currentGroup !== "object") { | ||
| return []; | ||
| } | ||
| addGroup(parentGroup, currentGroup.nodeId); | ||
| addLeafToGroup(currentGroup, leaf); | ||
| return currentGroup; | ||
| return [currentGroup]; | ||
| }); | ||
@@ -69,3 +74,5 @@ }); | ||
| export const byLabels = (item, labelNames) => { | ||
| return labelNames.map((labelName) => item.labels.filter((label) => labelName === label.name).map((label) => label.value ?? "__unknown") ?? []); | ||
| return labelNames | ||
| .map((labelName) => item.labels.filter((label) => labelName === label.name).map((label) => label.value ?? "__unknown") ?? []) | ||
| .filter((layer) => layer.length > 0); | ||
| }; | ||
@@ -117,3 +124,11 @@ export const filterTreeLabels = (data, labelNames) => { | ||
| export const byCategories = (item) => { | ||
| return [item.categories?.map((category) => category.name)]; | ||
| const categories = item.categories ?? []; | ||
| const result = []; | ||
| for (const category of categories) { | ||
| result.push([category.name]); | ||
| } | ||
| if (item.error?.message) { | ||
| result.push([item.error?.message]); | ||
| } | ||
| return result; | ||
| }; | ||
@@ -120,0 +135,0 @@ export const preciseTreeLabels = (labelNames, trs, labelNamesAccessor = (tr) => tr.labels.map(({ name }) => name)) => { |
+2
-2
| { | ||
| "name": "@allurereport/plugin-api", | ||
| "version": "3.2.0", | ||
| "version": "3.3.1", | ||
| "description": "Allure Plugin API", | ||
@@ -29,3 +29,3 @@ "keywords": [ | ||
| "dependencies": { | ||
| "@allurereport/core-api": "3.2.0" | ||
| "@allurereport/core-api": "3.3.1" | ||
| }, | ||
@@ -32,0 +32,0 @@ "devDependencies": { |
29163
8.47%620
9.35%+ Added
- Removed
Updated