Skip to content

Commit

Permalink
Migrate Image Size test to Playwright (#40467)
Browse files Browse the repository at this point in the history
* Migrate Image Size to Playwright

* Remove existing utils

* Remove unnecessary utils and image-size-test.js from e2e-tests
  • Loading branch information
juhi123 authored Apr 22, 2022
1 parent 102d366 commit dc1529a
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 71 deletions.
71 changes: 0 additions & 71 deletions packages/e2e-tests/specs/editor/plugins/image-size.test.js

This file was deleted.

Binary file added test/e2e/assets/1024x768_e2e_test_image_size.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
52 changes: 52 additions & 0 deletions test/e2e/specs/editor/plugins/image-size.spec.js
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'
);
} );
} );

0 comments on commit dc1529a

Please sign in to comment.