Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/test/smoke/src/areas/search/search.test.ts
3520 views
1
/*---------------------------------------------------------------------------------------------
2
* Copyright (c) Microsoft Corporation. All rights reserved.
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
*--------------------------------------------------------------------------------------------*/
5
6
import * as cp from 'child_process';
7
import { Application, Logger } from '../../../../automation';
8
import { installAllHandlers, retry } from '../../utils';
9
10
export function setup(logger: Logger) {
11
describe('Search', () => {
12
13
// Shared before/after handling
14
installAllHandlers(logger);
15
16
after(function () {
17
const app = this.app as Application;
18
retry(async () => cp.execSync('git checkout . --quiet', { cwd: app.workspacePathOrFolder }), 0, 5);
19
retry(async () => cp.execSync('git reset --hard HEAD --quiet', { cwd: app.workspacePathOrFolder }), 0, 5);
20
});
21
22
it('verifies the sidebar moves to the right', async function () {
23
const app = this.app as Application;
24
await app.workbench.search.openSearchViewlet();
25
26
await app.code.dispatchKeybinding('PageUp', async () => {
27
await app.workbench.search.hasActivityBarMoved();
28
});
29
30
await app.code.dispatchKeybinding('PageUp', async () => {
31
await app.workbench.search.hasActivityBarMoved();
32
});
33
});
34
35
it('searches for body & checks for correct result number', async function () {
36
const app = this.app as Application;
37
await app.workbench.search.openSearchViewlet();
38
await app.workbench.search.searchFor('body');
39
40
await app.workbench.search.waitForResultText('6 results in 3 files');
41
});
42
43
it('searches only for *.js files & checks for correct result number', async function () {
44
const app = this.app as Application;
45
try {
46
await app.workbench.search.setFilesToIncludeText('*.js');
47
await app.workbench.search.searchFor('body');
48
await app.workbench.search.showQueryDetails();
49
50
await app.workbench.search.waitForResultText('4 results in 1 file');
51
} finally {
52
await app.workbench.search.setFilesToIncludeText('');
53
await app.workbench.search.hideQueryDetails();
54
}
55
});
56
57
it('dismisses result & checks for correct result number', async function () {
58
const app = this.app as Application;
59
await app.workbench.search.searchFor('body');
60
await app.workbench.search.waitForResultText('6 results in 3 files');
61
await app.workbench.search.removeFileMatch('app.js', '2 results in 2 files');
62
});
63
64
it.skip('replaces first search result with a replace term', async function () { // TODO@roblourens https://github.com/microsoft/vscode/issues/137195
65
const app = this.app as Application;
66
67
await app.workbench.search.searchFor('body');
68
await app.workbench.search.waitForResultText('6 results in 3 files');
69
await app.workbench.search.expandReplace();
70
await app.workbench.search.setReplaceText('ydob');
71
await app.workbench.search.replaceFileMatch('app.js', '2 results in 2 files');
72
73
await app.workbench.search.searchFor('ydob');
74
await app.workbench.search.waitForResultText('4 results in 1 file');
75
await app.workbench.search.setReplaceText('body');
76
await app.workbench.search.replaceFileMatch('app.js', '0 results in 0 files');
77
await app.workbench.search.waitForResultText('0 results in 0 files');
78
});
79
});
80
81
describe('Quick Open', () => {
82
83
// Shared before/after handling
84
installAllHandlers(logger);
85
86
it('quick open search produces correct result', async function () {
87
const app = this.app as Application;
88
const expectedNames = [
89
'.eslintrc.json',
90
'tasks.json',
91
'settings.json',
92
'app.js',
93
'index.js',
94
'users.js',
95
'package.json',
96
'jsconfig.json'
97
];
98
99
await app.workbench.quickaccess.openFileQuickAccessAndWait('.js', 8);
100
await app.workbench.quickinput.waitForQuickInputElements(names => expectedNames.every(expectedName => names.some(name => expectedName === name)));
101
await app.workbench.quickinput.closeQuickInput();
102
});
103
104
it('quick open respects fuzzy matching', async function () {
105
const app = this.app as Application;
106
const expectedNames = [
107
'tasks.json',
108
'app.js',
109
'package.json'
110
];
111
112
await app.workbench.quickaccess.openFileQuickAccessAndWait('a.s', 3);
113
await app.workbench.quickinput.waitForQuickInputElements(names => expectedNames.every(expectedName => names.some(name => expectedName === name)));
114
await app.workbench.quickinput.closeQuickInput();
115
});
116
});
117
}
118
119