Skip to content

Commit cedeebc

Browse files
authored
Remove default history path in the config (#419)
1 parent 8c2295d commit cedeebc

13 files changed

Lines changed: 35 additions & 24 deletions

File tree

packages/core/src/api.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export interface FullConfig {
1919
output: string;
2020
open: boolean;
2121
port: string | undefined;
22-
historyPath: string;
22+
historyPath?: string;
2323
knownIssuesPath: string;
2424
/**
2525
* You can specify default labels for tests which don't have them at all

packages/core/src/config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ export const resolveConfig = async (config: Config, override: ConfigOverride = {
163163
const name = override.name ?? config.name ?? "Allure Report";
164164
const open = override.open ?? config.open ?? false;
165165
const port = override.port ?? config.port ?? undefined;
166-
const historyPath = resolve(override.historyPath ?? config.historyPath ?? "./.allure/history.jsonl");
166+
const historyPath = override.historyPath ?? config.historyPath;
167167
const appendHistory = config.appendHistory ?? true;
168168
const knownIssuesPath = resolve(override.knownIssuesPath ?? config.knownIssuesPath ?? "./allure/known.json");
169169
const output = resolve(override.output ?? config.output ?? "./allure-report");
@@ -185,12 +185,12 @@ export const resolveConfig = async (config: Config, override: ConfigOverride = {
185185
output,
186186
open,
187187
port,
188-
historyPath,
189188
knownIssuesPath,
190189
known,
191190
variables,
192191
environments,
193192
appendHistory,
193+
historyPath: historyPath ? resolve(historyPath) : undefined,
194194
reportFiles: new FileSystemReportFiles(output),
195195
plugins: pluginInstances,
196196
defaultLabels: config.defaultLabels ?? {},

packages/core/src/report.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,12 @@ export class AllureReport {
125125
this.#plugins = [...plugins];
126126
this.#reportFiles = reportFiles;
127127
this.#output = output;
128-
this.#history = this.#allureServiceClient
129-
? new AllureRemoteHistory(this.#allureServiceClient, this.#ci?.jobRunBranch)
130-
: new AllureLocalHistory(historyPath);
128+
129+
if (this.#allureServiceClient) {
130+
this.#history = new AllureRemoteHistory(this.#allureServiceClient, this.#ci?.jobRunBranch);
131+
} else if (historyPath) {
132+
this.#history = new AllureLocalHistory(historyPath);
133+
}
131134
}
132135

133136
get hasQualityGate() {

packages/core/src/store/store.ts

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -305,8 +305,10 @@ export class DefaultAllureStore implements AllureStore, ResultsVisitor {
305305
// Compute history-based statuses
306306
const trHistory = await this.historyByTr(testResult);
307307

308-
testResult.transition = getStatusTransition(testResult, trHistory);
309-
testResult.flaky = isFlaky(testResult, trHistory);
308+
if (trHistory) {
309+
testResult.transition = getStatusTransition(testResult, trHistory);
310+
testResult.flaky = isFlaky(testResult, trHistory);
311+
}
310312

311313
this.#testResults.set(testResult.id, testResult);
312314

@@ -545,14 +547,22 @@ export class DefaultAllureStore implements AllureStore, ResultsVisitor {
545547
return tr ? this.retriesByTr(tr) : [];
546548
}
547549

548-
async historyByTr(tr: TestResult): Promise<HistoryTestResult[]> {
550+
async historyByTr(tr: TestResult): Promise<HistoryTestResult[] | undefined> {
551+
if (!this.#history) {
552+
return undefined;
553+
}
554+
549555
return htrsByTr(this.#historyPoints, tr);
550556
}
551557

552-
async historyByTrId(trId: string): Promise<HistoryTestResult[]> {
558+
async historyByTrId(trId: string): Promise<HistoryTestResult[] | undefined> {
553559
const tr = await this.testResultById(trId);
554560

555-
return tr ? this.historyByTr(tr) : [];
561+
if (!tr) {
562+
return undefined;
563+
}
564+
565+
return this.historyByTr(tr);
556566
}
557567

558568
async fixturesByTrId(trId: string): Promise<TestFixtureResult[]> {

packages/core/test/config.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,11 +246,11 @@ describe("resolveConfig", () => {
246246
expect(resolved.name).toEqual("Custom");
247247
});
248248

249-
it("should set default history path if it's not provided", async () => {
249+
it("shouldn't set default history path if it's not provided", async () => {
250250
const fixture = {} as Config;
251251
const resolved = await resolveConfig(fixture);
252252

253-
expect(resolved.historyPath).toEqual(resolve("./.allure/history.jsonl"));
253+
expect(resolved.historyPath).toBeUndefined();
254254
});
255255

256256
it("should return provided history path", async () => {

packages/e2e/test/allure-awesome/test/tree.test.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,14 +109,13 @@ test.describe("commons", () => {
109109
test("statistics in metadata renders information about the tests", async () => {
110110
const stats = await treePage.getMetadataValues();
111111

112-
expect(stats).toEqual({
112+
expect(stats).toMatchObject({
113113
total: "5",
114114
passed: "1",
115115
failed: "1",
116116
broken: "1",
117117
skipped: "1",
118118
unknown: "1",
119-
new: "5",
120119
});
121120
});
122121

packages/e2e/test/types.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
import type { FullConfig } from "@allurereport/core";
22

3-
export type ReportConfig = Omit<FullConfig, "output" | "reportFiles" | "plugins" | "historyPath">;
3+
export type ReportConfig = Omit<FullConfig, "output" | "reportFiles" | "plugins" | "historyPath" | "open" | "port">;

packages/e2e/test/utils/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { AllureReport, FileSystemReportFiles, type FullConfig } from "@allurereport/core";
2-
import { type HistoryDataPoint, type TestError } from "@allurereport/core-api";
3-
import { type ExitCode, QualityGateValidationResult } from "@allurereport/plugin-api";
2+
import type { HistoryDataPoint, TestError } from "@allurereport/core-api";
3+
import type { ExitCode, QualityGateValidationResult } from "@allurereport/plugin-api";
44
import AwesomePlugin from "@allurereport/plugin-awesome";
55
import { BufferResultFile } from "@allurereport/reader-api";
66
import { serve } from "@allurereport/static-server";
@@ -20,7 +20,7 @@ export type GeneratorParams = {
2020
testResults?: Partial<TestResult>[];
2121
rawTestResults?: Partial<TestResult>[];
2222
attachments?: { source: string; content: Buffer }[];
23-
reportConfig?: Omit<FullConfig, "output" | "reportFiles" | "historyPath">;
23+
reportConfig?: Omit<FullConfig, "output" | "reportFiles" | "historyPath" | "port" | "open">;
2424
globals?: {
2525
exitCode?: ExitCode;
2626
errors?: TestError[];

packages/plugin-allure2/src/plugin.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export class Allure2Plugin implements Plugin {
4545
for (const value of tests) {
4646
const fixtures = await store.fixturesByTrId(value.id);
4747
const retries = await store.retriesByTrId(value.id);
48-
const history = await store.historyByTrId(value.id);
48+
const history = (await store.historyByTrId(value.id)) ?? [];
4949
const allure2TestResult = convertTestResult(
5050
{
5151
attachmentMap,

packages/plugin-api/src/store.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export interface AllureStore {
4444
attachmentsByTrId: (trId: string) => Promise<AttachmentLink[]>;
4545
retriesByTr: (tr: TestResult) => Promise<TestResult[]>;
4646
retriesByTrId: (trId: string) => Promise<TestResult[]>;
47-
historyByTrId: (trId: string) => Promise<HistoryTestResult[]>;
47+
historyByTrId: (trId: string) => Promise<HistoryTestResult[] | undefined>;
4848
fixturesByTrId: (trId: string) => Promise<TestFixtureResult[]>;
4949
// aggregate api
5050
failedTestResults: () => Promise<TestResult[]>;

0 commit comments

Comments
 (0)