-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate Keep Transform Block Test Case to Playwright (#49719)
* Migrate Keep Transform Block Test Case to Playwright * Update test case as CI was failing * Addressed Feedbacks * Fix stylelint issue * Update test case * Address feedbacks * Address feedbacks * Addressed feedbacks
- Loading branch information
1 parent
628a1f6
commit ac17761
Showing
3 changed files
with
99 additions
and
93 deletions.
There are no files selected for viewing
29 changes: 0 additions & 29 deletions
29
...e2e-tests/specs/editor/various/__snapshots__/keep-styles-on-block-transforms.test.js.snap
This file was deleted.
Oops, something went wrong.
64 changes: 0 additions & 64 deletions
64
packages/e2e-tests/specs/editor/various/keep-styles-on-block-transforms.test.js
This file was deleted.
Oops, something went wrong.
99 changes: 99 additions & 0 deletions
99
test/e2e/specs/editor/various/keep-styles-on-block-transforms.spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' ); | ||
|
||
test.describe( 'Keep styles on block transforms', () => { | ||
test.beforeEach( async ( { admin } ) => { | ||
await admin.createNewPost(); | ||
} ); | ||
|
||
test( 'Should keep colors during a transform', async ( { | ||
page, | ||
editor, | ||
} ) => { | ||
await page.click( 'role=button[name="Add default block"i]' ); | ||
await page.keyboard.type( '## Heading' ); | ||
await editor.openDocumentSettingsSidebar(); | ||
await page.click( 'role=button[name="Text"i]' ); | ||
await page.click( 'role=button[name="Color: Luminous vivid orange"i]' ); | ||
|
||
await page.click( 'role=button[name="Heading"i]' ); | ||
await page.click( 'role=menuitem[name="Paragraph"i]' ); | ||
|
||
await expect.poll( editor.getBlocks ).toMatchObject( [ | ||
{ | ||
name: 'core/paragraph', | ||
attributes: { | ||
content: 'Heading', | ||
textColor: 'luminous-vivid-orange', | ||
}, | ||
}, | ||
] ); | ||
} ); | ||
|
||
test( 'Should keep the font size during a transform from multiple blocks into multiple blocks', async ( { | ||
page, | ||
pageUtils, | ||
editor, | ||
} ) => { | ||
// Create a paragraph block with some content. | ||
await page.click( 'role=button[name="Add default block"i]' ); | ||
await page.keyboard.type( 'Line 1 to be made large' ); | ||
await page.keyboard.press( 'Enter' ); | ||
await page.keyboard.type( 'Line 2 to be made large' ); | ||
await page.keyboard.press( 'Enter' ); | ||
await page.keyboard.type( 'Line 3 to be made large' ); | ||
await pageUtils.pressKeys( 'shift+ArrowUp' ); | ||
await pageUtils.pressKeys( 'shift+ArrowUp' ); | ||
await page.click( 'role=radio[name="Large"i]' ); | ||
await page.click( 'role=button[name="Paragraph"i]' ); | ||
await page.click( 'role=menuitem[name="Heading"i]' ); | ||
|
||
await expect.poll( editor.getBlocks ).toMatchObject( [ | ||
{ | ||
name: 'core/heading', | ||
attributes: { fontSize: 'large' }, | ||
}, | ||
{ | ||
name: 'core/heading', | ||
attributes: { fontSize: 'large' }, | ||
}, | ||
{ | ||
name: 'core/heading', | ||
attributes: { fontSize: 'large' }, | ||
}, | ||
] ); | ||
} ); | ||
|
||
test( 'Should not include styles in the group block when grouping a block', async ( { | ||
page, | ||
editor, | ||
} ) => { | ||
// Create a paragraph block with some content. | ||
await page.click( 'role=button[name="Add default block"i]' ); | ||
await page.keyboard.type( 'Line 1 to be made large' ); | ||
await page.click( 'role=radio[name="Large"i]' ); | ||
await editor.showBlockToolbar(); | ||
await page.click( 'role=button[name="Paragraph"i]' ); | ||
await page.click( 'role=menuitem[name="Group"i]' ); | ||
|
||
await expect.poll( editor.getBlocks ).toMatchObject( [ | ||
{ | ||
name: 'core/group', | ||
attributes: expect.not.objectContaining( { | ||
fontSize: 'large', | ||
} ), | ||
innerBlocks: [ | ||
{ | ||
name: 'core/paragraph', | ||
attributes: { | ||
content: 'Line 1 to be made large', | ||
fontSize: 'large', | ||
}, | ||
}, | ||
], | ||
}, | ||
] ); | ||
} ); | ||
} ); |