feat(reporting): Add hyperlink rendering for URL fields in HTML reports
This commit is contained in:
parent
0e0b426e47
commit
39d5c81fa3
|
|
@ -72,11 +72,21 @@ function renderAnnotationDescription(description: string) {
|
|||
return description;
|
||||
}
|
||||
|
||||
function TestCaseAnnotationView({ annotation: { type, description } }: { annotation: TestCaseAnnotation }) {
|
||||
function renderAnnotationLink(url: string) {
|
||||
try {
|
||||
if (['http:', 'https:'].includes(new URL(url).protocol)) {
|
||||
return <a href={url} target='_blank' rel='noopener noreferrer'>{url}</a>;
|
||||
}
|
||||
} catch {}
|
||||
return url;
|
||||
}
|
||||
|
||||
function TestCaseAnnotationView({ annotation: { type, description, url } }: { annotation: TestCaseAnnotation }) {
|
||||
return (
|
||||
<div className='test-case-annotation'>
|
||||
<span style={{ fontWeight: 'bold' }}>{type}</span>
|
||||
{description && <span>: {renderAnnotationDescription(description)}</span>}
|
||||
{url && <span>: {renderAnnotationLink(url)}</span>}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue