Path: blob/main/test/smoke/src/areas/terminal/terminal-input.test.ts
3520 views
/*---------------------------------------------------------------------------------------------1* Copyright (c) Microsoft Corporation. All rights reserved.2* Licensed under the MIT License. See License.txt in the project root for license information.3*--------------------------------------------------------------------------------------------*/45import { Application, Terminal, SettingsEditor } from '../../../../automation';6import { setTerminalTestSettings } from './terminal-helpers';78export function setup(options?: { skipSuite: boolean }) {9(options?.skipSuite ? describe.skip : describe)('Terminal Input', () => {10let terminal: Terminal;11let settingsEditor: SettingsEditor;1213// Acquire automation API14before(async function () {15const app = this.app as Application;16terminal = app.workbench.terminal;17settingsEditor = app.workbench.settingsEditor;18await setTerminalTestSettings(app);19});2021after(async function () {22await settingsEditor.clearUserSettings();23});2425describe('Auto replies', function () {2627// HACK: Retry this suite only on Windows because conpty can rarely lead to unexpected behavior which would28// cause flakiness. If this does happen, the feature is expected to fail.29if (process.platform === 'win32') {30this.retries(3);31}3233async function writeTextForAutoReply(text: string): Promise<void> {34// Put the matching word in quotes to avoid powershell coloring the first word and35// on a new line to avoid cursor move/line switching sequences36await terminal.runCommandInTerminal(`"\r${text}`, true);37}3839it('should automatically reply to a custom entry', async () => {40await settingsEditor.addUserSetting('terminal.integrated.autoReplies', '{ "foo": "bar" }');41await terminal.createTerminal();42await writeTextForAutoReply('foo');43await terminal.waitForTerminalText(buffer => buffer.some(line => line.match(/foo.*bar/)));44});45});46});47}484950