Path: blob/main/test/smoke/src/areas/search/search.test.ts
3520 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;17retry(async () => cp.execSync('git checkout . --quiet', { cwd: app.workspacePathOrFolder }), 0, 5);18retry(async () => cp.execSync('git reset --hard HEAD --quiet', { cwd: app.workspacePathOrFolder }), 0, 5);19});2021it('verifies the sidebar moves to the right', async function () {22const app = this.app as Application;23await app.workbench.search.openSearchViewlet();2425await app.code.dispatchKeybinding('PageUp', async () => {26await app.workbench.search.hasActivityBarMoved();27});2829await app.code.dispatchKeybinding('PageUp', async () => {30await app.workbench.search.hasActivityBarMoved();31});32});3334it('searches for body & checks for correct result number', async function () {35const app = this.app as Application;36await app.workbench.search.openSearchViewlet();37await app.workbench.search.searchFor('body');3839await app.workbench.search.waitForResultText('6 results in 3 files');40});4142it('searches only for *.js files & checks for correct result number', async function () {43const app = this.app as Application;44try {45await app.workbench.search.setFilesToIncludeText('*.js');46await app.workbench.search.searchFor('body');47await app.workbench.search.showQueryDetails();4849await app.workbench.search.waitForResultText('4 results in 1 file');50} finally {51await app.workbench.search.setFilesToIncludeText('');52await app.workbench.search.hideQueryDetails();53}54});5556it('dismisses result & checks for correct result number', async function () {57const app = this.app as Application;58await app.workbench.search.searchFor('body');59await app.workbench.search.waitForResultText('6 results in 3 files');60await app.workbench.search.removeFileMatch('app.js', '2 results in 2 files');61});6263it.skip('replaces first search result with a replace term', async function () { // TODO@roblourens https://github.com/microsoft/vscode/issues/13719564const app = this.app as Application;6566await app.workbench.search.searchFor('body');67await app.workbench.search.waitForResultText('6 results in 3 files');68await app.workbench.search.expandReplace();69await app.workbench.search.setReplaceText('ydob');70await app.workbench.search.replaceFileMatch('app.js', '2 results in 2 files');7172await app.workbench.search.searchFor('ydob');73await app.workbench.search.waitForResultText('4 results in 1 file');74await app.workbench.search.setReplaceText('body');75await app.workbench.search.replaceFileMatch('app.js', '0 results in 0 files');76await app.workbench.search.waitForResultText('0 results in 0 files');77});78});7980describe('Quick Open', () => {8182// Shared before/after handling83installAllHandlers(logger);8485it('quick open search produces correct result', async function () {86const app = this.app as Application;87const expectedNames = [88'.eslintrc.json',89'tasks.json',90'settings.json',91'app.js',92'index.js',93'users.js',94'package.json',95'jsconfig.json'96];9798await app.workbench.quickaccess.openFileQuickAccessAndWait('.js', 8);99await app.workbench.quickinput.waitForQuickInputElements(names => expectedNames.every(expectedName => names.some(name => expectedName === name)));100await app.workbench.quickinput.closeQuickInput();101});102103it('quick open respects fuzzy matching', async function () {104const app = this.app as Application;105const expectedNames = [106'tasks.json',107'app.js',108'package.json'109];110111await app.workbench.quickaccess.openFileQuickAccessAndWait('a.s', 3);112await app.workbench.quickinput.waitForQuickInputElements(names => expectedNames.every(expectedName => names.some(name => expectedName === name)));113await app.workbench.quickinput.closeQuickInput();114});115});116}117118119