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.
Add mock theme with Woo Templates for E2E tests (#5920)
This PR adds a block-enabled theme with templates for WooCommerce which is intended to be used when testing the more complex scenarios such as template fallbacks. Additionally, since theme-dependent logic seems to be becoming more and more useful (see #5913), this PR also adds a utility function used to explicitly declare theme dependencies of a test (`useTheme`). Said function will activate the theme before running a given suite and then reactivate the previous theme, as to make sure to not have any side-effects (such as the ones described in #5913 above). Closes #5660
- Loading branch information
1 parent
adc8d05
commit 73d704c
Showing
18 changed files
with
221 additions
and
7 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
3 changes: 3 additions & 0 deletions
3
tests/mocks/theme-with-woo-templates/block-template-parts/header.html
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,3 @@ | ||
<!-- wp:site-title /--> | ||
|
||
<!-- wp:site-tagline /--> |
38 changes: 38 additions & 0 deletions
38
tests/mocks/theme-with-woo-templates/block-template-parts/mini-cart.html
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,38 @@ | ||
<!-- wp:woocommerce/mini-cart-contents {"className":"wc-block-mini-cart__contents"} --> | ||
<div class="wp-block-woocommerce-mini-cart-contents wc-block-mini-cart__contents"> | ||
<!-- wp:woocommerce/filled-mini-cart-contents-block --> | ||
<div class="wp-block-woocommerce-filled-mini-cart-contents-block"> | ||
<!-- wp:woocommerce/mini-cart-title-block --> | ||
<div class="wp-block-woocommerce-mini-cart-title-block"> | ||
</div> | ||
<!-- /wp:woocommerce/mini-cart-title-block --> | ||
<!-- wp:woocommerce/mini-cart-items-block --> | ||
<div class="wp-block-woocommerce-mini-cart-items-block"> | ||
<!-- wp:woocommerce/mini-cart-products-table-block --> | ||
<div class="wp-block-woocommerce-mini-cart-products-table-block"> | ||
</div> | ||
<!-- /wp:woocommerce/mini-cart-products-table-block --> | ||
</div> | ||
<!-- /wp:woocommerce/mini-cart-items-block --> | ||
<!-- wp:woocommerce/mini-cart-footer-block --> | ||
<div class="wp-block-woocommerce-mini-cart-footer-block"> | ||
</div> | ||
<!-- /wp:woocommerce/mini-cart-footer-block --> | ||
</div> | ||
<!-- /wp:woocommerce/filled-mini-cart-contents-block --> | ||
|
||
<!-- wp:woocommerce/empty-mini-cart-contents-block --> | ||
<div class="wp-block-woocommerce-empty-mini-cart-contents-block"> | ||
<!-- wp:paragraph {"align":"center"} --> | ||
<p class="has-text-align-center"> | ||
<strong>Your cart is currently empty!</strong> | ||
</p> | ||
<!-- /wp:paragraph --> | ||
|
||
<!-- wp:woocommerce/mini-cart-shopping-button-block --> | ||
<div class="wp-block-woocommerce-mini-cart-shopping-button-block"></div> | ||
<!-- /wp:woocommerce/mini-cart-shopping-button-block --> | ||
</div> | ||
<!-- /wp:woocommerce/empty-mini-cart-contents-block --> | ||
</div> | ||
<!-- /wp:woocommerce/mini-cart-contents --> |
8 changes: 8 additions & 0 deletions
8
tests/mocks/theme-with-woo-templates/block-templates/archive-product.html
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,8 @@ | ||
<!-- wp:template-part {"slug":"header"} /--> | ||
<!-- wp:group {"layout":{"inherit":true}} --> | ||
<h2 class="theme-template-title">Template loaded from theme</h2> | ||
<div class="wp-block-group"> | ||
<!-- wp:woocommerce/legacy-template {"template":"archive-product"} /--> | ||
</div> | ||
<!-- /wp:group --> | ||
<!-- wp:template-part {"slug":"footer"} /--> |
10 changes: 10 additions & 0 deletions
10
tests/mocks/theme-with-woo-templates/block-templates/index.html
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,10 @@ | ||
<!-- wp:template-part {"slug":"header","tagName":"header"} /--> | ||
|
||
<!-- wp:query {"queryId":1,"query":{"offset":0,"postType":"post","order":"desc","orderBy":"date","author":"","search":"","sticky":""}} --> | ||
<div class="wp-block-query"> | ||
<!-- wp:post-template --> | ||
<!-- wp:post-title {"isLink":true} /--> | ||
<!-- wp:post-excerpt /--> | ||
<!-- /wp:post-template --> | ||
</div> | ||
<!-- /wp:query --> |
8 changes: 8 additions & 0 deletions
8
tests/mocks/theme-with-woo-templates/block-templates/single-product.html
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,8 @@ | ||
<!-- wp:template-part {"slug":"header"} /--> | ||
<!-- wp:group {"layout":{"inherit":true}} --> | ||
<h2 class="theme-template-title">Template loaded from theme</h2> | ||
<div class="wp-block-group"> | ||
<!-- wp:woocommerce/legacy-template {"template":"single-product"} /--> | ||
</div> | ||
<!-- /wp:group --> | ||
<!-- wp:template-part {"slug":"footer"} /--> |
5 changes: 5 additions & 0 deletions
5
tests/mocks/theme-with-woo-templates/block-templates/singular.html
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,5 @@ | ||
<!-- wp:template-part {"slug":"header","tagName":"header"} /--> | ||
|
||
<!-- wp:post-title /--> | ||
|
||
<!-- wp:post-content {"layout":{"inherit":true}} /--> |
8 changes: 8 additions & 0 deletions
8
tests/mocks/theme-with-woo-templates/block-templates/taxonomy-product_cat.html
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,8 @@ | ||
<!-- wp:template-part {"slug":"header"} /--> | ||
<!-- wp:group {"layout":{"inherit":true}} --> | ||
<h2 class="theme-template-title">Template loaded from theme</h2> | ||
<div class="wp-block-group"> | ||
<!-- wp:woocommerce/legacy-template {"template":"taxonomy-product_cat"} /--> | ||
</div> | ||
<!-- /wp:group --> | ||
<!-- wp:template-part {"slug":"footer"} /--> |
8 changes: 8 additions & 0 deletions
8
tests/mocks/theme-with-woo-templates/block-templates/taxonomy-product_tag.html
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,8 @@ | ||
<!-- wp:template-part {"slug":"header"} /--> | ||
<!-- wp:group {"layout":{"inherit":true}} --> | ||
<h2 class="theme-template-title">Template loaded from theme</h2> | ||
<div class="wp-block-group"> | ||
<!-- wp:woocommerce/legacy-template {"template":"taxonomy-product_tag"} /--> | ||
</div> | ||
<!-- /wp:group --> | ||
<!-- wp:template-part {"slug":"footer"} /--> |
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,24 @@ | ||
<?php | ||
// phpcs:ignoreFile | ||
|
||
if ( ! function_exists( 'testtheme_support' ) ) : | ||
function testtheme_support() { | ||
|
||
// Adding support for core block visual styles. | ||
add_theme_support( 'wp-block-styles' ); | ||
|
||
// Enqueue editor styles. | ||
add_editor_style( 'style.css' ); | ||
} | ||
add_action( 'after_setup_theme', 'testtheme_support' ); | ||
endif; | ||
|
||
/** | ||
* Enqueue scripts and styles. | ||
*/ | ||
function testtheme_scripts() { | ||
// Enqueue theme stylesheet. | ||
wp_enqueue_style( 'testtheme-style', get_template_directory_uri() . '/style.css', array(), wp_get_theme()->get( 'Version' ) ); | ||
} | ||
|
||
add_action( 'wp_enqueue_scripts', 'testtheme_scripts' ); |
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,3 @@ | ||
<?php | ||
// phpcs:ignoreFile | ||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,13 @@ | ||
/* | ||
Theme Name: Theme with Woo Templates | ||
Theme URI: https://github.com/woocommerce/woocommerce-gutenberg-products-block | ||
Author: M. L. Giannotta <[email protected]> | ||
Description: The base for a block-based theme for WooCommerce. | ||
Requires at least: 5.3 | ||
Tested up to: 5.5 | ||
Requires PHP: 5.6 | ||
Version: 1.0 | ||
License: GNU General Public License v2 or later | ||
License URI: http://www.gnu.org/licenses/gpl-2.0.html | ||
Text Domain: themewithwootemplates | ||
*/ |
23 changes: 23 additions & 0 deletions
23
tests/mocks/theme-with-woo-templates/styles/variation.json
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,23 @@ | ||
{ | ||
"version": 2, | ||
"settings": { | ||
"color": { | ||
"palette": [ | ||
{ | ||
"slug": "foreground", | ||
"color": "#3F67C6", | ||
"name": "Foreground" | ||
} | ||
] | ||
} | ||
}, | ||
"styles": { | ||
"blocks": { | ||
"core/post-title": { | ||
"typography": { | ||
"fontWeight": "700" | ||
} | ||
} | ||
} | ||
} | ||
} |
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,10 @@ | ||
{ | ||
"version": 2, | ||
"settings": { | ||
"appearanceTools": true, | ||
"layout": { | ||
"contentSize": "840px", | ||
"wideSize": "1100px" | ||
} | ||
} | ||
} |