From d7f10626b85fbaaf0b80b20dc4d3887ddf833227 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Tue, 23 Nov 2021 15:18:38 -0800 Subject: [PATCH] Clean up terminal smoke test setup Part of #136064 --- .../areas/terminal/terminal-editors.test.ts | 16 +++---- .../terminal/terminal-persistence.test.ts | 13 +----- .../areas/terminal/terminal-profiles.test.ts | 16 +++---- .../src/areas/terminal/terminal-tabs.test.ts | 16 +++---- .../smoke/src/areas/terminal/terminal.test.ts | 44 +++++++++++++++++++ test/smoke/src/main.ts | 12 +---- 6 files changed, 62 insertions(+), 55 deletions(-) create mode 100644 test/smoke/src/areas/terminal/terminal.test.ts diff --git a/test/smoke/src/areas/terminal/terminal-editors.test.ts b/test/smoke/src/areas/terminal/terminal-editors.test.ts index a57d6d50d9c..14c4fb9ecbe 100644 --- a/test/smoke/src/areas/terminal/terminal-editors.test.ts +++ b/test/smoke/src/areas/terminal/terminal-editors.test.ts @@ -4,22 +4,16 @@ *--------------------------------------------------------------------------------------------*/ import { ParsedArgs } from 'minimist'; -import { Terminal, TerminalCommandId, TerminalCommandIdWithValue } from '../../../../automation/out'; -import { afterSuite, beforeSuite } from '../../utils'; +import { Application, Terminal, TerminalCommandId, TerminalCommandIdWithValue } from '../../../../automation/out'; export function setup(opts: ParsedArgs) { describe('Terminal Editors', () => { let terminal: Terminal; - beforeSuite(opts); - afterSuite(opts); - - before(function () { - terminal = this.app.workbench.terminal; - }); - - afterEach(async () => { - await terminal.runCommand(TerminalCommandId.KillAll); + // Acquire automation API + before(async function () { + const app = this.app as Application; + terminal = app.workbench.terminal; }); // TODO: This was flaky in CI diff --git a/test/smoke/src/areas/terminal/terminal-persistence.test.ts b/test/smoke/src/areas/terminal/terminal-persistence.test.ts index 50998b5ac76..754bff8f96c 100644 --- a/test/smoke/src/areas/terminal/terminal-persistence.test.ts +++ b/test/smoke/src/areas/terminal/terminal-persistence.test.ts @@ -5,26 +5,15 @@ import { ParsedArgs } from 'minimist'; import { Application, Terminal, TerminalCommandId, TerminalCommandIdWithValue } from '../../../../automation/out'; -import { afterSuite, beforeSuite } from '../../utils'; export function setup(opts: ParsedArgs) { describe('Terminal Persistence', () => { let terminal: Terminal; - beforeSuite(opts); - afterSuite(opts); - + // Acquire automation API before(async function () { 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"'); - await app.workbench.quickaccess.runCommand('workbench.action.closeAllEditors'); - }); - - afterEach(async () => { - await terminal.runCommand(TerminalCommandId.KillAll); }); describe('detach/attach', () => { diff --git a/test/smoke/src/areas/terminal/terminal-profiles.test.ts b/test/smoke/src/areas/terminal/terminal-profiles.test.ts index 0d111333689..597f03f8c5d 100644 --- a/test/smoke/src/areas/terminal/terminal-profiles.test.ts +++ b/test/smoke/src/areas/terminal/terminal-profiles.test.ts @@ -4,8 +4,7 @@ *--------------------------------------------------------------------------------------------*/ import { ParsedArgs } from 'minimist'; -import { Terminal, TerminalCommandId, TerminalCommandIdWithValue } from '../../../../automation'; -import { afterSuite, beforeSuite } from '../../utils'; +import { Application, Terminal, TerminalCommandId, TerminalCommandIdWithValue } from '../../../../automation'; const CONTRIBUTED_PROFILE_NAME = `JavaScript Debug Terminal`; const ANY_PROFILE_NAME = '^((?!JavaScript Debug Terminal).)*$'; @@ -14,15 +13,10 @@ export function setup(opts: ParsedArgs) { describe('Terminal Profiles', () => { let terminal: Terminal; - beforeSuite(opts); - afterSuite(opts); - - before(function () { - terminal = this.app.workbench.terminal; - }); - - afterEach(async () => { - await terminal.runCommand(TerminalCommandId.KillAll); + // Acquire automation API + before(async function () { + const app = this.app as Application; + terminal = app.workbench.terminal; }); it('should launch the default profile', async () => { diff --git a/test/smoke/src/areas/terminal/terminal-tabs.test.ts b/test/smoke/src/areas/terminal/terminal-tabs.test.ts index 287956135a0..19faa4ae13d 100644 --- a/test/smoke/src/areas/terminal/terminal-tabs.test.ts +++ b/test/smoke/src/areas/terminal/terminal-tabs.test.ts @@ -5,22 +5,16 @@ import { ParsedArgs } from 'minimist'; -import { Terminal, TerminalCommandId, TerminalCommandIdWithValue } from '../../../../automation/out'; -import { afterSuite, beforeSuite } from '../../utils'; +import { Application, Terminal, TerminalCommandId, TerminalCommandIdWithValue } from '../../../../automation/out'; export function setup(opts: ParsedArgs) { describe('Terminal Tabs', () => { let terminal: Terminal; - beforeSuite(opts); - afterSuite(opts); - - before(function () { - terminal = this.app.workbench.terminal; - }); - - afterEach(async () => { - await terminal.runCommand(TerminalCommandId.KillAll); + // Acquire automation API + before(async 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 () => { diff --git a/test/smoke/src/areas/terminal/terminal.test.ts b/test/smoke/src/areas/terminal/terminal.test.ts new file mode 100644 index 00000000000..a8010c28df2 --- /dev/null +++ b/test/smoke/src/areas/terminal/terminal.test.ts @@ -0,0 +1,44 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ + +import minimist = require('minimist'); +import { Application, Terminal, TerminalCommandId } from '../../../../automation/out'; +import { afterSuite, beforeSuite } from '../../utils'; +import { setup as setupTerminalEditorsTests } from './terminal-editors.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'; + +export function setup(opts: minimist.ParsedArgs) { + describe.only('Terminal', () => { + // TODO: Enable terminal tests for non-web when it moved to playwright + if (!opts.web) { + return; + } + + beforeSuite(opts); + afterSuite(opts); + + 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"'); + }); + + afterEach(async () => { + // Kill all terminals between every test for a consistent testing environment + await terminal.runCommand(TerminalCommandId.KillAll); + }); + + setupTerminalEditorsTests(opts); + setupTerminalPersistenceTests(opts); + setupTerminalProfileTests(opts); + setupTerminalTabsTests(opts); + }); +} diff --git a/test/smoke/src/main.ts b/test/smoke/src/main.ts index 4fd1871977a..e8690140263 100644 --- a/test/smoke/src/main.ts +++ b/test/smoke/src/main.ts @@ -28,10 +28,7 @@ import { setup as setupExtensionTests } from './areas/extensions/extensions.test import { setup as setupMultirootTests } from './areas/multiroot/multiroot.test'; import { setup as setupLocalizationTests } from './areas/workbench/localization.test'; import { setup as setupLaunchTests } from './areas/workbench/launch.test'; -import { setup as setupTerminalProfileTests } from './areas/terminal/terminal-profiles.test'; -import { setup as setupTerminalTabsTests } from './areas/terminal/terminal-tabs.test'; -import { setup as setupTerminalEditorsTests } from './areas/terminal/terminal-editors.test'; -import { setup as setupTerminalPersistenceTests } from './areas/terminal/terminal-persistence.test'; +import { setup as setupTerminalTests } from './areas/terminal/terminal.test'; try { gracefulify(fs); @@ -362,15 +359,10 @@ describe(`VSCode Smoke Tests (${opts.web ? 'Web' : 'Electron'})`, () => { setupNotebookTests(opts); setupLanguagesTests(opts); setupEditorTests(opts); + setupTerminalTests(opts); setupStatusbarTests(opts); setupExtensionTests(opts); if (!opts.web) { setupMultirootTests(opts); } if (!opts.web) { setupLocalizationTests(opts); } if (!opts.web) { setupLaunchTests(opts); } - - // TODO: Enable terminal tests for non-web when it moved to playwright - if (opts.web) { setupTerminalProfileTests(opts); } - if (opts.web) { setupTerminalTabsTests(opts); } - if (opts.web) { setupTerminalEditorsTests(opts); } - if (opts.web) { setupTerminalPersistenceTests(opts); } });