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

Migrate format API test for playwright #42035

Merged
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

This file was deleted.

36 changes: 0 additions & 36 deletions packages/e2e-tests/specs/editor/plugins/format-api.test.js

This file was deleted.

40 changes: 40 additions & 0 deletions test/e2e/specs/editor/plugins/format-api.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/**
* WordPress dependencies
*/
const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' );

test.describe( 'Using Format API', () => {
test.beforeAll( async ( { requestUtils } ) => {
await requestUtils.activatePlugin( 'gutenberg-test-format-api' );
} );

test.afterAll( async ( { requestUtils } ) => {
await requestUtils.deactivatePlugin( 'gutenberg-test-format-api' );
} );

test.beforeEach( async ( { admin } ) => {
await admin.createNewPost();
} );

test( 'Clicking the control wraps the selected text properly with HTML code', async ( {
editor,
page,
pageUtils,
} ) => {
await page.click( 'role=button[name="Add default block"i]' );
await page.keyboard.type( 'First paragraph' );
await pageUtils.pressKeyWithModifier( 'shiftAlt', 'ArrowLeft' );
await editor.clickBlockToolbarButton( 'More' );

// Used a regex to tackle the  in name of menuitem.(Custom Link).
await page.click( 'role=menuitem[name=/Custom Link/i]' );

// Check the content.
const content = await editor.getEditedPostContent();
expect( content ).toBe(
`<!-- wp:paragraph -->
<p>First <a href="https://example.com" class="my-plugin-link">paragraph</a></p>
<!-- /wp:paragraph -->`
);
} );
} );