-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate Image Size test to Playwright (#40467)
* Migrate Image Size to Playwright * Remove existing utils * Remove unnecessary utils and image-size-test.js from e2e-tests
- Loading branch information
Showing
3 changed files
with
52 additions
and
71 deletions.
There are no files selected for viewing
71 changes: 0 additions & 71 deletions
71
packages/e2e-tests/specs/editor/plugins/image-size.test.js
This file was deleted.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,52 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' ); | ||
|
||
test.describe( 'changing image size', () => { | ||
test.beforeEach( async ( { requestUtils, pageUtils } ) => { | ||
await requestUtils.activatePlugin( 'gutenberg-test-image-size' ); | ||
await pageUtils.createNewPost(); | ||
} ); | ||
|
||
test.afterEach( async ( { requestUtils } ) => { | ||
await requestUtils.deactivatePlugin( 'gutenberg-test-image-size' ); | ||
} ); | ||
|
||
test( 'should insert and change my image size', async ( { | ||
page, | ||
pageUtils, | ||
} ) => { | ||
await pageUtils.insertBlock( { name: 'core/image' } ); | ||
const inputElement = await page.$( | ||
'figure[aria-label="Block: Image"] input[type=file]' | ||
); | ||
|
||
const filename = '1024x768_e2e_test_image_size.jpeg'; | ||
const filepath = './test/e2e/assets/' + filename; | ||
|
||
await inputElement.setInputFiles( filepath ); | ||
|
||
// // Wait for upload to finish. | ||
const img = page.locator( `//img[contains(@src, "${ filename }")]` ); | ||
await img.waitFor(); | ||
|
||
await expect( img ).toBeVisible(); | ||
|
||
// Select the new size updated with the plugin. | ||
await pageUtils.openDocumentSettingsSidebar(); | ||
await page.selectOption( | ||
'.components-select-control__input', | ||
'custom-size-one' | ||
); | ||
|
||
// Verify that the custom size was applied to the image. | ||
await page.waitForSelector( '.wp-block-image.size-custom-size-one' ); | ||
await page.waitForFunction( | ||
() => | ||
document.querySelector( | ||
'.block-editor-image-size-control__width input' | ||
).value === '499' | ||
); | ||
} ); | ||
} ); |