-
Notifications
You must be signed in to change notification settings - Fork 17
/
mutant-view.ts
126 lines (115 loc) 路 4.12 KB
/
mutant-view.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
import { html, LitElement, nothing, PropertyValues, unsafeCSS } from 'lit';
import { customElement, property } from 'lit/decorators.js';
import { FileUnderTestModel, Metrics, MetricsResult } from 'mutation-testing-metrics';
import { MutantResult as MutantModel, Thresholds } from 'mutation-testing-report-schema/api';
import { MteCustomEvent } from '../../lib/custom-events';
import { tailwind } from '../../style';
import { DrawerMode } from '../drawer/drawer.component';
import { Column } from '../metrics-table/metrics-table.component';
import style from './mutant-view.scss';
@customElement('mte-mutant-view')
export class MutationTestReportMutantViewComponent extends LitElement {
@property()
public drawerMode: DrawerMode = 'closed';
@property()
private selectedMutant?: MutantModel;
public static styles = [unsafeCSS(style), tailwind];
@property()
public result!: MetricsResult<FileUnderTestModel, Metrics>;
@property({ attribute: false, reflect: false })
public thresholds!: Thresholds;
@property({ attribute: false, reflect: false })
public path!: string[];
private handleClick = () => {
// Close the drawer if the user clicks anywhere in the report (that didn't handle the click already)
this.drawerMode = 'closed';
};
private handleMutantSelected = (event: MteCustomEvent<'mutant-selected'>) => {
this.selectedMutant = event.detail.mutant;
this.drawerMode = event.detail.selected ? 'half' : 'closed';
};
updated(changes: PropertyValues) {
if (changes.has('result') && !this.result.file) {
this.drawerMode = 'closed';
}
}
public render() {
return html`
<main @click="${this.handleClick}">
<mte-metrics-table .columns="${COLUMNS}" .currentPath="${this.path}" .thresholds="${this.thresholds}" .model="${this.result}">
</mte-metrics-table>
${this.result.file ? html`<mte-file @mutant-selected="${this.handleMutantSelected}" .model="${this.result.file}"></mte-file>` : nothing}
</main>
<mte-drawer-mutant .mode="${this.drawerMode}" .mutant="${this.selectedMutant}"></mte-drawer-mutant>
`;
}
}
const COLUMNS: Column<Metrics>[] = [
{
key: 'mutationScore',
label: 'Mutation score',
tooltip: 'The percentage of mutants that were detected. The higher, the better!',
category: 'percentage',
},
{
key: 'killed',
label: 'Killed',
tooltip: 'At least one test failed while these mutants were active. This is what you want!',
category: 'number',
},
{
key: 'survived',
label: 'Survived',
tooltip: "All tests passed while these mutants were active. You're missing a test for them.",
category: 'number',
},
{
key: 'timeout',
label: 'Timeout',
tooltip: 'Running the tests while these mutants were active resulted in a timeout. For example, an infinite loop.',
category: 'number',
},
{
key: 'noCoverage',
label: 'No coverage',
tooltip: "These mutants aren't covered by one of your tests and survived as a result.",
category: 'number',
},
{
key: 'ignored',
label: 'Ignored',
tooltip: "These mutants weren't tested because they are ignored. Either by user action, or for another reason.",
category: 'number',
},
{
key: 'runtimeErrors',
label: 'Runtime errors',
tooltip: 'Running tests when these mutants are active resulted in an error (rather than a failed test). For example: an out of memory error.',
category: 'number',
},
{ key: 'compileErrors', label: 'Compile errors', tooltip: 'Mutants that caused a compile error.', category: 'number' },
{
key: 'totalDetected',
label: 'Detected',
tooltip: 'The number of mutants detected by your tests (killed + timeout).',
category: 'number',
width: 'large',
isBold: true,
},
{
key: 'totalUndetected',
label: 'Undetected',
tooltip: 'The number of mutants that are not detected by your tests (survived + no coverage).',
category: 'number',
width: 'large',
isBold: true,
},
{
key: 'totalMutants',
label: 'Total',
tooltip: 'All mutants (except runtimeErrors + compileErrors)',
category: 'number',
width: 'large',
isBold: true,
},
];