[RNMobile] Add reusable block insertion test case#32506
Conversation
We shouldn't update the state from the slot rendering because it's a different component, otherwise it fails with the following error: Warning: Cannot update a component (`BlockMobileToolbar`) while rendering a different component (`BlockSettingsFill`). To locate the bad setState() call inside `BlockSettingsFill`, follow the stack trace as described in https://fb.me/setstate-in-render
…-tests # Conflicts: # packages/block-library/src/block/test/edit.native.js # test/native/__mocks__/styleMock.js # test/native/helpers.js
|
Size Change: -3.04 kB (0%) Total Size: 1.04 MB
ℹ️ View Unchanged
|
| ) | ||
| ); | ||
|
|
||
| expect( reusableBlockRequest ).toBeDefined(); |
There was a problem hiding this comment.
I decided to remove this check because it's already covered when verifying the existence of the reusable block.
| expect( reusableBlockRequest ).toBeDefined(); | ||
| expect( reusableBlock ).toBeDefined(); | ||
| expect( blockDeleted ).toBeDefined(); | ||
| expect( getEditorHtml() ).toBe( initialHtml ); |
There was a problem hiding this comment.
We're not making modifications to the content so this check is not really necessary.
| searchFormPlaceholder: { | ||
| color: 'gray', | ||
| }, | ||
| ripple: { | ||
| backgroundColor: 'white', | ||
| }, |
There was a problem hiding this comment.
These styles are required to render the inserter menu.
| } ); | ||
|
|
||
| export async function initializeEditor( { initialHtml } ) { | ||
| export async function initializeEditor( props ) { |
There was a problem hiding this comment.
This change allows us to pass any Editor prop on the initialization like the capabilities object.
There was a problem hiding this comment.
The tests pass locally for me, however I noticed a few warning logs. Have you seen these as well? Can we address these or are they unrelated?
Test Warning Logs
console.warn
`wp.data.select( 'core/editor' ).getBlockSelectionEnd` is deprecated since version 5.3. Please use `wp.data.select( 'core/block-editor' ).getBlockSelectionEnd` instead.
75 |
76 | // eslint-disable-next-line no-console
> 77 | console.warn( message );
| ^
78 |
79 | logged[ message ] = true;
80 | }
at deprecated (packages/deprecated/src/index.js:77:10)
at packages/editor/src/store/selectors.js:1338:3
at selector (packages/data/src/factory.js:43:3)
at packages/data/src/redux-store/index.js:135:16
at getBlockSelectionEnd (packages/data/src/redux-store/index.js:280:27)
at mapSelectToProps (packages/edit-post/src/components/header/header-toolbar/index.native.js:128:28)
at mapSelect (packages/data/src/components/with-select/index.js:55:6)
console.warn
`wp.data.select( 'core/editor' ).getBlockRootClientId` is deprecated since version 5.3. Please use `wp.data.select( 'core/block-editor' ).getBlockRootClientId` instead.
75 |
76 | // eslint-disable-next-line no-console
> 77 | console.warn( message );
| ^
78 |
79 | logged[ message ] = true;
80 | }
at deprecated (packages/deprecated/src/index.js:77:10)
at packages/editor/src/store/selectors.js:1338:3
at selector (packages/data/src/factory.js:43:3)
at packages/data/src/redux-store/index.js:135:16
at getBlockRootClientId (packages/data/src/redux-store/index.js:280:27)
at mapSelectToProps (packages/edit-post/src/components/header/header-toolbar/index.native.js:128:6)
at mapSelect (packages/data/src/components/with-select/index.js:55:6)
console.warn
`wp.data.select( 'core/editor' ).hasInserterItems` is deprecated since version 5.3. Please use `wp.data.select( 'core/block-editor' ).hasInserterItems` instead.
75 |
76 | // eslint-disable-next-line no-console
> 77 | console.warn( message );
| ^
78 |
79 | logged[ message ] = true;
80 | }
at deprecated (packages/deprecated/src/index.js:77:10)
at packages/editor/src/store/selectors.js:1338:3
at selector (packages/data/src/factory.js:43:3)
at packages/data/src/redux-store/index.js:135:16
at hasInserterItems (packages/data/src/redux-store/index.js:280:27)
at mapSelectToProps (packages/edit-post/src/components/header/header-toolbar/index.native.js:127:5)
at mapSelect (packages/data/src/components/with-select/index.js:55:6)
Yeah, I noticed this too but it's also happening when running the app, probably began to happen after the RN |
I addressed this issue in this PR 🎊 . |
gutenberg-mobilePR: wordpress-mobile/gutenberg-mobile#3654Description
Add the block insertion case for the reusable block.
This PR also introduces fixes for rendering the inserter menu in the tests and addresses the warning
Cannot update component while rendering a different componentdescribed in this issue.How has this been tested?
npm run native test block/test(in gutenberg) ornpm run core test block/test(in gutenberg-mobile)Screenshots
N/A
Types of changes
New integration test.
Checklist:
*.native.jsfiles for terms that need renaming or removal).