Skip to content

Commit 4cdaf0d

Browse files
committed
Mock Openverse in the image drag-and-drop inserter e2e test.
1 parent 3b88414 commit 4cdaf0d

2 files changed

Lines changed: 30 additions & 0 deletions

File tree

78 Bytes
Loading

‎test/e2e/specs/editor/blocks/image.spec.js‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,36 @@ test.describe( 'Image', () => {
427427
page,
428428
editor,
429429
} ) => {
430+
// Serve Openverse and its image hosts locally; CI runners can't reliably fetch them.
431+
const mockImages = [
432+
'10x10_e2e_test_image_green.png',
433+
'10x10_e2e_test_image_z9T8jK.png',
434+
];
435+
await page.route( 'https://api.openverse.org/v1/images/?*', ( route ) =>
436+
route.fulfill( {
437+
json: {
438+
results: mockImages.map( ( fileName, index ) => ( {
439+
id: `mock-${ index }`,
440+
title: fileName,
441+
url: `https://openverse.test/${ fileName }`,
442+
thumbnail: `https://openverse.test/${ fileName }`,
443+
license: 'cc0',
444+
license_version: '1.0',
445+
} ) ),
446+
},
447+
} )
448+
);
449+
await page.route( 'https://openverse.test/*', ( route ) =>
450+
route.fulfill( {
451+
path: path.join(
452+
__dirname,
453+
'../../../assets',
454+
new URL( route.request().url() ).pathname
455+
),
456+
headers: { 'Access-Control-Allow-Origin': '*' },
457+
} )
458+
);
459+
430460
// This is a temp workaround for dragging and dropping images from the inserter.
431461
// This should be removed when we have the zoom out view for media categories.
432462
await page.setViewportSize( { width: 1400, height: 800 } );

0 commit comments

Comments
 (0)