Skip to content

Commit b23731a

Browse files
hugo-vrijswijkStryker Mutator NPA
andauthored
fix(drawer): preserve whitespace when rendering mutant description and statusReason (#2926)
--------- Co-authored-by: Stryker Mutator NPA <[email protected]>
1 parent 871c5d7 commit b23731a

File tree

18 files changed

+15
-2
lines changed

18 files changed

+15
-2
lines changed

packages/elements/src/components/drawer-mutant/drawer-mutant.component.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import type { TemplateResult } from 'lit';
12
import { html, nothing } from 'lit';
23
import { customElement, property } from 'lit/decorators.js';
34
import type { MutantModel, TestModel } from 'mutation-testing-metrics';
@@ -10,6 +11,11 @@ import { renderDetailLine, renderEmoji, renderSummaryContainer, renderSummaryLin
1011

1112
const describeTest = (test: TestModel) => `${test.name}${test.sourceFile && test.location ? ` (${describeLocation(test)})` : ''}`;
1213

14+
/**
15+
* Wrap so that the whitespace is preserved when rendered
16+
*/
17+
const whitespacePreserving = (content: string | TemplateResult) => html`<span class="whitespace-pre-wrap">${content}</span>`;
18+
1319
@customElement('mte-drawer-mutant')
1420
export class MutationTestReportDrawerMutant extends RealTimeElement {
1521
@property()
@@ -60,9 +66,14 @@ export class MutationTestReportDrawerMutant extends RealTimeElement {
6066
)}
6167
${renderIf(
6268
this.mutant?.statusReason?.trim(),
63-
renderSummaryLine(html`${renderEmoji('🕵️', 'spy')} ${this.mutant!.statusReason!}`, `Reason for the ${this.mutant!.status} status`),
69+
renderSummaryLine(
70+
html`${renderEmoji('🕵️', 'spy')} ${whitespacePreserving(this.mutant!.statusReason!)}`,
71+
`Reason for the ${this.mutant!.status} status`,
72+
),
6473
)}
65-
${renderIfPresent(this.mutant?.description, (description) => renderSummaryLine(html`${renderEmoji('📖', 'book')} ${description}`))}`,
74+
${renderIfPresent(this.mutant?.description, (description) =>
75+
renderSummaryLine(html`${renderEmoji('📖', 'book')} ${whitespacePreserving(description)}`),
76+
)}`,
6677
);
6778
}
6879

Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading

0 commit comments

Comments
 (0)