Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Address a11y issues in browser-based console UI #26872

Merged
merged 18 commits into from
May 16, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix test to toggle panel open before using it
move toggle to commands helper file

move toggle to ui-panel helper file

added shouldToggle arg to runcommand

fix console tests
MelSumner committed May 16, 2024

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
commit 36256daff1797a56b39a4b614ba687fa9a1e534a
10 changes: 4 additions & 6 deletions ui/tests/acceptance/console-test.js
Original file line number Diff line number Diff line change
@@ -25,8 +25,6 @@ module('Acceptance | console', function (hooks) {
assert.expect(6);
await enginesPage.visit();
await settled();
await consoleComponent.toggle();
await settled();
const ids = [uuidv4(), uuidv4(), uuidv4()];
for (const id of ids) {
const inputString = `write sys/mounts/console-route-${id} type=kv`;
@@ -59,7 +57,7 @@ module('Acceptance | console', function (hooks) {
test('fullscreen command expands the cli panel', async function (assert) {
await consoleComponent.toggle();
await settled();
await consoleComponent.runCommands('fullscreen');
await consoleComponent.runCommands('fullscreen', false);
await settled();
const consoleEle = document.querySelector('[data-test-component="console/ui-panel"]');
// wait for the CSS transition to finish
@@ -74,7 +72,7 @@ module('Acceptance | console', function (hooks) {
test('array output is correctly formatted', async function (assert) {
await consoleComponent.toggle();
await settled();
await consoleComponent.runCommands('read -field=policies /auth/token/lookup-self');
await consoleComponent.runCommands('read -field=policies /auth/token/lookup-self', false);
await settled();
const consoleOut = document.querySelector('.console-ui-output>pre');
// wait for the CSS transition to finish
@@ -86,7 +84,7 @@ module('Acceptance | console', function (hooks) {
test('number output is correctly formatted', async function (assert) {
await consoleComponent.toggle();
await settled();
await consoleComponent.runCommands('read -field=creation_time /auth/token/lookup-self');
await consoleComponent.runCommands('read -field=creation_time /auth/token/lookup-self', false);
await settled();
const consoleOut = document.querySelector('.console-ui-output>pre');
// wait for the CSS transition to finish
@@ -97,7 +95,7 @@ module('Acceptance | console', function (hooks) {
test('boolean output is correctly formatted', async function (assert) {
await consoleComponent.toggle();
await settled();
await consoleComponent.runCommands('read -field=orphan /auth/token/lookup-self');
await consoleComponent.runCommands('read -field=orphan /auth/token/lookup-self', false);
await settled();
const consoleOut = document.querySelector('.console-ui-output>pre');
// have to wrap in a later so that we can wait for the CSS transition to finish
5 changes: 3 additions & 2 deletions ui/tests/helpers/commands.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import consoleClass from 'vault/tests/pages/components/console/ui-panel';
import { create } from 'ember-cli-page-object';
/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: BUSL-1.1
*/

import consoleClass from 'vault/tests/pages/components/console/ui-panel';
import { create } from 'ember-cli-page-object';

/**
* Helper functions to run common commands in the consoleComponent during tests.
* Please note that a user must be logged in during the test context for the commands to run.
16 changes: 8 additions & 8 deletions ui/tests/integration/components/console/ui-panel-test.js
Original file line number Diff line number Diff line change
@@ -23,20 +23,21 @@ module('Integration | Component | console/ui panel', function (hooks) {

test('it clears console input on enter', async function (assert) {
await render(hbs`{{console/ui-panel}}`);

await component.runCommands('list this/thing/here');
await component.runCommands('list this/thing/here', false);
await settled();
assert.strictEqual(component.consoleInputValue, '', 'empties input field on enter');
});

test('it clears the log when using clear command', async function (assert) {
await render(hbs`{{console/ui-panel}}`);

await component.runCommands(['list this/thing/here', 'list this/other/thing', 'read another/thing']);
await component.runCommands(
['list this/thing/here', 'list this/other/thing', 'read another/thing'],
false
);
await settled();
assert.notEqual(component.logOutput, '', 'there is output in the log');

await component.runCommands('clear');
await component.runCommands('clear', false);
await settled();
await component.up();
await settled();
@@ -51,7 +52,7 @@ module('Integration | Component | console/ui panel', function (hooks) {
test('it adds command to history on enter', async function (assert) {
await render(hbs`{{console/ui-panel}}`);

await component.runCommands('list this/thing/here');
await component.runCommands('list this/thing/here', false);
await settled();
await component.up();
await settled();
@@ -67,8 +68,7 @@ module('Integration | Component | console/ui panel', function (hooks) {

test('it cycles through history with more than one command', async function (assert) {
await render(hbs`{{console/ui-panel}}`);

await component.runCommands(['list this/thing/here', 'read that/thing/there', 'qwerty']);
await component.runCommands(['list this/thing/here', 'read that/thing/there', 'qwerty'], false);
await settled();
await component.up();
await settled();
4 changes: 2 additions & 2 deletions ui/tests/integration/components/sidebar/frame-test.js
Original file line number Diff line number Diff line change
@@ -35,7 +35,7 @@ module('Integration | Component | sidebar-frame', function (hooks) {
assert.dom('[data-test-sidebar-nav]').doesNotExist('Sidebar is hidden');
});

test('it should render link status, console ui panel and yield block for app content', async function (assert) {
test('it should render link status, console ui panel container and yield block for app content', async function (assert) {
const currentCluster = this.owner.lookup('service:currentCluster');
currentCluster.setCluster({ hcpLinkStatus: 'connected' });
const version = this.owner.lookup('service:version');
@@ -50,7 +50,7 @@ module('Integration | Component | sidebar-frame', function (hooks) {
`);

assert.dom('[data-test-link-status]').exists('Link status component renders');
assert.dom('[data-test-component="console/ui-panel"]').exists('Console UI panel renders');
assert.dom('[data-test-console-panel]').exists('Console UI panel container renders');
assert.dom('.page-container').exists('Block yields for app content');
});

8 changes: 7 additions & 1 deletion ui/tests/pages/components/console/ui-panel.js
Original file line number Diff line number Diff line change
@@ -54,12 +54,18 @@ export default {
eventProperties: { keyCode: keys.ENTER },
}),
hasInput: isPresent('[data-test-component="console/command-input"] input'),
runCommands: async function (commands) {
runCommands: async function (commands, shouldToggle = true) {
Copy link
Contributor Author

@MelSumner MelSumner May 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We needed to add an extra condition here, because there are tests that don't actually need the toggle to happen. Maybe it's rendering the console/ui-panel directly, or maybe it's a test that runs multiple commands and multiple toggles would cause those tests to fail.

But in most cases this is a useful thing to do, so it defaults to true

const toExecute = Array.isArray(commands) ? commands : [commands];
if (shouldToggle) {
await this.toggle(); // toggle the console open
}
for (const command of toExecute) {
await this.consoleInput(command);
await this.enter();
await settled();
}
if (shouldToggle) {
await this.toggle(); // toggle it closed
}
},
};