use existing filename

This commit is contained in:
Simon Knott 2024-11-20 09:01:57 +01:00
parent 4027e3dff1
commit 85f6b4bd9b
No known key found for this signature in database
GPG key ID: 8CEDC00028084AEC

View file

@ -133,7 +133,7 @@ class HtmlReporter implements ReporterV2 {
const projectSuites = this.suite.suites; const projectSuites = this.suite.suites;
await removeFolders([this._outputFolder]); await removeFolders([this._outputFolder]);
const builder = new HtmlBuilder(this.config, this._outputFolder, this._attachmentsBaseURL); const builder = new HtmlBuilder(this.config, this._outputFolder, this._attachmentsBaseURL);
this._buildResult = await builder.build(this.config.metadata, this.config.rootDir, projectSuites, result, this._topLevelErrors); this._buildResult = await builder.build(this.config.metadata, projectSuites, result, this._topLevelErrors);
} }
async onExit() { async onExit() {
@ -238,13 +238,12 @@ class HtmlBuilder {
this._attachmentsBaseURL = attachmentsBaseURL; this._attachmentsBaseURL = attachmentsBaseURL;
} }
async build(metadata: Metadata, rootDir: string, projectSuites: Suite[], result: FullResult, topLevelErrors: TestError[]): Promise<{ ok: boolean, singleTestId: string | undefined }> { async build(metadata: Metadata, projectSuites: Suite[], result: FullResult, topLevelErrors: TestError[]): Promise<{ ok: boolean, singleTestId: string | undefined }> {
const data = new Map<string, { testFile: TestFile, testFileSummary: TestFileSummary }>(); const data = new Map<string, { testFile: TestFile, testFileSummary: TestFileSummary }>();
for (const projectSuite of projectSuites) { for (const projectSuite of projectSuites) {
for (const fileSuite of projectSuite.suites) { for (const fileSuite of projectSuite.suites) {
const fileName = this._relativeLocation(fileSuite.location)!.file; const fileName = this._relativeLocation(fileSuite.location)!.file;
const relativeFile = path.relative(rootDir, fileSuite.location!.file); const fileId = calculateSha1(toPosixPath(fileName)).slice(0, 20);
const fileId = calculateSha1(toPosixPath(relativeFile)).slice(0, 20);
let fileEntry = data.get(fileId); let fileEntry = data.get(fileId);
if (!fileEntry) { if (!fileEntry) {
fileEntry = { fileEntry = {