Merge from vscode 79a1f5a5ca0c6c53db617aa1fa5a2396d2caebe2

This commit is contained in:
ADS Merger
2020-05-31 19:47:51 +00:00
parent 84492049e8
commit 28be33cfea
913 changed files with 28242 additions and 15549 deletions

View File

@@ -148,11 +148,7 @@ export async function spawn(options: SpawnOptions): Promise<Code> {
if (codePath) {
// running against a build: copy the test resolver extension
const testResolverExtPath = path.join(options.extensionsPath, 'vscode-test-resolver');
if (!fs.existsSync(testResolverExtPath)) {
const orig = path.join(repoPath, 'extensions', 'vscode-test-resolver');
await new Promise((c, e) => ncp(orig, testResolverExtPath, err => err ? e(err) : c()));
}
copyExtension(options, 'vscode-test-resolver');
}
args.push('--enable-proposed-api=vscode.vscode-test-resolver');
const remoteDataDir = `${options.userDataDir}-server`;
@@ -160,6 +156,9 @@ export async function spawn(options: SpawnOptions): Promise<Code> {
env['TESTRESOLVER_DATA_FOLDER'] = remoteDataDir;
}
copyExtension(options, 'vscode-notebook-tests');
args.push('--enable-proposed-api=vscode.vscode-notebook-tests');
if (!codePath) {
args.unshift(repoPath);
}
@@ -185,6 +184,14 @@ export async function spawn(options: SpawnOptions): Promise<Code> {
return connect(connectDriver, child, outPath, handle, options.logger);
}
async function copyExtension(options: SpawnOptions, extId: string): Promise<void> {
const testResolverExtPath = path.join(options.extensionsPath, extId);
if (!fs.existsSync(testResolverExtPath)) {
const orig = path.join(repoPath, 'extensions', extId);
await new Promise((c, e) => ncp(orig, testResolverExtPath, err => err ? e(err) : c()));
}
}
async function poll<T>(
fn: () => Thenable<T>,
acceptFn: (result: T) => boolean,

View File

@@ -0,0 +1,92 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { Code } from './code';
import { QuickAccess } from './quickaccess';
const activeRowSelector = `.notebook-editor .monaco-list-row.focused`;
export class Notebook {
constructor(
private readonly quickAccess: QuickAccess,
private readonly code: Code) {
}
async openNotebook() {
await this.quickAccess.runCommand('vscode-notebook-tests.createNewNotebook');
await this.code.waitForElement(activeRowSelector);
await this.focusFirstCell();
await this.waitForActiveCellEditorContents('code()');
}
async focusNextCell() {
await this.code.dispatchKeybinding('down');
}
async focusFirstCell() {
await this.quickAccess.runCommand('notebook.focusTop');
}
async editCell() {
await this.code.dispatchKeybinding('enter');
}
async stopEditingCell() {
await this.code.dispatchKeybinding('esc');
}
async waitForTypeInEditor(text: string): Promise<any> {
const editor = `${activeRowSelector} .monaco-editor`;
await this.code.waitForElement(editor);
const textarea = `${editor} textarea`;
await this.code.waitForActiveElement(textarea);
await this.code.waitForTypeInEditor(textarea, text);
await this._waitForActiveCellEditorContents(c => c.indexOf(text) > -1);
}
async waitForActiveCellEditorContents(contents: string): Promise<any> {
return this._waitForActiveCellEditorContents(str => str === contents);
}
private async _waitForActiveCellEditorContents(accept: (contents: string) => boolean): Promise<any> {
const selector = `${activeRowSelector} .monaco-editor .view-lines`;
return this.code.waitForTextContent(selector, undefined, c => accept(c.replace(/\u00a0/g, ' ')));
}
async waitForMarkdownContents(markdownSelector: string, text: string): Promise<void> {
const selector = `${activeRowSelector} .markdown ${markdownSelector}`;
await this.code.waitForTextContent(selector, text);
}
async insertNotebookCell(kind: 'markdown' | 'code'): Promise<void> {
if (kind === 'markdown') {
await this.quickAccess.runCommand('notebook.cell.insertMarkdownCellBelow');
} else {
await this.quickAccess.runCommand('notebook.cell.insertCodeCellBelow');
}
}
async deleteActiveCell(): Promise<void> {
await this.quickAccess.runCommand('notebook.cell.delete');
}
async focusInCellOutput(): Promise<void> {
await this.quickAccess.runCommand('notebook.cell.focusInOutput');
await this.code.waitForActiveElement('webview, .webview');
}
async focusOutCellOutput(): Promise<void> {
await this.quickAccess.runCommand('notebook.cell.focusOutOutput');
}
async executeActiveCell(): Promise<void> {
await this.quickAccess.runCommand('notebook.cell.execute');
}
}

View File

@@ -25,7 +25,8 @@ const vscodeToPlaywrightKey: { [key: string]: string } = {
up: 'ArrowUp',
down: 'ArrowDown',
left: 'ArrowLeft',
home: 'Home'
home: 'Home',
esc: 'Escape'
};
function buildDriver(browser: playwright.Browser, page: playwright.Page): IDriver {
@@ -86,8 +87,6 @@ function timeout(ms: number): Promise<void> {
return new Promise<void>(r => setTimeout(r, ms));
}
// function runInDriver(call: string, args: (string | boolean)[]): Promise<any> {}
let server: ChildProcess | undefined;
let endpoint: string | undefined;
let workspacePath: string | undefined;
@@ -105,8 +104,10 @@ export async function launch(userDataDir: string, _workspacePath: string, extens
let serverLocation: string | undefined;
if (codeServerPath) {
serverLocation = join(codeServerPath, `server.${process.platform === 'win32' ? 'cmd' : 'sh'}`);
console.log(`Starting built server from '${serverLocation}'`);
} else {
serverLocation = join(__dirname, '..', '..', '..', `resources/server/web.${process.platform === 'win32' ? 'bat' : 'sh'}`);
console.log(`Starting server out of sources from '${serverLocation}'`);
}
server = spawn(
serverLocation,

View File

@@ -19,6 +19,7 @@ import { KeybindingsEditor } from './keybindings';
import { Editors } from './editors';
import { Code } from './code';
import { Terminal } from './terminal';
import { Notebook } from './notebook';
// {{SQL CARBON EDIT}}
import { ConnectionDialog } from './sql/connectionDialog';
@@ -48,6 +49,7 @@ export class Workbench {
readonly settingsEditor: SettingsEditor;
readonly keybindingsEditor: KeybindingsEditor;
readonly terminal: Terminal;
readonly notebook: Notebook;
// {{SQL CARBON EDIT}}
readonly connectionDialog: ConnectionDialog;
@@ -78,5 +80,6 @@ export class Workbench {
this.queryEditors = new QueryEditors(code);
this.queryEditor = new QueryEditor(code);
// {{END}}
this.notebook = new Notebook(this.quickaccess, code);
}
}