Merge pull request #7814 from backstage/remove-keyboardjs-usage

Remove usage of deprecated Keyboard class
This commit is contained in:
Johan Haals
2021-10-29 08:37:18 +02:00
committed by GitHub
3 changed files with 12 additions and 13 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/test-utils': patch
---
Update Keyboard deprecation with a link to the recommended successor
@@ -15,13 +15,10 @@
*/
import React from 'react';
import { render, fireEvent } from '@testing-library/react';
import {
wrapInTestApp,
Keyboard,
renderInTestApp,
} from '@backstage/test-utils';
import { fireEvent } from '@testing-library/react';
import { renderInTestApp } from '@backstage/test-utils';
import { HeaderActionMenu } from './HeaderActionMenu';
import userEvent from '@testing-library/user-event';
describe('<ComponentContextMenu />', () => {
it('renders without any items and without exploding', async () => {
@@ -89,16 +86,13 @@ describe('<ComponentContextMenu />', () => {
});
it('should close when hitting escape', async () => {
const rendered = render(
wrapInTestApp(
<HeaderActionMenu actionItems={[{ label: 'Some label' }]} />,
),
const rendered = await renderInTestApp(
<HeaderActionMenu actionItems={[{ label: 'Some label' }]} />,
);
expect(rendered.container.getAttribute('aria-hidden')).toBeNull();
fireEvent.click(rendered.getByTestId('header-action-menu'));
expect(rendered.container.getAttribute('aria-hidden')).toBe('true');
await Keyboard.type(rendered, '<Esc>');
userEvent.type(rendered.getByTestId('header-action-menu'), '{esc}');
expect(rendered.container.getAttribute('aria-hidden')).toBeNull();
});
});
@@ -25,7 +25,7 @@ const codes = {
/**
* @public
* @deprecated because it has no usages. Perhaps resurfaced in the future when need be.
* @deprecated superseded by {@link @testing-library/user-event#userEvent}
*/
export class Keyboard {
static async type(target, input) {