This repository has been archived by the owner on Feb 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 219
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Enable blockified templates * add html template * fix function * WIP * Migrate Classic Block E2E tests to Playwright (#9575) * Add E2E tests * add comment * set worker to 1 * try now * add beforeAll and afterAll hook * restore woocommerce-gutenberg-products-block.php * enable plugin with .wp-env configuration * remove waitForNetworkIdle * Products block: Add e2e tests (#9577) * migrate classic block to Playwright * fix can be inserted more than once tests * migrate classic block to Playwright * fix command * remove old tests * improve E2E tests * skip test * Products block: add E2E pw tests * Add E2E tests * fix E2E test * test now * try now * rename path * set one worker * try now * try now * try now * set 1 worker
- Loading branch information
Showing
31 changed files
with
478 additions
and
1,200 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
117 changes: 117 additions & 0 deletions
117
tests/e2e-pw/tests/classic-template/classic-template.block_theme.side_effects.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import { BlockData } from '@woocommerce/e2e-types'; | ||
import { test, expect } from '@woocommerce/e2e-playwright-utils'; | ||
import { cli } from '@woocommerce/e2e-utils'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
|
||
const blockData: BlockData = { | ||
name: 'woocommerce/legacy-template', | ||
mainClass: '.wc-block-price-filter', | ||
selectors: { | ||
frontend: {}, | ||
editor: {}, | ||
}, | ||
}; | ||
|
||
const templates = { | ||
'single-product': { | ||
templateTitle: 'Single Product', | ||
slug: 'single-product', | ||
frontendPage: '/product/single/', | ||
}, | ||
'taxonomy-product_attribute': { | ||
templateTitle: 'Product Attribute', | ||
slug: 'taxonomy-product_attribute', | ||
frontendPage: '/product-attribute/color/', | ||
}, | ||
|
||
'taxonomy-product_cat': { | ||
templateTitle: 'Product Category', | ||
slug: 'taxonomy-product_cat', | ||
frontendPage: '/product-category/music/', | ||
}, | ||
// We don't have products with tags in the test site. Uncomment this when we have products with tags. | ||
// 'taxonomy-product_tag': { | ||
// templateTitle: 'Product Tag', | ||
// slug: 'taxonomy-product_tag', | ||
// frontendPage: '/product-tag/hoodie/', | ||
// }, | ||
'archive-product': { | ||
templateTitle: 'Product Catalog', | ||
slug: 'archive-product', | ||
frontendPage: '/shop/', | ||
}, | ||
'product-search-results': { | ||
templateTitle: 'Product Search Results', | ||
slug: 'product-search-results', | ||
frontendPage: '/?s=single&post_type=product', | ||
}, | ||
}; | ||
|
||
for ( const { templateTitle, slug, frontendPage } of Object.values( | ||
templates | ||
) ) { | ||
test.describe( `${ blockData.name } Block `, () => { | ||
test.beforeAll( async () => { | ||
await cli( | ||
'npm run wp-env run tests-cli "wp option update wc_blocks_use_blockified_product_grid_block_as_template false"' | ||
); | ||
} ); | ||
|
||
test( `is rendered on ${ templateTitle } template`, async ( { | ||
admin, | ||
editorUtils, | ||
editor, | ||
} ) => { | ||
await admin.visitSiteEditor( { | ||
postId: `woocommerce/woocommerce//${ slug }`, | ||
postType: 'wp_template', | ||
} ); | ||
|
||
await editor.canvas.click( 'body' ); | ||
|
||
const block = await editorUtils.getBlockByName( blockData.name ); | ||
expect( block ).not.toBeNull(); | ||
} ); | ||
|
||
test( `is rendered on ${ templateTitle } template - frontend side`, async ( { | ||
admin, | ||
editor, | ||
page, | ||
} ) => { | ||
await admin.visitSiteEditor( { | ||
postId: `woocommerce/woocommerce//${ slug }`, | ||
postType: 'wp_template', | ||
} ); | ||
|
||
await editor.canvas.click( 'body' ); | ||
|
||
await editor.insertBlock( { | ||
name: 'core/paragraph', | ||
attributes: { content: 'Hello World' }, | ||
} ); | ||
|
||
await editor.saveSiteEditorEntities(); | ||
|
||
await page.goto( frontendPage ); | ||
|
||
const helloWorldText = await page.getByText( 'Hello World' ); | ||
|
||
expect( helloWorldText ).not.toBeNull(); | ||
} ); | ||
|
||
test.afterAll( async ( { requestUtils } ) => { | ||
await cli( | ||
'npm run wp-env run tests-cli "wp option delete wc_blocks_use_blockified_product_grid_block_as_template"' | ||
); | ||
|
||
await requestUtils.deleteAllTemplates( 'wp_template' ); | ||
await requestUtils.deleteAllTemplates( 'wp_template_part' ); | ||
} ); | ||
} ); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
export const WOOCOMMERCE_ID = 'woocommerce/woocommerce'; | ||
|
||
export const getDefaultTemplateProps = ( templateTitle: string ) => { | ||
return { | ||
templateTitle, | ||
addedBy: WOOCOMMERCE_ID, | ||
hasActions: false, | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.