mirror of
https://github.com/Microsoft/vscode
synced 2024-07-05 01:08:57 +00:00
improve search smoke test (#161652)
* improve search smoke test * prevent text to show when clearing results
This commit is contained in:
parent
f8feede2ae
commit
f8aa3a7c04
|
@ -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);
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 () {
|
||||
|
|
|
@ -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 () {
|
||||
|
|
Loading…
Reference in New Issue
Block a user