Skip to content

Commit

Permalink
Merge branch 'trunk' into fix/mobile-api-fetch-json-response
Browse files Browse the repository at this point in the history
  • Loading branch information
Gerardo committed Jul 11, 2024
2 parents c4f2dc2 + 3750091 commit c200965
Show file tree
Hide file tree
Showing 14 changed files with 152 additions and 203 deletions.
12 changes: 11 additions & 1 deletion docs/reference-guides/interactivity-api/api-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -1054,7 +1054,12 @@ Apart from the store function, there are also some methods that allows the devel

#### getContext()

Retrieves the context inherited by the element evaluating a function from the store. The returned value depends on the element and the namespace where the function calling `getContext()` exists.
Retrieves the context inherited by the element evaluating a function from the store. The returned value depends on the element and the namespace where the function calling `getContext()` exists. It can also take an optional namespace argument to retrieve the context of a specific interactive region.

```js
const context = getContext('namespace');
```
- `namespace` (optional): A string that matches the namespace of an interactive region. If not provided, it retrieves the context of the current interactive region.

```php
// render.php
Expand All @@ -1073,6 +1078,11 @@ store( "myPlugin", {
const context = getContext();
// Logs "false"
console.log('context => ', context.isOpen)

// With namespace argument.
const myPluginContext = getContext("myPlugin");
// Logs "false"
console.log('myPlugin isOpen => ', myPluginContext.isOpen);
},
},
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,21 +106,21 @@ exports[`Embed block edit URL sets empty state when setting an empty URL 1`] = `

exports[`Embed block insert via slash inserter insert generic embed block 1`] = `"<!-- wp:embed /-->"`;

exports[`Embed block insert via slash inserter inserts Twitter embed block 1`] = `"<!-- wp:embed {"providerNameSlug":"twitter","responsive":true} /-->"`;
exports[`Embed block insert via slash inserter inserts Twitter Embed block 1`] = `"<!-- wp:embed {"providerNameSlug":"twitter","responsive":true} /-->"`;

exports[`Embed block insert via slash inserter inserts Vimeo embed block 1`] = `"<!-- wp:embed {"providerNameSlug":"vimeo","responsive":true} /-->"`;
exports[`Embed block insert via slash inserter inserts Vimeo Embed block 1`] = `"<!-- wp:embed {"providerNameSlug":"vimeo","responsive":true} /-->"`;

exports[`Embed block insert via slash inserter inserts WordPress embed block 1`] = `"<!-- wp:embed {"providerNameSlug":"wordpress"} /-->"`;
exports[`Embed block insert via slash inserter inserts WordPress Embed block 1`] = `"<!-- wp:embed {"providerNameSlug":"wordpress"} /-->"`;

exports[`Embed block insert via slash inserter inserts YouTube embed block 1`] = `"<!-- wp:embed {"providerNameSlug":"youtube","responsive":true} /-->"`;
exports[`Embed block insert via slash inserter inserts YouTube Embed block 1`] = `"<!-- wp:embed {"providerNameSlug":"youtube","responsive":true} /-->"`;

exports[`Embed block insertion inserts Twitter embed block 1`] = `"<!-- wp:embed {"providerNameSlug":"twitter","responsive":true} /-->"`;
exports[`Embed block insertion inserts Twitter Embed block 1`] = `"<!-- wp:embed {"providerNameSlug":"twitter","responsive":true} /-->"`;

exports[`Embed block insertion inserts Vimeo embed block 1`] = `"<!-- wp:embed {"providerNameSlug":"vimeo","responsive":true} /-->"`;
exports[`Embed block insertion inserts Vimeo Embed block 1`] = `"<!-- wp:embed {"providerNameSlug":"vimeo","responsive":true} /-->"`;

exports[`Embed block insertion inserts WordPress embed block 1`] = `"<!-- wp:embed {"providerNameSlug":"wordpress"} /-->"`;
exports[`Embed block insertion inserts WordPress Embed block 1`] = `"<!-- wp:embed {"providerNameSlug":"wordpress"} /-->"`;

exports[`Embed block insertion inserts YouTube embed block 1`] = `"<!-- wp:embed {"providerNameSlug":"youtube","responsive":true} /-->"`;
exports[`Embed block insertion inserts YouTube Embed block 1`] = `"<!-- wp:embed {"providerNameSlug":"youtube","responsive":true} /-->"`;

exports[`Embed block insertion inserts generic embed block 1`] = `"<!-- wp:embed /-->"`;

Expand Down
2 changes: 1 addition & 1 deletion packages/block-library/src/embed/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ describe( 'utils', () => {
expect( getEmbedInfoByProvider( 'instagram' ) ).toEqual(
expect.objectContaining( {
icon: embedInstagramIcon,
title: 'Instagram',
title: 'Instagram Embed',
} )
);
} );
Expand Down
47 changes: 24 additions & 23 deletions packages/block-library/src/embed/test/index.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ describe( 'Embed block', () => {
} );

MOST_USED_PROVIDERS.forEach( ( { title } ) =>
it( `inserts ${ title } embed block`, async () => {
it( `inserts ${ title } block`, async () => {
const { block } = await insertEmbedBlock( title );
const blockName = within( block ).getByText( title );

Expand Down Expand Up @@ -285,10 +285,10 @@ describe( 'Embed block', () => {
const blockSettingsModal = await editor.findByTestId(
'block-settings-modal'
);
// Get Twitter link field.
// Get Twitter Embed link field.
const twitterLinkField = within(
blockSettingsModal
).getByLabelText( `Twitter link, ${ expectedURL }` );
).getByLabelText( `Twitter Embed link, ${ expectedURL }` );

expect( twitterLinkField ).toBeDefined();
expect( getEditorHtml() ).toMatchSnapshot();
Expand Down Expand Up @@ -321,10 +321,10 @@ describe( 'Embed block', () => {
const blockSettingsModal = await editor.findByTestId(
'block-settings-modal'
);
// Get Twitter link field.
// Get Twitter Embed link field.
const twitterLinkField = within(
blockSettingsModal
).getByLabelText( `Twitter link, ${ clipboardURL }` );
).getByLabelText( `Twitter Embed link, ${ clipboardURL }` );

expect( autopastedLinkField ).toBeDefined();
expect( twitterLinkField ).toBeDefined();
Expand Down Expand Up @@ -383,10 +383,10 @@ describe( 'Embed block', () => {
const blockSettingsModal = await editor.findByTestId(
'block-settings-modal'
);
// Get Twitter link field.
// Get Twitter Embed link field.
const twitterLinkField = within(
blockSettingsModal
).getByLabelText( `Twitter link, ${ expectedURL }` );
).getByLabelText( `Twitter Embed link, ${ expectedURL }` );

expect( twitterLinkField ).toBeDefined();
expect( getEditorHtml() ).toMatchSnapshot();
Expand Down Expand Up @@ -422,10 +422,10 @@ describe( 'Embed block', () => {
const blockSettingsModal = await editor.findByTestId(
'block-settings-modal'
);
// Get Twitter link field.
// Get Twitter Embed link field.
const twitterLinkField = within(
blockSettingsModal
).getByLabelText( `Twitter link, ${ clipboardURL }` );
).getByLabelText( `Twitter Embed link, ${ clipboardURL }` );

expect( embedLink ).toBeDefined();
expect( twitterLinkField ).toBeDefined();
Expand Down Expand Up @@ -472,10 +472,10 @@ describe( 'Embed block', () => {
);
await waitForModalVisible( blockSettingsModal );

// Start editing link.
// Start editing Embed link.
fireEvent.press(
within( blockSettingsModal ).getByLabelText(
`Twitter link, ${ initialURL }`
`Twitter Embed link, ${ initialURL }`
)
);

Expand All @@ -491,10 +491,10 @@ describe( 'Embed block', () => {
await waitFor( () => editor.UNSAFE_getByType( WebView ) );
await editor.findByText( 'Media settings' );

// Get YouTube link field.
// Get YouTube Embed link field.
const youtubeLinkField = await within(
blockSettingsModal
).findByLabelText( `YouTube link, ${ expectedURL }` );
).findByLabelText( `YouTube Embed link, ${ expectedURL }` );

expect( youtubeLinkField ).toBeDefined();
expect( getEditorHtml() ).toMatchSnapshot();
Expand All @@ -519,7 +519,7 @@ describe( 'Embed block', () => {
// Start editing link.
fireEvent.press(
within( blockSettingsModal ).getByLabelText(
`Twitter link, ${ previousURL }`
`Twitter Embed link, ${ previousURL }`
)
);

Expand Down Expand Up @@ -557,7 +557,7 @@ describe( 'Embed block', () => {
// Start editing link.
fireEvent.press(
within( blockSettingsModal ).getByLabelText(
`Twitter link, ${ previousURL }`
`Twitter Embed link, ${ previousURL }`
)
);

Expand Down Expand Up @@ -661,10 +661,10 @@ describe( 'Embed block', () => {
fireEvent( blockSettingsModal, 'backdropPress' );
fireEvent( blockSettingsModal, MODAL_DISMISS_EVENT );

// Get Twitter link field.
// Get Twitter Embed link field.
const twitterLinkField = await within(
blockSettingsModal
).findByLabelText( `Twitter link, ${ expectedURL }` );
).findByLabelText( `Twitter Embed link, ${ expectedURL }` );

expect( twitterLinkField ).toBeDefined();
expect( getEditorHtml() ).toMatchSnapshot();
Expand Down Expand Up @@ -728,10 +728,10 @@ describe( 'Embed block', () => {
const blockSettingsModal = await editor.findByTestId(
'block-settings-modal'
);
// Get Twitter link field.
// Get Twitter Embed link field.
const twitterLinkField = within(
blockSettingsModal
).getByLabelText( `Twitter link, ${ expectedURL }` );
).getByLabelText( `Twitter Embed link, ${ expectedURL }` );

expect( twitterLinkField ).toBeDefined();
expect( getEditorHtml() ).toMatchSnapshot();
Expand Down Expand Up @@ -811,10 +811,10 @@ describe( 'Embed block', () => {
const blockSettingsModal = await editor.findByTestId(
'block-settings-modal'
);
// Get Twitter link field.
// Get Twitter embed link field.
const twitterLinkField = within(
blockSettingsModal
).getByLabelText( `Twitter link, ${ successURL }` );
).getByLabelText( `Twitter Embed link, ${ successURL }` );

expect( twitterLinkField ).toBeDefined();
expect( getEditorHtml() ).toMatchSnapshot();
Expand Down Expand Up @@ -1000,8 +1000,9 @@ describe( 'Embed block', () => {
} );

MOST_USED_PROVIDERS.forEach( ( { title } ) =>
it( `inserts ${ title } embed block`, async () => {
const embedBlockSlashInserter = `/${ title }`;
it( `inserts ${ title } block`, async () => {
// Get just the first word of the title ("Twitter") as the full title ("Twitter Embed") breaks the test.
const embedBlockSlashInserter = `/${ title.split( ' ' )[ 0 ] }`;
const editor = await initializeEditor( {
initialHtml: EMPTY_PARAGRAPH_HTML,
} );
Expand Down
Loading

0 comments on commit c200965

Please sign in to comment.