Skip to content

Commit

Permalink
fix(drawer): preserve whitespace when rendering mutant description an…
Browse files Browse the repository at this point in the history
…d statusReason (#2926)


---------

Co-authored-by: Stryker Mutator NPA <[email protected]>
  • Loading branch information
hugo-vrijswijk and Stryker Mutator NPA authored Dec 23, 2023
1 parent 871c5d7 commit b23731a
Show file tree
Hide file tree
Showing 18 changed files with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { TemplateResult } from 'lit';
import { html, nothing } from 'lit';
import { customElement, property } from 'lit/decorators.js';
import type { MutantModel, TestModel } from 'mutation-testing-metrics';
Expand All @@ -10,6 +11,11 @@ import { renderDetailLine, renderEmoji, renderSummaryContainer, renderSummaryLin

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

/**
* Wrap so that the whitespace is preserved when rendered
*/
const whitespacePreserving = (content: string | TemplateResult) => html`<span class="whitespace-pre-wrap">${content}</span>`;

@customElement('mte-drawer-mutant')
export class MutationTestReportDrawerMutant extends RealTimeElement {
@property()
Expand Down Expand Up @@ -60,9 +66,14 @@ export class MutationTestReportDrawerMutant extends RealTimeElement {
)}
${renderIf(
this.mutant?.statusReason?.trim(),
renderSummaryLine(html`${renderEmoji('🕵️', 'spy')} ${this.mutant!.statusReason!}`, `Reason for the ${this.mutant!.status} status`),
renderSummaryLine(
html`${renderEmoji('🕵️', 'spy')} ${whitespacePreserving(this.mutant!.statusReason!)}`,
`Reason for the ${this.mutant!.status} status`,
),
)}
${renderIfPresent(this.mutant?.description, (description) => renderSummaryLine(html`${renderEmoji('📖', 'book')} ${description}`))}`,
${renderIfPresent(this.mutant?.description, (description) =>
renderSummaryLine(html`${renderEmoji('📖', 'book')} ${whitespacePreserving(description)}`),
)}`,
);
}

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -1000,6 +1000,8 @@
"mutatorName": "ConditionalExpression",
"replacement": "false",
"status": "Survived",
"statusReason": "First line\nSecond line",
"description": "Also first line\nAlso second line",
"testsCompleted": 2,
"static": false,
"coveredBy": ["2", "3"]
Expand Down

0 comments on commit b23731a

Please sign in to comment.