Path: blob/main/test/smoke/src/areas/terminal/terminal-persistence.test.ts
5359 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, TerminalCommandId, TerminalCommandIdWithValue, SettingsEditor } from '../../../../automation';6import { setTerminalTestSettings } from './terminal-helpers';78export function setup(options?: { skipSuite: boolean }) {9(options?.skipSuite ? describe.skip : describe)('Terminal Persistence', () => {10// Acquire automation API11let terminal: Terminal;12let settingsEditor: SettingsEditor;1314before(async function () {15const app = this.app as Application;16terminal = app.workbench.terminal;17settingsEditor = app.workbench.settingsEditor;18await setTerminalTestSettings(app, [19// Use ${process} for terminal title to ensure stable names for detach/attach20['terminal.integrated.tabs.title', '"${process}"']21]);22});2324after(async function () {25await settingsEditor.clearUserSettings();26});2728describe('detach/attach', () => {29// https://github.com/microsoft/vscode/issues/13779930it('should support basic reconnection', async () => {31await terminal.createTerminal();32// TODO: Handle passing in an actual regex, not string33await terminal.assertTerminalGroups([34[{ name: '.*' }]35]);3637// Get the terminal name38await terminal.assertTerminalGroups([39[{ name: '.*' }]40]);41const name = (await terminal.getTerminalGroups())[0][0].name!;4243// Detach44await terminal.runCommand(TerminalCommandId.DetachSession);45await terminal.assertTerminalViewHidden();4647// Attach48await terminal.runCommandWithValue(TerminalCommandIdWithValue.AttachToSession, name);49await terminal.assertTerminalGroups([50[{ name }]51]);52});5354it.skip('should persist buffer content', async () => {55await terminal.createTerminal();56// TODO: Handle passing in an actual regex, not string57await terminal.assertTerminalGroups([58[{ name: '.*' }]59]);6061// Get the terminal name62await terminal.assertTerminalGroups([63[{ name: '.*' }]64]);65const name = (await terminal.getTerminalGroups())[0][0].name!;6667// Write in terminal68await terminal.runCommandInTerminal('echo terminal_test_content');69await terminal.waitForTerminalText(buffer => buffer.some(e => e.includes('terminal_test_content')));7071// Detach72await terminal.runCommand(TerminalCommandId.DetachSession);73await terminal.assertTerminalViewHidden();7475// Attach76await terminal.runCommandWithValue(TerminalCommandIdWithValue.AttachToSession, name);77await terminal.assertTerminalGroups([78[{ name }]79]);80// There can be line wrapping, so remove newlines and carriage returns #21646481await terminal.waitForTerminalText(buffer => buffer.some(e => e.replaceAll(/[\r\n]/g, '').includes('terminal_test_content')));82});83});84});85}868788