Filter test case in report by annoations
This commit is contained in:
parent
3a9fb3f7d2
commit
a7c45a156b
|
|
@ -15,12 +15,12 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import type { TestCaseSummary } from './types';
|
import type { TestCaseSummary } from './types';
|
||||||
|
|
||||||
export class Filter {
|
export class Filter {
|
||||||
project: string[] = [];
|
project: string[] = [];
|
||||||
status: string[] = [];
|
status: string[] = [];
|
||||||
text: string[] = [];
|
text: string[] = [];
|
||||||
labels: string[] = [];
|
labels: string[] = [];
|
||||||
|
annotations: string[] = [];
|
||||||
|
|
||||||
empty(): boolean {
|
empty(): boolean {
|
||||||
return this.project.length + this.status.length + this.text.length === 0;
|
return this.project.length + this.status.length + this.text.length === 0;
|
||||||
|
|
@ -32,6 +32,7 @@ export class Filter {
|
||||||
const status = new Set<string>();
|
const status = new Set<string>();
|
||||||
const text: string[] = [];
|
const text: string[] = [];
|
||||||
const labels = new Set<string>();
|
const labels = new Set<string>();
|
||||||
|
const annotations = new Set<string>();
|
||||||
for (const token of tokens) {
|
for (const token of tokens) {
|
||||||
if (token.startsWith('p:')) {
|
if (token.startsWith('p:')) {
|
||||||
project.add(token.slice(2));
|
project.add(token.slice(2));
|
||||||
|
|
@ -45,6 +46,10 @@ export class Filter {
|
||||||
labels.add(token);
|
labels.add(token);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (token.startsWith('a:')) {
|
||||||
|
annotations.add(token.slice(2));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
text.push(token.toLowerCase());
|
text.push(token.toLowerCase());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -53,6 +58,7 @@ export class Filter {
|
||||||
filter.project = [...project];
|
filter.project = [...project];
|
||||||
filter.status = [...status];
|
filter.status = [...status];
|
||||||
filter.labels = [...labels];
|
filter.labels = [...labels];
|
||||||
|
filter.annotations = [...annotations];
|
||||||
return filter;
|
return filter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -114,6 +120,7 @@ export class Filter {
|
||||||
line: String(test.location.line),
|
line: String(test.location.line),
|
||||||
column: String(test.location.column),
|
column: String(test.location.column),
|
||||||
labels: test.tags.map(tag => tag.toLowerCase()),
|
labels: test.tags.map(tag => tag.toLowerCase()),
|
||||||
|
annotations: test.annotations.map(a => a.type.toLowerCase() + ':' + a.description?.toLocaleLowerCase())
|
||||||
};
|
};
|
||||||
(test as any).searchValues = searchValues;
|
(test as any).searchValues = searchValues;
|
||||||
}
|
}
|
||||||
|
|
@ -144,7 +151,14 @@ export class Filter {
|
||||||
if (!matches)
|
if (!matches)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (this.annotations.length) {
|
||||||
|
const matches = this.annotations.every(annotation =>
|
||||||
|
searchValues.annotations.some(_annotation => (
|
||||||
|
_annotation.includes(annotation)
|
||||||
|
)));
|
||||||
|
if (!matches)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -157,5 +171,6 @@ type SearchValues = {
|
||||||
line: string;
|
line: string;
|
||||||
column: string;
|
column: string;
|
||||||
labels: string[];
|
labels: string[];
|
||||||
|
annotations: string[];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue