Skip to content

Commit b690e68

Browse files
manzoorwanijkandrewserongMamaduka
authored andcommitted
E2E: Mock Openverse in image drag-and-drop inserter test (WordPress#83842)
Co-authored-by: manzoorwanijk <manzoorwanijk@git.wordpress.org> Co-authored-by: andrewserong <andrewserong@git.wordpress.org> Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
1 parent 54939c8 commit b690e68

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

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

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,36 @@ test.describe( 'Image', () => {
312312
page,
313313
editor,
314314
} ) => {
315+
// Serve Openverse and its image hosts locally; CI runners can't reliably fetch them.
316+
const mockImages = [
317+
'10x10_e2e_test_image_green.png',
318+
'10x10_e2e_test_image_z9T8jK.png',
319+
];
320+
await page.route( 'https://api.openverse.org/v1/images/?*', ( route ) =>
321+
route.fulfill( {
322+
json: {
323+
results: mockImages.map( ( fileName, index ) => ( {
324+
id: `mock-${ index }`,
325+
title: fileName,
326+
url: `https://openverse.test/${ fileName }`,
327+
thumbnail: `https://openverse.test/${ fileName }`,
328+
license: 'cc0',
329+
license_version: '1.0',
330+
} ) ),
331+
},
332+
} )
333+
);
334+
await page.route( 'https://openverse.test/*', ( route ) =>
335+
route.fulfill( {
336+
path: path.join(
337+
__dirname,
338+
'../../../assets',
339+
new URL( route.request().url() ).pathname
340+
),
341+
headers: { 'Access-Control-Allow-Origin': '*' },
342+
} )
343+
);
344+
315345
await editor.insertBlock( { name: 'core/image' } );
316346
const imageBlock = editor.canvas.getByRole( 'document', {
317347
name: 'Block: Image',

0 commit comments

Comments
 (0)