-
Notifications
You must be signed in to change notification settings - Fork 4.3k
/
Copy pathimage-size.spec.js
61 lines (52 loc) · 1.58 KB
/
image-size.spec.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/**
* External dependencies
*/
const path = require( 'path' );
/**
* WordPress dependencies
*/
const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' );
test.describe( 'changing image size', () => {
test.beforeAll( async ( { requestUtils } ) => {
await requestUtils.activatePlugin( 'gutenberg-test-image-size' );
await requestUtils.deleteAllMedia();
} );
test.afterEach( async ( { requestUtils } ) => {
await requestUtils.deleteAllMedia();
} );
test.afterAll( async ( { requestUtils } ) => {
await requestUtils.deactivatePlugin( 'gutenberg-test-image-size' );
} );
test( 'should insert and change my image size', async ( {
admin,
editor,
page,
requestUtils,
} ) => {
const filename = '1024x768_e2e_test_image_size.jpeg';
const filepath = path.join( './test/e2e/assets', filename );
await admin.createNewPost();
const media = await requestUtils.uploadMedia( filepath );
await editor.insertBlock( {
name: 'core/image',
attributes: {
// Specify alt text so that it can be queried by role selectors.
alt: filename,
id: media.id,
url: media.source_url,
},
} );
// Select the new size updated with the plugin.
await editor.openDocumentSettingsSidebar();
await page.selectOption( 'role=combobox[name="Resolution"i]', {
label: 'Custom Size One',
} );
// Verify that the custom size was applied to the image.
await expect(
editor.canvas.locator( `role=img[name="${ filename }"]` )
).toHaveCSS( 'width', '499px' );
await expect(
page.locator( 'role=spinbutton[name="Width"i]' )
).toHaveValue( '' );
} );
} );