|
| 1 | +/** |
| 2 | + * External dependencies |
| 3 | + */ |
| 4 | +import { test, expect } from '@woocommerce/e2e-playwright-utils'; |
| 5 | + |
| 6 | +/** |
| 7 | + * Internal dependencies |
| 8 | + */ |
| 9 | +const blockData = { |
| 10 | + name: 'woocommerce/product-gallery-large-image', |
| 11 | + selectors: { |
| 12 | + frontend: {}, |
| 13 | + editor: {}, |
| 14 | + }, |
| 15 | + slug: 'single-product', |
| 16 | + productPage: '/product/v-neck-t-shirt/', |
| 17 | +}; |
| 18 | + |
| 19 | +test.describe( `${ blockData.name }`, () => { |
| 20 | + test.beforeEach( async ( { requestUtils, admin, editorUtils } ) => { |
| 21 | + await requestUtils.deleteAllTemplates( 'wp_template' ); |
| 22 | + await requestUtils.deleteAllTemplates( 'wp_template_part' ); |
| 23 | + await admin.visitSiteEditor( { |
| 24 | + postId: `woocommerce/woocommerce//${ blockData.slug }`, |
| 25 | + postType: 'wp_template', |
| 26 | + } ); |
| 27 | + await editorUtils.enterEditMode(); |
| 28 | + } ); |
| 29 | + |
| 30 | + test( 'Renders Product Gallery Large Image block on the editor and frontend side', async ( { |
| 31 | + page, |
| 32 | + editor, |
| 33 | + editorUtils, |
| 34 | + frontendUtils, |
| 35 | + } ) => { |
| 36 | + await editor.insertBlock( { |
| 37 | + name: 'woocommerce/product-gallery', |
| 38 | + } ); |
| 39 | + |
| 40 | + const block = await editorUtils.getBlockByName( blockData.name ); |
| 41 | + |
| 42 | + await expect( block ).toBeVisible(); |
| 43 | + |
| 44 | + await Promise.all( [ |
| 45 | + editor.saveSiteEditorEntities(), |
| 46 | + page.waitForResponse( ( response ) => |
| 47 | + response.url().includes( 'wp-json/wp/v2/templates/' ) |
| 48 | + ), |
| 49 | + ] ); |
| 50 | + |
| 51 | + await page.goto( blockData.productPage, { |
| 52 | + waitUntil: 'networkidle', |
| 53 | + } ); |
| 54 | + |
| 55 | + const blockFrontend = await frontendUtils.getBlockByName( |
| 56 | + blockData.name |
| 57 | + ); |
| 58 | + |
| 59 | + await expect( blockFrontend ).toBeVisible(); |
| 60 | + } ); |
| 61 | +} ); |
0 commit comments