mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-03-12 12:01:37 -04:00
Merge from vscode 8df646d3c5477b02737fc10343fa7cf0cc3f606b
This commit is contained in:
@@ -9,10 +9,19 @@ export class QuickInput {
|
||||
|
||||
static QUICK_INPUT = '.quick-input-widget';
|
||||
static QUICK_INPUT_INPUT = `${QuickInput.QUICK_INPUT} .quick-input-box input`;
|
||||
static QUICK_INPUT_FOCUSED_ELEMENT = `${QuickInput.QUICK_INPUT} .quick-open-tree .monaco-tree-row.focused .monaco-highlighted-label`;
|
||||
static QUICK_INPUT_ROW = `${QuickInput.QUICK_INPUT} .quick-input-list .monaco-list-row`;
|
||||
static QUICK_INPUT_FOCUSED_ELEMENT = `${QuickInput.QUICK_INPUT_ROW}.focused .monaco-highlighted-label`;
|
||||
static QUICK_INPUT_ENTRY_LABEL = `${QuickInput.QUICK_INPUT_ROW} .label-name`;
|
||||
static QUICK_INPUT_ENTRY_LABEL_SPAN = `${QuickInput.QUICK_INPUT_ROW} .monaco-highlighted-label span`;
|
||||
|
||||
constructor(private code: Code) { }
|
||||
|
||||
async submit(text: string): Promise<void> {
|
||||
await this.code.waitForSetValue(QuickInput.QUICK_INPUT_INPUT, text);
|
||||
await this.code.dispatchKeybinding('enter');
|
||||
await this.waitForQuickInputClosed();
|
||||
}
|
||||
|
||||
async closeQuickInput(): Promise<void> {
|
||||
await this.code.dispatchKeybinding('escape');
|
||||
await this.waitForQuickInputClosed();
|
||||
@@ -22,7 +31,11 @@ export class QuickInput {
|
||||
await this.code.waitForActiveElement(QuickInput.QUICK_INPUT_INPUT, retryCount);
|
||||
}
|
||||
|
||||
private async waitForQuickInputClosed(): Promise<void> {
|
||||
async waitForQuickInputElements(accept: (names: string[]) => boolean): Promise<void> {
|
||||
await this.code.waitForElements(QuickInput.QUICK_INPUT_ENTRY_LABEL, false, els => accept(els.map(e => e.textContent)));
|
||||
}
|
||||
|
||||
async waitForQuickInputClosed(): Promise<void> {
|
||||
await this.code.waitForElement(QuickInput.QUICK_INPUT, r => !!r && r.attributes.style.indexOf('display: none;') !== -1);
|
||||
}
|
||||
|
||||
|
||||
@@ -5,17 +5,11 @@
|
||||
|
||||
import { Editors } from './editors';
|
||||
import { Code } from './code';
|
||||
import { QuickInput } from './quickinput';
|
||||
|
||||
export class QuickOpen {
|
||||
|
||||
static QUICK_OPEN = 'div.monaco-quick-open-widget';
|
||||
static QUICK_OPEN_HIDDEN = 'div.monaco-quick-open-widget[aria-hidden="true"]';
|
||||
static QUICK_OPEN_INPUT = `${QuickOpen.QUICK_OPEN} .quick-open-input input`;
|
||||
static QUICK_OPEN_FOCUSED_ELEMENT = `${QuickOpen.QUICK_OPEN} .quick-open-tree .monaco-tree-row.focused .monaco-highlighted-label`;
|
||||
static QUICK_OPEN_ENTRY_SELECTOR = 'div[aria-label="Quick Picker"] .monaco-tree-rows.show-twisties .monaco-tree-row .quick-open-entry';
|
||||
static QUICK_OPEN_ENTRY_LABEL_SELECTOR = 'div[aria-label="Quick Picker"] .monaco-tree-rows.show-twisties .monaco-tree-row .quick-open-entry .label-name';
|
||||
|
||||
constructor(private code: Code, private editors: Editors) { }
|
||||
constructor(private code: Code, private editors: Editors, private quickInput: QuickInput) { }
|
||||
|
||||
async openQuickOpen(value: string): Promise<void> {
|
||||
let retries = 0;
|
||||
@@ -29,7 +23,7 @@ export class QuickOpen {
|
||||
}
|
||||
|
||||
try {
|
||||
await this.waitForQuickOpenOpened(10);
|
||||
await this.quickInput.waitForQuickInputOpened(10);
|
||||
break;
|
||||
} catch (err) {
|
||||
if (++retries > 5) {
|
||||
@@ -41,59 +35,27 @@ export class QuickOpen {
|
||||
}
|
||||
|
||||
if (value) {
|
||||
await this.code.waitForSetValue(QuickOpen.QUICK_OPEN_INPUT, value);
|
||||
await this.code.waitForSetValue(QuickInput.QUICK_INPUT_INPUT, value);
|
||||
}
|
||||
}
|
||||
|
||||
async closeQuickOpen(): Promise<void> {
|
||||
await this.code.dispatchKeybinding('escape');
|
||||
await this.waitForQuickOpenClosed();
|
||||
}
|
||||
|
||||
async openFile(fileName: string): Promise<void> {
|
||||
await this.openQuickOpen(fileName);
|
||||
|
||||
await this.waitForQuickOpenElements(names => names[0] === fileName);
|
||||
await this.quickInput.waitForQuickInputElements(names => names[0] === fileName);
|
||||
await this.code.dispatchKeybinding('enter');
|
||||
await this.editors.waitForActiveTab(fileName);
|
||||
await this.editors.waitForEditorFocus(fileName);
|
||||
}
|
||||
|
||||
async waitForQuickOpenOpened(retryCount?: number): Promise<void> {
|
||||
await this.code.waitForActiveElement(QuickOpen.QUICK_OPEN_INPUT, retryCount);
|
||||
}
|
||||
|
||||
private async waitForQuickOpenClosed(): Promise<void> {
|
||||
await this.code.waitForElement(QuickOpen.QUICK_OPEN_HIDDEN);
|
||||
}
|
||||
|
||||
async submit(text: string): Promise<void> {
|
||||
await this.code.waitForSetValue(QuickOpen.QUICK_OPEN_INPUT, text);
|
||||
await this.code.dispatchKeybinding('enter');
|
||||
await this.waitForQuickOpenClosed();
|
||||
}
|
||||
|
||||
async selectQuickOpenElement(index: number): Promise<void> {
|
||||
await this.waitForQuickOpenOpened();
|
||||
for (let from = 0; from < index; from++) {
|
||||
await this.code.dispatchKeybinding('down');
|
||||
}
|
||||
await this.code.dispatchKeybinding('enter');
|
||||
await this.waitForQuickOpenClosed();
|
||||
}
|
||||
|
||||
async waitForQuickOpenElements(accept: (names: string[]) => boolean): Promise<void> {
|
||||
await this.code.waitForElements(QuickOpen.QUICK_OPEN_ENTRY_LABEL_SELECTOR, false, els => accept(els.map(e => e.textContent)));
|
||||
}
|
||||
|
||||
async runCommand(command: string): Promise<void> {
|
||||
await this.openQuickOpen(`> ${command}`);
|
||||
async runCommand(commandId: string): Promise<void> {
|
||||
await this.openQuickOpen(`>${commandId}`);
|
||||
|
||||
// wait for best choice to be focused
|
||||
await this.code.waitForTextContent(QuickOpen.QUICK_OPEN_FOCUSED_ELEMENT, command);
|
||||
await this.code.waitForTextContent(QuickInput.QUICK_INPUT_FOCUSED_ELEMENT);
|
||||
|
||||
// wait and click on best choice
|
||||
await this.code.waitAndClick(QuickOpen.QUICK_OPEN_FOCUSED_ELEMENT);
|
||||
await this.quickInput.selectQuickInputElement(0);
|
||||
}
|
||||
|
||||
async openQuickOutline(): Promise<void> {
|
||||
@@ -106,13 +68,13 @@ export class QuickOpen {
|
||||
await this.code.dispatchKeybinding('ctrl+shift+o');
|
||||
}
|
||||
|
||||
const text = await this.code.waitForTextContent('div[aria-label="Quick Picker"] .monaco-tree-rows.show-twisties div.monaco-tree-row .quick-open-entry .monaco-icon-label .label-name .monaco-highlighted-label span');
|
||||
const text = await this.code.waitForTextContent(QuickInput.QUICK_INPUT_ENTRY_LABEL_SPAN);
|
||||
|
||||
if (text !== 'No symbol information for the file') {
|
||||
return;
|
||||
}
|
||||
|
||||
await this.closeQuickOpen();
|
||||
await this.quickInput.closeQuickInput();
|
||||
await new Promise(c => setTimeout(c, 250));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,6 +32,6 @@ export class SettingsEditor {
|
||||
}
|
||||
|
||||
private async openSettings(): Promise<void> {
|
||||
await this.quickopen.runCommand('Preferences: Open Settings (JSON)');
|
||||
await this.quickopen.runCommand('workbench.action.openSettingsJson');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,32 +4,16 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { Editors } from '../editors';
|
||||
import { QuickOpen } from '../quickopen';
|
||||
import { Code } from '../code';
|
||||
import * as path from 'path';
|
||||
|
||||
export class QueryEditors extends Editors {
|
||||
|
||||
constructor(
|
||||
private vsCode: Code,
|
||||
private quickopen: QuickOpen
|
||||
private vsCode: Code
|
||||
) {
|
||||
super(vsCode);
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens the specified file - this correctly handles SQL files which are opened in a Query Editor window
|
||||
* @param filePath The full path of the file to open.
|
||||
*/
|
||||
async openFile(filePath: string): Promise<void> {
|
||||
await this.quickopen.openQuickOpen(filePath);
|
||||
|
||||
const fileBaseName = path.basename(filePath);
|
||||
await this.quickopen.waitForQuickOpenElements(names => names[0] === fileBaseName);
|
||||
await this.vsCode.dispatchKeybinding('enter');
|
||||
await this.waitForEditorFocus(fileBaseName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Waits for an active SQL Query Editor tab for the specified file. This is a modification of the editors.waitForActiveTab that
|
||||
* takes into account the connected status displayed in the title of Query Editors.
|
||||
@@ -41,7 +25,6 @@ export class QueryEditors extends Editors {
|
||||
await this.vsCode.waitForElement(`.tabs-container div.tab.active${isDirty ? '.dirty' : ''}[aria-selected="true"][aria-label="${fileName} - disconnected, tab"]`);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Waits for an active Query Editor for the specified file to have focus. This is a modification of the editors.waitForEditorFocus
|
||||
* that takes into account the connected status displayed in the title of Query Editors.
|
||||
|
||||
@@ -15,7 +15,7 @@ export class Terminal {
|
||||
constructor(private code: Code, private quickopen: QuickOpen) { }
|
||||
|
||||
async showTerminal(): Promise<void> {
|
||||
await this.quickopen.runCommand('View: Toggle Integrated Terminal');
|
||||
await this.quickopen.runCommand('workbench.action.terminal.toggleTerminal');
|
||||
await this.code.waitForActiveElement(XTERM_TEXTAREA);
|
||||
await this.code.waitForTerminalBuffer(XTERM_SELECTOR, lines => lines.some(line => line.length > 0));
|
||||
}
|
||||
|
||||
@@ -56,8 +56,8 @@ export class Workbench {
|
||||
|
||||
constructor(code: Code, userDataPath: string) {
|
||||
this.editors = new Editors(code);
|
||||
this.quickopen = new QuickOpen(code, this.editors);
|
||||
this.quickinput = new QuickInput(code);
|
||||
this.quickopen = new QuickOpen(code, this.editors, this.quickinput);
|
||||
this.explorer = new Explorer(code, this.editors);
|
||||
this.activitybar = new ActivityBar(code);
|
||||
this.search = new Search(code);
|
||||
@@ -73,7 +73,7 @@ export class Workbench {
|
||||
// {{SQL CARBON EDIT}}
|
||||
this.connectionDialog = new ConnectionDialog(code);
|
||||
this.profiler = new Profiler(code, this.quickopen);
|
||||
this.queryEditors = new QueryEditors(code, this.quickopen);
|
||||
this.queryEditors = new QueryEditors(code);
|
||||
// {{END}}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ export function setup() {
|
||||
await app.workbench.quickopen.openFile('www');
|
||||
|
||||
await app.workbench.quickopen.openQuickOutline();
|
||||
await app.workbench.quickopen.waitForQuickOpenElements(names => names.length >= 6);
|
||||
await app.workbench.quickinput.waitForQuickInputElements(names => names.length >= 6);
|
||||
});
|
||||
|
||||
// it('folds/unfolds the code correctly', async function () {
|
||||
|
||||
@@ -12,7 +12,7 @@ export function setup() {
|
||||
await app.workbench.quickopen.openFile('style.css');
|
||||
|
||||
await app.workbench.quickopen.openQuickOutline();
|
||||
await app.workbench.quickopen.waitForQuickOpenElements(names => names.length === 2);
|
||||
await app.workbench.quickinput.waitForQuickInputElements(names => names.length === 2);
|
||||
});
|
||||
|
||||
it('verifies problems view', async function () {
|
||||
|
||||
@@ -47,8 +47,8 @@ export function setup() {
|
||||
const app = this.app as Application;
|
||||
await app.workbench.quickopen.openQuickOpen('*.*');
|
||||
|
||||
await app.workbench.quickopen.waitForQuickOpenElements(names => names.length === 6);
|
||||
await app.workbench.quickopen.closeQuickOpen();
|
||||
await app.workbench.quickinput.waitForQuickInputElements(names => names.length === 6);
|
||||
await app.workbench.quickinput.closeQuickInput();
|
||||
});
|
||||
|
||||
it('shows workspace name in title', async function () {
|
||||
|
||||
@@ -10,8 +10,8 @@ export function setup() {
|
||||
describe('Search', () => {
|
||||
after(function () {
|
||||
const app = this.app as Application;
|
||||
cp.execSync('git checkout .', { cwd: app.workspacePathOrFolder });
|
||||
cp.execSync('git reset --hard origin/master', { cwd: app.workspacePathOrFolder });
|
||||
cp.execSync('git checkout . --quiet', { cwd: app.workspacePathOrFolder });
|
||||
cp.execSync('git reset --hard origin/master --quiet', { cwd: app.workspacePathOrFolder });
|
||||
});
|
||||
|
||||
it('searches for body & checks for correct result number', async function () {
|
||||
@@ -71,7 +71,7 @@ export function setup() {
|
||||
];
|
||||
|
||||
await app.workbench.quickopen.openQuickOpen('.js');
|
||||
await app.workbench.quickopen.waitForQuickOpenElements(names => expectedNames.every(n => names.some(m => n === m)));
|
||||
await app.workbench.quickinput.waitForQuickInputElements(names => expectedNames.every(n => names.some(m => n === m)));
|
||||
await app.code.dispatchKeybinding('escape');
|
||||
});
|
||||
|
||||
@@ -84,7 +84,7 @@ export function setup() {
|
||||
];
|
||||
|
||||
await app.workbench.quickopen.openQuickOpen('a.s');
|
||||
await app.workbench.quickopen.waitForQuickOpenElements(names => expectedNames.every(n => names.some(m => n === m)));
|
||||
await app.workbench.quickinput.waitForQuickInputElements(names => expectedNames.every(n => names.some(m => n === m)));
|
||||
await app.code.dispatchKeybinding('escape');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -77,9 +77,9 @@ export function setup(isWeb) {
|
||||
await app.workbench.quickopen.openFile('app.js');
|
||||
await app.workbench.statusbar.clickOn(StatusBarElement.SELECTION_STATUS);
|
||||
|
||||
await app.workbench.quickopen.waitForQuickOpenOpened();
|
||||
await app.workbench.quickinput.waitForQuickInputOpened();
|
||||
|
||||
await app.workbench.quickopen.submit(':15');
|
||||
await app.workbench.quickinput.submit(':15');
|
||||
await app.workbench.editor.waitForHighlightingLine('app.js', 15);
|
||||
});
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ export function setup() {
|
||||
await fs.writeFile(testFilePath, '');
|
||||
try {
|
||||
const app = this.app as Application;
|
||||
await app.workbench.queryEditors.openFile(testFilePath);
|
||||
await app.workbench.quickopen.openFile(testFilePath);
|
||||
const fileBaseName = path.basename(testFilePath);
|
||||
await app.workbench.editor.waitForTypeInEditor(fileBaseName, 'SELECT * FROM sys.tables');
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
./scripts/test.[sh|bat]
|
||||
|
||||
All unit tests are run inside a electron-browser environment which access to DOM and Nodejs api. This is the closest to the enviroment in which VS Code itself ships. Notes:
|
||||
All unit tests are run inside a electron-browser environment which access to DOM and Nodejs api. This is the closest to the environment in which VS Code itself ships. Notes:
|
||||
|
||||
- use the `--debug` to see an electron window with dev tools which allows for debugging
|
||||
- to run only a subset of tests use the `--run` or `--glob` options
|
||||
|
||||
Reference in New Issue
Block a user