Changeset 65748
- Timestamp:
- 11/23/2026 11:28:40 PM (6 days ago)
- Location:
- trunk
- Files:
-
- 2 edited
-
src/js/_enqueues/admin/media-upload-pipeline.js (modified) (2 diffs)
-
tests/e2e/specs/media-new-client-side-upload.test.js (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/js/_enqueues/admin/media-upload-pipeline.js
r65356 r65748 47 47 48 48 /** 49 * Recursively appends data to a FormData object, supporting nested objects .49 * Recursively appends data to a FormData object, supporting nested objects and arrays. 50 50 * 51 51 * Mirrors flattenFormData() in the media-utils package. … … 57 57 function flattenFormData( formData, key, data ) { 58 58 if ( 59 data !== null && 60 typeof data === 'object' && 61 Object.getPrototypeOf( data ) === Object.prototype 59 Array.isArray( data ) || 60 ( data !== null && 61 typeof data === 'object' && 62 Object.getPrototypeOf( data ) === Object.prototype ) 62 63 ) { 63 64 Object.keys( data ).forEach( function ( name ) { -
trunk/tests/e2e/specs/media-new-client-side-upload.test.js
r65521 r65748 1 /** 2 * External dependencies 3 */ 4 import { randomUUID } from 'node:crypto'; 5 1 6 /** 2 7 * Internal dependencies … … 167 172 } ); 168 173 174 test( 'creates every image size when two sizes share dimensions', async ( { 175 page, 176 admin, 177 attachments, 178 requestUtils, 179 muPlugin, 180 baseURL, 181 } ) => { 182 // Sizes with the same dimensions are sideloaded as one file, with 183 // their names sent as an array in `image_size`. Other workers share 184 // the site, so only this test's requests see the extra sizes. 185 const trigger = `e2e_${ randomUUID().replaceAll( '-', '' ) }`; 186 await muPlugin.write( 187 'shared-image-sizes.php', 188 `<?php 189 if ( isset( $_COOKIE['${ trigger }'] ) ) { 190 add_action( 191 'after_setup_theme', 192 function () { 193 add_image_size( 'e2e-shared-a', 320, 320, true ); 194 add_image_size( 'e2e-shared-b', 320, 320, true ); 195 } 196 ); 197 }` 198 ); 199 await page 200 .context() 201 .addCookies( [ { name: trigger, value: '1', url: baseURL } ] ); 202 203 await admin.visitAdminPage( 'media-new.php' ); 204 205 await expectCrossOriginIsolated( page ); 206 207 const sideloadStatuses = []; 208 page.on( 'response', ( response ) => { 209 if ( 210 /\/wp\/v2\/media\/\d+\/sideload/.test( 211 decodeURIComponent( response.url() ) 212 ) 213 ) { 214 sideloadStatuses.push( response.status() ); 215 } 216 } ); 217 218 const ids = trackUploads( page, attachments ); 219 const fileInput = page.locator( FILE_INPUT_SELECTOR ).first(); 220 await expect( fileInput ).toBeAttached( { timeout: 30_000 } ); 221 await fileInput.setInputFiles( TEST_IMAGE_PATH ); 222 223 await expect( editLinks( page ) ).toBeVisible( { timeout: 60_000 } ); 224 225 expect( sideloadStatuses.length ).toBeGreaterThanOrEqual( 1 ); 226 expect( 227 sideloadStatuses.filter( ( status ) => status !== 200 ) 228 ).toEqual( [] ); 229 230 const attachment = await requestUtils.rest( { 231 path: `/wp/v2/media/${ ids.at( -1 ) }`, 232 } ); 233 expect( Object.keys( attachment.media_details.sizes || {} ) ).toEqual( 234 expect.arrayContaining( [ 'e2e-shared-a', 'e2e-shared-b' ] ) 235 ); 236 } ); 237 169 238 test( 'warns before leaving while a pipeline upload is in flight', async ( { 170 239 page,
Note:
See TracChangeset
for help on using the changeset viewer.