diff --git a/packages-internal/test-utils/src/focusVisible.ts b/packages-internal/test-utils/src/focusVisible.ts
index 8b650bc01ee0ae..ebc2f9cac1a07d 100644
--- a/packages-internal/test-utils/src/focusVisible.ts
+++ b/packages-internal/test-utils/src/focusVisible.ts
@@ -14,6 +14,10 @@ export function simulatePointerDevice() {
fireEvent.pointerDown(document.body);
}
+export function simulateKeyboardDevice() {
+ fireEvent.keyDown(document.body, { key: 'TAB' });
+}
+
/**
* See https://bugs.chromium.org/p/chromium/issues/detail?id=1127875 for more details.
*/
diff --git a/packages/mui-material/src/Button/Button.test.js b/packages/mui-material/src/Button/Button.test.js
index 0b887e085482df..d711feb1458cbd 100644
--- a/packages/mui-material/src/Button/Button.test.js
+++ b/packages/mui-material/src/Button/Button.test.js
@@ -1,11 +1,12 @@
import * as React from 'react';
import { expect } from 'chai';
-import { act, createRenderer, fireEvent, screen } from '@mui/internal-test-utils';
+import { act, createRenderer, fireEvent, screen, simulateKeyboardDevice } from '@mui/internal-test-utils';
import { ClassNames } from '@emotion/react';
import { ThemeProvider, createTheme } from '@mui/material/styles';
import Button, { buttonClasses as classes } from '@mui/material/Button';
import ButtonBase, { touchRippleClasses } from '@mui/material/ButtonBase';
import describeConformance from '../../test/describeConformance';
+import * as ripple from '../../test/ripple';
describe('', () => {
const { render, renderToString } = createRenderer();
@@ -555,23 +556,23 @@ describe('', () => {
expect(endIcon).not.to.have.class(classes.startIcon);
});
- it('should have a ripple by default', () => {
+ it('should have a ripple', async () => {
const { getByRole } = render(
,
);
const button = getByRole('button');
-
+ await ripple.startTouch(button);
expect(button.querySelector('.touch-ripple')).not.to.equal(null);
});
- it('can disable the ripple', () => {
+ it('can disable the ripple', async () => {
const { getByRole } = render(
,
);
const button = getByRole('button');
-
+ await ripple.startTouch(button);
expect(button.querySelector('.touch-ripple')).to.equal(null);
});
@@ -582,7 +583,7 @@ describe('', () => {
expect(button).to.have.class(classes.disableElevation);
});
- it('should have a focusRipple by default', () => {
+ it('should have a focusRipple', async () => {
const { getByRole } = render(