Merge vscode 1.67 (#20883)

* 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
This commit is contained in:
Karl Burtram
2022-10-19 19:13:18 -07:00
committed by GitHub
parent 33c6daaea1
commit 8a3d08f0de
3738 changed files with 192313 additions and 107208 deletions

View File

@@ -1,23 +0,0 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import minimist = require('minimist');
import { Application } from '../../../../automation';
import { afterSuite, beforeSuite } from '../../utils';
export function setup(opts: minimist.ParsedArgs) {
describe('Editor', () => {
beforeSuite(opts);
afterSuite(opts);
it('shows correct quick outline', async function () {
const app = this.app as Application;
await app.workbench.quickaccess.openFile('www');
await app.workbench.quickaccess.openQuickOutline();
await app.workbench.quickinput.waitForQuickInputElements(names => names.length >= 6);
});
});
}

View File

@@ -3,24 +3,19 @@
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import minimist = require('minimist');
import { Application, Quality } from '../../../../automation';
import { afterSuite, beforeSuite } from '../../utils';
import { Application, Logger } from '../../../../automation';
import { installAllHandlers } from '../../utils';
export function setup(opts: minimist.ParsedArgs) {
export function setup(logger: Logger) {
describe('Extensions', () => {
beforeSuite(opts);
afterSuite(opts);
it(`install and enable vscode-smoketest-check extension`, async function () {
// Shared before/after handling
installAllHandlers(logger);
it('install and enable vscode-smoketest-check extension', async function () {
const app = this.app as Application;
if (app.quality === Quality.Dev) {
this.skip();
}
await app.workbench.extensions.openExtensionsViewlet();
await app.workbench.extensions.installExtension('ms-vscode.vscode-smoketest-check', true);
// Close extension editor because keybindings dispatch is not working when web views are opened and focused
@@ -29,6 +24,5 @@ export function setup(opts: minimist.ParsedArgs) {
await app.workbench.quickaccess.runCommand('Smoke Test Check');
});
});
}

View File

@@ -3,26 +3,37 @@
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import minimist = require('minimist');
import { Application, ProblemSeverity, Problems } from '../../../../automation/out';
import { afterSuite, beforeSuite } from '../../utils';
import { join } from 'path';
import { Application, ProblemSeverity, Problems, Logger } from '../../../../automation';
import { installAllHandlers } from '../../utils';
export function setup(opts: minimist.ParsedArgs) {
export function setup(logger: Logger) {
describe('Language Features', () => {
beforeSuite(opts);
afterSuite(opts);
it('verifies quick outline', async function () {
// Shared before/after handling
installAllHandlers(logger);
it('verifies quick outline (js)', async function () {
const app = this.app as Application;
await app.workbench.quickaccess.openFile('style.css');
await app.workbench.quickaccess.openFile(join(app.workspacePathOrFolder, 'bin', 'www'));
await app.workbench.quickaccess.openQuickOutline();
await app.workbench.quickinput.waitForQuickInputElements(names => names.length >= 6);
await app.workbench.quickinput.closeQuickInput();
});
it('verifies quick outline (css)', async function () {
const app = this.app as Application;
await app.workbench.quickaccess.openFile(join(app.workspacePathOrFolder, 'public', 'stylesheets', 'style.css'));
await app.workbench.quickaccess.openQuickOutline();
await app.workbench.quickinput.waitForQuickInputElements(names => names.length === 2);
await app.workbench.quickinput.closeQuickInput();
});
it('verifies problems view', async function () {
it('verifies problems view (css)', async function () {
const app = this.app as Application;
await app.workbench.quickaccess.openFile('style.css');
await app.workbench.quickaccess.openFile(join(app.workspacePathOrFolder, 'public', 'stylesheets', 'style.css'));
await app.workbench.editor.waitForTypeInEditor('style.css', '.foo{}');
await app.code.waitForElement(Problems.getSelectorInEditor(ProblemSeverity.WARNING));
@@ -32,10 +43,10 @@ export function setup(opts: minimist.ParsedArgs) {
await app.workbench.problems.hideProblemsView();
});
it('verifies settings', async function () {
it('verifies settings (css)', async function () {
const app = this.app as Application;
await app.workbench.settingsEditor.addUserSetting('css.lint.emptyRules', '"error"');
await app.workbench.quickaccess.openFile('style.css');
await app.workbench.quickaccess.openFile(join(app.workspacePathOrFolder, 'public', 'stylesheets', 'style.css'));
await app.code.waitForElement(Problems.getSelectorInEditor(ProblemSeverity.ERROR));

View File

@@ -3,11 +3,10 @@
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as fs from 'fs';
import minimist = require('minimist');
import * as path from 'path';
import { Application } from '../../../../automation';
import { afterSuite, beforeSuite } from '../../utils';
import { writeFileSync } from 'fs';
import { join, dirname } from 'path';
import { Application, Logger } from '../../../../automation';
import { installAllHandlers } from '../../utils';
function toUri(path: string): string {
if (process.platform === 'win32') {
@@ -17,44 +16,59 @@ function toUri(path: string): string {
return `${path}`;
}
async function createWorkspaceFile(workspacePath: string): Promise<string> {
const workspaceFilePath = path.join(path.dirname(workspacePath), 'smoketest.code-workspace');
function createWorkspaceFile(workspacePath: string): string {
const workspaceFilePath = join(dirname(workspacePath), 'smoketest.code-workspace');
const workspace = {
folders: [
{ path: toUri(path.join(workspacePath, 'public')) },
{ path: toUri(path.join(workspacePath, 'routes')) },
{ path: toUri(path.join(workspacePath, 'views')) }
{ path: toUri(join(workspacePath, 'public')) },
{ path: toUri(join(workspacePath, 'routes')) },
{ path: toUri(join(workspacePath, 'views')) }
],
settings: {
'workbench.startupEditor': 'none',
'workbench.enableExperiments': false
'workbench.enableExperiments': false,
'typescript.disableAutomaticTypeAcquisition': true,
'json.schemaDownload.enable': false,
'npm.fetchOnlinePackageInfo': false,
'npm.autoDetect': 'off',
'workbench.editor.languageDetection': false,
"workbench.localHistory.enabled": false
}
};
fs.writeFileSync(workspaceFilePath, JSON.stringify(workspace, null, '\t'));
writeFileSync(workspaceFilePath, JSON.stringify(workspace, null, '\t'));
return workspaceFilePath;
}
export function setup(opts: minimist.ParsedArgs) {
export function setup(logger: Logger) {
describe('Multiroot', () => {
beforeSuite(opts, async opts => {
const workspacePath = await createWorkspaceFile(opts.workspacePath);
// Shared before/after handling
installAllHandlers(logger, opts => {
const workspacePath = createWorkspaceFile(opts.workspacePath);
return { ...opts, workspacePath };
});
afterSuite(opts);
it('shows results from all folders', async function () {
const app = this.app as Application;
await app.workbench.quickaccess.openQuickAccess('*.*');
const expectedNames = [
'index.js',
'users.js',
'style.css',
'error.pug',
'index.pug',
'layout.pug'
];
await app.workbench.quickinput.waitForQuickInputElements(names => names.length === 6);
await app.workbench.quickaccess.openFileQuickAccessAndWait('*.*', 6);
await app.workbench.quickinput.waitForQuickInputElements(names => expectedNames.every(expectedName => names.some(name => expectedName === name)));
await app.workbench.quickinput.closeQuickInput();
});
it('shows workspace name in title', async function () {
const app = this.app as Application;
await app.code.waitForTitle(title => /smoketest \(Workspace\)/i.test(title));
});
});

View File

@@ -4,13 +4,14 @@
*--------------------------------------------------------------------------------------------*/
import * as cp from 'child_process';
import minimist = require('minimist');
import { Application } from '../../../../automation';
import { afterSuite, beforeSuite } from '../../utils';
import { Application, Logger } from '../../../../automation';
import { installAllHandlers } from '../../utils';
export function setup(opts: minimist.ParsedArgs) {
describe.skip('Notebooks', () => {
beforeSuite(opts);
export function setup(logger: Logger) {
describe.skip('Notebooks', () => { // TODO@rebornix https://github.com/microsoft/vscode/issues/140575
// Shared before/after handling
installAllHandlers(logger);
afterEach(async function () {
const app = this.app as Application;
@@ -24,9 +25,7 @@ export function setup(opts: minimist.ParsedArgs) {
cp.execSync('git reset --hard HEAD --quiet', { cwd: app.workspacePathOrFolder });
});
afterSuite(opts);
it.skip('inserts/edits code cell', async function () {
it.skip('inserts/edits code cell', async function () { // TODO@rebornix https://github.com/microsoft/vscode/issues/139672
const app = this.app as Application;
await app.workbench.notebook.openNotebook();
await app.workbench.notebook.focusNextCell();
@@ -55,7 +54,7 @@ export function setup(opts: minimist.ParsedArgs) {
await app.workbench.notebook.waitForMarkdownContents('p', 'Markdown Cell');
});
it.skip('moves focus in and out of output', async function () { // TODO@rebornix https://github.com/microsoft/vscode/issues/113882
it.skip('moves focus in and out of output', async function () { // TODO@rebornix https://github.com/microsoft/vscode/issues/139270
const app = this.app as Application;
await app.workbench.notebook.openNotebook();
await app.workbench.notebook.executeActiveCell();
@@ -64,7 +63,7 @@ export function setup(opts: minimist.ParsedArgs) {
await app.workbench.notebook.waitForActiveCellEditorContents('code()');
});
it.skip('cell action execution', async function () {
it.skip('cell action execution', async function () { // TODO@rebornix https://github.com/microsoft/vscode/issues/139270
const app = this.app as Application;
await app.workbench.notebook.openNotebook();
await app.workbench.notebook.insertNotebookCell('code');

View File

@@ -3,31 +3,31 @@
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import minimist = require('minimist');
import { Application, ActivityBarPosition } from '../../../../automation';
import { afterSuite, beforeSuite } from '../../utils';
import { Application, ActivityBarPosition, Logger } from '../../../../automation';
import { installAllHandlers } from '../../utils';
export function setup(opts: minimist.ParsedArgs) {
export function setup(logger: Logger) {
describe('Preferences', () => {
beforeSuite(opts);
afterSuite(opts);
// Shared before/after handling
installAllHandlers(logger);
it('turns off editor line numbers and verifies the live change', async function () {
const app = this.app as Application;
await app.workbench.quickaccess.openFile('app.js');
await app.workbench.settingsEditor.openUserSettingsFile();
await app.code.waitForElements('.line-numbers', false, elements => !!elements.length);
await app.workbench.settingsEditor.addUserSetting('editor.lineNumbers', '"off"');
await app.workbench.editors.selectTab('app.js');
await app.code.waitForElements('.line-numbers', false, result => !result || result.length === 0);
});
it(`changes 'workbench.action.toggleSidebarPosition' command key binding and verifies it`, async function () {
it('changes "workbench.action.toggleSidebarPosition" command key binding and verifies it', async function () {
const app = this.app as Application;
await app.workbench.activitybar.waitForActivityBar(ActivityBarPosition.LEFT);
await app.workbench.keybindingsEditor.updateKeybinding('workbench.action.toggleSidebarPosition', 'View: Toggle Side Bar Position', 'ctrl+u', 'Control+U');
await app.workbench.keybindingsEditor.updateKeybinding('workbench.action.toggleSidebarPosition', 'View: Toggle Primary Side Bar Position', 'ctrl+u', 'Control+U');
await app.code.dispatchKeybinding('ctrl+u');
await app.workbench.activitybar.waitForActivityBar(ActivityBarPosition.RIGHT);

View File

@@ -4,14 +4,14 @@
*--------------------------------------------------------------------------------------------*/
import * as cp from 'child_process';
import minimist = require('minimist');
import { Application } from '../../../../automation';
import { afterSuite, beforeSuite, retry } from '../../utils';
import { Application, Logger } from '../../../../automation';
import { installAllHandlers, retry } from '../../utils';
export function setup(opts: minimist.ParsedArgs) {
// https://github.com/microsoft/vscode/issues/115244
export function setup(logger: Logger) {
describe('Search', () => {
beforeSuite(opts);
// Shared before/after handling
installAllHandlers(logger);
after(function () {
const app = this.app as Application;
@@ -19,23 +19,12 @@ export function setup(opts: minimist.ParsedArgs) {
retry(async () => cp.execSync('git reset --hard HEAD --quiet', { cwd: app.workspacePathOrFolder }), 0, 5);
});
afterSuite(opts);
// https://github.com/microsoft/vscode/issues/124146
it.skip /* https://github.com/microsoft/vscode/issues/124335 */('has a tooltp with a keybinding', async function () {
const app = this.app as Application;
const tooltip: string = await app.workbench.search.getSearchTooltip();
if (!/Search \(.+\)/.test(tooltip)) {
throw Error(`Expected search tooltip to contain keybinding but got ${tooltip}`);
}
});
it('searches for body & checks for correct result number', async function () {
const app = this.app as Application;
await app.workbench.search.openSearchViewlet();
await app.workbench.search.searchFor('body');
await app.workbench.search.waitForResultText('16 results in 5 files');
await app.workbench.search.waitForResultText('6 results in 3 files');
});
it('searches only for *.js files & checks for correct result number', async function () {
@@ -50,38 +39,41 @@ export function setup(opts: minimist.ParsedArgs) {
await app.workbench.search.hideQueryDetails();
});
it.skip('dismisses result & checks for correct result number', async function () {
it('dismisses result & checks for correct result number', async function () {
const app = this.app as Application;
await app.workbench.search.searchFor('body');
await app.workbench.search.removeFileMatch('app.js');
await app.workbench.search.waitForResultText('12 results in 4 files');
await app.workbench.search.waitForResultText('6 results in 3 files');
await app.workbench.search.removeFileMatch('app.js', '2 results in 2 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');
await app.workbench.search.waitForResultText('6 results in 3 files');
await app.workbench.search.expandReplace();
await app.workbench.search.setReplaceText('ydob');
await app.workbench.search.replaceFileMatch('app.js');
await app.workbench.search.waitForResultText('12 results in 4 files');
await app.workbench.search.replaceFileMatch('app.js', '12 results in 4 files');
await app.workbench.search.searchFor('ydob');
await app.workbench.search.waitForResultText('4 results in 1 file');
await app.workbench.search.setReplaceText('body');
await app.workbench.search.replaceFileMatch('app.js');
await app.workbench.search.replaceFileMatch('app.js', '0 results in 0 files');
await app.workbench.search.waitForResultText('0 results in 0 files');
});
});
describe('Quick Access', () => {
beforeSuite(opts);
afterSuite(opts);
describe('Quick Open', () => {
it('quick access search produces correct result', async function () {
// Shared before/after handling
installAllHandlers(logger);
it('quick open search produces correct result', async function () {
const app = this.app as Application;
const expectedNames = [
'.eslintrc.json',
'tasks.json',
'settings.json',
'app.js',
'index.js',
'users.js',
@@ -89,12 +81,12 @@ export function setup(opts: minimist.ParsedArgs) {
'jsconfig.json'
];
await app.workbench.quickaccess.openQuickAccess('.js');
await app.workbench.quickinput.waitForQuickInputElements(names => expectedNames.every(n => names.some(m => n === m)));
await app.code.dispatchKeybinding('escape');
await app.workbench.quickaccess.openFileQuickAccessAndWait('.js', 8);
await app.workbench.quickinput.waitForQuickInputElements(names => expectedNames.every(expectedName => names.some(name => expectedName === name)));
await app.workbench.quickinput.closeQuickInput();
});
it('quick access respects fuzzy matching', async function () {
it('quick open respects fuzzy matching', async function () {
const app = this.app as Application;
const expectedNames = [
'tasks.json',
@@ -102,9 +94,9 @@ export function setup(opts: minimist.ParsedArgs) {
'package.json'
];
await app.workbench.quickaccess.openQuickAccess('a.s');
await app.workbench.quickinput.waitForQuickInputElements(names => expectedNames.every(n => names.some(m => n === m)));
await app.code.dispatchKeybinding('escape');
await app.workbench.quickaccess.openFileQuickAccessAndWait('a.s', 3);
await app.workbench.quickinput.waitForQuickInputElements(names => expectedNames.every(expectedName => names.some(name => expectedName === name)));
await app.workbench.quickinput.closeQuickInput();
});
});
}

View File

@@ -3,18 +3,18 @@
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import minimist = require('minimist');
import { Application, Quality, StatusBarElement } from '../../../../automation';
import { afterSuite, beforeSuite } from '../../utils';
import { join } from 'path';
import { Application, Quality, StatusBarElement, Logger } from '../../../../automation';
import { installAllHandlers } from '../../utils';
export function setup(opts: minimist.ParsedArgs) {
export function setup(logger: Logger) {
describe('Statusbar', () => {
beforeSuite(opts);
afterSuite(opts);
// Shared before/after handling
installAllHandlers(logger);
it('verifies presence of all default status bar elements', async function () {
const app = this.app as Application;
await app.workbench.statusbar.waitForStatusbarElement(StatusBarElement.BRANCH_STATUS);
if (app.quality !== Quality.Dev) {
await app.workbench.statusbar.waitForStatusbarElement(StatusBarElement.FEEDBACK_ICON);
@@ -22,11 +22,8 @@ export function setup(opts: minimist.ParsedArgs) {
await app.workbench.statusbar.waitForStatusbarElement(StatusBarElement.SYNC_STATUS);
await app.workbench.statusbar.waitForStatusbarElement(StatusBarElement.PROBLEMS_STATUS);
await app.workbench.quickaccess.openFile('app.js');
if (!opts.web) {
// Encoding picker currently hidden in web (only UTF-8 supported)
await app.workbench.statusbar.waitForStatusbarElement(StatusBarElement.ENCODING_STATUS);
}
await app.workbench.quickaccess.openFile(join(app.workspacePathOrFolder, 'readme.md'));
await app.workbench.statusbar.waitForStatusbarElement(StatusBarElement.ENCODING_STATUS);
await app.workbench.statusbar.waitForStatusbarElement(StatusBarElement.EOL_STATUS);
await app.workbench.statusbar.waitForStatusbarElement(StatusBarElement.INDENTATION_STATUS);
await app.workbench.statusbar.waitForStatusbarElement(StatusBarElement.LANGUAGE_STATUS);
@@ -35,21 +32,17 @@ export function setup(opts: minimist.ParsedArgs) {
it(`verifies that 'quick input' opens when clicking on status bar elements`, async function () {
const app = this.app as Application;
await app.workbench.statusbar.clickOn(StatusBarElement.BRANCH_STATUS);
await app.workbench.quickinput.waitForQuickInputOpened();
await app.workbench.quickinput.closeQuickInput();
await app.workbench.quickaccess.openFile('app.js');
await app.workbench.quickaccess.openFile(join(app.workspacePathOrFolder, 'readme.md'));
await app.workbench.statusbar.clickOn(StatusBarElement.INDENTATION_STATUS);
await app.workbench.quickinput.waitForQuickInputOpened();
await app.workbench.quickinput.closeQuickInput();
if (!opts.web) {
// Encoding picker currently hidden in web (only UTF-8 supported)
await app.workbench.statusbar.clickOn(StatusBarElement.ENCODING_STATUS);
await app.workbench.quickinput.waitForQuickInputOpened();
await app.workbench.quickinput.closeQuickInput();
}
await app.workbench.statusbar.clickOn(StatusBarElement.ENCODING_STATUS);
await app.workbench.quickinput.waitForQuickInputOpened();
await app.workbench.quickinput.closeQuickInput();
await app.workbench.statusbar.clickOn(StatusBarElement.EOL_STATUS);
await app.workbench.quickinput.waitForQuickInputOpened();
await app.workbench.quickinput.closeQuickInput();
@@ -60,18 +53,15 @@ export function setup(opts: minimist.ParsedArgs) {
it(`verifies that 'Problems View' appears when clicking on 'Problems' status element`, async function () {
const app = this.app as Application;
await app.workbench.statusbar.clickOn(StatusBarElement.PROBLEMS_STATUS);
await app.workbench.problems.waitForProblemsView();
});
it(`verifies if changing EOL is reflected in the status bar`, async function () {
const app = this.app as Application;
await app.workbench.quickaccess.openFile('app.js');
await app.workbench.quickaccess.openFile(join(app.workspacePathOrFolder, 'readme.md'));
await app.workbench.statusbar.clickOn(StatusBarElement.EOL_STATUS);
await app.workbench.quickinput.waitForQuickInputOpened();
await app.workbench.quickinput.selectQuickInputElement(1);
await app.workbench.statusbar.waitForEOL('CRLF');
@@ -79,7 +69,6 @@ export function setup(opts: minimist.ParsedArgs) {
it(`verifies that 'Tweet us feedback' pop-up appears when clicking on 'Feedback' icon`, async function () {
const app = this.app as Application;
if (app.quality === Quality.Dev) {
return this.skip();
}

View File

@@ -0,0 +1,78 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { Application, Terminal, TerminalCommandId, TerminalCommandIdWithValue } from '../../../../automation';
export function setup() {
describe('Terminal Editors', () => {
let terminal: Terminal;
let app: Application;
// Acquire automation API
before(async function () {
app = this.app as Application;
terminal = app.workbench.terminal;
});
it('should update color of the tab', async () => {
await terminal.runCommand(TerminalCommandId.CreateNewEditor);
const color = 'Cyan';
await terminal.runCommandWithValue(TerminalCommandIdWithValue.ChangeColor, color);
await terminal.assertSingleTab({ color }, true);
});
it('should update icon of the tab', async () => {
await terminal.runCommand(TerminalCommandId.CreateNewEditor);
const icon = 'symbol-method';
await terminal.runCommandWithValue(TerminalCommandIdWithValue.ChangeIcon, icon);
await terminal.assertSingleTab({ icon }, true);
});
it('should rename the tab', async () => {
await terminal.runCommand(TerminalCommandId.CreateNewEditor);
const name = 'my terminal name';
await terminal.runCommandWithValue(TerminalCommandIdWithValue.Rename, name);
await terminal.assertSingleTab({ name }, true);
});
it('should show the panel when the terminal is moved there and close the editor', async () => {
await terminal.runCommand(TerminalCommandId.CreateNewEditor);
await terminal.runCommand(TerminalCommandId.MoveToPanel);
await terminal.assertSingleTab({});
});
it('should open a terminal in a new group for open to the side', async () => {
await terminal.runCommand(TerminalCommandId.CreateNewEditor);
await terminal.runCommand(TerminalCommandId.SplitEditor);
await terminal.assertEditorGroupCount(2);
});
it('should open a terminal in a new group when the split button is pressed', async () => {
await terminal.runCommand(TerminalCommandId.CreateNewEditor);
await terminal.clickSplitButton();
await terminal.assertEditorGroupCount(2);
});
it('should create new terminals in the active editor group via command', async () => {
await terminal.runCommand(TerminalCommandId.CreateNewEditor);
await terminal.runCommand(TerminalCommandId.CreateNewEditor);
await terminal.assertEditorGroupCount(1);
});
it('should create new terminals in the active editor group via plus button', async () => {
await terminal.runCommand(TerminalCommandId.CreateNewEditor);
await terminal.clickPlusButton();
await terminal.assertEditorGroupCount(1);
});
it.skip('should create a terminal in the editor area by default', async () => {
await app.workbench.settingsEditor.addUserSetting('terminal.integrated.defaultLocation', '"editor"');
// Close the settings editor
await app.workbench.quickaccess.runCommand('workbench.action.closeAllEditors');
await terminal.createTerminal('editor');
await terminal.assertEditorGroupCount(1);
await terminal.assertTerminalViewHidden();
});
});
}

View File

@@ -0,0 +1,48 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { Application, Terminal, SettingsEditor } from '../../../../automation';
export function setup() {
describe('Terminal Input', () => {
let terminal: Terminal;
let settingsEditor: SettingsEditor;
// Acquire automation API
before(async function () {
const app = this.app as Application;
terminal = app.workbench.terminal;
settingsEditor = app.workbench.settingsEditor;
});
describe('Auto replies', function () {
// HACK: Retry this suite only on Windows because conpty can rarely lead to unexpected behavior which would
// cause flakiness. If this does happen, the feature is expected to fail.
if (process.platform === 'win32') {
this.retries(3);
}
async function writeTextForAutoReply(text: string): Promise<void> {
// Put the matching word in quotes to avoid powershell coloring the first word and
// on a new line to avoid cursor move/line switching sequences
await terminal.runCommandInTerminal(`"\r${text}`, true);
}
it.skip('should automatically reply to default "Terminate batch job (Y/N)"', async () => { // TODO: #139076
await terminal.createTerminal();
await writeTextForAutoReply('Terminate batch job (Y/N)?');
await terminal.waitForTerminalText(buffer => buffer.some(line => line.match(/\?.*Y/)));
});
it('should automatically reply to a custom entry', async () => {
await settingsEditor.addUserSetting('terminal.integrated.autoReplies', '{ "foo": "bar" }');
await terminal.createTerminal();
await writeTextForAutoReply('foo');
await terminal.waitForTerminalText(buffer => buffer.some(line => line.match(/foo.*bar/)));
});
});
});
}

View File

@@ -0,0 +1,101 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { Application, Terminal, TerminalCommandId, TerminalCommandIdWithValue } from '../../../../automation';
export function setup() {
describe('Terminal Persistence', () => {
// Acquire automation API
let terminal: Terminal;
before(function () {
const app = this.app as Application;
terminal = app.workbench.terminal;
});
describe('detach/attach', () => {
// https://github.com/microsoft/vscode/issues/137799
it.skip('should support basic reconnection', async () => {
await terminal.createTerminal();
// TODO: Handle passing in an actual regex, not string
await terminal.assertTerminalGroups([
[{ name: '.*' }]
]);
// Get the terminal name
await terminal.assertTerminalGroups([
[{ name: '.*' }]
]);
const name = (await terminal.getTerminalGroups())[0][0].name!;
// Detach
await terminal.runCommand(TerminalCommandId.DetachSession);
await terminal.assertTerminalViewHidden();
// Attach
await terminal.runCommandWithValue(TerminalCommandIdWithValue.AttachToSession, name);
await terminal.assertTerminalGroups([
[{ name }]
]);
});
it.skip('should persist buffer content', async () => {
await terminal.createTerminal();
// TODO: Handle passing in an actual regex, not string
await terminal.assertTerminalGroups([
[{ name: '.*' }]
]);
// Get the terminal name
await terminal.assertTerminalGroups([
[{ name: '.*' }]
]);
const name = (await terminal.getTerminalGroups())[0][0].name!;
// Write in terminal
await terminal.runCommandInTerminal('echo terminal_test_content');
await terminal.waitForTerminalText(buffer => buffer.some(e => e.includes('terminal_test_content')));
// Detach
await terminal.runCommand(TerminalCommandId.DetachSession);
await terminal.assertTerminalViewHidden();
// Attach
await terminal.runCommandWithValue(TerminalCommandIdWithValue.AttachToSession, name);
await terminal.assertTerminalGroups([
[{ name }]
]);
await terminal.waitForTerminalText(buffer => buffer.some(e => e.includes('terminal_test_content')));
});
// TODO: This is currently flaky because it takes time to send over the new icon to the backend
it.skip('should persist terminal icon', async () => {
await terminal.createTerminal();
// TODO: Handle passing in an actual regex, not string
await terminal.assertTerminalGroups([
[{ name: '.*' }]
]);
// Get the terminal name
const name = (await terminal.getTerminalGroups())[0][0].name!;
// Set the icon
await terminal.runCommandWithValue(TerminalCommandIdWithValue.ChangeIcon, 'symbol-method');
await terminal.assertSingleTab({ icon: 'symbol-method' });
// Detach
await terminal.runCommand(TerminalCommandId.DetachSession);
await terminal.assertTerminalViewHidden();
// Attach
await terminal.runCommandWithValue(TerminalCommandIdWithValue.AttachToSession, name);
await terminal.assertTerminalGroups([
[{ name }]
]);
// TODO: This fails due to a bug
await terminal.assertSingleTab({ icon: 'symbol-method' });
});
});
});
}

View File

@@ -0,0 +1,74 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { Application, Terminal, TerminalCommandId, TerminalCommandIdWithValue } from '../../../../automation';
const CONTRIBUTED_PROFILE_NAME = `JavaScript Debug Terminal`;
const ANY_PROFILE_NAME = '^((?!JavaScript Debug Terminal).)*$';
export function setup() {
describe('Terminal Profiles', () => {
// Acquire automation API
let terminal: Terminal;
before(function () {
const app = this.app as Application;
terminal = app.workbench.terminal;
});
it('should launch the default profile', async () => {
await terminal.runCommand(TerminalCommandId.Show);
await terminal.assertSingleTab({ name: ANY_PROFILE_NAME });
});
it.skip('should set the default profile to a contributed one', async () => {
await terminal.runCommandWithValue(TerminalCommandIdWithValue.SelectDefaultProfile, CONTRIBUTED_PROFILE_NAME);
await terminal.createTerminal();
await terminal.assertSingleTab({ name: CONTRIBUTED_PROFILE_NAME });
});
it.skip('should use the default contributed profile on panel open and for splitting', async () => {
await terminal.runCommandWithValue(TerminalCommandIdWithValue.SelectDefaultProfile, CONTRIBUTED_PROFILE_NAME);
await terminal.runCommand(TerminalCommandId.Show);
await terminal.runCommand(TerminalCommandId.Split);
await terminal.assertTerminalGroups([[{ name: CONTRIBUTED_PROFILE_NAME }, { name: CONTRIBUTED_PROFILE_NAME }]]);
});
it('should set the default profile', async () => {
await terminal.runCommandWithValue(TerminalCommandIdWithValue.SelectDefaultProfile, process.platform === 'win32' ? 'PowerShell' : undefined);
await terminal.createTerminal();
await terminal.assertSingleTab({ name: ANY_PROFILE_NAME });
});
it('should use the default profile on panel open and for splitting', async () => {
await terminal.runCommand(TerminalCommandId.Show);
await terminal.assertSingleTab({ name: ANY_PROFILE_NAME });
await terminal.runCommand(TerminalCommandId.Split);
await terminal.assertTerminalGroups([[{}, {}]]);
});
it('createWithProfile command should create a terminal with a profile', async () => {
await terminal.runCommandWithValue(TerminalCommandIdWithValue.NewWithProfile);
await terminal.assertSingleTab({ name: ANY_PROFILE_NAME });
});
it.skip('createWithProfile command should create a terminal with a contributed profile', async () => {
await terminal.runCommandWithValue(TerminalCommandIdWithValue.NewWithProfile, CONTRIBUTED_PROFILE_NAME);
await terminal.assertSingleTab({ name: CONTRIBUTED_PROFILE_NAME });
});
it('createWithProfile command should create a split terminal with a profile', async () => {
await terminal.runCommand(TerminalCommandId.Show);
await terminal.runCommandWithValue(TerminalCommandIdWithValue.NewWithProfile, undefined, true);
await terminal.assertTerminalGroups([[{}, {}]]);
});
it.skip('createWithProfile command should create a split terminal with a contributed profile', async () => {
await terminal.runCommand(TerminalCommandId.Show);
await terminal.assertSingleTab({});
await terminal.runCommandWithValue(TerminalCommandIdWithValue.NewWithProfile, CONTRIBUTED_PROFILE_NAME, true);
await terminal.assertTerminalGroups([[{ name: ANY_PROFILE_NAME }, { name: CONTRIBUTED_PROFILE_NAME }]]);
});
});
}

View File

@@ -0,0 +1,64 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { Application, Terminal, SettingsEditor } from '../../../../automation';
export function setup() {
describe('Terminal Shell Integration', () => {
let terminal: Terminal;
let settingsEditor: SettingsEditor;
let app: Application;
// Acquire automation API
before(async function () {
app = this.app as Application;
terminal = app.workbench.terminal;
settingsEditor = app.workbench.settingsEditor;
await settingsEditor.addUserSetting('terminal.integrated.shellIntegration.enabled', 'true');
});
describe('Shell integration', function () {
describe('Activation', function () {
it('should activate shell integration on creation of a terminal', async () => {
await terminal.createTerminal();
await terminal.assertShellIntegrationActivated();
});
});
(process.platform === 'win32' ? describe.skip : describe)('Decorations', function () {
describe('Should show default icons', function () {
it('Placeholder', async () => {
await terminal.createTerminal();
await terminal.assertShellIntegrationActivated();
await terminal.assertCommandDecorations({ placeholder: 1, success: 0, error: 0 });
});
it('Success', async () => {
await terminal.createTerminal();
await terminal.assertShellIntegrationActivated();
await terminal.runCommandInTerminal(`ls`);
await terminal.assertCommandDecorations({ placeholder: 1, success: 1, error: 0 });
});
it('Error', async () => {
await terminal.createTerminal();
await terminal.assertShellIntegrationActivated();
await terminal.runCommandInTerminal(`fsdkfsjdlfksjdkf`);
await terminal.assertCommandDecorations({ placeholder: 1, success: 0, error: 1 });
});
});
describe('Custom configuration', function () {
it('Should update and show custom icons', async () => {
await terminal.createTerminal();
await terminal.assertShellIntegrationActivated();
await terminal.assertCommandDecorations({ placeholder: 1, success: 0, error: 0 });
await terminal.runCommandInTerminal(`ls`);
await terminal.runCommandInTerminal(`fsdkfsjdlfksjdkf`);
await settingsEditor.addUserSetting('terminal.integrated.shellIntegration.decorationIcon', '"zap"');
await settingsEditor.addUserSetting('terminal.integrated.shellIntegration.decorationIconSuccess', '"zap"');
await settingsEditor.addUserSetting('terminal.integrated.shellIntegration.decorationIconError', '"zap"');
await terminal.assertCommandDecorations(undefined, { updatedIcon: "zap", count: 3 });
});
});
});
});
});
}

View File

@@ -0,0 +1,31 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { Application, Terminal } from '../../../../automation';
export function setup() {
describe('Terminal splitCwd', () => {
// Acquire automation API
let terminal: Terminal;
before(async function () {
const app = this.app as Application;
terminal = app.workbench.terminal;
await app.workbench.settingsEditor.addUserSetting('terminal.integrated.splitCwd', '"inherited"');
await app.workbench.quickaccess.runCommand('workbench.action.closeAllEditors');
});
it('should inherit cwd when split and update the tab description - alt click', async () => {
await terminal.createTerminal();
const cwd = 'test';
await terminal.runCommandInTerminal(`mkdir ${cwd}`);
await terminal.runCommandInTerminal(`cd ${cwd}`);
const page = await terminal.getPage();
page.keyboard.down('Alt');
await terminal.clickSingleTab();
page.keyboard.up('Alt');
await terminal.assertTerminalGroups([[{ description: cwd }, { description: cwd }]]);
});
});
}

View File

@@ -0,0 +1,131 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { Application, Terminal, TerminalCommandId, TerminalCommandIdWithValue } from '../../../../automation';
export function setup() {
describe('Terminal Tabs', () => {
// Acquire automation API
let terminal: Terminal;
before(function () {
const app = this.app as Application;
terminal = app.workbench.terminal;
});
it('clicking the plus button should create a terminal and display the tabs view showing no split decorations', async () => {
await terminal.createTerminal();
await terminal.clickPlusButton();
await terminal.assertTerminalGroups([[{}], [{}]]);
});
it('should update color of the single tab', async () => {
await terminal.createTerminal();
const color = 'Cyan';
await terminal.runCommandWithValue(TerminalCommandIdWithValue.ChangeColor, color);
await terminal.assertSingleTab({ color });
});
it('should update color of the tab in the tabs list', async () => {
await terminal.createTerminal();
await terminal.runCommand(TerminalCommandId.Split);
await terminal.waitForTerminalText(lines => lines.some(line => line.length > 0), undefined, 1);
const color = 'Cyan';
await terminal.runCommandWithValue(TerminalCommandIdWithValue.ChangeColor, color);
await terminal.assertTerminalGroups([[{}, { color }]]);
});
it('should update icon of the single tab', async () => {
await terminal.createTerminal();
const icon = 'symbol-method';
await terminal.runCommandWithValue(TerminalCommandIdWithValue.ChangeIcon, icon);
await terminal.assertSingleTab({ icon });
});
it('should update icon of the tab in the tabs list', async () => {
await terminal.createTerminal();
await terminal.runCommand(TerminalCommandId.Split);
const icon = 'symbol-method';
await terminal.runCommandWithValue(TerminalCommandIdWithValue.ChangeIcon, icon);
await terminal.assertTerminalGroups([[{}, { icon }]]);
});
it('should rename the single tab', async () => {
await terminal.createTerminal();
const name = 'my terminal name';
await terminal.runCommandWithValue(TerminalCommandIdWithValue.Rename, name);
await terminal.assertSingleTab({ name });
});
it.skip('should reset the tab name to the default value when no name is provided', async () => { // https://github.com/microsoft/vscode/issues/146796
await terminal.createTerminal();
const defaultName = await terminal.getSingleTabName();
const name = 'my terminal name';
await terminal.runCommandWithValue(TerminalCommandIdWithValue.Rename, name);
await terminal.assertSingleTab({ name });
await terminal.runCommandWithValue(TerminalCommandIdWithValue.Rename, undefined);
await terminal.assertSingleTab({ name: defaultName });
});
it('should rename the tab in the tabs list', async () => {
await terminal.createTerminal();
await terminal.runCommand(TerminalCommandId.Split);
const name = 'my terminal name';
await terminal.runCommandWithValue(TerminalCommandIdWithValue.Rename, name);
await terminal.assertTerminalGroups([[{}, { name }]]);
});
it('should create a split terminal when single tab is alt clicked', async () => {
await terminal.createTerminal();
const page = await terminal.getPage();
page.keyboard.down('Alt');
await terminal.clickSingleTab();
page.keyboard.up('Alt');
await terminal.assertTerminalGroups([[{}, {}]]);
});
it('should do nothing when join tabs is run with only one terminal', async () => {
await terminal.runCommand(TerminalCommandId.Show);
await terminal.runCommand(TerminalCommandId.Join);
await terminal.assertTerminalGroups([[{}]]);
});
it('should do nothing when join tabs is run with only split terminals', async () => {
await terminal.runCommand(TerminalCommandId.Show);
await terminal.runCommand(TerminalCommandId.Split);
await terminal.runCommand(TerminalCommandId.Join);
await terminal.assertTerminalGroups([[{}], [{}]]);
});
it('should join tabs when more than one non-split terminal', async () => {
await terminal.runCommand(TerminalCommandId.Show);
await terminal.createTerminal();
await terminal.runCommand(TerminalCommandId.Join);
await terminal.assertTerminalGroups([[{}, {}]]);
});
it('should do nothing when unsplit tabs called with no splits', async () => {
await terminal.runCommand(TerminalCommandId.Show);
await terminal.createTerminal();
await terminal.assertTerminalGroups([[{}], [{}]]);
await terminal.runCommand(TerminalCommandId.Unsplit);
await terminal.assertTerminalGroups([[{}], [{}]]);
});
it('should unsplit tabs', async () => {
await terminal.runCommand(TerminalCommandId.Show);
await terminal.runCommand(TerminalCommandId.Split);
await terminal.assertTerminalGroups([[{}, {}]]);
await terminal.runCommand(TerminalCommandId.Unsplit);
await terminal.assertTerminalGroups([[{}], [{}]]);
});
it('should move the terminal to the editor area', async () => {
await terminal.runCommand(TerminalCommandId.Show);
await terminal.assertSingleTab({});
await terminal.runCommand(TerminalCommandId.MoveToEditor);
await terminal.assertEditorGroupCount(1);
});
});
}

View File

@@ -0,0 +1,56 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { Application, Terminal, TerminalCommandId, Logger } from '../../../../automation';
import { installAllHandlers } from '../../utils';
import { setup as setupTerminalEditorsTests } from './terminal-editors.test';
import { setup as setupTerminalInputTests } from './terminal-input.test';
import { setup as setupTerminalPersistenceTests } from './terminal-persistence.test';
import { setup as setupTerminalProfileTests } from './terminal-profiles.test';
import { setup as setupTerminalTabsTests } from './terminal-tabs.test';
import { setup as setupTerminalSplitCwdTests } from './terminal-splitCwd.test';
import { setup as setupTerminalShellIntegrationTests } from './terminal-shellIntegration.test';
export function setup(logger: Logger) {
describe('Terminal', function () {
// Retry tests 3 times to minimize build failures due to any flakiness
this.retries(3);
// Shared before/after handling
installAllHandlers(logger);
let terminal: Terminal;
before(async function () {
// Fetch terminal automation API
const app = this.app as Application;
terminal = app.workbench.terminal;
// Always show tabs to make getting terminal groups easier
await app.workbench.settingsEditor.addUserSetting('terminal.integrated.tabs.hideCondition', '"never"');
// Use the DOM renderer for smoke tests so they can be inspected in the playwright trace
// viewer
await app.workbench.settingsEditor.addUserSetting('terminal.integrated.gpuAcceleration', '"off"');
// Close the settings editor
await app.workbench.quickaccess.runCommand('workbench.action.closeAllEditors');
});
afterEach(async () => {
// Kill all terminals between every test for a consistent testing environment
await terminal.runCommand(TerminalCommandId.KillAll);
});
setupTerminalEditorsTests();
setupTerminalInputTests();
setupTerminalPersistenceTests();
setupTerminalProfileTests();
setupTerminalTabsTests();
setupTerminalShellIntegrationTests();
if (!process.platform.startsWith('win')) {
setupTerminalSplitCwdTests();
}
});
}

View File

@@ -3,37 +3,258 @@
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import minimist = require('minimist');
import { Application } from '../../../../automation';
import { afterSuite, beforeSuite } from '../../utils';
import { join } from 'path';
import { Application, ApplicationOptions, Logger, Quality } from '../../../../automation';
import { createApp, timeout, installDiagnosticsHandler, installAppAfterHandler, getRandomUserDataDir, suiteLogsPath } from '../../utils';
export function setup(opts: minimist.ParsedArgs) {
export function setup(ensureStableCode: () => string | undefined, logger: Logger) {
describe('Data Loss (insiders -> insiders)', () => {
describe('Dataloss', () => {
beforeSuite(opts);
afterSuite(opts);
let app: Application | undefined = undefined;
it(`verifies that 'hot exit' works for dirty files`, async function () {
const app = this.app as Application;
// Shared before/after handling
installDiagnosticsHandler(logger, () => app);
installAppAfterHandler(() => app);
it('verifies opened editors are restored', async function () {
app = createApp({
...this.defaultOptions,
logsPath: suiteLogsPath(this.defaultOptions, 'test_verifies_opened_editors_are_restored')
});
await app.start();
// Open 3 editors
await app.workbench.quickaccess.openFile(join(app.workspacePathOrFolder, 'bin', 'www'));
await app.workbench.quickaccess.runCommand('View: Keep Editor');
await app.workbench.quickaccess.openFile(join(app.workspacePathOrFolder, 'app.js'));
await app.workbench.quickaccess.runCommand('View: Keep Editor');
await app.workbench.editors.newUntitledFile();
const untitled = 'Untitled-1';
const textToTypeInUntitled = 'Hello from Untitled';
await app.workbench.editor.waitForTypeInEditor(untitled, textToTypeInUntitled);
await app.restart();
const readmeMd = 'readme.md';
const textToType = 'Hello, Code';
await app.workbench.quickaccess.openFile(readmeMd);
await app.workbench.editor.waitForTypeInEditor(readmeMd, textToType);
// Verify 3 editors are open
await app.workbench.editors.selectTab('Untitled-1');
await app.workbench.editors.selectTab('app.js');
await app.workbench.editors.selectTab('www');
await app.reload();
await app.workbench.editors.waitForActiveTab(readmeMd, true);
await app.workbench.editor.waitForEditorContents(readmeMd, c => c.indexOf(textToType) > -1);
await app.workbench.editors.waitForTab(untitled);
await app.workbench.editors.selectTab(untitled);
await app.workbench.editor.waitForEditorContents(untitled, c => c.indexOf(textToTypeInUntitled) > -1);
await app.stop();
app = undefined;
});
it('verifies editors can save and restore', async function () {
app = createApp({
...this.defaultOptions,
logsPath: suiteLogsPath(this.defaultOptions, 'test_verifies_editors_can_save_and_restore')
});
await app.start();
const textToType = 'Hello, Code';
// open editor and type
await app.workbench.quickaccess.openFile(join(app.workspacePathOrFolder, 'app.js'));
await app.workbench.editor.waitForTypeInEditor('app.js', textToType);
await app.workbench.editors.waitForTab('app.js', true);
// save
await app.workbench.editors.saveOpenedFile();
await app.workbench.editors.waitForTab('app.js', false);
// restart
await app.restart();
// verify contents
await app.workbench.editor.waitForEditorContents('app.js', contents => contents.indexOf(textToType) > -1);
await app.stop();
app = undefined;
});
it('verifies that "hot exit" works for dirty files (without delay)', function () {
return testHotExit.call(this, 'test_verifies_that_hot_exit_works_for_dirty_files_without_delay', undefined);
});
it('verifies that "hot exit" works for dirty files (with delay)', function () {
return testHotExit.call(this, 'test_verifies_that_hot_exit_works_for_dirty_files_with_delay', 2000);
});
it('verifies that auto save triggers on shutdown', function () {
return testHotExit.call(this, 'test_verifies_that_auto_save_triggers_on_shutdown', undefined, true);
});
async function testHotExit(title: string, restartDelay: number | undefined, autoSave: boolean | undefined) {
app = createApp({
...this.defaultOptions,
logsPath: suiteLogsPath(this.defaultOptions, title)
});
await app.start();
if (autoSave) {
await app.workbench.settingsEditor.addUserSetting('files.autoSave', '"afterDelay"');
}
const textToTypeInUntitled = 'Hello from Untitled';
await app.workbench.editors.newUntitledFile();
await app.workbench.editor.waitForTypeInEditor('Untitled-1', textToTypeInUntitled);
await app.workbench.editors.waitForTab('Untitled-1', true);
const textToType = 'Hello, Code';
await app.workbench.quickaccess.openFile(join(app.workspacePathOrFolder, 'readme.md'));
await app.workbench.editor.waitForTypeInEditor('readme.md', textToType);
await app.workbench.editors.waitForTab('readme.md', !autoSave);
if (typeof restartDelay === 'number') {
// this is an OK use of a timeout in a smoke test:
// we want to simulate a user having typed into
// the editor and pausing for a moment before
// terminating
await timeout(restartDelay);
}
await app.restart();
await app.workbench.editors.waitForTab('readme.md', !autoSave);
await app.workbench.editors.waitForTab('Untitled-1', true);
await app.workbench.editors.selectTab('readme.md');
await app.workbench.editor.waitForEditorContents('readme.md', contents => contents.indexOf(textToType) > -1);
await app.workbench.editors.selectTab('Untitled-1');
await app.workbench.editor.waitForEditorContents('Untitled-1', contents => contents.indexOf(textToTypeInUntitled) > -1);
await app.stop();
app = undefined;
}
});
describe.skip('Data Loss (stable -> insiders)', () => { //TODO@bpasero enable again once we shipped 1.67.x
let insidersApp: Application | undefined = undefined;
let stableApp: Application | undefined = undefined;
// Shared before/after handling
installDiagnosticsHandler(logger, () => insidersApp ?? stableApp);
installAppAfterHandler(() => insidersApp ?? stableApp, async () => stableApp?.stop());
it('verifies opened editors are restored', async function () {
const stableCodePath = ensureStableCode();
if (!stableCodePath) {
this.skip();
}
// macOS: the first launch of stable Code will trigger
// additional checks in the OS (notarization validation)
// so it can take a very long time. as such we install
// a retry handler to make sure we do not fail as a
// consequence.
if (process.platform === 'darwin') {
this.retries(2);
}
const userDataDir = getRandomUserDataDir(this.defaultOptions);
const logsPath = suiteLogsPath(this.defaultOptions, 'test_verifies_opened_editors_are_restored_from_stable');
const stableOptions: ApplicationOptions = Object.assign({}, this.defaultOptions);
stableOptions.codePath = stableCodePath;
stableOptions.userDataDir = userDataDir;
stableOptions.quality = Quality.Stable;
stableOptions.logsPath = logsPath;
stableApp = new Application(stableOptions);
await stableApp.start();
// Open 3 editors
await stableApp.workbench.quickaccess.openFile(join(stableApp.workspacePathOrFolder, 'bin', 'www'));
await stableApp.workbench.quickaccess.runCommand('View: Keep Editor');
await stableApp.workbench.quickaccess.openFile(join(stableApp.workspacePathOrFolder, 'app.js'));
await stableApp.workbench.quickaccess.runCommand('View: Keep Editor');
await stableApp.workbench.editors.newUntitledFile();
await stableApp.stop();
stableApp = undefined;
const insiderOptions: ApplicationOptions = Object.assign({}, this.defaultOptions);
insiderOptions.userDataDir = userDataDir;
insiderOptions.logsPath = logsPath;
insidersApp = new Application(insiderOptions);
await insidersApp.start();
// Verify 3 editors are open
await insidersApp.workbench.editors.selectTab('Untitled-1');
await insidersApp.workbench.editors.selectTab('app.js');
await insidersApp.workbench.editors.selectTab('www');
await insidersApp.stop();
insidersApp = undefined;
});
it('verifies that "hot exit" works for dirty files (without delay)', async function () {
return testHotExit.call(this, `test_verifies_that_hot_exit_works_for_dirty_files_without_delay_from_stable`, undefined);
});
it('verifies that "hot exit" works for dirty files (with delay)', async function () {
return testHotExit.call(this, `test_verifies_that_hot_exit_works_for_dirty_files_with_delay_from_stable`, 2000);
});
async function testHotExit(title: string, restartDelay: number | undefined) {
const stableCodePath = ensureStableCode();
if (!stableCodePath) {
this.skip();
}
const userDataDir = getRandomUserDataDir(this.defaultOptions);
const logsPath = suiteLogsPath(this.defaultOptions, title);
const stableOptions: ApplicationOptions = Object.assign({}, this.defaultOptions);
stableOptions.codePath = stableCodePath;
stableOptions.userDataDir = userDataDir;
stableOptions.quality = Quality.Stable;
stableOptions.logsPath = logsPath;
stableApp = new Application(stableOptions);
await stableApp.start();
const textToTypeInUntitled = 'Hello from Untitled';
await stableApp.workbench.editors.newUntitledFile();
await stableApp.workbench.editor.waitForTypeInEditor('Untitled-1', textToTypeInUntitled);
await stableApp.workbench.editors.waitForTab('Untitled-1', true);
const textToType = 'Hello, Code';
await stableApp.workbench.quickaccess.openFile(join(stableApp.workspacePathOrFolder, 'readme.md'));
await stableApp.workbench.editor.waitForTypeInEditor('readme.md', textToType);
await stableApp.workbench.editors.waitForTab('readme.md', true);
if (typeof restartDelay === 'number') {
// this is an OK use of a timeout in a smoke test
// we want to simulate a user having typed into
// the editor and pausing for a moment before
// terminating
await timeout(restartDelay);
}
await stableApp.stop();
stableApp = undefined;
const insiderOptions: ApplicationOptions = Object.assign({}, this.defaultOptions);
insiderOptions.userDataDir = userDataDir;
insiderOptions.logsPath = logsPath;
insidersApp = new Application(insiderOptions);
await insidersApp.start();
await insidersApp.workbench.editors.waitForTab('readme.md', true);
await insidersApp.workbench.editors.waitForTab('Untitled-1', true);
await insidersApp.workbench.editors.selectTab('readme.md');
await insidersApp.workbench.editor.waitForEditorContents('readme.md', contents => contents.indexOf(textToType) > -1);
await insidersApp.workbench.editors.selectTab('Untitled-1');
await insidersApp.workbench.editor.waitForEditorContents('Untitled-1', contents => contents.indexOf(textToTypeInUntitled) > -1);
await insidersApp.stop();
insidersApp = undefined;
}
});
}

View File

@@ -1,110 +0,0 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { Application, ApplicationOptions, Quality } from '../../../../automation';
import { join } from 'path';
import { ParsedArgs } from 'minimist';
import { timeout } from '../../utils';
export function setup(opts: ParsedArgs, testDataPath: string) {
describe('Datamigration', () => {
it(`verifies opened editors are restored`, async function () {
const stableCodePath = opts['stable-build'];
if (!stableCodePath) {
this.skip();
}
// On macOS, the stable app fails to launch on first try,
// so let's retry this once
// https://github.com/microsoft/vscode/pull/127799
if (process.platform === 'darwin') {
this.retries(2);
}
const userDataDir = join(testDataPath, 'd2'); // different data dir from the other tests
const stableOptions: ApplicationOptions = Object.assign({}, this.defaultOptions);
stableOptions.codePath = stableCodePath;
stableOptions.userDataDir = userDataDir;
stableOptions.quality = Quality.Stable;
const stableApp = new Application(stableOptions);
await stableApp.start();
// Open 3 editors and pin 2 of them
await stableApp.workbench.quickaccess.openFile('www');
await stableApp.workbench.quickaccess.runCommand('View: Keep Editor');
await stableApp.workbench.quickaccess.openFile('app.js');
await stableApp.workbench.quickaccess.runCommand('View: Keep Editor');
await stableApp.workbench.editors.newUntitledFile();
await stableApp.stop();
const insiderOptions: ApplicationOptions = Object.assign({}, this.defaultOptions);
insiderOptions.userDataDir = userDataDir;
const insidersApp = new Application(insiderOptions);
await insidersApp.start();
// Verify 3 editors are open
await insidersApp.workbench.editors.selectTab('Untitled-1');
await insidersApp.workbench.editors.selectTab('app.js');
await insidersApp.workbench.editors.selectTab('www');
await insidersApp.stop();
});
it(`verifies that 'hot exit' works for dirty files`, async function () {
const stableCodePath = opts['stable-build'];
if (!stableCodePath) {
this.skip();
}
const userDataDir = join(testDataPath, 'd3'); // different data dir from the other tests
const stableOptions: ApplicationOptions = Object.assign({}, this.defaultOptions);
stableOptions.codePath = stableCodePath;
stableOptions.userDataDir = userDataDir;
stableOptions.quality = Quality.Stable;
const stableApp = new Application(stableOptions);
await stableApp.start();
await stableApp.workbench.editors.newUntitledFile();
const untitled = 'Untitled-1';
const textToTypeInUntitled = 'Hello from Untitled';
await stableApp.workbench.editor.waitForTypeInEditor(untitled, textToTypeInUntitled);
const readmeMd = 'readme.md';
const textToType = 'Hello, Code';
await stableApp.workbench.quickaccess.openFile(readmeMd);
await stableApp.workbench.editor.waitForTypeInEditor(readmeMd, textToType);
await timeout(2000); // give time to store the backup before stopping the app
await stableApp.stop();
const insiderOptions: ApplicationOptions = Object.assign({}, this.defaultOptions);
insiderOptions.userDataDir = userDataDir;
const insidersApp = new Application(insiderOptions);
await insidersApp.start();
await insidersApp.workbench.editors.waitForTab(readmeMd, true);
await insidersApp.workbench.editors.selectTab(readmeMd);
await insidersApp.workbench.editor.waitForEditorContents(readmeMd, c => c.indexOf(textToType) > -1);
await insidersApp.workbench.editors.waitForTab(untitled, true);
await insidersApp.workbench.editors.selectTab(untitled);
await insidersApp.workbench.editor.waitForEditorContents(untitled, c => c.indexOf(textToTypeInUntitled) > -1);
await insidersApp.stop();
});
});
}

View File

@@ -3,36 +3,19 @@
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as path from 'path';
import { Application, ApplicationOptions } from '../../../../automation';
export function setup() {
import { join } from 'path';
import { Application, Logger } from '../../../../automation';
import { installAllHandlers } from '../../utils';
export function setup(logger: Logger) {
describe('Launch', () => {
let app: Application;
// Shared before/after handling
installAllHandlers(logger, opts => ({ ...opts, userDataDir: join(opts.userDataDir, 'ø') }));
after(async function () {
if (app) {
await app.stop();
}
it('verifies that application launches when user data directory has non-ascii characters', async function () {
const app = this.app as Application;
await app.workbench.explorer.openExplorerView();
});
afterEach(async function () {
if (app) {
if (this.currentTest!.state === 'failed') {
const name = this.currentTest!.fullTitle().replace(/[^a-z0-9\-]/ig, '_');
await app.captureScreenshot(name);
}
}
});
it(`verifies that application launches when user data directory has non-ascii characters`, async function () {
const defaultOptions = this.defaultOptions as ApplicationOptions;
const options: ApplicationOptions = { ...defaultOptions, userDataDir: path.join(defaultOptions.userDataDir, 'abcdø') };
app = new Application(options);
await app.start();
});
});
}

View File

@@ -3,22 +3,19 @@
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import minimist = require('minimist');
import { Application, Quality } from '../../../../automation';
import { afterSuite, beforeSuite } from '../../utils';
import { Logger, Application } from '../../../../automation';
import { installAllHandlers } from '../../utils';
export function setup(logger: Logger) {
export function setup(opts: minimist.ParsedArgs) {
describe('Localization', () => {
beforeSuite(opts);
afterSuite(opts);
it(`starts with 'DE' locale and verifies title and viewlets text is in German`, async function () {
// Shared before/after handling
installAllHandlers(logger);
it('starts with "DE" locale and verifies title and viewlets text is in German', async function () {
const app = this.app as Application;
if (app.quality === Quality.Dev || app.remote) {
return this.skip();
}
await app.workbench.extensions.openExtensionsViewlet();
await app.workbench.extensions.installExtension('ms-ceintl.vscode-language-pack-de', false);
await app.restart({ extraArgs: ['--locale=DE'] });

View File

@@ -3,9 +3,9 @@
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import minimist = require('minimist');
import { Suite, Context } from 'mocha';
import { Application, ApplicationOptions } from '../../automation';
import { dirname, join } from 'path';
import { Application, ApplicationOptions, Logger } from '../../automation';
export function describeRepeat(n: number, description: string, callback: (this: Suite) => void): void {
for (let i = 0; i < n; i++) {
@@ -19,32 +19,131 @@ export function itRepeat(n: number, description: string, callback: (this: Contex
}
}
export function beforeSuite(opts: minimist.ParsedArgs, optionsTransform?: (opts: ApplicationOptions) => Promise<ApplicationOptions>) {
before(async function () {
let options: ApplicationOptions = { ...this.defaultOptions };
/**
* Defines a test-case that will run but will be skips it if it throws an exception. This is useful
* to get some runs in CI when trying to stabilize a flaky test, without failing the build. Note
* that this only works if something inside the test throws, so a test's overall timeout won't work
* but throwing due to a polling timeout will.
* @param title The test-case title.
* @param callback The test-case callback.
*/
export function itSkipOnFail(title: string, callback: (this: Context) => any): void {
it(title, function () {
return Promise.resolve().then(() => {
return callback.apply(this, arguments);
}).catch(e => {
console.warn(`Test "${title}" failed but was marked as skip on fail:`, e);
this.skip();
});
});
}
if (optionsTransform) {
options = await optionsTransform(options);
export function installAllHandlers(logger: Logger, optionsTransform?: (opts: ApplicationOptions) => ApplicationOptions) {
installDiagnosticsHandler(logger);
installAppBeforeHandler(optionsTransform);
installAppAfterHandler();
}
export function installDiagnosticsHandler(logger: Logger, appFn?: () => Application | undefined) {
// Before each suite
before(async function () {
const suiteTitle = this.currentTest?.parent?.title;
logger.log('');
logger.log(`>>> Suite start: '${suiteTitle ?? 'unknown'}' <<<`);
logger.log('');
});
// Before each test
beforeEach(async function () {
const testTitle = this.currentTest?.title;
logger.log('');
logger.log(`>>> Test start: '${testTitle ?? 'unknown'}' <<<`);
logger.log('');
const app: Application = appFn?.() ?? this.app;
await app?.startTracing(testTitle ?? 'unknown');
});
// After each test
afterEach(async function () {
const currentTest = this.currentTest;
if (!currentTest) {
return;
}
// https://github.com/microsoft/vscode/issues/34988
const userDataPathSuffix = [...Array(8)].map(() => Math.random().toString(36)[3]).join('');
const userDataDir = options.userDataDir.concat(`-${userDataPathSuffix}`);
const failed = currentTest.state === 'failed';
const testTitle = currentTest.title;
logger.log('');
if (failed) {
logger.log(`>>> !!! FAILURE !!! Test end: '${testTitle}' !!! FAILURE !!! <<<`);
} else {
logger.log(`>>> Test end: '${testTitle}' <<<`);
}
logger.log('');
const app = new Application({ ...options, userDataDir });
await app.start();
this.app = app;
const app: Application = appFn?.() ?? this.app;
await app?.stopTracing(testTitle.replace(/[^a-z0-9\-]/ig, '_'), failed);
});
}
if (opts.log) {
const title = this.currentTest!.fullTitle();
app.logger.log('*** Test start:', title);
let logsCounter = 1;
export function suiteLogsPath(options: ApplicationOptions, suiteName: string): string {
return join(dirname(options.logsPath), `${logsCounter++}_suite_${suiteName.replace(/[^a-z0-9\-]/ig, '_')}`);
}
function installAppBeforeHandler(optionsTransform?: (opts: ApplicationOptions) => ApplicationOptions) {
before(async function () {
const suiteName = this.test?.parent?.title ?? 'unknown';
this.app = createApp({
...this.defaultOptions,
logsPath: suiteLogsPath(this.defaultOptions, suiteName)
}, optionsTransform);
await this.app.start();
});
}
export function installAppAfterHandler(appFn?: () => Application | undefined, joinFn?: () => Promise<unknown>) {
after(async function () {
const app: Application = appFn?.() ?? this.app;
if (app) {
await app.stop();
}
if (joinFn) {
await joinFn();
}
});
}
export function afterSuite(opts: minimist.ParsedArgs) {
export function createApp(options: ApplicationOptions, optionsTransform?: (opts: ApplicationOptions) => ApplicationOptions): Application {
if (optionsTransform) {
options = optionsTransform({ ...options });
}
const app = new Application({
...options,
userDataDir: getRandomUserDataDir(options)
});
return app;
}
export function getRandomUserDataDir(options: ApplicationOptions): string {
// Pick a random user data dir suffix that is not
// too long to not run into max path length issues
// https://github.com/microsoft/vscode/issues/34988
const userDataPathSuffix = [...Array(8)].map(() => Math.random().toString(36)[3]).join('');
return options.userDataDir.concat(`-${userDataPathSuffix}`);
}
export function installCommonAfterHandlers(opts: minimist.ParsedArgs, appFn?: () => Application | undefined, joinFn?: () => Promise<unknown>) {
afterEach(async function () {
const app = this.app as Application;
const app: Application = appFn?.() ?? this.app;
if (this.currentTest?.state === 'failed' && opts.screenshots) {
const name = this.currentTest!.fullTitle().replace(/[^a-z0-9\-]/ig, '_');
@@ -62,6 +161,14 @@ export function afterSuite(opts: minimist.ParsedArgs) {
if (app) {
await app.stop();
}
if (joinFn) {
await joinFn();
}
});
afterEach(async function () {
await this.app?.stopTracing(this.currentTest?.title, this.currentTest?.state === 'failed');
});
}
@@ -73,15 +180,44 @@ export function timeout(i: number) {
});
}
export async function retryWithRestart(app: Application, testFn: () => Promise<unknown>, retries = 3, timeoutMs = 20000): Promise<unknown> {
let lastError: Error | undefined = undefined;
for (let i = 0; i < retries; i++) {
const result = await Promise.race([
testFn().then(() => true, error => {
lastError = error;
return false;
}),
timeout(timeoutMs).then(() => false)
]);
if (result) {
return;
}
await app.restart();
}
throw lastError ?? new Error('retryWithRestart failed with an unknown error');
}
export interface ITask<T> {
(): T;
}
export async function retry<T>(task: ITask<Promise<T>>, delay: number, retries: number): Promise<T> {
export async function retry<T>(task: ITask<Promise<T>>, delay: number, retries: number, onBeforeRetry?: () => Promise<unknown>): Promise<T> {
let lastError: Error | undefined;
for (let i = 0; i < retries; i++) {
try {
if (i > 0 && typeof onBeforeRetry === 'function') {
try {
await onBeforeRetry();
} catch (error) {
console.warn(`onBeforeRetry failed with: ${error}`);
}
}
return await task();
} catch (error) {
lastError = error;