diff --git a/ui/tests/helpers/xterm.ts b/ui/tests/helpers/xterm.ts index 7a634f08f6f..07906fe3938 100644 --- a/ui/tests/helpers/xterm.ts +++ b/ui/tests/helpers/xterm.ts @@ -1,5 +1,17 @@ import { triggerEvent, triggerKeyEvent, focus } from '@ember/test-helpers'; +// At the time of writing, xterm.js only implements the Macintosh “select all” +// keyboard shortcut (cmd+a), not the Linux and Windows equivalent (ctrl+a). +// What follows is a dreadful hack to make `getTerminalText` work in Linux CI. +// Note: this needs to happen before xterm is required, so you’ll find an +// import in `tests/test-helper.js`. +Object.defineProperty(navigator, 'platform', { + value: 'Macintosh', + configurable: true, + enumerable: true, + writable: false, +}); + /** * Returns the text from an xterm.js terminal element. * @@ -10,9 +22,8 @@ import { triggerEvent, triggerKeyEvent, focus } from '@ember/test-helpers'; export async function getTerminalText(): Promise { await focus('.xterm-helper-textarea'); - // Trigger cmd+a and ctrl+a to select all + // Trigger cmd+a to select all await triggerKeyEvent('.xterm-helper-textarea', 'keydown', 65, { metaKey: true }); - await triggerKeyEvent('.xterm-helper-textarea', 'keydown', 65, { ctrlKey: true }); let clipboardData = new DataTransfer(); await triggerEvent('.xterm', 'copy', { clipboardData }); diff --git a/ui/tests/test-helper.js b/ui/tests/test-helper.js index 706330d006a..5a7ba415455 100644 --- a/ui/tests/test-helper.js +++ b/ui/tests/test-helper.js @@ -6,6 +6,7 @@ import { setup } from 'qunit-dom'; import { start } from 'ember-qunit'; import { setup as setupA11yTesting } from './helpers/a11y'; import './helpers/flash-message'; +import './helpers/xterm'; setApplication(Application.create(config.APP));