improve search smoke test (#161652)

* improve search smoke test
* prevent text to show when clearing results
This commit is contained in:
Andrea Mah 2022-10-05 08:52:39 -07:00 committed by GitHub
parent f8feede2ae
commit f8aa3a7c04
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 17 additions and 14 deletions

View File

@ -527,7 +527,7 @@ export class SearchView extends ViewPane {
private refreshAndUpdateCount(event?: IChangeEvent): void {
this.searchWidget.setReplaceAllActionState(!this.viewModel.searchResult.isEmpty());
this.updateSearchResultCount(this.viewModel.searchResult.query!.userDisabledExcludesAndIgnoreFiles, this.viewModel.searchResult.query?.onlyOpenEditors);
this.updateSearchResultCount(this.viewModel.searchResult.query!.userDisabledExcludesAndIgnoreFiles, this.viewModel.searchResult.query?.onlyOpenEditors, event?.clearingAll);
return this.refreshTree(event);
}
@ -1646,14 +1646,14 @@ export class SearchView extends ViewPane {
this.inputPatternIncludes.setOnlySearchInOpenEditors(false);
}
private updateSearchResultCount(disregardExcludesAndIgnores?: boolean, onlyOpenEditors?: boolean): void {
private updateSearchResultCount(disregardExcludesAndIgnores?: boolean, onlyOpenEditors?: boolean, clear: boolean = false): void {
const fileCount = this.viewModel.searchResult.fileCount();
this.hasSearchResultsKey.set(fileCount > 0);
const msgWasHidden = this.messagesElement.style.display === 'none';
const messageEl = this.clearMessage();
const resultMsg = this.buildResultCountMessage(this.viewModel.searchResult.count(), fileCount);
const resultMsg = clear ? '' : this.buildResultCountMessage(this.viewModel.searchResult.count(), fileCount);
this.tree.ariaLabel = resultMsg + nls.localize('forTerm', " - Search: {0}", this.searchResult.query?.contentPattern.pattern ?? '');
dom.append(messageEl, resultMsg);

View File

@ -476,6 +476,7 @@ export interface IChangeEvent {
elements: FileMatch[];
added?: boolean;
removed?: boolean;
clearingAll?: boolean;
}
export class FolderMatch extends Disposable {
@ -578,10 +579,10 @@ export class FolderMatch extends Disposable {
folderMatch.onDispose(() => disposable.dispose());
}
clear(): void {
clear(clearingAll = false): void {
const changed: FileMatch[] = this.downstreamFileMatches();
this.disposeMatches();
this._onChange.fire({ elements: changed, removed: true, added: false });
this._onChange.fire({ elements: changed, removed: true, added: false, clearingAll });
}
remove(matches: FileMatch | FolderMatchWithResource | (FileMatch | FolderMatchWithResource)[]): void {
@ -1191,7 +1192,7 @@ export class SearchResult extends Disposable {
}
clear(): void {
this.folderMatches().forEach((folderMatch) => folderMatch.clear());
this.folderMatches().forEach((folderMatch) => folderMatch.clear(true));
this.disposeMatches();
this._folderMatches = [];
this._otherFilesMatch = null;

View File

@ -449,7 +449,7 @@ suite('SearchResult', () => {
testObject.onChange(target);
testObject.remove(folderMatch);
assert.ok(target.calledOnce);
assert.deepStrictEqual([{ elements: expectedArrayResult, removed: true, added: false }], target.args[0]);
assert.deepStrictEqual([{ elements: expectedArrayResult, removed: true, added: false, clearingAll: false }], target.args[0]);
});
test('Replacing an intermediate folder should remove all downstream folders and file matches', async function () {

View File

@ -29,14 +29,16 @@ export function setup(logger: Logger) {
it('searches only for *.js files & checks for correct result number', async function () {
const app = this.app as Application;
await app.workbench.search.searchFor('body');
await app.workbench.search.showQueryDetails();
await app.workbench.search.setFilesToIncludeText('*.js');
await app.workbench.search.submitSearch();
try {
await app.workbench.search.setFilesToIncludeText('*.js');
await app.workbench.search.searchFor('body');
await app.workbench.search.showQueryDetails();
await app.workbench.search.waitForResultText('4 results in 1 file');
await app.workbench.search.setFilesToIncludeText('');
await app.workbench.search.hideQueryDetails();
await app.workbench.search.waitForResultText('4 results in 1 file');
} finally {
await app.workbench.search.setFilesToIncludeText('');
await app.workbench.search.hideQueryDetails();
}
});
it('dismisses result & checks for correct result number', async function () {