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

test: Fix Rich Text failures #60290

Merged
merged 2 commits into from
Mar 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
15 changes: 9 additions & 6 deletions packages/block-editor/src/components/rich-text/index.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -655,29 +655,32 @@ export function RichTextWrapper(
);
}

const ForwardedRichTextContainer = withDeprecations(
// This export does not actually implement a private API, but was exported
// under this name for interoperability with the web version of the RichText
// component.
export const PrivateRichText = withDeprecations(
forwardRef( RichTextWrapper )
);

ForwardedRichTextContainer.Content = Content;
PrivateRichText.Content = Content;

ForwardedRichTextContainer.isEmpty = ( value ) => {
PrivateRichText.isEmpty = ( value ) => {
return ! value || value.length === 0;
};

ForwardedRichTextContainer.Content.defaultProps = {
PrivateRichText.Content.defaultProps = {
format: 'string',
value: '',
};

ForwardedRichTextContainer.Raw = forwardRef( ( props, ref ) => (
PrivateRichText.Raw = forwardRef( ( props, ref ) => (
<RichText { ...props } nativeEditorRef={ ref } />
) );

/**
* @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/rich-text/README.md
*/
export default ForwardedRichTextContainer;
export default PrivateRichText;
export { RichTextShortcut } from './shortcut';
export { RichTextToolbarButton } from './toolbar-button';
export { __unstableRichTextInputEvent } from './input-event';
2 changes: 2 additions & 0 deletions packages/block-editor/src/private-apis.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import * as globalStyles from './components/global-styles';
import { ExperimentalBlockEditorProvider } from './components/provider';
import { getRichTextValues } from './components/rich-text/get-rich-text-values';
import { lock } from './lock-unlock';
import { PrivateRichText } from './components/rich-text/';

/**
* Private @wordpress/block-editor APIs.
Expand All @@ -14,4 +15,5 @@ lock( privateApis, {
...globalStyles,
ExperimentalBlockEditorProvider,
getRichTextValues,
PrivateRichText,
} );
1 change: 1 addition & 0 deletions test/native/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ jest.mock( '@wordpress/api-fetch', () => {
jest.mock( '@wordpress/react-native-bridge', () => {
return {
addEventListener: jest.fn(),
logException: jest.fn(),
Copy link
Contributor

Choose a reason for hiding this comment

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

Good catch! Since this function is only invoked when there's an error, we overlooked adding it because unit tests were passing. Thanks @dcalhoun for fixing it 🙇 !

mediaUploadSync: jest.fn(),
removeEventListener: jest.fn(),
requestBlockTypeImpressions: jest.fn( ( callback ) => {
Expand Down
Loading