Skip to content

Commit d2d6ebe

Browse files
committed
Mock Openverse in the image drag-and-drop inserter e2e test.
1 parent 9b42593 commit d2d6ebe

2 files changed

Lines changed: 32 additions & 0 deletions

File tree

78 Bytes
Loading

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

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,38 @@ test.describe( 'Image', () => {
424424
page,
425425
editor,
426426
} ) => {
427+
// Serve Openverse and its image hosts locally; CI runners can't reliably fetch them.
428+
const mockImages = [
429+
'10x10_e2e_test_image_green.png',
430+
'10x10_e2e_test_image_z9T8jK.png',
431+
];
432+
await page.route(
433+
'https://api.openverse.engineering/v1/images/?*',
434+
( route ) =>
435+
route.fulfill( {
436+
json: {
437+
results: mockImages.map( ( fileName, index ) => ( {
438+
id: `mock-${ index }`,
439+
title: fileName,
440+
url: `https://openverse.test/${ fileName }`,
441+
thumbnail: `https://openverse.test/${ fileName }`,
442+
license: 'cc0',
443+
license_version: '1.0',
444+
} ) ),
445+
},
446+
} )
447+
);
448+
await page.route( 'https://openverse.test/*', ( route ) =>
449+
route.fulfill( {
450+
path: path.join(
451+
__dirname,
452+
'../../../assets',
453+
new URL( route.request().url() ).pathname
454+
),
455+
headers: { 'Access-Control-Allow-Origin': '*' },
456+
} )
457+
);
458+
427459
await editor.insertBlock( { name: 'core/image' } );
428460
const imageBlock = editor.canvas.getByRole( 'document', {
429461
name: 'Block: Image',

0 commit comments

Comments
 (0)