mirror of
https://github.com/Microsoft/vscode
synced 2024-10-05 19:02:54 +00:00
Write basic terminal default profile test
Co-authored-by: Megan Rogge <merogge@microsoft.com>
This commit is contained in:
parent
628f486b1d
commit
bd98431baf
|
@ -8,6 +8,7 @@ import { coalesce } from 'vs/base/common/arrays';
|
|||
import { language, locale } from 'vs/base/common/platform';
|
||||
import { IElement, ILocaleInfo, ILocalizedStrings, IWindowDriver } from 'vs/platform/driver/common/driver';
|
||||
import localizedStrings from 'vs/platform/localizations/common/localizedStrings';
|
||||
import type { Terminal } from 'xterm';
|
||||
|
||||
function serializeElement(element: Element, recursive: boolean): IElement {
|
||||
const attributes = Object.create(null);
|
||||
|
@ -132,16 +133,15 @@ export abstract class BaseWindowDriver implements IWindowDriver {
|
|||
throw new Error(`Terminal not found: ${selector}`);
|
||||
}
|
||||
|
||||
const xterm = (element as any).xterm;
|
||||
const xterm = (element as any).xterm as Terminal;
|
||||
|
||||
if (!xterm) {
|
||||
throw new Error(`Xterm not found: ${selector}`);
|
||||
}
|
||||
|
||||
const lines: string[] = [];
|
||||
|
||||
for (let i = 0; i < xterm.buffer.length; i++) {
|
||||
lines.push(xterm.buffer.getLine(i)!.translateToString(true));
|
||||
for (let i = 0; i < xterm.buffer.active.length; i++) {
|
||||
lines.push(xterm.buffer.active.getLine(i)!.translateToString(true));
|
||||
}
|
||||
|
||||
return lines;
|
||||
|
@ -154,13 +154,13 @@ export abstract class BaseWindowDriver implements IWindowDriver {
|
|||
throw new Error(`Element not found: ${selector}`);
|
||||
}
|
||||
|
||||
const xterm = (element as any).xterm;
|
||||
const xterm = (element as any).xterm as Terminal;
|
||||
|
||||
if (!xterm) {
|
||||
throw new Error(`Xterm not found: ${selector}`);
|
||||
}
|
||||
|
||||
xterm._core._coreService.triggerDataEvent(text);
|
||||
(xterm as any)._core._coreService.triggerDataEvent(text);
|
||||
}
|
||||
|
||||
getLocaleInfo(): Promise<ILocaleInfo> {
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
import { Code } from './code';
|
||||
import { QuickAccess } from './quickaccess';
|
||||
|
||||
const PANEL_SELECTOR = 'div[id="workbench.panel.terminal"]';
|
||||
const XTERM_SELECTOR = `${PANEL_SELECTOR} .terminal-wrapper`;
|
||||
const TERMINAL_VIEW_SELECTOR = `#terminal`;
|
||||
const XTERM_SELECTOR = `${TERMINAL_VIEW_SELECTOR} .terminal-wrapper`;
|
||||
const XTERM_TEXTAREA = `${XTERM_SELECTOR} textarea.xterm-helper-textarea`;
|
||||
|
||||
export class Terminal {
|
||||
|
@ -27,7 +27,14 @@ export class Terminal {
|
|||
await this.code.dispatchKeybinding('enter');
|
||||
}
|
||||
|
||||
async waitForTerminalText(accept: (buffer: string[]) => boolean): Promise<void> {
|
||||
await this.code.waitForTerminalBuffer(XTERM_SELECTOR, accept);
|
||||
async waitForTerminalText(accept: (buffer: string[]) => boolean, message?: string): Promise<void> {
|
||||
try {
|
||||
await this.code.waitForTerminalBuffer(XTERM_SELECTOR, accept);
|
||||
} catch (err: any) {
|
||||
if (message) {
|
||||
throw new Error(`${message}\n\nInner exception:\n${err.message}`);
|
||||
}
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,18 +3,34 @@
|
|||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { ok } from 'assert';
|
||||
import { ParsedArgs } from 'minimist';
|
||||
import { Application } from '../../../../automation';
|
||||
import { afterSuite, beforeSuite } from '../../utils';
|
||||
|
||||
export function setup(opts: ParsedArgs) {
|
||||
describe.skip('Terminal Profiles', () => {
|
||||
describe('Terminal Profiles', () => {
|
||||
let app: Application;
|
||||
|
||||
beforeSuite(opts);
|
||||
afterSuite(opts);
|
||||
|
||||
it.skip('should launch the default profile', async () => {
|
||||
const app = this.app as Application;
|
||||
console.log(app);
|
||||
before(function () {
|
||||
app = this.app;
|
||||
});
|
||||
|
||||
it('should launch the default profile', async function () {
|
||||
await app.workbench.terminal.showTerminal();
|
||||
|
||||
// Verify the terminal buffer has some content
|
||||
await app.workbench.terminal.waitForTerminalText(buffer => {
|
||||
return buffer.some(e => e.length > 100);
|
||||
}, 'The terminal buffer should have some content');
|
||||
|
||||
|
||||
// Verify the terminal single tab shows up and has a title
|
||||
const terminalTab = await app.code.waitForElement('.single-terminal-tab');
|
||||
ok(terminalTab.textContent.trim().length > 0);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue