testing: improve test item labels

Fixes #119635
Fixes #119643
This commit is contained in:
Connor Peet 2021-03-29 15:05:15 -07:00
parent 20fc2a175a
commit 3aff04dcae
No known key found for this signature in database
GPG key ID: CF8FD2EA0DBC61BD

View file

@ -725,25 +725,29 @@ class TreeSorter implements ITreeSorter<ITestTreeElement> {
}
}
const getLabelForTestTreeElement = (element: ITestTreeElement) => {
let label = localize({
key: 'testing.treeElementLabel',
comment: ['label then the unit tests state, for example "Addition Tests (Running)"'],
}, '{0} ({1})', element.label, testStateNames[element.state]);
if (element.retired) {
label = localize({
key: 'testing.treeElementLabelOutdated',
comment: ['{0} is the original label in testing.treeElementLabel'],
}, '{0}, outdated result', label, testStateNames[element.state]);
}
return label;
};
class ListAccessibilityProvider implements IListAccessibilityProvider<ITestTreeElement> {
getWidgetAriaLabel(): string {
return localize('testExplorer', "Test Explorer");
}
getAriaLabel(element: ITestTreeElement): string {
let label = localize({
key: 'testing.treeElementLabel',
comment: ['label then the unit tests state, for example "Addition Tests (Running)"'],
}, '{0} ({1})', element.label, testStateNames[element.state]);
if (element.retired) {
label = localize({
key: 'testing.treeElementLabelOutdated',
comment: ['{0} is the original label in testing.treeElementLabel'],
}, '{0}, outdated result', label, testStateNames[element.state]);
}
return label;
return getLabelForTestTreeElement(element);
}
}
@ -839,13 +843,7 @@ class TestsRenderer extends Disposable implements ITreeRenderer<ITestTreeElement
const test = element.test;
if (test) {
label.resource = test.item.uri;
let title = element.label;
for (let p = element.parentItem; p; p = p.parentItem) {
title = `${p.label}, ${title}`;
}
options.title = title;
options.title = getLabelForTestTreeElement(element);
options.fileKind = FileKind.FILE;
label.description = element.description;
} else {