Skip to content

Commit

Permalink
smoke - improve runCommand and disable more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bpasero committed Dec 20, 2021
1 parent 807bf59 commit bb39ae8
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 36 deletions.
Expand Up @@ -44,7 +44,7 @@ suite('Notebook Editor', function () {
testDisposables.length = 0;
});

test('showNotebookDocment', async function () {
test.skip('showNotebookDocument', async function () { // TODO@rebornix https://github.com/microsoft/vscode/issues/139078

const notebookDocumentsFromOnDidOpen = new Set<vscode.NotebookDocument>();
const sub = vscode.workspace.onDidOpenNotebookDocument(e => {
Expand Down Expand Up @@ -86,7 +86,7 @@ suite('Notebook Editor', function () {
assert.strictEqual(editor.document.uri.toString(), resource.toString());
});

test('Active/Visible Editor', async function () {
test.skip('Active/Visible Editor', async function () { // TODO@rebornix https://github.com/microsoft/vscode/issues/139078
const firstEditorOpen = utils.asPromise(vscode.window.onDidChangeActiveNotebookEditor);
const resource = await utils.createRandomFile(undefined, undefined, '.nbdtest');
const firstEditor = await vscode.window.showNotebookDocument(resource);
Expand Down
3 changes: 2 additions & 1 deletion src/vs/platform/environment/test/node/nativeModules.test.ts
Expand Up @@ -5,12 +5,13 @@

import * as assert from 'assert';
import { isLinux, isWindows } from 'vs/base/common/platform';
import { flakySuite } from 'vs/base/test/common/testUtils';

function testErrorMessage(module: string): string {
return `Unable to load "${module}" dependency. It was probably not compiled for the right operating system architecture or had missing build tools.`;
}

suite('Native Modules (all platforms)', () => {
flakySuite('Native Modules (all platforms)', () => {

test('native-is-elevated', async () => {
const isElevated = await import('native-is-elevated');
Expand Down
61 changes: 30 additions & 31 deletions test/automation/src/quickaccess.ts
Expand Up @@ -8,6 +8,12 @@ import { Code } from './code';
import { QuickInput } from './quickinput';
import { basename, isAbsolute } from 'path';

enum QuickAccessKind {
Files = 1,
Commands,
Symbols
}

export class QuickAccess {

constructor(private code: Code, private editors: Editors, private quickInput: QuickInput) { }
Expand All @@ -30,7 +36,7 @@ export class QuickAccess {
let retry = false;

try {
await this.openFileQuickAccess(searchValue);
await this.openQuickAccessWithRetry(QuickAccessKind.Files, searchValue);
await this.quickInput.waitForQuickInputElements(elementNames => {
this.code.logger.log('QuickAccess: resulting elements: ', elementNames);

Expand Down Expand Up @@ -125,36 +131,49 @@ export class QuickAccess {
await this.editors.selectTab(fileName);
}

private async openFileQuickAccess(value: string): Promise<void> {
private async openQuickAccessWithRetry(kind: QuickAccessKind, value?: string): Promise<void> {
let retries = 0;

// other parts of code might steal focus away from quickinput :(
// Other parts of code might steal focus away from quickinput :(
while (retries < 5) {
if (process.platform === 'darwin') {
await this.code.dispatchKeybinding('cmd+p');
} else {
await this.code.dispatchKeybinding('ctrl+p');

// Open via keybinding
switch (kind) {
case QuickAccessKind.Files:
await this.code.dispatchKeybinding(process.platform === 'darwin' ? 'cmd+p' : 'ctrl+p');
break;
case QuickAccessKind.Symbols:
await this.code.dispatchKeybinding(process.platform === 'darwin' ? 'cmd+shift+o' : 'ctrl+shift+o');
break;
case QuickAccessKind.Commands:
await this.code.dispatchKeybinding(process.platform === 'darwin' ? 'cmd+shift+p' : 'ctrl+shift+p');
break;
}

// Await for quick input widget opened
try {
await this.quickInput.waitForQuickInputOpened(10);
break;
} catch (err) {
if (++retries > 5) {
throw err;
throw new Error(`QuickAccess.openQuickAccessWithRetry(kind: ${kind}) failed: ${err}`);
}

// Retry
await this.code.dispatchKeybinding('escape');
}
}

await this.quickInput.type(value);
// Type value if any
if (value) {
await this.quickInput.type(value);
}
}

async runCommand(commandId: string, keepOpen?: boolean): Promise<void> {

// open commands picker
await this.openCommands(`>${commandId}`);
await this.openQuickAccessWithRetry(QuickAccessKind.Commands, `>${commandId}`);

// wait for best choice to be focused
await this.quickInput.waitForQuickInputElementFocused();
Expand All @@ -163,33 +182,13 @@ export class QuickAccess {
await this.quickInput.selectQuickInputElement(0, keepOpen);
}

private async openCommands(value: string): Promise<void> {

// open commands via keybinding
if (process.platform === 'darwin') {
await this.code.dispatchKeybinding('cmd+shift+p');
} else {
await this.code.dispatchKeybinding('ctrl+shift+p');
}

// wait for commands
await this.quickInput.waitForQuickInputElementFocused();

// narrow down to provided value
await this.quickInput.type(value);
}

async openQuickOutline(): Promise<void> {
let retries = 0;

while (++retries < 10) {

// open quick outline via keybinding
if (process.platform === 'darwin') {
await this.code.dispatchKeybinding('cmd+shift+o');
} else {
await this.code.dispatchKeybinding('ctrl+shift+o');
}
await this.openQuickAccessWithRetry(QuickAccessKind.Symbols);

const text = await this.quickInput.waitForQuickInputElementText();

Expand Down
2 changes: 1 addition & 1 deletion test/smoke/src/areas/search/search.test.ts
Expand Up @@ -55,7 +55,7 @@ export function setup(logger: Logger) {
await app.workbench.search.removeFileMatch('app.js', '12 results in 4 files');
});

it('replaces first search result with a replace term', async function () {
it.skip('replaces first search result with a replace term', async function () { // TODo@roblourens https://github.com/microsoft/vscode/issues/137195
const app = this.app as Application;

await app.workbench.search.searchFor('body');
Expand Down
3 changes: 2 additions & 1 deletion test/smoke/src/areas/terminal/terminal-input.test.ts
Expand Up @@ -4,6 +4,7 @@
*--------------------------------------------------------------------------------------------*/

import { Application, Terminal, SettingsEditor } from '../../../../automation';
import { itSkipOnFail } from '../../utils';

export function setup() {
describe('Terminal Input', () => {
Expand All @@ -24,7 +25,7 @@ export function setup() {
await terminal.runCommandInTerminal(`"\r${text}`, true);
}

it('should automatically reply to default "Terminate batch job (Y/N)"', async () => {
itSkipOnFail('should automatically reply to default "Terminate batch job (Y/N)"', async () => { // TODO@daniel https://github.com/microsoft/vscode/issues/139076
await terminal.createTerminal();
await writeTextForAutoReply('Terminate batch job (Y/N)?');
await terminal.waitForTerminalText(buffer => buffer.some(line => line.match(/\?.*Y/)));
Expand Down

0 comments on commit bb39ae8

Please sign in to comment.