mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-30 01:25:38 -05:00
* Fix initial build breaks from 1.67 merge (#2514) * Update yarn lock files * Update build scripts * Fix tsconfig * Build breaks * WIP * Update yarn lock files * Misc breaks * Updates to package.json * Breaks * Update yarn * Fix breaks * Breaks * Build breaks * Breaks * Breaks * Breaks * Breaks * Breaks * Missing file * Breaks * Breaks * Breaks * Breaks * Breaks * Fix several runtime breaks (#2515) * Missing files * Runtime breaks * Fix proxy ordering issue * Remove commented code * Fix breaks with opening query editor * Fix post merge break * Updates related to setup build and other breaks (#2516) * Fix bundle build issues * Update distro * Fix distro merge and update build JS files * Disable pipeline steps * Remove stats call * Update license name * Make new RPM dependencies a warning * Fix extension manager version checks * Update JS file * Fix a few runtime breaks * Fixes * Fix runtime issues * Fix build breaks * Update notebook tests (part 1) * Fix broken tests * Linting errors * Fix hygiene * Disable lint rules * Bump distro * Turn off smoke tests * Disable integration tests * Remove failing "activate" test * Remove failed test assertion * Disable other broken test * Disable query history tests * Disable extension unit tests * Disable failing tasks
147 lines
4.8 KiB
TypeScript
147 lines
4.8 KiB
TypeScript
/*---------------------------------------------------------------------------------------------
|
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
|
*--------------------------------------------------------------------------------------------*/
|
|
|
|
import { Viewlet } from './viewlet';
|
|
import { Code } from './code';
|
|
|
|
const VIEWLET = '.search-view';
|
|
const INPUT = `${VIEWLET} .search-widget .search-container .monaco-inputbox textarea`;
|
|
const INCLUDE_INPUT = `${VIEWLET} .query-details .file-types.includes .monaco-inputbox input`;
|
|
const FILE_MATCH = (filename: string) => `${VIEWLET} .results .filematch[data-resource$="${filename}"]`;
|
|
|
|
async function retry(setup: () => Promise<any>, attempt: () => Promise<any>) {
|
|
let count = 0;
|
|
while (true) {
|
|
await setup();
|
|
|
|
try {
|
|
await attempt();
|
|
return;
|
|
} catch (err) {
|
|
if (++count > 5) {
|
|
throw err;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
export class Search extends Viewlet {
|
|
|
|
constructor(code: Code) {
|
|
super(code);
|
|
}
|
|
|
|
async clearSearchResults(): Promise<void> {
|
|
await retry(
|
|
() => this.code.waitAndClick(`.sidebar .codicon-search-clear-results`),
|
|
() => this.waitForNoResultText(10));
|
|
}
|
|
|
|
async openSearchViewlet(): Promise<any> {
|
|
if (process.platform === 'darwin') {
|
|
await this.code.dispatchKeybinding('cmd+shift+f');
|
|
} else {
|
|
await this.code.dispatchKeybinding('ctrl+shift+f');
|
|
}
|
|
|
|
await this.waitForInputFocus(INPUT);
|
|
}
|
|
|
|
async getSearchTooltip(): Promise<any> {
|
|
const icon = await this.code.waitForElement(`.activitybar .action-label.codicon.codicon-search-view-icon`, (el) => !!el?.attributes?.['title']);
|
|
return icon.attributes['title'];
|
|
}
|
|
|
|
async searchFor(text: string): Promise<void> {
|
|
await this.clearSearchResults();
|
|
await this.waitForInputFocus(INPUT);
|
|
await this.code.waitForSetValue(INPUT, text);
|
|
await this.submitSearch();
|
|
}
|
|
|
|
async submitSearch(): Promise<void> {
|
|
await this.waitForInputFocus(INPUT);
|
|
|
|
await this.code.dispatchKeybinding('enter');
|
|
await this.code.waitForElement(`${VIEWLET} .messages`);
|
|
}
|
|
|
|
async setFilesToIncludeText(text: string): Promise<void> {
|
|
await this.waitForInputFocus(INCLUDE_INPUT);
|
|
await this.code.waitForSetValue(INCLUDE_INPUT, text || '');
|
|
}
|
|
|
|
async showQueryDetails(): Promise<void> {
|
|
await this.code.waitAndClick(`${VIEWLET} .query-details .more`);
|
|
}
|
|
|
|
async hideQueryDetails(): Promise<void> {
|
|
await this.code.waitAndClick(`${VIEWLET} .query-details.more .more`);
|
|
}
|
|
|
|
async removeFileMatch(filename: string, expectedText: string): Promise<void> {
|
|
const fileMatch = FILE_MATCH(filename);
|
|
|
|
// Retry this because the click can fail if the search tree is rerendered at the same time
|
|
await retry(
|
|
async () => {
|
|
await this.code.waitAndClick(fileMatch);
|
|
await this.code.waitAndClick(`${fileMatch} .action-label.codicon-search-remove`);
|
|
},
|
|
async () => this.waitForResultText(expectedText, 10));
|
|
}
|
|
|
|
async expandReplace(): Promise<void> {
|
|
await this.code.waitAndClick(`${VIEWLET} .search-widget .monaco-button.toggle-replace-button.codicon-search-hide-replace`);
|
|
}
|
|
|
|
async collapseReplace(): Promise<void> {
|
|
await this.code.waitAndClick(`${VIEWLET} .search-widget .monaco-button.toggle-replace-button.codicon-search-show-replace`);
|
|
}
|
|
|
|
async setReplaceText(text: string): Promise<void> {
|
|
await this.code.waitForSetValue(`${VIEWLET} .search-widget .replace-container .monaco-inputbox textarea[title="Replace"]`, text);
|
|
}
|
|
|
|
async replaceFileMatch(filename: string, expectedText: string): Promise<void> {
|
|
const fileMatch = FILE_MATCH(filename);
|
|
|
|
// Retry this because the click can fail if the search tree is rerendered at the same time
|
|
await retry(
|
|
async () => {
|
|
await this.code.waitAndClick(fileMatch);
|
|
await this.code.waitAndClick(`${fileMatch} .action-label.codicon.codicon-search-replace-all`);
|
|
},
|
|
() => this.waitForResultText(expectedText, 10));
|
|
}
|
|
|
|
async waitForResultText(text: string, retryCount?: number): Promise<void> {
|
|
// The label can end with " - " depending on whether the search editor is enabled
|
|
await this.code.waitForTextContent(`${VIEWLET} .messages .message`, undefined, result => result.startsWith(text), retryCount);
|
|
}
|
|
|
|
async waitForNoResultText(retryCount?: number): Promise<void> {
|
|
await this.code.waitForTextContent(`${VIEWLET} .messages`, undefined, text => text === '' || text.startsWith('Search was canceled before any results could be found'), retryCount);
|
|
}
|
|
|
|
private async waitForInputFocus(selector: string): Promise<void> {
|
|
let retries = 0;
|
|
|
|
// other parts of code might steal focus away from input boxes :(
|
|
while (retries < 5) {
|
|
await this.code.waitAndClick(INPUT, 2, 2);
|
|
|
|
try {
|
|
await this.code.waitForActiveElement(INPUT, 10);
|
|
break;
|
|
} catch (err) {
|
|
if (++retries > 5) {
|
|
throw err;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|