Fix broken links in report summary

Resolves #566
This commit is contained in:
Michael Marcus 2025-03-25 14:35:49 -04:00
parent 6e6a65b7a0
commit 314ef1dd49
19 changed files with 667 additions and 664 deletions

View file

@ -185,7 +185,7 @@ function getSuitesReport(tr: TestRunResult, runIndex: number, options: ReportOpt
const suites = options.listSuites === 'failed' ? tr.failedSuites : tr.suites
if (options.listSuites !== 'none') {
const trSlug = makeRunSlug(runIndex)
const trSlug = makeRunSlug(runIndex, options)
const nameLink = `<a id="${trSlug.id}" href="${options.baseUrl + trSlug.link}">${tr.path}</a>`
const icon = getResultIcon(tr.result)
sections.push(`## ${icon}\xa0${nameLink}`)
@ -205,7 +205,7 @@ function getSuitesReport(tr: TestRunResult, runIndex: number, options: ReportOpt
const tsTime = formatTime(s.time)
const tsName = s.name
const skipLink = options.listTests === 'none' || (options.listTests === 'failed' && s.result !== 'failed')
const tsAddr = options.baseUrl + makeSuiteSlug(runIndex, suiteIndex).link
const tsAddr = options.baseUrl + makeSuiteSlug(runIndex, suiteIndex, options).link
const tsNameLink = skipLink ? tsName : link(tsName, tsAddr)
const passed = s.passed > 0 ? `${s.passed} ${Icon.success}` : ''
const failed = s.failed > 0 ? `${s.failed} ${Icon.fail}` : ''
@ -240,7 +240,7 @@ function getTestsReport(ts: TestSuiteResult, runIndex: number, suiteIndex: numbe
const sections: string[] = []
const tsName = ts.name
const tsSlug = makeSuiteSlug(runIndex, suiteIndex)
const tsSlug = makeSuiteSlug(runIndex, suiteIndex, options)
const tsNameLink = `<a id="${tsSlug.id}" href="${options.baseUrl + tsSlug.link}">${tsName}</a>`
const icon = getResultIcon(ts.result)
sections.push(`### ${icon}\xa0${tsNameLink}`)
@ -269,14 +269,14 @@ function getTestsReport(ts: TestSuiteResult, runIndex: number, suiteIndex: numbe
return sections
}
function makeRunSlug(runIndex: number): {id: string; link: string} {
function makeRunSlug(runIndex: number, options: ReportOptions): {id: string; link: string} {
// use prefix to avoid slug conflicts after escaping the paths
return slug(`r${runIndex}`)
return slug(`r${runIndex}`, options)
}
function makeSuiteSlug(runIndex: number, suiteIndex: number): {id: string; link: string} {
function makeSuiteSlug(runIndex: number, suiteIndex: number, options: ReportOptions): {id: string; link: string} {
// use prefix to avoid slug conflicts after escaping the paths
return slug(`r${runIndex}s${suiteIndex}`)
return slug(`r${runIndex}s${suiteIndex}`, options)
}
function getResultIcon(result: TestExecutionResult): string {