@allurereport/core 3.4.1 → 3.5.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.
- package/dist/api.d.ts +8 -21
- package/dist/config.js +34 -4
- package/dist/report.js +26 -4
- package/dist/store/store.d.ts +6 -3
- package/dist/store/store.js +166 -20
- package/dist/utils/environment.d.ts +6 -0
- package/dist/utils/environment.js +33 -0
- package/dist/utils/event.d.ts +7 -6
- package/dist/utils/event.js +2 -2
- package/package.json +21 -19
package/dist/api.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { CategoriesConfig,
|
|
2
|
-
import type { Plugin,
|
|
1
|
+
import type { CategoriesConfig, KnownTestFailure } from "@allurereport/core-api";
|
|
2
|
+
import type { Plugin, ReportFiles, Config } from "@allurereport/plugin-api";
|
|
3
3
|
import type { ResultsReader } from "@allurereport/reader-api";
|
|
4
4
|
export interface PluginInstance {
|
|
5
5
|
id: string;
|
|
@@ -7,29 +7,16 @@ export interface PluginInstance {
|
|
|
7
7
|
plugin: Plugin;
|
|
8
8
|
options: Record<string, any>;
|
|
9
9
|
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
open: boolean;
|
|
14
|
-
port: string | undefined;
|
|
15
|
-
hideLabels?: (string | RegExp)[];
|
|
16
|
-
historyPath?: string;
|
|
17
|
-
historyLimit?: number;
|
|
18
|
-
knownIssuesPath: string;
|
|
19
|
-
defaultLabels?: DefaultLabelsConfig;
|
|
20
|
-
dump?: string;
|
|
21
|
-
environment?: string;
|
|
22
|
-
environments?: EnvironmentsConfig;
|
|
23
|
-
variables?: ReportVariables;
|
|
10
|
+
type FullConfigRequiredFromConfig = Required<Pick<Config, "name" | "output" | "open" | "knownIssuesPath">>;
|
|
11
|
+
export interface FullConfig extends Omit<Config, "name" | "output" | "open" | "knownIssuesPath" | "plugins" | "port">, FullConfigRequiredFromConfig {
|
|
12
|
+
port: Config["port"] | undefined;
|
|
24
13
|
reportFiles: ReportFiles;
|
|
25
14
|
readers?: ResultsReader[];
|
|
26
15
|
plugins?: PluginInstance[];
|
|
27
|
-
appendHistory?: boolean;
|
|
28
16
|
known?: KnownTestFailure[];
|
|
29
17
|
realTime?: any;
|
|
30
|
-
qualityGate?:
|
|
18
|
+
qualityGate?: Config["qualityGate"];
|
|
31
19
|
categories?: CategoriesConfig;
|
|
32
|
-
|
|
33
|
-
accessToken?: string;
|
|
34
|
-
};
|
|
20
|
+
globalAttachments?: string[];
|
|
35
21
|
}
|
|
22
|
+
export {};
|
package/dist/config.js
CHANGED
|
@@ -6,7 +6,7 @@ import { validateEnvironmentName } from "@allurereport/core-api";
|
|
|
6
6
|
import { parse } from "yaml";
|
|
7
7
|
import { readKnownIssues } from "./known.js";
|
|
8
8
|
import { FileSystemReportFiles } from "./plugin.js";
|
|
9
|
-
import { environmentIdentityById, environmentIdentityByName, normalizeEnvironmentDescriptorMap, } from "./utils/environment.js";
|
|
9
|
+
import { environmentIdentityById, environmentIdentityByName, validateAllowedEnvironmentIds, normalizeEnvironmentDescriptorMap, validateAllowedEnvironmentId, } from "./utils/environment.js";
|
|
10
10
|
import { importWrapper } from "./utils/module.js";
|
|
11
11
|
import { normalizeImportPath } from "./utils/path.js";
|
|
12
12
|
import { assertValidPluginIdForWindows, isWindows } from "./utils/windows.js";
|
|
@@ -19,6 +19,12 @@ const CONFIG_FILENAMES = [
|
|
|
19
19
|
"allurerc.yml",
|
|
20
20
|
];
|
|
21
21
|
const DEFAULT_CONFIG = {};
|
|
22
|
+
const isAgentDescriptor = (value) => {
|
|
23
|
+
return value === "agent" || value === "@allurereport/plugin-agent";
|
|
24
|
+
};
|
|
25
|
+
const hasConfiguredAgent = (plugins) => {
|
|
26
|
+
return Object.entries(plugins).some(([key, descriptor]) => isAgentDescriptor(key) || isAgentDescriptor(descriptor.import));
|
|
27
|
+
};
|
|
22
28
|
export const assertValidPluginId = (id) => {
|
|
23
29
|
if (id.length === 0) {
|
|
24
30
|
throw new Error("Invalid plugin id: must not be empty");
|
|
@@ -85,11 +91,13 @@ export const validateConfig = (config) => {
|
|
|
85
91
|
"defaultLabels",
|
|
86
92
|
"variables",
|
|
87
93
|
"environment",
|
|
94
|
+
"allowedEnvironments",
|
|
88
95
|
"environments",
|
|
89
96
|
"appendHistory",
|
|
90
97
|
"qualityGate",
|
|
91
98
|
"allureService",
|
|
92
99
|
"categories",
|
|
100
|
+
"globalAttachments",
|
|
93
101
|
];
|
|
94
102
|
const unsupportedFields = Object.keys(config).filter((key) => !supportedFields.includes(key));
|
|
95
103
|
return {
|
|
@@ -128,9 +136,10 @@ export const loadJsConfig = async (configPath) => {
|
|
|
128
136
|
};
|
|
129
137
|
const resolveConfigEnvironments = (config) => {
|
|
130
138
|
const errors = [];
|
|
139
|
+
const { ids: allowedEnvironments, idsSet: allowedEnvironmentIds, errors: allowedEnvironmentErrors, } = validateAllowedEnvironmentIds(config.allowedEnvironments, "config.allowedEnvironments");
|
|
131
140
|
const { normalized: environments, errors: environmentErrors } = normalizeEnvironmentDescriptorMap(config.environments ?? {}, "config.environments");
|
|
132
141
|
let environment;
|
|
133
|
-
errors.push(...environmentErrors);
|
|
142
|
+
errors.push(...allowedEnvironmentErrors, ...environmentErrors);
|
|
134
143
|
if (config.environment !== undefined) {
|
|
135
144
|
const environmentResult = validateEnvironmentName(config.environment);
|
|
136
145
|
if (!environmentResult.valid) {
|
|
@@ -142,6 +151,16 @@ const resolveConfigEnvironments = (config) => {
|
|
|
142
151
|
environmentIdentityById(environments, normalizedEnvironment)?.id ??
|
|
143
152
|
environmentIdentityByName(environments, normalizedEnvironment)?.id ??
|
|
144
153
|
normalizedEnvironment;
|
|
154
|
+
const allowedEnvironmentError = validateAllowedEnvironmentId(environment, allowedEnvironmentIds, "config");
|
|
155
|
+
if (allowedEnvironmentError) {
|
|
156
|
+
throw new Error(`The provided Allure config contains invalid environments: ${allowedEnvironmentError}`);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
for (const environmentId of Object.keys(environments)) {
|
|
161
|
+
const allowedEnvironmentError = validateAllowedEnvironmentId(environmentId, allowedEnvironmentIds, "config.environments");
|
|
162
|
+
if (allowedEnvironmentError) {
|
|
163
|
+
throw new Error(`The provided Allure config contains invalid environments: ${allowedEnvironmentError}`);
|
|
145
164
|
}
|
|
146
165
|
}
|
|
147
166
|
if (errors.length > 0) {
|
|
@@ -150,6 +169,7 @@ const resolveConfigEnvironments = (config) => {
|
|
|
150
169
|
return {
|
|
151
170
|
environments,
|
|
152
171
|
environment,
|
|
172
|
+
allowedEnvironments,
|
|
153
173
|
};
|
|
154
174
|
};
|
|
155
175
|
export const resolveConfig = async (config, override = {}) => {
|
|
@@ -157,7 +177,7 @@ export const resolveConfig = async (config, override = {}) => {
|
|
|
157
177
|
if (!validationResult.valid) {
|
|
158
178
|
throw new Error(`The provided Allure config contains unsupported fields: ${validationResult.fields.join(", ")}`);
|
|
159
179
|
}
|
|
160
|
-
const { environments, environment } = resolveConfigEnvironments(config);
|
|
180
|
+
const { environments, environment, allowedEnvironments } = resolveConfigEnvironments(config);
|
|
161
181
|
const name = override.name ?? config.name ?? "Allure Report";
|
|
162
182
|
const open = override.open ?? config.open ?? false;
|
|
163
183
|
const port = override.port ?? config.port ?? undefined;
|
|
@@ -170,13 +190,21 @@ export const resolveConfig = async (config, override = {}) => {
|
|
|
170
190
|
const known = await readKnownIssues(knownIssuesPath);
|
|
171
191
|
const variables = config.variables ?? {};
|
|
172
192
|
const configuredPlugins = override.plugins ?? config.plugins;
|
|
173
|
-
const
|
|
193
|
+
const basePlugins = Object.keys(configuredPlugins ?? {}).length === 0
|
|
174
194
|
? {
|
|
175
195
|
awesome: {
|
|
176
196
|
options: {},
|
|
177
197
|
},
|
|
178
198
|
}
|
|
179
199
|
: configuredPlugins;
|
|
200
|
+
const plugins = hasConfiguredAgent(basePlugins)
|
|
201
|
+
? basePlugins
|
|
202
|
+
: {
|
|
203
|
+
...basePlugins,
|
|
204
|
+
agent: {
|
|
205
|
+
options: {},
|
|
206
|
+
},
|
|
207
|
+
};
|
|
180
208
|
const pluginInstances = await resolvePlugins(plugins);
|
|
181
209
|
return {
|
|
182
210
|
name,
|
|
@@ -187,6 +215,7 @@ export const resolveConfig = async (config, override = {}) => {
|
|
|
187
215
|
knownIssuesPath,
|
|
188
216
|
known,
|
|
189
217
|
environment,
|
|
218
|
+
allowedEnvironments,
|
|
190
219
|
variables,
|
|
191
220
|
environments,
|
|
192
221
|
appendHistory,
|
|
@@ -198,6 +227,7 @@ export const resolveConfig = async (config, override = {}) => {
|
|
|
198
227
|
qualityGate: config.qualityGate,
|
|
199
228
|
allureService: config.allureService,
|
|
200
229
|
categories: config.categories,
|
|
230
|
+
globalAttachments: config.globalAttachments,
|
|
201
231
|
};
|
|
202
232
|
};
|
|
203
233
|
export const readConfig = async (cwd = process.cwd(), configPath, override) => {
|
package/dist/report.js
CHANGED
|
@@ -9,14 +9,14 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
9
9
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
10
10
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
11
|
};
|
|
12
|
-
var _AllureReport_instances, _AllureReport_reportName, _AllureReport_reportVariables, _AllureReport_ci, _AllureReport_store, _AllureReport_readers, _AllureReport_plugins, _AllureReport_reportFiles, _AllureReport_eventEmitter, _AllureReport_realtimeSubscriber, _AllureReport_realtimeDispatcher, _AllureReport_realTime, _AllureReport_hideLabels, _AllureReport_output, _AllureReport_history, _AllureReport_allureServiceClient, _AllureReport_qualityGate, _AllureReport_dump, _AllureReport_categories, _AllureReport_environments, _AllureReport_dumpTempDirs, _AllureReport_state, _AllureReport_executionStage, _AllureReport_publish_get, _AllureReport_update, _AllureReport_eachPlugin, _AllureReport_getPluginState;
|
|
12
|
+
var _AllureReport_instances, _AllureReport_reportName, _AllureReport_reportVariables, _AllureReport_ci, _AllureReport_store, _AllureReport_readers, _AllureReport_plugins, _AllureReport_reportFiles, _AllureReport_eventEmitter, _AllureReport_realtimeSubscriber, _AllureReport_realtimeDispatcher, _AllureReport_realTime, _AllureReport_hideLabels, _AllureReport_output, _AllureReport_history, _AllureReport_allureServiceClient, _AllureReport_qualityGate, _AllureReport_dump, _AllureReport_categories, _AllureReport_environments, _AllureReport_globalAttachments, _AllureReport_dumpTempDirs, _AllureReport_state, _AllureReport_executionStage, _AllureReport_publish_get, _AllureReport_update, _AllureReport_eachPlugin, _AllureReport_getPluginState;
|
|
13
13
|
import console from "node:console";
|
|
14
14
|
import { randomUUID } from "node:crypto";
|
|
15
15
|
import { EventEmitter } from "node:events";
|
|
16
16
|
import { createReadStream, createWriteStream, existsSync, readFileSync } from "node:fs";
|
|
17
17
|
import { lstat, mkdtemp, opendir, readdir, realpath, rename, rm, writeFile } from "node:fs/promises";
|
|
18
18
|
import { tmpdir } from "node:os";
|
|
19
|
-
import { basename, dirname, join, resolve } from "node:path";
|
|
19
|
+
import { basename, dirname, join, resolve, sep } from "node:path";
|
|
20
20
|
import { promisify } from "node:util";
|
|
21
21
|
import { detect } from "@allurereport/ci";
|
|
22
22
|
import { normalizeCategoriesConfig } from "@allurereport/core-api";
|
|
@@ -25,6 +25,7 @@ import { allure1, allure2, attachments, cucumberjson, junitXml, readXcResultBund
|
|
|
25
25
|
import { PathResultFile } from "@allurereport/reader-api";
|
|
26
26
|
import { AllureRemoteHistory, AllureServiceClient, KnownError, UnknownError } from "@allurereport/service";
|
|
27
27
|
import { generateSummary } from "@allurereport/summary";
|
|
28
|
+
import { glob } from "glob";
|
|
28
29
|
import ZipReadStream from "node-stream-zip";
|
|
29
30
|
import pLimit from "p-limit";
|
|
30
31
|
import ProgressBar from "progress";
|
|
@@ -60,6 +61,7 @@ export class AllureReport {
|
|
|
60
61
|
_AllureReport_dump.set(this, void 0);
|
|
61
62
|
_AllureReport_categories.set(this, void 0);
|
|
62
63
|
_AllureReport_environments.set(this, void 0);
|
|
64
|
+
_AllureReport_globalAttachments.set(this, void 0);
|
|
63
65
|
_AllureReport_dumpTempDirs.set(this, []);
|
|
64
66
|
_AllureReport_state.set(this, void 0);
|
|
65
67
|
_AllureReport_executionStage.set(this, "init");
|
|
@@ -128,6 +130,24 @@ export class AllureReport {
|
|
|
128
130
|
throw new Error("the report is already stopped, the restart isn't supported at the moment");
|
|
129
131
|
}
|
|
130
132
|
__classPrivateFieldSet(this, _AllureReport_executionStage, "running", "f");
|
|
133
|
+
const cwd = resolve(process.cwd());
|
|
134
|
+
const cwdWithSep = cwd.endsWith(sep) ? cwd : `${cwd}${sep}`;
|
|
135
|
+
if (__classPrivateFieldGet(this, _AllureReport_globalAttachments, "f")?.length) {
|
|
136
|
+
const matchedFiles = new Set();
|
|
137
|
+
for (const pattern of __classPrivateFieldGet(this, _AllureReport_globalAttachments, "f")) {
|
|
138
|
+
const files = await glob(pattern, { cwd, nodir: true, absolute: true });
|
|
139
|
+
files.forEach((filePath) => matchedFiles.add(filePath));
|
|
140
|
+
}
|
|
141
|
+
for (const filePath of matchedFiles) {
|
|
142
|
+
const absoluteFilePath = resolve(filePath);
|
|
143
|
+
const isInsideCwd = absoluteFilePath === cwd || absoluteFilePath.startsWith(cwdWithSep);
|
|
144
|
+
if (!isInsideCwd) {
|
|
145
|
+
continue;
|
|
146
|
+
}
|
|
147
|
+
const originalFileName = basename(absoluteFilePath);
|
|
148
|
+
__classPrivateFieldGet(this, _AllureReport_realtimeDispatcher, "f").sendGlobalAttachment(new PathResultFile(absoluteFilePath, originalFileName), originalFileName);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
131
151
|
if (__classPrivateFieldGet(this, _AllureReport_allureServiceClient, "f") && __classPrivateFieldGet(this, _AllureReport_instances, "a", _AllureReport_publish_get) && branch) {
|
|
132
152
|
const { url } = await __classPrivateFieldGet(this, _AllureReport_allureServiceClient, "f").createReport({
|
|
133
153
|
reportUuid: this.reportUuid,
|
|
@@ -532,7 +552,7 @@ export class AllureReport {
|
|
|
532
552
|
}
|
|
533
553
|
}
|
|
534
554
|
});
|
|
535
|
-
const { name, readers = [allure1, allure2, cucumberjson, junitXml, attachments], plugins = [], known, reportFiles, realTime, historyPath, historyLimit, defaultLabels = {}, variables = {}, environment, environments, output, hideLabels, qualityGate, dump, categories, allureService: allureServiceConfig, } = opts;
|
|
555
|
+
const { name, readers = [allure1, allure2, cucumberjson, junitXml, attachments], plugins = [], known, reportFiles, realTime, historyPath, historyLimit, defaultLabels = {}, variables = {}, environment, allowedEnvironments, environments, output, hideLabels, qualityGate, dump, categories, allureService: allureServiceConfig, globalAttachments, } = opts;
|
|
536
556
|
__classPrivateFieldSet(this, _AllureReport_allureServiceClient, allureServiceConfig?.accessToken
|
|
537
557
|
? new AllureServiceClient(allureServiceConfig)
|
|
538
558
|
: undefined, "f");
|
|
@@ -548,6 +568,7 @@ export class AllureReport {
|
|
|
548
568
|
__classPrivateFieldSet(this, _AllureReport_dump, dump, "f");
|
|
549
569
|
__classPrivateFieldSet(this, _AllureReport_hideLabels, hideLabels, "f");
|
|
550
570
|
__classPrivateFieldSet(this, _AllureReport_environments, environments ?? {}, "f");
|
|
571
|
+
__classPrivateFieldSet(this, _AllureReport_globalAttachments, globalAttachments, "f");
|
|
551
572
|
if (qualityGate) {
|
|
552
573
|
__classPrivateFieldSet(this, _AllureReport_qualityGate, new QualityGate(qualityGate), "f");
|
|
553
574
|
}
|
|
@@ -574,6 +595,7 @@ export class AllureReport {
|
|
|
574
595
|
known,
|
|
575
596
|
defaultLabels,
|
|
576
597
|
environment,
|
|
598
|
+
allowedEnvironments,
|
|
577
599
|
}), "f");
|
|
578
600
|
__classPrivateFieldSet(this, _AllureReport_readers, [...readers], "f");
|
|
579
601
|
__classPrivateFieldSet(this, _AllureReport_plugins, [...plugins], "f");
|
|
@@ -593,7 +615,7 @@ export class AllureReport {
|
|
|
593
615
|
return __classPrivateFieldGet(this, _AllureReport_realtimeDispatcher, "f");
|
|
594
616
|
}
|
|
595
617
|
}
|
|
596
|
-
_AllureReport_reportName = new WeakMap(), _AllureReport_reportVariables = new WeakMap(), _AllureReport_ci = new WeakMap(), _AllureReport_store = new WeakMap(), _AllureReport_readers = new WeakMap(), _AllureReport_plugins = new WeakMap(), _AllureReport_reportFiles = new WeakMap(), _AllureReport_eventEmitter = new WeakMap(), _AllureReport_realtimeSubscriber = new WeakMap(), _AllureReport_realtimeDispatcher = new WeakMap(), _AllureReport_realTime = new WeakMap(), _AllureReport_hideLabels = new WeakMap(), _AllureReport_output = new WeakMap(), _AllureReport_history = new WeakMap(), _AllureReport_allureServiceClient = new WeakMap(), _AllureReport_qualityGate = new WeakMap(), _AllureReport_dump = new WeakMap(), _AllureReport_categories = new WeakMap(), _AllureReport_environments = new WeakMap(), _AllureReport_dumpTempDirs = new WeakMap(), _AllureReport_state = new WeakMap(), _AllureReport_executionStage = new WeakMap(), _AllureReport_update = new WeakMap(), _AllureReport_eachPlugin = new WeakMap(), _AllureReport_instances = new WeakSet(), _AllureReport_publish_get = function _AllureReport_publish_get() {
|
|
618
|
+
_AllureReport_reportName = new WeakMap(), _AllureReport_reportVariables = new WeakMap(), _AllureReport_ci = new WeakMap(), _AllureReport_store = new WeakMap(), _AllureReport_readers = new WeakMap(), _AllureReport_plugins = new WeakMap(), _AllureReport_reportFiles = new WeakMap(), _AllureReport_eventEmitter = new WeakMap(), _AllureReport_realtimeSubscriber = new WeakMap(), _AllureReport_realtimeDispatcher = new WeakMap(), _AllureReport_realTime = new WeakMap(), _AllureReport_hideLabels = new WeakMap(), _AllureReport_output = new WeakMap(), _AllureReport_history = new WeakMap(), _AllureReport_allureServiceClient = new WeakMap(), _AllureReport_qualityGate = new WeakMap(), _AllureReport_dump = new WeakMap(), _AllureReport_categories = new WeakMap(), _AllureReport_environments = new WeakMap(), _AllureReport_globalAttachments = new WeakMap(), _AllureReport_dumpTempDirs = new WeakMap(), _AllureReport_state = new WeakMap(), _AllureReport_executionStage = new WeakMap(), _AllureReport_update = new WeakMap(), _AllureReport_eachPlugin = new WeakMap(), _AllureReport_instances = new WeakSet(), _AllureReport_publish_get = function _AllureReport_publish_get() {
|
|
597
619
|
return __classPrivateFieldGet(this, _AllureReport_plugins, "f").some(({ enabled, options }) => enabled && options.publish);
|
|
598
620
|
}, _AllureReport_getPluginState = function _AllureReport_getPluginState(init, id) {
|
|
599
621
|
return init ? new DefaultPluginState({}) : __classPrivateFieldGet(this, _AllureReport_state, "f")?.[id];
|
package/dist/store/store.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type AllureHistory, type AttachmentLink, type
|
|
2
|
-
import { type AllureStore, type AllureStoreDump, type ExitCode, type QualityGateValidationResult, type RealtimeEventsDispatcher, type RealtimeSubscriber, type ResultFile, type TestResultFilter } from "@allurereport/plugin-api";
|
|
1
|
+
import { type AllureHistory, type AttachmentLink, type DefaultLabelsConfig, type EnvironmentIdentity, type EnvironmentsConfig, type HistoryDataPoint, type HistoryTestResult, type KnownTestFailure, type ReportVariables, type Statistic, type TestCase, type TestEnvGroup, type TestError, type TestFixtureResult, type TestResult } from "@allurereport/core-api";
|
|
2
|
+
import { type AllureStore, type AllureStoreDump, type ExitCode, type PluginGlobalAttachment, type PluginGlobalError, type QualityGateValidationResult, type RealtimeEventsDispatcher, type RealtimeSubscriber, type ResultFile, type TestResultFilter } from "@allurereport/plugin-api";
|
|
3
3
|
import type { RawFixtureResult, RawGlobals, RawMetadata, RawTestResult, ReaderContext, ResultsVisitor } from "@allurereport/reader-api";
|
|
4
4
|
export declare const mapToObject: <K extends string | number | symbol, T = any>(map: Map<K, T>) => Record<K, T>;
|
|
5
5
|
export declare const updateMapWithRecord: <K extends string | number | symbol, T = any>(map: Map<K, T>, record: Record<K, T>) => Map<K, T>;
|
|
@@ -20,6 +20,7 @@ export declare class DefaultAllureStore implements AllureStore, ResultsVisitor {
|
|
|
20
20
|
realtimeSubscriber?: RealtimeSubscriber;
|
|
21
21
|
defaultLabels?: DefaultLabelsConfig;
|
|
22
22
|
environment?: string;
|
|
23
|
+
allowedEnvironments?: string[];
|
|
23
24
|
environmentsConfig?: EnvironmentsConfig;
|
|
24
25
|
reportVariables?: ReportVariables;
|
|
25
26
|
});
|
|
@@ -30,7 +31,9 @@ export declare class DefaultAllureStore implements AllureStore, ResultsVisitor {
|
|
|
30
31
|
qualityGateResultsByEnvironmentId(): Promise<Record<string, QualityGateValidationResult[]>>;
|
|
31
32
|
globalExitCode(): Promise<ExitCode | undefined>;
|
|
32
33
|
allGlobalErrors(): Promise<TestError[]>;
|
|
33
|
-
|
|
34
|
+
allGlobalErrorsByEnv(): Promise<Record<string, PluginGlobalError[]>>;
|
|
35
|
+
allGlobalAttachments(): Promise<AttachmentLink[]>;
|
|
36
|
+
allGlobalAttachmentsByEnv(): Promise<Record<string, PluginGlobalAttachment[]>>;
|
|
34
37
|
visitTestResult(raw: RawTestResult, context: ReaderContext): Promise<void>;
|
|
35
38
|
visitTestFixtureResult(result: RawFixtureResult, context: ReaderContext): Promise<void>;
|
|
36
39
|
visitAttachmentFile(resultFile: ResultFile): Promise<void>;
|
package/dist/store/store.js
CHANGED
|
@@ -9,11 +9,11 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
9
9
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
10
10
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
11
|
};
|
|
12
|
-
var _DefaultAllureStore_instances, _DefaultAllureStore_testResults, _DefaultAllureStore_environmentDisplayNames, _DefaultAllureStore_environmentNameToId, _DefaultAllureStore_attachments, _DefaultAllureStore_attachmentContents, _DefaultAllureStore_testCases, _DefaultAllureStore_metadata, _DefaultAllureStore_history, _DefaultAllureStore_known, _DefaultAllureStore_fixtures, _DefaultAllureStore_defaultLabels, _DefaultAllureStore_environment, _DefaultAllureStore_environmentsConfig, _DefaultAllureStore_reportVariables, _DefaultAllureStore_realtimeDispatcher, _DefaultAllureStore_realtimeSubscriber, _DefaultAllureStore_globalAttachmentIds, _DefaultAllureStore_globalErrors, _DefaultAllureStore_globalExitCode, _DefaultAllureStore_qualityGateResults, _DefaultAllureStore_historyPoints, _DefaultAllureStore_environments, _DefaultAllureStore_mergeEnvironmentIdentity, _DefaultAllureStore_environmentIdForLookup, _DefaultAllureStore_addEnvironments, _DefaultAllureStore_environmentIdByName, _DefaultAllureStore_setTestResultEnvironmentId, _DefaultAllureStore_environmentIdByTestResult;
|
|
12
|
+
var _DefaultAllureStore_instances, _DefaultAllureStore_testResults, _DefaultAllureStore_environmentDisplayNames, _DefaultAllureStore_environmentNameToId, _DefaultAllureStore_attachments, _DefaultAllureStore_attachmentContents, _DefaultAllureStore_testCases, _DefaultAllureStore_metadata, _DefaultAllureStore_history, _DefaultAllureStore_known, _DefaultAllureStore_fixtures, _DefaultAllureStore_defaultLabels, _DefaultAllureStore_environment, _DefaultAllureStore_environmentsConfig, _DefaultAllureStore_reportVariables, _DefaultAllureStore_realtimeDispatcher, _DefaultAllureStore_realtimeSubscriber, _DefaultAllureStore_allowedEnvironmentIds, _DefaultAllureStore_globalAttachmentIds, _DefaultAllureStore_globalAttachmentIdsByEnv, _DefaultAllureStore_globalErrors, _DefaultAllureStore_globalErrorsByEnv, _DefaultAllureStore_globalExitCode, _DefaultAllureStore_qualityGateResults, _DefaultAllureStore_historyPoints, _DefaultAllureStore_environments, _DefaultAllureStore_mergeEnvironmentIdentity, _DefaultAllureStore_environmentIdForLookup, _DefaultAllureStore_addEnvironments, _DefaultAllureStore_environmentIdByName, _DefaultAllureStore_setTestResultEnvironmentId, _DefaultAllureStore_assertAllowedEnvironmentId, _DefaultAllureStore_assertAllowedStoredEnvironment, _DefaultAllureStore_environmentIdByTestResult, _DefaultAllureStore_resolveGlobalEnvironmentIdentity, _DefaultAllureStore_globalAttachmentId, _DefaultAllureStore_indexGlobalError, _DefaultAllureStore_addGlobalError, _DefaultAllureStore_indexGlobalAttachment, _DefaultAllureStore_addGlobalAttachment;
|
|
13
13
|
import { extname } from "node:path";
|
|
14
14
|
import { DEFAULT_ENVIRONMENT, DEFAULT_ENVIRONMENT_IDENTITY, compareBy, createDictionary, getHistoryIdCandidates, getWorstStatus, nullsLast, ordinal, reverse, selectHistoryTestResults, validateEnvironmentId, validateEnvironmentName, } from "@allurereport/core-api";
|
|
15
15
|
import { md5, } from "@allurereport/plugin-api";
|
|
16
|
-
import { environmentIdentityById, normalizeEnvironmentDescriptorMap, resolveEnvironmentIdentity, resolveStoredEnvironmentIdentity, } from "../utils/environment.js";
|
|
16
|
+
import { environmentIdentityById, normalizeEnvironmentDescriptorMap, resolveEnvironmentIdentity, resolveStoredEnvironmentIdentity, validateAllowedEnvironmentId, } from "../utils/environment.js";
|
|
17
17
|
import { isFlaky } from "../utils/flaky.js";
|
|
18
18
|
import { getStatusTransition } from "../utils/new.js";
|
|
19
19
|
import { testFixtureResultRawToState, testResultRawToState } from "./convert.js";
|
|
@@ -83,6 +83,7 @@ export class DefaultAllureStore {
|
|
|
83
83
|
_DefaultAllureStore_reportVariables.set(this, {});
|
|
84
84
|
_DefaultAllureStore_realtimeDispatcher.set(this, void 0);
|
|
85
85
|
_DefaultAllureStore_realtimeSubscriber.set(this, void 0);
|
|
86
|
+
_DefaultAllureStore_allowedEnvironmentIds.set(this, void 0);
|
|
86
87
|
this.indexTestResultByTestCase = new Map();
|
|
87
88
|
this.indexTestResultByEnvironmentId = new Map();
|
|
88
89
|
this.indexLatestEnvTestResultByHistoryId = new Map();
|
|
@@ -92,12 +93,14 @@ export class DefaultAllureStore {
|
|
|
92
93
|
this.indexFixturesByTestResult = new Map();
|
|
93
94
|
this.indexKnownByHistoryId = new Map();
|
|
94
95
|
_DefaultAllureStore_globalAttachmentIds.set(this, []);
|
|
96
|
+
_DefaultAllureStore_globalAttachmentIdsByEnv.set(this, new Map());
|
|
95
97
|
_DefaultAllureStore_globalErrors.set(this, []);
|
|
98
|
+
_DefaultAllureStore_globalErrorsByEnv.set(this, new Map());
|
|
96
99
|
_DefaultAllureStore_globalExitCode.set(this, void 0);
|
|
97
100
|
_DefaultAllureStore_qualityGateResults.set(this, []);
|
|
98
101
|
_DefaultAllureStore_historyPoints.set(this, []);
|
|
99
102
|
_DefaultAllureStore_environments.set(this, []);
|
|
100
|
-
const { history, known = [], realtimeDispatcher, realtimeSubscriber, defaultLabels = {}, environment, environmentsConfig = {}, reportVariables = {}, } = params ?? {};
|
|
103
|
+
const { history, known = [], realtimeDispatcher, realtimeSubscriber, defaultLabels = {}, environment, allowedEnvironments, environmentsConfig = {}, reportVariables = {}, } = params ?? {};
|
|
101
104
|
const errors = [];
|
|
102
105
|
const { normalized: normalizedEnvironmentsConfig, identities, errors: configErrors, } = normalizeEnvironmentDescriptorMap(environmentsConfig, "environmentsConfig");
|
|
103
106
|
errors.push(...configErrors);
|
|
@@ -130,6 +133,7 @@ export class DefaultAllureStore {
|
|
|
130
133
|
__classPrivateFieldSet(this, _DefaultAllureStore_environmentsConfig, normalizedEnvironmentsConfig, "f");
|
|
131
134
|
__classPrivateFieldSet(this, _DefaultAllureStore_environment, resolvedEnvironment, "f");
|
|
132
135
|
__classPrivateFieldSet(this, _DefaultAllureStore_reportVariables, reportVariables, "f");
|
|
136
|
+
__classPrivateFieldSet(this, _DefaultAllureStore_allowedEnvironmentIds, new Set(allowedEnvironments ?? []), "f");
|
|
133
137
|
__classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_addEnvironments).call(this, environments);
|
|
134
138
|
__classPrivateFieldGet(this, _DefaultAllureStore_realtimeSubscriber, "f")?.onQualityGateResults(async (results) => {
|
|
135
139
|
__classPrivateFieldGet(this, _DefaultAllureStore_qualityGateResults, "f").push(...results);
|
|
@@ -156,12 +160,13 @@ export class DefaultAllureStore {
|
|
|
156
160
|
__classPrivateFieldSet(this, _DefaultAllureStore_globalExitCode, exitCode, "f");
|
|
157
161
|
});
|
|
158
162
|
__classPrivateFieldGet(this, _DefaultAllureStore_realtimeSubscriber, "f")?.onGlobalError(async (error) => {
|
|
159
|
-
__classPrivateFieldGet(this,
|
|
163
|
+
__classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_addGlobalError).call(this, error);
|
|
160
164
|
});
|
|
161
|
-
__classPrivateFieldGet(this, _DefaultAllureStore_realtimeSubscriber, "f")?.onGlobalAttachment(async ({ attachment, fileName }) => {
|
|
165
|
+
__classPrivateFieldGet(this, _DefaultAllureStore_realtimeSubscriber, "f")?.onGlobalAttachment(async ({ attachment, fileName, environment }) => {
|
|
162
166
|
const originalFileName = attachment.getOriginalFileName();
|
|
167
|
+
const resolvedEnvironment = __classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_resolveGlobalEnvironmentIdentity).call(this, environment);
|
|
163
168
|
const attachmentLink = {
|
|
164
|
-
id:
|
|
169
|
+
id: __classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_globalAttachmentId).call(this, originalFileName, resolvedEnvironment?.id),
|
|
165
170
|
name: fileName || originalFileName,
|
|
166
171
|
missed: false,
|
|
167
172
|
used: true,
|
|
@@ -169,10 +174,9 @@ export class DefaultAllureStore {
|
|
|
169
174
|
contentType: attachment.getContentType(),
|
|
170
175
|
contentLength: attachment.getContentLength(),
|
|
171
176
|
originalFileName,
|
|
177
|
+
environment: resolvedEnvironment?.name ?? environment,
|
|
172
178
|
};
|
|
173
|
-
__classPrivateFieldGet(this,
|
|
174
|
-
__classPrivateFieldGet(this, _DefaultAllureStore_attachmentContents, "f").set(attachmentLink.id, attachment);
|
|
175
|
-
__classPrivateFieldGet(this, _DefaultAllureStore_globalAttachmentIds, "f").push(attachmentLink.id);
|
|
179
|
+
__classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_addGlobalAttachment).call(this, attachmentLink, attachment);
|
|
176
180
|
});
|
|
177
181
|
}
|
|
178
182
|
async readHistory() {
|
|
@@ -233,6 +237,9 @@ export class DefaultAllureStore {
|
|
|
233
237
|
async allGlobalErrors() {
|
|
234
238
|
return __classPrivateFieldGet(this, _DefaultAllureStore_globalErrors, "f");
|
|
235
239
|
}
|
|
240
|
+
async allGlobalErrorsByEnv() {
|
|
241
|
+
return mapToObject(__classPrivateFieldGet(this, _DefaultAllureStore_globalErrorsByEnv, "f"));
|
|
242
|
+
}
|
|
236
243
|
async allGlobalAttachments() {
|
|
237
244
|
return __classPrivateFieldGet(this, _DefaultAllureStore_globalAttachmentIds, "f").reduce((acc, id) => {
|
|
238
245
|
const attachment = __classPrivateFieldGet(this, _DefaultAllureStore_attachments, "f").get(id);
|
|
@@ -243,6 +250,20 @@ export class DefaultAllureStore {
|
|
|
243
250
|
return acc;
|
|
244
251
|
}, []);
|
|
245
252
|
}
|
|
253
|
+
async allGlobalAttachmentsByEnv() {
|
|
254
|
+
const result = {};
|
|
255
|
+
__classPrivateFieldGet(this, _DefaultAllureStore_globalAttachmentIdsByEnv, "f").forEach((attachmentIds, environmentId) => {
|
|
256
|
+
result[environmentId] = attachmentIds.reduce((acc, id) => {
|
|
257
|
+
const attachment = __classPrivateFieldGet(this, _DefaultAllureStore_attachments, "f").get(id);
|
|
258
|
+
if (!attachment) {
|
|
259
|
+
return acc;
|
|
260
|
+
}
|
|
261
|
+
acc.push(attachment);
|
|
262
|
+
return acc;
|
|
263
|
+
}, []);
|
|
264
|
+
});
|
|
265
|
+
return result;
|
|
266
|
+
}
|
|
246
267
|
async visitTestResult(raw, context) {
|
|
247
268
|
const attachmentLinks = [];
|
|
248
269
|
const testResult = testResultRawToState({
|
|
@@ -324,6 +345,22 @@ export class DefaultAllureStore {
|
|
|
324
345
|
contentLength: resultFile.getContentLength(),
|
|
325
346
|
});
|
|
326
347
|
}
|
|
348
|
+
for (const globalAttachmentId of __classPrivateFieldGet(this, _DefaultAllureStore_globalAttachmentIds, "f")) {
|
|
349
|
+
const globalAttachment = __classPrivateFieldGet(this, _DefaultAllureStore_attachments, "f").get(globalAttachmentId);
|
|
350
|
+
if (!globalAttachment || globalAttachment.originalFileName !== originalFileName) {
|
|
351
|
+
continue;
|
|
352
|
+
}
|
|
353
|
+
const linkedGlobalAttachment = globalAttachment;
|
|
354
|
+
linkedGlobalAttachment.missed = false;
|
|
355
|
+
linkedGlobalAttachment.ext =
|
|
356
|
+
linkedGlobalAttachment.ext === undefined || linkedGlobalAttachment.ext === ""
|
|
357
|
+
? resultFile.getExtension()
|
|
358
|
+
: linkedGlobalAttachment.ext;
|
|
359
|
+
linkedGlobalAttachment.contentType = linkedGlobalAttachment.contentType ?? resultFile.getContentType();
|
|
360
|
+
linkedGlobalAttachment.contentLength = resultFile.getContentLength();
|
|
361
|
+
__classPrivateFieldGet(this, _DefaultAllureStore_attachmentContents, "f").set(globalAttachmentId, resultFile);
|
|
362
|
+
__classPrivateFieldGet(this, _DefaultAllureStore_realtimeDispatcher, "f")?.sendAttachmentFile(globalAttachmentId);
|
|
363
|
+
}
|
|
327
364
|
__classPrivateFieldGet(this, _DefaultAllureStore_realtimeDispatcher, "f")?.sendAttachmentFile(id);
|
|
328
365
|
}
|
|
329
366
|
async visitMetadata(metadata) {
|
|
@@ -333,21 +370,26 @@ export class DefaultAllureStore {
|
|
|
333
370
|
}
|
|
334
371
|
async visitGlobals(globals) {
|
|
335
372
|
const { errors, attachments } = globals;
|
|
336
|
-
|
|
373
|
+
errors.forEach((error) => {
|
|
374
|
+
__classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_addGlobalError).call(this, error);
|
|
375
|
+
});
|
|
337
376
|
attachments.forEach((attachment) => {
|
|
338
377
|
const originalFileName = attachment.originalFileName;
|
|
339
|
-
const
|
|
378
|
+
const resolvedEnvironment = __classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_resolveGlobalEnvironmentIdentity).call(this, attachment.environment);
|
|
379
|
+
const linkedAttachment = __classPrivateFieldGet(this, _DefaultAllureStore_attachments, "f").get(md5(originalFileName));
|
|
380
|
+
const attachmentContent = __classPrivateFieldGet(this, _DefaultAllureStore_attachmentContents, "f").get(md5(originalFileName));
|
|
340
381
|
const attachmentLink = {
|
|
341
|
-
id,
|
|
382
|
+
id: __classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_globalAttachmentId).call(this, originalFileName, resolvedEnvironment?.id),
|
|
342
383
|
name: attachment?.name || originalFileName,
|
|
343
384
|
originalFileName,
|
|
344
385
|
ext: extname(originalFileName),
|
|
345
386
|
used: true,
|
|
346
|
-
missed:
|
|
347
|
-
contentType: attachment?.contentType,
|
|
387
|
+
missed: !attachmentContent,
|
|
388
|
+
contentType: attachment?.contentType ?? linkedAttachment?.contentType,
|
|
389
|
+
contentLength: linkedAttachment?.contentLength,
|
|
390
|
+
environment: resolvedEnvironment?.name ?? attachment.environment,
|
|
348
391
|
};
|
|
349
|
-
__classPrivateFieldGet(this,
|
|
350
|
-
__classPrivateFieldGet(this, _DefaultAllureStore_globalAttachmentIds, "f").push(id);
|
|
392
|
+
__classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_addGlobalAttachment).call(this, attachmentLink, attachmentContent);
|
|
351
393
|
});
|
|
352
394
|
}
|
|
353
395
|
async allTestCases() {
|
|
@@ -780,6 +822,14 @@ export class DefaultAllureStore {
|
|
|
780
822
|
});
|
|
781
823
|
})
|
|
782
824
|
.filter(Boolean);
|
|
825
|
+
environments.forEach((environmentValue, index) => {
|
|
826
|
+
const environmentParams = typeof environmentValue === "string"
|
|
827
|
+
? { environmentName: environmentValue }
|
|
828
|
+
: { environment: environmentValue.id, environmentName: environmentValue.name };
|
|
829
|
+
__classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_assertAllowedStoredEnvironment).call(this, environmentParams, `restored environments[${index}]`, {
|
|
830
|
+
fallbackToMatch: false,
|
|
831
|
+
});
|
|
832
|
+
});
|
|
783
833
|
__classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_addEnvironments).call(this, [...storedEnvironmentAliases, ...normalizedEnvironments]);
|
|
784
834
|
const envNameToId = new Map();
|
|
785
835
|
for (const { id, name } of __classPrivateFieldGet(this, _DefaultAllureStore_environments, "f")) {
|
|
@@ -790,14 +840,36 @@ export class DefaultAllureStore {
|
|
|
790
840
|
__classPrivateFieldGet(this, _DefaultAllureStore_testResults, "f").set(testResult.id, testResult);
|
|
791
841
|
const storedEnvKey = typeof testResult.environment === "string" ? testResult.environment : undefined;
|
|
792
842
|
const envId = (storedEnvKey ? envNameToId.get(storedEnvKey) : undefined) ?? __classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_environmentIdByTestResult).call(this, testResult);
|
|
843
|
+
__classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_assertAllowedEnvironmentId).call(this, envId, `restored testResults[${JSON.stringify(testResult.id)}]`);
|
|
793
844
|
__classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_setTestResultEnvironmentId).call(this, testResult, envId);
|
|
794
845
|
});
|
|
795
846
|
updateMapWithRecord(__classPrivateFieldGet(this, _DefaultAllureStore_attachments, "f"), attachments);
|
|
796
847
|
updateMapWithRecord(__classPrivateFieldGet(this, _DefaultAllureStore_testCases, "f"), testCases);
|
|
797
848
|
updateMapWithRecord(__classPrivateFieldGet(this, _DefaultAllureStore_fixtures, "f"), fixtures);
|
|
798
849
|
updateMapWithRecord(__classPrivateFieldGet(this, _DefaultAllureStore_attachmentContents, "f"), attachmentsContents);
|
|
799
|
-
|
|
800
|
-
|
|
850
|
+
globalAttachmentIds.forEach((id) => {
|
|
851
|
+
const attachment = __classPrivateFieldGet(this, _DefaultAllureStore_attachments, "f").get(id);
|
|
852
|
+
if (!attachment) {
|
|
853
|
+
return;
|
|
854
|
+
}
|
|
855
|
+
__classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_assertAllowedStoredEnvironment).call(this, {
|
|
856
|
+
environment: attachment.environment,
|
|
857
|
+
environmentName: attachment.environment,
|
|
858
|
+
}, `restored globalAttachments[${JSON.stringify(id)}]`, {
|
|
859
|
+
fallbackToMatch: false,
|
|
860
|
+
});
|
|
861
|
+
__classPrivateFieldGet(this, _DefaultAllureStore_globalAttachmentIds, "f").push(id);
|
|
862
|
+
__classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_indexGlobalAttachment).call(this, attachment);
|
|
863
|
+
});
|
|
864
|
+
globalErrors.forEach((error, index) => {
|
|
865
|
+
__classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_assertAllowedStoredEnvironment).call(this, {
|
|
866
|
+
environment: error.environment,
|
|
867
|
+
environmentName: error.environment,
|
|
868
|
+
}, `restored globalErrors[${index}]`, {
|
|
869
|
+
fallbackToMatch: false,
|
|
870
|
+
});
|
|
871
|
+
__classPrivateFieldGet(this, _DefaultAllureStore_globalErrors, "f").push(__classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_indexGlobalError).call(this, error));
|
|
872
|
+
});
|
|
801
873
|
Object.assign(__classPrivateFieldGet(this, _DefaultAllureStore_reportVariables, "f"), reportVariables);
|
|
802
874
|
Object.entries(indexAttachmentByTestResult).forEach(([trId, links]) => {
|
|
803
875
|
const attachmentsLinks = links.map((id) => __classPrivateFieldGet(this, _DefaultAllureStore_attachments, "f").get(id)).filter(Boolean);
|
|
@@ -881,6 +953,7 @@ export class DefaultAllureStore {
|
|
|
881
953
|
return;
|
|
882
954
|
}
|
|
883
955
|
const normalizedEnvironmentId = environmentIdValidation.normalized;
|
|
956
|
+
__classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_assertAllowedEnvironmentId).call(this, normalizedEnvironmentId, `restored indexLatestEnvTestResultByHistoryId[${JSON.stringify(environmentId)}]`);
|
|
884
957
|
Object.values(historyIds).forEach((trId) => {
|
|
885
958
|
const tr = __classPrivateFieldGet(this, _DefaultAllureStore_testResults, "f").get(trId);
|
|
886
959
|
if (!tr) {
|
|
@@ -916,10 +989,18 @@ export class DefaultAllureStore {
|
|
|
916
989
|
}
|
|
917
990
|
});
|
|
918
991
|
}
|
|
919
|
-
|
|
992
|
+
qualityGateResults.forEach((result, index) => {
|
|
993
|
+
__classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_assertAllowedStoredEnvironment).call(this, {
|
|
994
|
+
environment: result.environment,
|
|
995
|
+
environmentName: result.environment,
|
|
996
|
+
}, `restored qualityGateResults[${index}]`, {
|
|
997
|
+
fallbackToMatch: false,
|
|
998
|
+
});
|
|
999
|
+
__classPrivateFieldGet(this, _DefaultAllureStore_qualityGateResults, "f").push(result);
|
|
1000
|
+
});
|
|
920
1001
|
}
|
|
921
1002
|
}
|
|
922
|
-
_DefaultAllureStore_testResults = new WeakMap(), _DefaultAllureStore_environmentDisplayNames = new WeakMap(), _DefaultAllureStore_environmentNameToId = new WeakMap(), _DefaultAllureStore_attachments = new WeakMap(), _DefaultAllureStore_attachmentContents = new WeakMap(), _DefaultAllureStore_testCases = new WeakMap(), _DefaultAllureStore_metadata = new WeakMap(), _DefaultAllureStore_history = new WeakMap(), _DefaultAllureStore_known = new WeakMap(), _DefaultAllureStore_fixtures = new WeakMap(), _DefaultAllureStore_defaultLabels = new WeakMap(), _DefaultAllureStore_environment = new WeakMap(), _DefaultAllureStore_environmentsConfig = new WeakMap(), _DefaultAllureStore_reportVariables = new WeakMap(), _DefaultAllureStore_realtimeDispatcher = new WeakMap(), _DefaultAllureStore_realtimeSubscriber = new WeakMap(), _DefaultAllureStore_globalAttachmentIds = new WeakMap(), _DefaultAllureStore_globalErrors = new WeakMap(), _DefaultAllureStore_globalExitCode = new WeakMap(), _DefaultAllureStore_qualityGateResults = new WeakMap(), _DefaultAllureStore_historyPoints = new WeakMap(), _DefaultAllureStore_environments = new WeakMap(), _DefaultAllureStore_instances = new WeakSet(), _DefaultAllureStore_mergeEnvironmentIdentity = function _DefaultAllureStore_mergeEnvironmentIdentity(existingEnvironment, incomingEnvironment) {
|
|
1003
|
+
_DefaultAllureStore_testResults = new WeakMap(), _DefaultAllureStore_environmentDisplayNames = new WeakMap(), _DefaultAllureStore_environmentNameToId = new WeakMap(), _DefaultAllureStore_attachments = new WeakMap(), _DefaultAllureStore_attachmentContents = new WeakMap(), _DefaultAllureStore_testCases = new WeakMap(), _DefaultAllureStore_metadata = new WeakMap(), _DefaultAllureStore_history = new WeakMap(), _DefaultAllureStore_known = new WeakMap(), _DefaultAllureStore_fixtures = new WeakMap(), _DefaultAllureStore_defaultLabels = new WeakMap(), _DefaultAllureStore_environment = new WeakMap(), _DefaultAllureStore_environmentsConfig = new WeakMap(), _DefaultAllureStore_reportVariables = new WeakMap(), _DefaultAllureStore_realtimeDispatcher = new WeakMap(), _DefaultAllureStore_realtimeSubscriber = new WeakMap(), _DefaultAllureStore_allowedEnvironmentIds = new WeakMap(), _DefaultAllureStore_globalAttachmentIds = new WeakMap(), _DefaultAllureStore_globalAttachmentIdsByEnv = new WeakMap(), _DefaultAllureStore_globalErrors = new WeakMap(), _DefaultAllureStore_globalErrorsByEnv = new WeakMap(), _DefaultAllureStore_globalExitCode = new WeakMap(), _DefaultAllureStore_qualityGateResults = new WeakMap(), _DefaultAllureStore_historyPoints = new WeakMap(), _DefaultAllureStore_environments = new WeakMap(), _DefaultAllureStore_instances = new WeakSet(), _DefaultAllureStore_mergeEnvironmentIdentity = function _DefaultAllureStore_mergeEnvironmentIdentity(existingEnvironment, incomingEnvironment) {
|
|
923
1004
|
const configuredEnvironment = environmentIdentityById(__classPrivateFieldGet(this, _DefaultAllureStore_environmentsConfig, "f"), incomingEnvironment.id);
|
|
924
1005
|
if (configuredEnvironment) {
|
|
925
1006
|
return configuredEnvironment;
|
|
@@ -987,6 +1068,26 @@ _DefaultAllureStore_testResults = new WeakMap(), _DefaultAllureStore_environment
|
|
|
987
1068
|
return;
|
|
988
1069
|
}
|
|
989
1070
|
index(this.indexTestResultByEnvironmentId, environmentId, testResult);
|
|
1071
|
+
}, _DefaultAllureStore_assertAllowedEnvironmentId = function _DefaultAllureStore_assertAllowedEnvironmentId(environmentId, sourcePath) {
|
|
1072
|
+
if (!environmentId) {
|
|
1073
|
+
return;
|
|
1074
|
+
}
|
|
1075
|
+
const error = validateAllowedEnvironmentId(environmentId, __classPrivateFieldGet(this, _DefaultAllureStore_allowedEnvironmentIds, "f"), sourcePath);
|
|
1076
|
+
if (error) {
|
|
1077
|
+
throw new Error(error);
|
|
1078
|
+
}
|
|
1079
|
+
}, _DefaultAllureStore_assertAllowedStoredEnvironment = function _DefaultAllureStore_assertAllowedStoredEnvironment(params, sourcePath, options) {
|
|
1080
|
+
const identity = resolveStoredEnvironmentIdentity(params, __classPrivateFieldGet(this, _DefaultAllureStore_environmentsConfig, "f"), {
|
|
1081
|
+
forcedEnvironment: __classPrivateFieldGet(this, _DefaultAllureStore_environment, "f"),
|
|
1082
|
+
fallbackToMatch: options?.fallbackToMatch,
|
|
1083
|
+
});
|
|
1084
|
+
const environmentKey = identity?.id ??
|
|
1085
|
+
(typeof params.environment === "string" ? params.environment : undefined) ??
|
|
1086
|
+
(typeof params.environmentName === "string" ? params.environmentName : undefined);
|
|
1087
|
+
if (environmentKey === undefined) {
|
|
1088
|
+
return;
|
|
1089
|
+
}
|
|
1090
|
+
__classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_assertAllowedEnvironmentId).call(this, environmentKey, sourcePath);
|
|
990
1091
|
}, _DefaultAllureStore_environmentIdByTestResult = function _DefaultAllureStore_environmentIdByTestResult(testResult) {
|
|
991
1092
|
const storedEnvironmentKey = typeof testResult.environment === "string" ? testResult.environment : undefined;
|
|
992
1093
|
return ((storedEnvironmentKey ? __classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_environmentIdByName).call(this, storedEnvironmentKey) : undefined) ??
|
|
@@ -996,4 +1097,49 @@ _DefaultAllureStore_testResults = new WeakMap(), _DefaultAllureStore_environment
|
|
|
996
1097
|
}, __classPrivateFieldGet(this, _DefaultAllureStore_environmentsConfig, "f"), {
|
|
997
1098
|
forcedEnvironment: __classPrivateFieldGet(this, _DefaultAllureStore_environment, "f"),
|
|
998
1099
|
})?.id);
|
|
1100
|
+
}, _DefaultAllureStore_resolveGlobalEnvironmentIdentity = function _DefaultAllureStore_resolveGlobalEnvironmentIdentity(environment) {
|
|
1101
|
+
if (environment !== undefined) {
|
|
1102
|
+
const resolvedEnvironment = resolveStoredEnvironmentIdentity({
|
|
1103
|
+
environment,
|
|
1104
|
+
environmentName: environment,
|
|
1105
|
+
}, __classPrivateFieldGet(this, _DefaultAllureStore_environmentsConfig, "f"), {
|
|
1106
|
+
fallbackToMatch: false,
|
|
1107
|
+
});
|
|
1108
|
+
if (resolvedEnvironment) {
|
|
1109
|
+
return resolvedEnvironment;
|
|
1110
|
+
}
|
|
1111
|
+
}
|
|
1112
|
+
if (__classPrivateFieldGet(this, _DefaultAllureStore_environment, "f")) {
|
|
1113
|
+
return __classPrivateFieldGet(this, _DefaultAllureStore_environment, "f");
|
|
1114
|
+
}
|
|
1115
|
+
return DEFAULT_ENVIRONMENT_IDENTITY;
|
|
1116
|
+
}, _DefaultAllureStore_globalAttachmentId = function _DefaultAllureStore_globalAttachmentId(originalFileName, environmentId) {
|
|
1117
|
+
return md5(environmentId ? `${environmentId}:${originalFileName}` : originalFileName);
|
|
1118
|
+
}, _DefaultAllureStore_indexGlobalError = function _DefaultAllureStore_indexGlobalError(error) {
|
|
1119
|
+
const resolvedEnvironment = __classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_resolveGlobalEnvironmentIdentity).call(this, error.environment);
|
|
1120
|
+
if (!resolvedEnvironment) {
|
|
1121
|
+
return error;
|
|
1122
|
+
}
|
|
1123
|
+
error.environment = resolvedEnvironment.name;
|
|
1124
|
+
__classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_addEnvironments).call(this, [resolvedEnvironment]);
|
|
1125
|
+
index(__classPrivateFieldGet(this, _DefaultAllureStore_globalErrorsByEnv, "f"), resolvedEnvironment.id, error);
|
|
1126
|
+
return error;
|
|
1127
|
+
}, _DefaultAllureStore_addGlobalError = function _DefaultAllureStore_addGlobalError(error) {
|
|
1128
|
+
__classPrivateFieldGet(this, _DefaultAllureStore_globalErrors, "f").push(__classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_indexGlobalError).call(this, error));
|
|
1129
|
+
}, _DefaultAllureStore_indexGlobalAttachment = function _DefaultAllureStore_indexGlobalAttachment(attachmentLink) {
|
|
1130
|
+
const resolvedEnvironment = __classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_resolveGlobalEnvironmentIdentity).call(this, attachmentLink.environment);
|
|
1131
|
+
if (!resolvedEnvironment) {
|
|
1132
|
+
return attachmentLink;
|
|
1133
|
+
}
|
|
1134
|
+
attachmentLink.environment = resolvedEnvironment.name;
|
|
1135
|
+
__classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_addEnvironments).call(this, [resolvedEnvironment]);
|
|
1136
|
+
index(__classPrivateFieldGet(this, _DefaultAllureStore_globalAttachmentIdsByEnv, "f"), resolvedEnvironment.id, attachmentLink.id);
|
|
1137
|
+
return attachmentLink;
|
|
1138
|
+
}, _DefaultAllureStore_addGlobalAttachment = function _DefaultAllureStore_addGlobalAttachment(attachmentLink, attachment) {
|
|
1139
|
+
const indexedAttachment = __classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_indexGlobalAttachment).call(this, { ...attachmentLink });
|
|
1140
|
+
__classPrivateFieldGet(this, _DefaultAllureStore_attachments, "f").set(indexedAttachment.id, indexedAttachment);
|
|
1141
|
+
if (attachment) {
|
|
1142
|
+
__classPrivateFieldGet(this, _DefaultAllureStore_attachmentContents, "f").set(indexedAttachment.id, attachment);
|
|
1143
|
+
}
|
|
1144
|
+
__classPrivateFieldGet(this, _DefaultAllureStore_globalAttachmentIds, "f").push(indexedAttachment.id);
|
|
999
1145
|
};
|
|
@@ -4,6 +4,12 @@ export type NormalizedEnvironmentsResult = {
|
|
|
4
4
|
identities: EnvironmentIdentity[];
|
|
5
5
|
errors: string[];
|
|
6
6
|
};
|
|
7
|
+
export declare const validateAllowedEnvironmentIds: (input: string[] | undefined, sourcePath: string) => {
|
|
8
|
+
ids: string[];
|
|
9
|
+
idsSet: Set<string>;
|
|
10
|
+
errors: string[];
|
|
11
|
+
};
|
|
12
|
+
export declare const validateAllowedEnvironmentId: (environmentId: string, allowedIds: ReadonlySet<string>, sourcePath: string) => string | undefined;
|
|
7
13
|
export declare const normalizeEnvironmentDescriptorMap: (input: EnvironmentsConfig, sourcePath: string) => NormalizedEnvironmentsResult;
|
|
8
14
|
export declare const environmentIdentityById: (environmentsConfig: EnvironmentsConfig, environmentId: string) => EnvironmentIdentity | undefined;
|
|
9
15
|
export declare const environmentIdentityByName: (environmentsConfig: EnvironmentsConfig, environmentName: string) => EnvironmentIdentity | undefined;
|
|
@@ -4,6 +4,39 @@ const createIdentity = (id, descriptor) => ({
|
|
|
4
4
|
name: descriptor?.name ?? id,
|
|
5
5
|
});
|
|
6
6
|
const compatibilityIdentityFromName = (normalizedName) => normalizedName === DEFAULT_ENVIRONMENT ? DEFAULT_ENVIRONMENT_IDENTITY : { id: normalizedName, name: normalizedName };
|
|
7
|
+
export const validateAllowedEnvironmentIds = (input, sourcePath) => {
|
|
8
|
+
const ids = [];
|
|
9
|
+
const idsSet = new Set();
|
|
10
|
+
const errors = [];
|
|
11
|
+
for (const [index, environmentId] of (input ?? []).entries()) {
|
|
12
|
+
const validation = validateEnvironmentId(environmentId);
|
|
13
|
+
if (!validation.valid) {
|
|
14
|
+
errors.push(`${sourcePath}[${index}]: ${validation.reason}`);
|
|
15
|
+
continue;
|
|
16
|
+
}
|
|
17
|
+
if (validation.normalized !== environmentId) {
|
|
18
|
+
errors.push(`${sourcePath}[${index}]: id must not contain leading or trailing whitespace`);
|
|
19
|
+
continue;
|
|
20
|
+
}
|
|
21
|
+
if (idsSet.has(environmentId)) {
|
|
22
|
+
errors.push(`${sourcePath}: duplicated environment id ${JSON.stringify(environmentId)}`);
|
|
23
|
+
continue;
|
|
24
|
+
}
|
|
25
|
+
idsSet.add(environmentId);
|
|
26
|
+
ids.push(environmentId);
|
|
27
|
+
}
|
|
28
|
+
return {
|
|
29
|
+
ids,
|
|
30
|
+
idsSet,
|
|
31
|
+
errors,
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
export const validateAllowedEnvironmentId = (environmentId, allowedIds, sourcePath) => {
|
|
35
|
+
if (environmentId === DEFAULT_ENVIRONMENT || allowedIds.size === 0 || allowedIds.has(environmentId)) {
|
|
36
|
+
return undefined;
|
|
37
|
+
}
|
|
38
|
+
return `${sourcePath}: environment id ${JSON.stringify(environmentId)} is not listed in allowedEnvironments`;
|
|
39
|
+
};
|
|
7
40
|
export const normalizeEnvironmentDescriptorMap = (input, sourcePath) => {
|
|
8
41
|
const normalized = {};
|
|
9
42
|
const identities = [];
|
package/dist/utils/event.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { EventEmitter } from "node:events";
|
|
2
|
-
import type {
|
|
3
|
-
import type { BatchOptions, ExitCode, QualityGateValidationResult, RealtimeEventsDispatcher as RealtimeEventsDispatcherType, RealtimeSubscriber as RealtimeSubscriberType, ResultFile } from "@allurereport/plugin-api";
|
|
2
|
+
import type { BatchOptions, ExitCode, PluginGlobalError, QualityGateValidationResult, RealtimeEventsDispatcher as RealtimeEventsDispatcherType, RealtimeSubscriber as RealtimeSubscriberType, ResultFile } from "@allurereport/plugin-api";
|
|
4
3
|
export declare enum RealtimeEvents {
|
|
5
4
|
TestResult = "testResult",
|
|
6
5
|
TestFixtureResult = "testFixtureResult",
|
|
@@ -18,16 +17,17 @@ export interface AllureStoreEvents {
|
|
|
18
17
|
[RealtimeEvents.GlobalAttachment]: [{
|
|
19
18
|
attachment: ResultFile;
|
|
20
19
|
fileName?: string;
|
|
20
|
+
environment?: string;
|
|
21
21
|
}];
|
|
22
22
|
[RealtimeEvents.GlobalExitCode]: [ExitCode];
|
|
23
|
-
[RealtimeEvents.GlobalError]: [
|
|
23
|
+
[RealtimeEvents.GlobalError]: [PluginGlobalError];
|
|
24
24
|
}
|
|
25
25
|
export declare class RealtimeEventsDispatcher implements RealtimeEventsDispatcherType {
|
|
26
26
|
#private;
|
|
27
27
|
constructor(emitter: EventEmitter<AllureStoreEvents>);
|
|
28
|
-
sendGlobalAttachment(attachment: ResultFile, fileName?: string): void;
|
|
28
|
+
sendGlobalAttachment(attachment: ResultFile, fileName?: string, environment?: string): void;
|
|
29
29
|
sendGlobalExitCode(codes: ExitCode): void;
|
|
30
|
-
sendGlobalError(error:
|
|
30
|
+
sendGlobalError(error: PluginGlobalError): void;
|
|
31
31
|
sendQualityGateResults(payload: QualityGateValidationResult[]): void;
|
|
32
32
|
sendTestResult(trId: string): void;
|
|
33
33
|
sendTestFixtureResult(tfrId: string): void;
|
|
@@ -39,9 +39,10 @@ export declare class RealtimeSubscriber implements RealtimeSubscriberType {
|
|
|
39
39
|
onGlobalAttachment(listener: (payload: {
|
|
40
40
|
attachment: ResultFile;
|
|
41
41
|
fileName?: string;
|
|
42
|
+
environment?: string;
|
|
42
43
|
}) => Promise<void>): () => void;
|
|
43
44
|
onGlobalExitCode(listener: (payload: ExitCode) => Promise<void>): () => void;
|
|
44
|
-
onGlobalError(listener: (error:
|
|
45
|
+
onGlobalError(listener: (error: PluginGlobalError) => Promise<void>): () => void;
|
|
45
46
|
onQualityGateResults(listener: (payload: QualityGateValidationResult[]) => Promise<void>): () => void;
|
|
46
47
|
onTestResults(listener: (trIds: string[]) => Promise<void>, options?: BatchOptions): () => void;
|
|
47
48
|
onTestFixtureResults(listener: (tfrIds: string[]) => Promise<void>, options?: BatchOptions): () => void;
|
package/dist/utils/event.js
CHANGED
|
@@ -27,8 +27,8 @@ export class RealtimeEventsDispatcher {
|
|
|
27
27
|
_RealtimeEventsDispatcher_emitter.set(this, void 0);
|
|
28
28
|
__classPrivateFieldSet(this, _RealtimeEventsDispatcher_emitter, emitter, "f");
|
|
29
29
|
}
|
|
30
|
-
sendGlobalAttachment(attachment, fileName) {
|
|
31
|
-
__classPrivateFieldGet(this, _RealtimeEventsDispatcher_emitter, "f").emit(RealtimeEvents.GlobalAttachment, { attachment, fileName });
|
|
30
|
+
sendGlobalAttachment(attachment, fileName, environment) {
|
|
31
|
+
__classPrivateFieldGet(this, _RealtimeEventsDispatcher_emitter, "f").emit(RealtimeEvents.GlobalAttachment, { attachment, fileName, environment });
|
|
32
32
|
}
|
|
33
33
|
sendGlobalExitCode(codes) {
|
|
34
34
|
__classPrivateFieldGet(this, _RealtimeEventsDispatcher_emitter, "f").emit(RealtimeEvents.GlobalExitCode, codes);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@allurereport/core",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.5.0",
|
|
4
4
|
"description": "Collection of generic Allure utilities used across the entire project",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"allure"
|
|
@@ -25,24 +25,26 @@
|
|
|
25
25
|
"lint:fix": "oxlint --import-plugin --fix src test features stories"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@allurereport/ci": "3.
|
|
29
|
-
"@allurereport/core-api": "3.
|
|
30
|
-
"@allurereport/plugin-
|
|
31
|
-
"@allurereport/plugin-
|
|
32
|
-
"@allurereport/plugin-
|
|
33
|
-
"@allurereport/plugin-
|
|
34
|
-
"@allurereport/plugin-
|
|
35
|
-
"@allurereport/plugin-
|
|
36
|
-
"@allurereport/plugin-
|
|
37
|
-
"@allurereport/plugin-
|
|
38
|
-
"@allurereport/plugin-
|
|
39
|
-
"@allurereport/plugin-
|
|
40
|
-
"@allurereport/plugin-
|
|
41
|
-
"@allurereport/plugin-
|
|
42
|
-
"@allurereport/
|
|
43
|
-
"@allurereport/reader
|
|
44
|
-
"@allurereport/
|
|
45
|
-
"@allurereport/
|
|
28
|
+
"@allurereport/ci": "3.5.0",
|
|
29
|
+
"@allurereport/core-api": "3.5.0",
|
|
30
|
+
"@allurereport/plugin-agent": "3.5.0",
|
|
31
|
+
"@allurereport/plugin-allure2": "3.5.0",
|
|
32
|
+
"@allurereport/plugin-api": "3.5.0",
|
|
33
|
+
"@allurereport/plugin-awesome": "3.5.0",
|
|
34
|
+
"@allurereport/plugin-classic": "3.5.0",
|
|
35
|
+
"@allurereport/plugin-csv": "3.5.0",
|
|
36
|
+
"@allurereport/plugin-dashboard": "3.5.0",
|
|
37
|
+
"@allurereport/plugin-jira": "3.5.0",
|
|
38
|
+
"@allurereport/plugin-log": "3.5.0",
|
|
39
|
+
"@allurereport/plugin-progress": "3.5.0",
|
|
40
|
+
"@allurereport/plugin-slack": "3.5.0",
|
|
41
|
+
"@allurereport/plugin-testops": "3.5.0",
|
|
42
|
+
"@allurereport/plugin-testplan": "3.5.0",
|
|
43
|
+
"@allurereport/reader": "3.5.0",
|
|
44
|
+
"@allurereport/reader-api": "3.5.0",
|
|
45
|
+
"@allurereport/service": "3.5.0",
|
|
46
|
+
"@allurereport/summary": "3.5.0",
|
|
47
|
+
"glob": "^13.0.6",
|
|
46
48
|
"handlebars": "^4.7.9",
|
|
47
49
|
"node-stream-zip": "^1.15.0",
|
|
48
50
|
"p-limit": "^7.2.0",
|