Make sticky scroll smoketest more consistent

This commit is contained in:
Daniel Imms 2023-11-08 06:30:51 -08:00
parent 26db70d00a
commit 90d1e81ce9
No known key found for this signature in database
GPG key ID: E5CF412B63651C69

View file

@ -3,7 +3,8 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { Application, Terminal, SettingsEditor } from '../../../../automation';
import { Application, Terminal, SettingsEditor, TerminalCommandIdWithValue } from '../../../../automation';
import { timeout } from '../../utils';
import { setTerminalTestSettings } from './terminal-helpers';
export function setup() {
@ -17,7 +18,8 @@ export function setup() {
terminal = app.workbench.terminal;
settingsEditor = app.workbench.settingsEditor;
await setTerminalTestSettings(app, [
['terminal.integrated.enableStickyScroll', 'true']
['terminal.integrated.enableStickyScroll', 'true'],
['terminal.integrated.shellIntegration.enabled', 'true']
]);
});
@ -25,14 +27,26 @@ export function setup() {
await settingsEditor.clearUserSettings();
});
async function createShellIntegrationProfile() {
await terminal.runCommandWithValue(TerminalCommandIdWithValue.NewWithProfile, process.platform === 'win32' ? 'PowerShell' : 'bash');
}
it('should show sticky scroll when appropriate', async () => {
// There should not be a visible sticky scroll element initially
await terminal.createTerminal();
await createShellIntegrationProfile();
await app.code.waitForElements('.terminal-sticky-scroll', false, elements => elements.length === 0);
// Print a simple command in order to ensure shell integration sequences appear at the
// correct place. This helps avoid a race condition if too much data floods into the
// terminal before things are initialized.
await terminal.runCommandInTerminal('echo "start up"');
await terminal.waitForTerminalText(buffer => buffer.some(line => line.startsWith('start up')));
// Allow to settle, again to avoid race conditions (with conpty)
await timeout(500);
// Running ls should show the sticky scroll element
await terminal.runCommandInTerminal(`ls`); // Long in pwsh
await terminal.runCommandInTerminal(`ls -la`); // Long in bash/zsh
await terminal.runCommandInTerminal(process.platform === 'win32' ? `ls` : `ls -la`);
await app.code.waitForElements('.terminal-sticky-scroll', false, elements => elements.length === 1 && elements[0].textContent.indexOf('ls') >= 0);
});
});