Path: blob/main/test/smoke/src/areas/search/search.test.ts
5313 views
/*---------------------------------------------------------------------------------------------1* Copyright (c) Microsoft Corporation. All rights reserved.2* Licensed under the MIT License. See License.txt in the project root for license information.3*--------------------------------------------------------------------------------------------*/45import * as cp from 'child_process';6import { Application, Logger } from '../../../../automation';7import { installAllHandlers, retry } from '../../utils';89export function setup(logger: Logger) {10describe('Search', () => {1112// Shared before/after handling13installAllHandlers(logger);1415after(function () {16const app = this.app as Application;1718retry(async () => cp.execSync('git checkout . --quiet', { cwd: app.workspacePathOrFolder }), 0, 5);19retry(async () => cp.execSync('git reset --hard HEAD --quiet', { cwd: app.workspacePathOrFolder }), 0, 5);20});2122it('verifies the sidebar moves to the right', async function () {23const app = this.app as Application;24await app.workbench.search.openSearchViewlet();2526await app.code.dispatchKeybinding('PageUp', async () => {27await app.workbench.search.hasActivityBarMoved();28});2930await app.code.dispatchKeybinding('PageUp', async () => {31await app.workbench.search.hasActivityBarMoved();32});33});3435it('searches for body & checks for correct result number', async function () {36const app = this.app as Application;37await app.workbench.search.openSearchViewlet();38await app.workbench.search.searchFor('body');3940await app.workbench.search.waitForResultText('6 results in 3 files');41});4243it('searches only for *.js files & checks for correct result number', async function () {44const app = this.app as Application;45try {46await app.workbench.search.setFilesToIncludeText('*.js');47await app.workbench.search.searchFor('body');48await app.workbench.search.showQueryDetails();4950await app.workbench.search.waitForResultText('4 results in 1 file');51} finally {52await app.workbench.search.setFilesToIncludeText('');53await app.workbench.search.hideQueryDetails();54}55});5657it('dismisses result & checks for correct result number', async function () {58const app = this.app as Application;59await app.workbench.search.searchFor('body');60await app.workbench.search.waitForResultText('6 results in 3 files');61await app.workbench.search.removeFileMatch('app.js', '2 results in 2 files');62});6364it.skip('replaces first search result with a replace term', async function () { // TODO@roblourens https://github.com/microsoft/vscode/issues/13719565const app = this.app as Application;6667await app.workbench.search.searchFor('body');68await app.workbench.search.waitForResultText('6 results in 3 files');69await app.workbench.search.expandReplace();70await app.workbench.search.setReplaceText('ydob');71await app.workbench.search.replaceFileMatch('app.js', '2 results in 2 files');7273await app.workbench.search.searchFor('ydob');74await app.workbench.search.waitForResultText('4 results in 1 file');75await app.workbench.search.setReplaceText('body');76await app.workbench.search.replaceFileMatch('app.js', '0 results in 0 files');77await app.workbench.search.waitForResultText('0 results in 0 files');78});79});8081describe('Quick Open', () => {8283// Shared before/after handling84installAllHandlers(logger);8586it('quick open search produces correct result', async function () {87const app = this.app as Application;88const 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];9899await app.workbench.quickaccess.openFileQuickAccessAndWait('.js', 8);100await app.workbench.quickinput.waitForQuickInputElements(names => expectedNames.every(expectedName => names.some(name => expectedName === name)));101await app.workbench.quickinput.closeQuickInput();102});103104it('quick open respects fuzzy matching', async function () {105const app = this.app as Application;106const expectedNames = [107'tasks.json',108'app.js',109'package.json'110];111112await app.workbench.quickaccess.openFileQuickAccessAndWait('a.s', 3);113await app.workbench.quickinput.waitForQuickInputElements(names => expectedNames.every(expectedName => names.some(name => expectedName === name)));114await app.workbench.quickinput.closeQuickInput();115});116});117}118119120