Skip to content
This repository was archived by the owner on Feb 23, 2024. It is now read-only.

Commit 1e4d336

Browse files
E2E: Fixing failed tests with Gutenberg (#7554)
Co-authored-by: Lucio Giannotta <[email protected]>
1 parent a7f4d0e commit 1e4d336

20 files changed

+176
-89
lines changed

package-lock.json

Lines changed: 13 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@
145145
"@wordpress/data-controls": "2.2.7",
146146
"@wordpress/dependency-extraction-webpack-plugin": "3.2.1",
147147
"@wordpress/dom": "3.16.0",
148-
"@wordpress/e2e-test-utils": "8.3.0",
148+
"@wordpress/e2e-test-utils": "8.4.0",
149149
"@wordpress/e2e-tests": "4.6.0",
150150
"@wordpress/element": "4.0.4",
151151
"@wordpress/env": "^4.9.0",

tests/e2e/specs/backend/__snapshots__/site-editing-templates.test.js.snap

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
exports[`Store Editing Templates Product Catalog block template should contain the "WooCommerce Product Grid Block" classic template 1`] = `
44
"<!-- wp:template-part {\\"slug\\":\\"header\\",\\"theme\\":\\"emptytheme\\",\\"tagName\\":\\"header\\"} /-->
55
6-
<!-- wp:group {\\"layout\\":{\\"inherit\\":true}} -->
6+
<!-- wp:group {\\"layout\\":{\\"inherit\\":true,\\"type\\":\\"constrained\\"}} -->
77
<div class=\\"wp-block-group\\"><!-- wp:woocommerce/legacy-template {\\"template\\":\\"archive-product\\"} /--></div>
88
<!-- /wp:group -->
99
@@ -13,7 +13,7 @@ exports[`Store Editing Templates Product Catalog block template should contain t
1313
exports[`Store Editing Templates Product Search Results block template should contain the "WooCommerce Product Grid Block" classic template 1`] = `
1414
"<!-- wp:template-part {\\"slug\\":\\"header\\",\\"theme\\":\\"emptytheme\\",\\"tagName\\":\\"header\\"} /-->
1515
16-
<!-- wp:group {\\"layout\\":{\\"inherit\\":true}} -->
16+
<!-- wp:group {\\"layout\\":{\\"inherit\\":true,\\"type\\":\\"constrained\\"}} -->
1717
<div class=\\"wp-block-group\\"><!-- wp:woocommerce/legacy-template {\\"template\\":\\"product-search-results\\"} /--></div>
1818
<!-- /wp:group -->
1919
@@ -23,7 +23,7 @@ exports[`Store Editing Templates Product Search Results block template should co
2323
exports[`Store Editing Templates Product by Category block template should contain the "WooCommerce Product Taxonomy Block" classic template 1`] = `
2424
"<!-- wp:template-part {\\"slug\\":\\"header\\",\\"theme\\":\\"emptytheme\\",\\"tagName\\":\\"header\\"} /-->
2525
26-
<!-- wp:group {\\"layout\\":{\\"inherit\\":true}} -->
26+
<!-- wp:group {\\"layout\\":{\\"inherit\\":true,\\"type\\":\\"constrained\\"}} -->
2727
<div class=\\"wp-block-group\\"><!-- wp:woocommerce/legacy-template {\\"template\\":\\"taxonomy-product_cat\\"} /--></div>
2828
<!-- /wp:group -->
2929
@@ -33,7 +33,7 @@ exports[`Store Editing Templates Product by Category block template should conta
3333
exports[`Store Editing Templates Products by Tag block template should contain the "WooCommerce Product Taxonomy Block" classic template 1`] = `
3434
"<!-- wp:template-part {\\"slug\\":\\"header\\",\\"theme\\":\\"emptytheme\\",\\"tagName\\":\\"header\\"} /-->
3535
36-
<!-- wp:group {\\"layout\\":{\\"inherit\\":true}} -->
36+
<!-- wp:group {\\"layout\\":{\\"inherit\\":true,\\"type\\":\\"constrained\\"}} -->
3737
<div class=\\"wp-block-group\\"><!-- wp:woocommerce/legacy-template {\\"template\\":\\"taxonomy-product_tag\\"} /--></div>
3838
<!-- /wp:group -->
3939
@@ -43,7 +43,7 @@ exports[`Store Editing Templates Products by Tag block template should contain t
4343
exports[`Store Editing Templates Single Product block template should contain the "WooCommerce Single Product Block" classic template 1`] = `
4444
"<!-- wp:template-part {\\"slug\\":\\"header\\",\\"theme\\":\\"emptytheme\\",\\"tagName\\":\\"header\\"} /-->
4545
46-
<!-- wp:group {\\"layout\\":{\\"inherit\\":true}} -->
46+
<!-- wp:group {\\"layout\\":{\\"inherit\\":true,\\"type\\":\\"constrained\\"}} -->
4747
<div class=\\"wp-block-group\\"><!-- wp:woocommerce/legacy-template {\\"template\\":\\"single-product\\"} /--></div>
4848
<!-- /wp:group -->
4949

tests/e2e/specs/backend/product-query.test.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,12 @@ describeOrSkip( GUTENBERG_EDITOR_CONTEXT === 'gutenberg' )(
4444
await expect( page ).toRenderBlock( block );
4545
} );
4646

47-
it( 'Editor preview shows only on sale products after enabling `Show only products on sale`', async () => {
47+
/**
48+
* We changed the “Show only products on sale” from a top-level toggle
49+
* setting to a product filter, but tests for them haven't been updated
50+
* yet. We will fix these tests in a follow-up PR.
51+
*/
52+
it.skip( 'Editor preview shows only on sale products after enabling `Show only products on sale`', async () => {
4853
await visitBlockPage( `${ block.name } Block` );
4954
const canvasEl = canvas();
5055
await openDocumentSettingsSidebar();
@@ -84,7 +89,12 @@ describeOrSkip( GUTENBERG_EDITOR_CONTEXT === 'gutenberg' )(
8489
expect( products ).toHaveLength( 1 );
8590
} );
8691

87-
it( 'Does not have on sale toggle', async () => {
92+
/**
93+
* We changed the “Show only products on sale” from a top-level toggle
94+
* setting to a product filter, but tests for them haven't been updated
95+
* yet. We will fix these tests in a follow-up PR.
96+
*/
97+
it.skip( 'Does not have on sale toggle', async () => {
8898
await openDocumentSettingsSidebar();
8999
await openListView();
90100
await page.click(

tests/e2e/specs/shopper/active-filters.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
} from '@wordpress/e2e-test-utils';
1212
import { SHOP_PAGE } from '@woocommerce/e2e-utils';
1313
import { Frame, Page } from 'puppeteer';
14+
import { insertBlockUsingSlash } from '@woocommerce/blocks-test-utils';
1415

1516
/**
1617
* Internal dependencies
@@ -97,7 +98,7 @@ describe( 'Shopper → Active Filters Block', () => {
9798
} );
9899

99100
await insertBlocks();
100-
await insertBlock( 'All Products' );
101+
await insertBlockUsingSlash( 'All Products' );
101102
await configurateFilterProductsByAttributeBlock( page );
102103
await publishPost();
103104

tests/e2e/specs/shopper/cart-checkout/account.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ describe( 'Shopper → Checkout → Account', () => {
4646
await selectBlockByName(
4747
'woocommerce/checkout-contact-information-block'
4848
);
49-
await openBlockEditorSettings( { isFSEEditor: false } );
49+
await openBlockEditorSettings();
5050
//Enable shoppers to sign up at checkout option.
5151
// eslint-disable-next-line jest/no-standalone-expect
5252
await expect( page ).toClick( 'label', {

tests/e2e/specs/shopper/cart-checkout/checkout.test.js

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ import {
88
unsetCheckbox,
99
withRestApi,
1010
} from '@woocommerce/e2e-utils';
11-
1211
import {
1312
visitBlockPage,
1413
selectBlockByName,
1514
saveOrPublish,
15+
getToggleIdByLabel,
1616
} from '@woocommerce/blocks-test-utils';
1717

1818
/**
@@ -36,7 +36,6 @@ if ( process.env.WOOCOMMERCE_BLOCKS_PHASE < 2 ) {
3636
test.only( 'Skipping Cart & Checkout tests', () => {} );
3737
}
3838

39-
let companyCheckboxId = null;
4039
let coupon;
4140

4241
describe( 'Shopper → Checkout', () => {
@@ -75,16 +74,7 @@ describe( 'Shopper → Checkout', () => {
7574
'woocommerce/checkout-shipping-address-block'
7675
);
7776

78-
// This checkbox ID is unstable, so, we're getting its value from "for" attribute of the label
79-
const [ companyCheckboxLabel ] = await page.$x(
80-
`//label[contains(text(), "Company") and contains(@class, "components-toggle-control__label")]`
81-
);
82-
companyCheckboxId = await page.evaluate(
83-
( label ) => `#${ label.getAttribute( 'for' ) }`,
84-
companyCheckboxLabel
85-
);
86-
87-
await setCheckbox( companyCheckboxId );
77+
await setCheckbox( await getToggleIdByLabel( 'Company' ) );
8878
await saveOrPublish();
8979
await shopper.block.emptyCart();
9080
} );
@@ -96,7 +86,7 @@ describe( 'Shopper → Checkout', () => {
9686
await selectBlockByName(
9787
'woocommerce/checkout-shipping-address-block'
9888
);
99-
await unsetCheckbox( companyCheckboxId );
89+
await unsetCheckbox( await getToggleIdByLabel( 'Company' ) );
10090
await saveOrPublish();
10191
await merchant.logout();
10292
await reactivateCompatibilityNotice();

tests/e2e/specs/shopper/filter-products-by-attribute.test.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@ import {
99
switchUserToAdmin,
1010
publishPost,
1111
} from '@wordpress/e2e-test-utils';
12-
import { selectBlockByName } from '@woocommerce/blocks-test-utils';
12+
import {
13+
selectBlockByName,
14+
insertBlockUsingSlash,
15+
} from '@woocommerce/blocks-test-utils';
1316

1417
/**
1518
* Internal dependencies
@@ -65,7 +68,7 @@ describe( `${ block.name } Block`, () => {
6568
title: block.name,
6669
} );
6770

68-
await insertBlock( 'All Products' );
71+
await insertBlockUsingSlash( 'All Products' );
6972
await insertBlock( block.name );
7073
const canvasEl = canvas();
7174

@@ -185,7 +188,7 @@ describe( `${ block.name } Block`, () => {
185188
} );
186189

187190
await selectBlockByName( block.slug );
188-
await openBlockEditorSettings( { isFSEEditor: true } );
191+
await openBlockEditorSettings();
189192
const [ filterButtonToggle ] = await page.$x(
190193
block.selectors.editor.filterButtonToggle
191194
);

tests/e2e/specs/shopper/filter-products-by-price.test.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ import {
88
switchUserToAdmin,
99
publishPost,
1010
} from '@wordpress/e2e-test-utils';
11-
import { selectBlockByName } from '@woocommerce/blocks-test-utils';
11+
import {
12+
selectBlockByName,
13+
insertBlockUsingSlash,
14+
} from '@woocommerce/blocks-test-utils';
1215

1316
/**
1417
* Internal dependencies
@@ -70,7 +73,7 @@ describe( `${ block.name } Block`, () => {
7073
} );
7174

7275
await insertBlock( block.name );
73-
await insertBlock( 'All Products' );
76+
await insertBlockUsingSlash( 'All Products' );
7477
await insertBlock( 'Active Product Filters' );
7578
await publishPost();
7679

@@ -182,7 +185,7 @@ describe( `${ block.name } Block`, () => {
182185
} );
183186

184187
await selectBlockByName( block.slug );
185-
await openBlockEditorSettings( { isFSEEditor: true } );
188+
await openBlockEditorSettings();
186189
await page.waitForXPath(
187190
block.selectors.editor.filterButtonToggle
188191
);

tests/e2e/specs/shopper/filter-products-by-rating.test.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ import {
88
switchUserToAdmin,
99
publishPost,
1010
} from '@wordpress/e2e-test-utils';
11-
import { selectBlockByName } from '@woocommerce/blocks-test-utils';
11+
import {
12+
selectBlockByName,
13+
insertBlockUsingSlash,
14+
} from '@woocommerce/blocks-test-utils';
1215

1316
/**
1417
* Internal dependencies
@@ -62,7 +65,7 @@ describe( `${ block.name } Block`, () => {
6265
} );
6366

6467
await insertBlock( block.name );
65-
await insertBlock( 'All Products' );
68+
await insertBlockUsingSlash( 'All Products' );
6669
await publishPost();
6770

6871
link = await page.evaluate( () =>

0 commit comments

Comments
 (0)