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
Embed block integration tests part 2 #35533
Changes from 1 commit
ae77e2e
d7446d1
afc1ddb
67ae243
f03d25d
eab90f9
e9f5c8b
4b9d41f
5000152
0f4d623
f03c6ad
9ee25d0
b75b4e9
9b4287d
b675261
60e8cab
3b7faa9
9b29c49
95a8a23
1d3bce0
afffdc1
8d01d96
231d832
3b1b260
651c80e
8e932aa
b56dc46
520680a
70475b7
a13c5fd
902ca9b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -816,4 +816,36 @@ describe( 'Embed block', () => { | |||
|
||||
expect( cannotEmbedText ).toBeDefined(); | ||||
} ); | ||||
|
||||
it( 'insert embed from slash inserter', async () => { | ||||
const embedBlockSlashInserter = '/Embed'; | ||||
const { getByPlaceholderText, getByA11yLabel } = await initializeEditor( | ||||
{ | ||||
initialHtml: | ||||
'<!-- wp:paragraph --><p></p><!-- /wp:paragraph -->', | ||||
} | ||||
); | ||||
|
||||
const paragraphText = getByPlaceholderText( 'Start writing…' ); | ||||
fireEvent( paragraphText, 'focus' ); | ||||
fireEvent( paragraphText, 'onChange', { | ||||
nativeEvent: { | ||||
eventCount: 1, | ||||
target: undefined, | ||||
text: embedBlockSlashInserter, | ||||
}, | ||||
} ); | ||||
|
||||
fireEvent.press( | ||||
await waitFor( () => getByA11yLabel( 'Embed block' ) ) | ||||
); | ||||
|
||||
const block = await waitFor( () => | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Currently, the test is failing at this point. It seems the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. From an investigation standpoint, I realized that the
I am wondering if a prop is missing from the mocked There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Once the aforementioned issue is resolved, I am going to be replicating the test setup here https://github.com/WordPress/gutenberg/blob/rnmobile/add/embed-block-integration-tests-2/packages/block-library/src/embed/test/index.native.js#L193 so that all the providers that are shown within the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Interesting, I'll investigate this further in case we need to add extra functionality in the mock. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. After digging into how the autocomplete works, I found out that we had to trigger a different event in the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In the following commits are the changes for addressing this issue: |
||||
getByA11yLabel( /Embed Block\. Row 1/ ) | ||||
); | ||||
|
||||
const blockName = within( block ).getByText( 'Embed' ); | ||||
|
||||
expect( blockName ).toBeDefined(); | ||||
} ); | ||||
} ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The idea here is that the Slash inserter should be visible once the text that has the
/
followed byEmbed
is entered. Therefore, we should be able to press theEmbed block
button within the Autocomplete UI.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a great idea, I'm wondering if we could query by the
Embed
text instead of the a11y label, as the items in the slash inserter display a text label, wdyt?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I applied this suggestion in this commit.