Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/test/smoke/src/areas/terminal/terminal-input.test.ts
3520 views
1
/*---------------------------------------------------------------------------------------------
2
* Copyright (c) Microsoft Corporation. All rights reserved.
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
*--------------------------------------------------------------------------------------------*/
5
6
import { Application, Terminal, SettingsEditor } from '../../../../automation';
7
import { setTerminalTestSettings } from './terminal-helpers';
8
9
export function setup(options?: { skipSuite: boolean }) {
10
(options?.skipSuite ? describe.skip : describe)('Terminal Input', () => {
11
let terminal: Terminal;
12
let settingsEditor: SettingsEditor;
13
14
// Acquire automation API
15
before(async function () {
16
const app = this.app as Application;
17
terminal = app.workbench.terminal;
18
settingsEditor = app.workbench.settingsEditor;
19
await setTerminalTestSettings(app);
20
});
21
22
after(async function () {
23
await settingsEditor.clearUserSettings();
24
});
25
26
describe('Auto replies', function () {
27
28
// HACK: Retry this suite only on Windows because conpty can rarely lead to unexpected behavior which would
29
// cause flakiness. If this does happen, the feature is expected to fail.
30
if (process.platform === 'win32') {
31
this.retries(3);
32
}
33
34
async function writeTextForAutoReply(text: string): Promise<void> {
35
// Put the matching word in quotes to avoid powershell coloring the first word and
36
// on a new line to avoid cursor move/line switching sequences
37
await terminal.runCommandInTerminal(`"\r${text}`, true);
38
}
39
40
it('should automatically reply to a custom entry', async () => {
41
await settingsEditor.addUserSetting('terminal.integrated.autoReplies', '{ "foo": "bar" }');
42
await terminal.createTerminal();
43
await writeTextForAutoReply('foo');
44
await terminal.waitForTerminalText(buffer => buffer.some(line => line.match(/foo.*bar/)));
45
});
46
});
47
});
48
}
49
50