diff options
author | Daniel Imms <2193314+Tyriar@users.noreply.github.com> | 2022-06-16 04:50:34 +0300 |
---|---|---|
committer | Daniel Imms <2193314+Tyriar@users.noreply.github.com> | 2022-06-16 04:50:34 +0300 |
commit | 87a99dba093285e9cc88151d1b47808c6e578ed7 (patch) | |
tree | 2907580044c77ea61b4d7fe1f746e8531ecea438 /test | |
parent | 18408b909006d18e2e08e8b1c50d20b31854b644 (diff) |
Speed up shell integration tests and improve reliability
Diffstat (limited to 'test')
-rw-r--r-- | test/automation/src/settings.ts | 20 | ||||
-rw-r--r-- | test/automation/src/terminal.ts | 12 | ||||
-rw-r--r-- | test/smoke/src/areas/terminal/terminal-helpers.ts | 18 | ||||
-rw-r--r-- | test/smoke/src/areas/terminal/terminal-shellIntegration.test.ts | 19 |
4 files changed, 52 insertions, 17 deletions
diff --git a/test/automation/src/settings.ts b/test/automation/src/settings.ts index cda80632998..49cd35a5daa 100644 --- a/test/automation/src/settings.ts +++ b/test/automation/src/settings.ts @@ -12,6 +12,12 @@ export class SettingsEditor { constructor(private code: Code, private editors: Editors, private editor: Editor, private quickaccess: QuickAccess) { } + /** + * Write a single setting key value pair. + * + * Warning: You may need to set `editor.wordWrap` to `"on"` if this is called with a really long + * setting. + */ async addUserSetting(setting: string, value: string): Promise<void> { await this.openUserSettingsFile(); @@ -20,6 +26,20 @@ export class SettingsEditor { await this.editors.saveOpenedFile(); } + /** + * Write several settings faster than multiple calls to {@link addUserSetting}. + * + * Warning: You will likely also need to set `editor.wordWrap` to `"on"` if `addUserSetting` is + * called after this in the test. + */ + async addUserSettings(settings: [key: string, value: string][]): Promise<void> { + await this.openUserSettingsFile(); + + await this.code.dispatchKeybinding('right'); + await this.editor.waitForTypeInEditor('settings.json', settings.map(v => `"${v[0]}": ${v[1]},`).join('')); + await this.editors.saveOpenedFile(); + } + async clearUserSettings(): Promise<void> { await this.openUserSettingsFile(); await this.quickaccess.runCommand('editor.action.selectAll'); diff --git a/test/automation/src/terminal.ts b/test/automation/src/terminal.ts index 1dfeac42aeb..dfb24636716 100644 --- a/test/automation/src/terminal.ts +++ b/test/automation/src/terminal.ts @@ -83,8 +83,16 @@ export class Terminal { await this.code.dispatchKeybinding('enter'); await this.quickinput.waitForQuickInputClosed(); } - if (commandId === TerminalCommandId.Show || commandId === TerminalCommandId.CreateNewEditor || commandId === TerminalCommandId.CreateNew || commandId === TerminalCommandId.NewWithProfile) { - return await this._waitForTerminal(expectedLocation === 'editor' || commandId === TerminalCommandId.CreateNewEditor ? 'editor' : 'panel'); + switch (commandId) { + case TerminalCommandId.Show: + case TerminalCommandId.CreateNewEditor: + case TerminalCommandId.CreateNew: + case TerminalCommandId.NewWithProfile: + await this._waitForTerminal(expectedLocation === 'editor' || commandId === TerminalCommandId.CreateNewEditor ? 'editor' : 'panel'); + break; + case TerminalCommandId.KillAll: + await this.code.waitForElements(Selector.Xterm, true, e => e.length === 0); + break; } } diff --git a/test/smoke/src/areas/terminal/terminal-helpers.ts b/test/smoke/src/areas/terminal/terminal-helpers.ts index 24eccb0c2db..c333df0bc5a 100644 --- a/test/smoke/src/areas/terminal/terminal-helpers.ts +++ b/test/smoke/src/areas/terminal/terminal-helpers.ts @@ -5,12 +5,18 @@ import { Application } from '../../../../automation'; -export async function setTerminalTestSettings(app: Application) { - // Always show tabs to make getting terminal groups easier - await app.workbench.settingsEditor.addUserSetting('terminal.integrated.tabs.hideCondition', '"never"'); - // Use the DOM renderer for smoke tests so they can be inspected in the playwright trace - // viewer - await app.workbench.settingsEditor.addUserSetting('terminal.integrated.gpuAcceleration', '"off"'); +export async function setTerminalTestSettings(app: Application, additionalSettings: [key: string, value: string][] = []) { + await app.workbench.settingsEditor.addUserSettings([ + // Work wrap is required when calling settingsEditor.addUserSetting multiple times or the + // click to focus will fail + ['editor.wordWrap', '"on"'], + // Always show tabs to make getting terminal groups easier + ['terminal.integrated.tabs.hideCondition', '"never"'], + // Use the DOM renderer for smoke tests so they can be inspected in the playwright trace + // viewer + ['terminal.integrated.gpuAcceleration', '"off"'], + ...additionalSettings + ]); // Close the settings editor await app.workbench.quickaccess.runCommand('workbench.action.closeAllEditors'); diff --git a/test/smoke/src/areas/terminal/terminal-shellIntegration.test.ts b/test/smoke/src/areas/terminal/terminal-shellIntegration.test.ts index 24dc769beb8..75fa3ca8a65 100644 --- a/test/smoke/src/areas/terminal/terminal-shellIntegration.test.ts +++ b/test/smoke/src/areas/terminal/terminal-shellIntegration.test.ts @@ -17,18 +17,17 @@ export function setup() { app = this.app as Application; terminal = app.workbench.terminal; settingsEditor = app.workbench.settingsEditor; - await settingsEditor.addUserSetting('terminal.integrated.shellIntegration.enabled', 'true'); - await setTerminalTestSettings(app); - }); - - after(async function () { - await settingsEditor.clearUserSettings(); + await setTerminalTestSettings(app, [['terminal.integrated.shellIntegration.enabled', 'true']]); }); afterEach(async function () { await app.workbench.terminal.runCommand(TerminalCommandId.KillAll); }); + after(async function () { + await settingsEditor.clearUserSettings(); + }); + async function createShellIntegrationProfile() { await terminal.runCommandWithValue(TerminalCommandIdWithValue.NewWithProfile, process.platform === 'win32' ? 'PowerShell' : 'bash'); } @@ -36,6 +35,7 @@ export function setup() { describe(`Shell integration ${i}`, function () { describe('Decorations', function () { describe('Should show default icons', function () { + it('Placeholder', async () => { await createShellIntegrationProfile(); await terminal.assertCommandDecorations({ placeholder: 1, success: 0, error: 0 }); @@ -47,7 +47,7 @@ export function setup() { }); it('Error', async () => { await createShellIntegrationProfile(); - await terminal.runCommandInTerminal(`fsdkfsjdlfksjdkf`); + await terminal.runCommandInTerminal(`false`); await terminal.assertCommandDecorations({ placeholder: 1, success: 0, error: 1 }); }); }); @@ -55,12 +55,13 @@ export function setup() { it('Should update and show custom icons', async () => { await createShellIntegrationProfile(); await terminal.assertCommandDecorations({ placeholder: 1, success: 0, error: 0 }); - await terminal.runCommandInTerminal(`echo "success"`); - await terminal.runCommandInTerminal(`fsdkfsjdlfksjdkf`); + await terminal.runCommandInTerminal(`echo "foo"`); + await terminal.runCommandInTerminal(`bar`); await settingsEditor.addUserSetting('terminal.integrated.shellIntegration.decorationIcon', '"zap"'); await settingsEditor.addUserSetting('terminal.integrated.shellIntegration.decorationIconSuccess', '"zap"'); await settingsEditor.addUserSetting('terminal.integrated.shellIntegration.decorationIconError', '"zap"'); await terminal.assertCommandDecorations(undefined, { updatedIcon: "zap", count: 3 }); + await app.workbench.terminal.runCommand(TerminalCommandId.KillAll); }); }); }); |