Skip to content

Commit

Permalink
test: Automate mobile editor tests (#53991)
Browse files Browse the repository at this point in the history
* test: Remove duplicative tests

These are covered by:

`packages/block-library/src/social-links/test/edit.native.js`

* test: Social Links sets a link URL

Assert the fundamental functionality of setting a URL for a Social Link
link.
  • Loading branch information
dcalhoun authored Aug 29, 2023
1 parent df40f46 commit 2653b5e
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 143 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ const EmbedLinkSettings = ( {
onDismiss={ onDismiss }
setAttributes={ onSetAttributes }
options={ linkSettingsOptions }
testID="embed-edit-url-modal"
withBottomSheet={ withBottomSheet }
showIcon
/>
Expand Down
18 changes: 9 additions & 9 deletions packages/block-library/src/embed/test/index.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ describe( 'Embed block', () => {

// Wait for edit URL modal to be visible.
const embedEditURLModal = editor.getByTestId(
'embed-edit-url-modal'
'link-settings-navigation'
);
await waitForModalVisible( embedEditURLModal );

Expand All @@ -259,7 +259,7 @@ describe( 'Embed block', () => {

// Wait for edit URL modal to be visible.
const embedEditURLModal = editor.getByTestId(
'embed-edit-url-modal'
'link-settings-navigation'
);
await waitForModalVisible( embedEditURLModal );

Expand Down Expand Up @@ -299,7 +299,7 @@ describe( 'Embed block', () => {

// Wait for edit URL modal to be visible.
const embedEditURLModal = editor.getByTestId(
'embed-edit-url-modal'
'link-settings-navigation'
);
await waitForModalVisible( embedEditURLModal );

Expand Down Expand Up @@ -338,7 +338,7 @@ describe( 'Embed block', () => {

// Wait for edit URL modal to be visible.
const embedEditURLModal = editor.getByTestId(
'embed-edit-url-modal'
'link-settings-navigation'
);
await waitForModalVisible( embedEditURLModal );

Expand All @@ -359,7 +359,7 @@ describe( 'Embed block', () => {

// Wait for edit URL modal to be visible.
const embedEditURLModal = editor.getByTestId(
'embed-edit-url-modal'
'link-settings-navigation'
);
await waitForModalVisible( embedEditURLModal );

Expand Down Expand Up @@ -400,7 +400,7 @@ describe( 'Embed block', () => {

// Wait for edit URL modal to be visible.
const embedEditURLModal = editor.getByTestId(
'embed-edit-url-modal'
'link-settings-navigation'
);
await waitForModalVisible( embedEditURLModal );

Expand Down Expand Up @@ -584,7 +584,7 @@ describe( 'Embed block', () => {

// Wait for edit URL modal to be visible.
const embedEditURLModal = editor.getByTestId(
'embed-edit-url-modal'
'link-settings-navigation'
);
await waitForModalVisible( embedEditURLModal );

Expand Down Expand Up @@ -623,7 +623,7 @@ describe( 'Embed block', () => {

// Wait for edit URL modal to be visible.
const embedEditURLModal = editor.getByTestId(
'embed-edit-url-modal'
'link-settings-navigation'
);
await waitForModalVisible( embedEditURLModal );

Expand Down Expand Up @@ -804,7 +804,7 @@ describe( 'Embed block', () => {

// Dismiss the edit URL modal.
const embedEditURLModal = editor.getByTestId(
'embed-edit-url-modal'
'link-settings-navigation'
);
fireEvent( embedEditURLModal, 'backdropPress' );
fireEvent( embedEditURLModal, MODAL_DISMISS_EVENT );
Expand Down
132 changes: 0 additions & 132 deletions packages/block-library/src/social-link/test/index.native.js

This file was deleted.

30 changes: 30 additions & 0 deletions packages/block-library/src/social-links/test/edit.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
*/
import {
addBlock,
dismissModal,
fireEvent,
getEditorHtml,
initializeEditor,
within,
getBlock,
waitFor,
waitForModalVisible,
} from 'test/helpers';

/**
Expand Down Expand Up @@ -197,4 +199,32 @@ describe( 'Social links block', () => {

expect( getEditorHtml() ).toMatchSnapshot();
} );

it( "should set a icon's URL", async () => {
const screen = await initializeEditor();
await addBlock( screen, 'Social Icons' );
fireEvent.press( screen.getByLabelText( 'Facebook social icon' ) );
fireEvent.press( screen.getByLabelText( 'Add link to Facebook' ) );

await waitForModalVisible(
screen.getByTestId( 'link-settings-navigation' )
);
fireEvent.changeText(
screen.getByPlaceholderText( 'Add URL' ),
'https://facebook.com'
);
dismissModal( screen.getByTestId( 'link-settings-navigation' ) );

expect( getEditorHtml() ).toMatchInlineSnapshot( `
"<!-- wp:social-links -->
<ul class="wp-block-social-links"><!-- wp:social-link {"url":"https://wordpress.org","service":"wordpress"} /-->
<!-- wp:social-link {"url":"https://facebook.com","service":"facebook","label":"","rel":""} /-->
<!-- wp:social-link {"service":"twitter"} /-->
<!-- wp:social-link {"service":"instagram"} /--></ul>
<!-- /wp:social-links -->"
` );
} );
} );
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function LinkSettingsNavigation( props ) {
isVisible={ props.isVisible }
onClose={ props.onClose }
onDismiss={ props.onDismiss }
testID={ props.testID }
testID="link-settings-navigation"
hideHeader
hasNavigation
>
Expand Down

1 comment on commit 2653b5e

@github-actions
Copy link

Choose a reason for hiding this comment

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

Flaky tests detected in 2653b5e.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/6012055428
📝 Reported issues:

Please sign in to comment.