Skip to content

Commit

Permalink
feat(mutant-view): show status reason in drawer (#1290)
Browse files Browse the repository at this point in the history
  • Loading branch information
nicojs committed Jul 31, 2021
1 parent ea9a948 commit 0e6750d
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 29 deletions.
15 changes: 0 additions & 15 deletions packages/elements/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,20 @@ export class MutationTestReportDrawerMutant extends LitElement {
${this.mutant.killedByTests.length > 1 ? html`(and ${this.mutant.killedByTests.length - 1} more)` : undefined}</h6
>`
: undefined}
${renderIf(
this.mutant?.static || this.mutant?.coveredByTests,
html`<h6 class="pe-4">
${this.mutant?.static
? html`🗿 Static mutant`
: renderIfPresent(
this.mutant?.coveredByTests,
(coveredTests) =>
html`☂️ Covered by ${coveredTests.length} test${plural(coveredTests)}
${renderIf(this.mutant?.status === MutantStatus.Survived, '(yet still survived)')}`
)}
</h6>`
${renderIf(this.mutant?.static, html`<h6 class="pe-4">🗿 Static mutant</h6>`)}
${renderIfPresent(
this.mutant?.coveredByTests,
(coveredTests) =>
html`<h6 class="pe-4"
>☂️ Covered by ${coveredTests.length} test${plural(coveredTests)}
${renderIf(this.mutant?.status === MutantStatus.Survived, '(yet still survived)')}</h6
>`
)}
${renderIfPresent(
this.mutant?.statusReason,
(reason) => html`<h6 class="pe-4" title="Reason for the ${this.mutant!.status} status">🕵️ ${reason}</h6>`
)}
${renderIfPresent(this.mutant?.description, (description) => html`<h6>📖 ${description}</h6>`)}
${renderIfPresent(this.mutant?.description, (description) => html`<h6 class="pe-4">📖 ${description}</h6>`)}
</div>`;
}

Expand Down
9 changes: 9 additions & 0 deletions packages/elements/test/integration/drawer.it.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,15 @@ describe('Drawer', () => {
await actScreenshotMatch(this);
});

it('should show the statusReason', async function () {
// Mutant 17 has a statusReason
await page.mutantView.mutant(17).toggleMutant();
await drawer.whenHalfOpen();
const summary = await drawer.summaryText();
expect(summary).contains('Survived despite covered by 3 tests');
await actScreenshotMatch(this);
});

it('should close the drawer when deselecting the mutant', async () => {
await mutant.toggleMutant();
await drawer.whenClosed();
Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions packages/elements/test/integration/po/Drawer.po.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ export class Drawer extends PageObject {
return this.header.getText();
}

public summaryText() {
return this.$('[slot="summary"]').getText();
}

public whenOpen() {
return this.browser.wait(() => this.isOpen(), DEFAULT_TIMEOUT);
}
Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 @@ -104,6 +104,15 @@ describe(MutationTestReportDrawerMutant.name, () => {
expect(summary).contains('📖 Replaced "foo" with "bar"');
});

it('should contain the status reason', async () => {
mutant.status = MutantStatus.Timeout;
mutant.statusReason = 'Hit limit reached (501 > 500)';
sut.element.mutant = mutant;
await sut.whenStable();
const summary = summaryText();
expect(summary).contains('🕵️ Hit limit reached (501 > 500)');
});

function summaryText() {
return sut.$('[slot="summary"]').innerText;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -960,6 +960,7 @@
"mutatorName": "ConditionalExpression",
"replacement": "false",
"status": "Survived",
"statusReason": "Survived despite covered by 3 tests",
"testsCompleted": 3,
"static": false,
"coveredBy": ["1", "2", "3"]
Expand All @@ -979,7 +980,6 @@
"mutatorName": "EqualityOperator",
"replacement": "defaultValue !== undefined",
"status": "Killed",
"description": "Killed by: deepMerge should deep merge overrides into the target object",
"testsCompleted": 2,
"static": false,
"coveredBy": ["1", "2", "3"],
Expand Down

0 comments on commit 0e6750d

Please sign in to comment.