Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions e2e/test-utils/media.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,19 +224,19 @@ export async function expectNewMediaMime(
async () => {
const created = await getMediaCreatedAfter( requestUtils, afterId )
if ( ! created.length ) {
return null
return 'none'
}
const mimeType = created[ 0 ].mime_type
if ( mime instanceof RegExp ) {
return mime.test( mimeType ) ? mimeType : null
return mime.test( mimeType ) ? mimeType : `unexpected:${ mimeType }`
}
return mimeType === mime ? mimeType : null
return mimeType === mime ? mimeType : `unexpected:${ mimeType }`
},
{
timeout,
message: `Expected a new ${ mimeLabel } media attachment after upload`,
}
).not.toBeNull()
).toMatch( mime instanceof RegExp ? mime : new RegExp( `^${ mime.replace( /[.*+?^${}()|[\]\\]/g, '\\$&' ) }$` ) )

const created = await getMediaCreatedAfter( requestUtils, afterId )
const newest = created[ 0 ]
Expand Down Expand Up @@ -316,7 +316,11 @@ export async function uploadSampleViaMediaNew(
'.media-upload-form input[type="file"], #async-upload, input[name="async-upload"]'
).first()
await expect( fileInput ).toBeAttached( { timeout: 15_000 } )
await fileInput.setInputFiles( filePath )
await fileInput.setInputFiles( {
name: path.basename( filePath ),
mimeType,
buffer: fs.readFileSync( filePath ),
} )

if ( options.expectedMime ) {
return await expectNewMediaMime(
Expand Down
1 change: 1 addition & 0 deletions e2e/tests/premium/lqip.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ test.describe( 'Premium LQIP', () => {
lqip_enabled: 0,
disable_thumbnail_generation: 0,
max_image_dimension: 0,
smart_optimization: 1,
} )
} )

Expand Down
1 change: 1 addition & 0 deletions e2e/tests/premium/optimization-toggle.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ test.describe( 'Premium optimization toggle', () => {
show_optimization_toggle: 0,
persist_optimization_toggle: 0,
disable_thumbnail_generation: 0,
smart_optimization: 1,
} )
} )

Expand Down
1 change: 1 addition & 0 deletions e2e/tests/premium/optimize-all.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ test.describe( 'Premium optimize all media uploads', () => {
await saveCimoOptions( requestUtils, {
optimize_all_media: 0,
disable_thumbnail_generation: 0,
smart_optimization: 1,
} )
} )

Expand Down
12 changes: 12 additions & 0 deletions e2e/tests/premium/settings-unlocked.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,23 @@ import {
expect,
gotoCimoSettings,
SAMPLE_JPG,
saveCimoOptions,
} from '../../test-utils'

test.describe.configure( { timeout: 120_000 } )

test.describe( 'Premium settings unlocked', () => {
test.beforeEach( async ( { requestUtils } ) => {
// Prior premium specs often leave smart_optimization off; restore defaults
// so this smoke test asserts the true premium out-of-box settings.
await saveCimoOptions( requestUtils, {
smart_optimization: 1,
optimize_all_media: 0,
show_optimization_toggle: 0,
stealth_mode_enabled: 0,
} )
} )

test( 'premium build enables gated controls and working bulk UI', async ( {
admin,
page,
Expand Down
1 change: 1 addition & 0 deletions e2e/tests/premium/stealth.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ test.describe( 'Premium stealth mode', () => {
stealth_mode_enabled: 0,
show_optimization_toggle: 0,
disable_thumbnail_generation: 0,
smart_optimization: 1,
} )
} )

Expand Down
6 changes: 5 additions & 1 deletion e2e/tests/premium/svg-heic.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ test.describe( 'Premium SVG and HEIC uploads', () => {
await saveCimoOptions( requestUtils, {
svg_upload: 0,
disable_thumbnail_generation: 0,
smart_optimization: 1,
} )
} )

Expand Down Expand Up @@ -78,7 +79,10 @@ test.describe( 'Premium SVG and HEIC uploads', () => {
page,
requestUtils,
SAMPLE_HEIC,
'image/heic'
'image/heic',
// heic2any ships a ~1.3MB WASM worker; cold load on CI regularly
// exceeds the default 60s media poll window.
{ timeout: 180_000 }
)
expect( media.mime_type ).toBe( 'image/webp' )
expect( media.source_url ).toMatch( /\.webp(\?|$)/i )
Expand Down
Loading