From 81212dc64ac84ebe9dcd589b6ad82cfcf1824ae5 Mon Sep 17 00:00:00 2001
From: David Calhoun <438664+dcalhoun@users.noreply.github.com>
Date: Wed, 15 Feb 2023 08:27:32 -0500
Subject: [PATCH] test: Fix errors in Rich Text performance test
- Remove unnecessary lint warning disable line caused by erroneous
placement of `screen` argument.
- Query UI components via user-facing attributes, e.g. a11y label.
- Pass mock function to required `onChange` prop to `RichText`
component.
---
.../src/components/rich-text/test/index.perf-test.js | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)
diff --git a/packages/block-editor/src/components/rich-text/test/index.perf-test.js b/packages/block-editor/src/components/rich-text/test/index.perf-test.js
index a1f44f89711471..d3fb6b2628be19 100644
--- a/packages/block-editor/src/components/rich-text/test/index.perf-test.js
+++ b/packages/block-editor/src/components/rich-text/test/index.perf-test.js
@@ -5,6 +5,7 @@ import {
changeTextOfRichText,
fireEvent,
measurePerformance,
+ screen,
} from 'test/helpers';
/**
@@ -13,10 +14,9 @@ import {
import { RichText } from '@wordpress/block-editor';
describe( 'RichText Performance', () => {
- // eslint-disable-next-line jest/no-done-callback
- it( 'performance is stable', async ( screen ) => {
+ it( 'performance is stable', async () => {
const scenario = async () => {
- const richTextInput = screen.getByTestId( 'performance' );
+ const richTextInput = screen.getByLabelText( 'Text input. Empty' );
fireEvent( richTextInput, 'focus' );
@@ -24,12 +24,9 @@ describe( 'RichText Performance', () => {
richTextInput,
'Bold italic strikethrough text'
);
-
- // Check if the onChange is called and the state is updated.
- expect( changeTextOfRichText ).toHaveBeenCalledTimes( 1 );
};
- await measurePerformance( , {
+ await measurePerformance( , {
scenario,
} );
} );