* Update @wordpress/e2e-test-utils

* Remove WP 6.1 specific code

* Don't call switchBlockInspectorTab in blocks that don't have inspector tabs

* Typos and code styling fixes

* Make .toRenderBlock() more resilient

* Make sure we only open the Settings tab when the block has been selected

* Fix goToSiteEditor in WP 6.2

* Create insertAllProductsBlock util

* Create openSettingsSidebar util as an alternative to openDocumentSettingsSidebar so it works in WP 6.2

* Update WOOCOMMERCE_PARSED_ID

* Create enableApplyFiltersButton() util
This commit is contained in:
Albert Juhé Lluveras 2023-04-03 15:02:36 +02:00 committed by GitHub
parent 965491de4e
commit b143048c81
30 changed files with 303 additions and 421 deletions

View File

@ -104,7 +104,7 @@
"@wordpress/data-controls": "2.2.7", "@wordpress/data-controls": "2.2.7",
"@wordpress/dependency-extraction-webpack-plugin": "3.2.1", "@wordpress/dependency-extraction-webpack-plugin": "3.2.1",
"@wordpress/dom": "3.27.0", "@wordpress/dom": "3.27.0",
"@wordpress/e2e-test-utils": "9.2.0", "@wordpress/e2e-test-utils": "10.1.0",
"@wordpress/e2e-tests": "4.6.0", "@wordpress/e2e-tests": "4.6.0",
"@wordpress/element": "4.20.0", "@wordpress/element": "4.20.0",
"@wordpress/env": "^4.9.0", "@wordpress/env": "^4.9.0",
@ -14052,15 +14052,15 @@
} }
}, },
"node_modules/@wordpress/e2e-test-utils": { "node_modules/@wordpress/e2e-test-utils": {
"version": "9.2.0", "version": "10.1.0",
"resolved": "https://registry.npmjs.org/@wordpress/e2e-test-utils/-/e2e-test-utils-9.2.0.tgz", "resolved": "https://registry.npmjs.org/@wordpress/e2e-test-utils/-/e2e-test-utils-10.1.0.tgz",
"integrity": "sha512-kfnIwgoo4fd1+h85btWFyoMcPBqYA4szwWI3GmrBny8ybyFljRed1XVleZ/oD6MaFgid4uB6V4+OKTlsw5mg/Q==", "integrity": "sha512-FybFtoN7qq+3ne+Sy8OThUBvBtm3Qd5Rh8BQ0hXdE3izIclwqPVePlDOhyz9AHvOajmgLn4v/YXs3D1uOOhVKA==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"@babel/runtime": "^7.16.0", "@babel/runtime": "^7.16.0",
"@wordpress/api-fetch": "^6.22.0", "@wordpress/api-fetch": "^6.27.0",
"@wordpress/keycodes": "^3.25.0", "@wordpress/keycodes": "^3.30.0",
"@wordpress/url": "^3.26.0", "@wordpress/url": "^3.31.0",
"change-case": "^4.1.2", "change-case": "^4.1.2",
"form-data": "^4.0.0", "form-data": "^4.0.0",
"node-fetch": "^2.6.0" "node-fetch": "^2.6.0"
@ -14069,32 +14069,32 @@
"node": ">=14" "node": ">=14"
}, },
"peerDependencies": { "peerDependencies": {
"jest": ">=27", "jest": ">=29",
"puppeteer-core": ">=11" "puppeteer-core": ">=11"
} }
}, },
"node_modules/@wordpress/e2e-test-utils/node_modules/@wordpress/api-fetch": { "node_modules/@wordpress/e2e-test-utils/node_modules/@wordpress/api-fetch": {
"version": "6.22.0", "version": "6.27.0",
"resolved": "https://registry.npmjs.org/@wordpress/api-fetch/-/api-fetch-6.22.0.tgz", "resolved": "https://registry.npmjs.org/@wordpress/api-fetch/-/api-fetch-6.27.0.tgz",
"integrity": "sha512-IO7Shv1Qz93bo/Rq20beAV+p1qSOCs4uUi98rzhhih7U0SF88Jo69mlNmQbpALWcG040a2DRQR8E18Mj7JwViQ==", "integrity": "sha512-5DAOOhvA4rmAGIoQX8gbut73Ls0nD5vKo4ImhaeMt+5o7JO7Mn+FU1t7GFy2MwzdBEu/toh/XuCHqF6F3HaooQ==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"@babel/runtime": "^7.16.0", "@babel/runtime": "^7.16.0",
"@wordpress/i18n": "^4.25.0", "@wordpress/i18n": "^4.30.0",
"@wordpress/url": "^3.26.0" "@wordpress/url": "^3.31.0"
}, },
"engines": { "engines": {
"node": ">=12" "node": ">=12"
} }
}, },
"node_modules/@wordpress/e2e-test-utils/node_modules/@wordpress/i18n": { "node_modules/@wordpress/e2e-test-utils/node_modules/@wordpress/i18n": {
"version": "4.25.0", "version": "4.30.0",
"resolved": "https://registry.npmjs.org/@wordpress/i18n/-/i18n-4.25.0.tgz", "resolved": "https://registry.npmjs.org/@wordpress/i18n/-/i18n-4.30.0.tgz",
"integrity": "sha512-cKU5Ox1DKa3WShRu+QrCU+QzNvyoQhrNtS6kcvw17DfMBjPe7AsYjd7ZBb7Io327jP97Oqh5BtaYdUq/4S1cIw==", "integrity": "sha512-vIntwrTBSU2MXOBlpyFntPgimHP+RW+k7/Y00BMPL+xoxPr7J7sXX/GNoYlH1BNsAo7XOi5AY5FrUnQ7ZIYdtQ==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"@babel/runtime": "^7.16.0", "@babel/runtime": "^7.16.0",
"@wordpress/hooks": "^3.25.0", "@wordpress/hooks": "^3.30.0",
"gettext-parser": "^1.3.1", "gettext-parser": "^1.3.1",
"memize": "^1.1.0", "memize": "^1.1.0",
"sprintf-js": "^1.1.1", "sprintf-js": "^1.1.1",
@ -14108,9 +14108,9 @@
} }
}, },
"node_modules/@wordpress/e2e-test-utils/node_modules/@wordpress/url": { "node_modules/@wordpress/e2e-test-utils/node_modules/@wordpress/url": {
"version": "3.26.0", "version": "3.31.0",
"resolved": "https://registry.npmjs.org/@wordpress/url/-/url-3.26.0.tgz", "resolved": "https://registry.npmjs.org/@wordpress/url/-/url-3.31.0.tgz",
"integrity": "sha512-oqIYWqUo1sr1qU4jxbRhzusSqMClSHn4bNtlR835VcqZoBnTM7/RwfrmTo6aCWDcSAd7LQVV1vykTjJsAYdxsA==", "integrity": "sha512-3sxbDKU8OQTeGat3Roef9dN/NR0Rb6ld9KN0618Ec+FHU05dI+7nolA0jfOAJka+Vvf7gfP0WQ7cJAZdlwfNuw==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"@babel/runtime": "^7.16.0", "@babel/runtime": "^7.16.0",
@ -16254,9 +16254,9 @@
} }
}, },
"node_modules/@wordpress/hooks": { "node_modules/@wordpress/hooks": {
"version": "3.27.0", "version": "3.30.0",
"resolved": "https://registry.npmjs.org/@wordpress/hooks/-/hooks-3.27.0.tgz", "resolved": "https://registry.npmjs.org/@wordpress/hooks/-/hooks-3.30.0.tgz",
"integrity": "sha512-izhRvOJzc/VFsu59KC+et1/35GL0Op7I60RZj2lkTnEz1vGvtClY3okCbOtGN0Adc8ewbTf4kB6qgKMsLtW0Dg==", "integrity": "sha512-cvM5OWMQx0D2+wxvsTCI68LXy4cHz1Db97LliiQ+KprSBmYRG5Uy2PqtPv1sMlK8IOypKOlzmG5H5V1CwBN44A==",
"dependencies": { "dependencies": {
"@babel/runtime": "^7.16.0" "@babel/runtime": "^7.16.0"
}, },
@ -16412,26 +16412,25 @@
"license": "MIT" "license": "MIT"
}, },
"node_modules/@wordpress/keycodes": { "node_modules/@wordpress/keycodes": {
"version": "3.25.0", "version": "3.30.0",
"resolved": "https://registry.npmjs.org/@wordpress/keycodes/-/keycodes-3.25.0.tgz", "resolved": "https://registry.npmjs.org/@wordpress/keycodes/-/keycodes-3.30.0.tgz",
"integrity": "sha512-y55wL9bj/XrW7Uyvg6kyQeVjPQOezG7HTI+L3nzI12waL50eGhqM1DSOv6PhMrcoHG4CN5Lg8bXNUF6TrAntfA==", "integrity": "sha512-rDZYk/t3a/WtOi8SrfVrHP63mT5NXw13kNf3+VL/jk+hcacb6TXImFEwH0F5nLHVYpvv0fPSoFUDo5bYqwbHZQ==",
"dependencies": { "dependencies": {
"@babel/runtime": "^7.16.0", "@babel/runtime": "^7.16.0",
"@wordpress/i18n": "^4.25.0", "@wordpress/i18n": "^4.30.0",
"change-case": "^4.1.2", "change-case": "^4.1.2"
"lodash": "^4.17.21"
}, },
"engines": { "engines": {
"node": ">=12" "node": ">=12"
} }
}, },
"node_modules/@wordpress/keycodes/node_modules/@wordpress/i18n": { "node_modules/@wordpress/keycodes/node_modules/@wordpress/i18n": {
"version": "4.25.0", "version": "4.30.0",
"resolved": "https://registry.npmjs.org/@wordpress/i18n/-/i18n-4.25.0.tgz", "resolved": "https://registry.npmjs.org/@wordpress/i18n/-/i18n-4.30.0.tgz",
"integrity": "sha512-cKU5Ox1DKa3WShRu+QrCU+QzNvyoQhrNtS6kcvw17DfMBjPe7AsYjd7ZBb7Io327jP97Oqh5BtaYdUq/4S1cIw==", "integrity": "sha512-vIntwrTBSU2MXOBlpyFntPgimHP+RW+k7/Y00BMPL+xoxPr7J7sXX/GNoYlH1BNsAo7XOi5AY5FrUnQ7ZIYdtQ==",
"dependencies": { "dependencies": {
"@babel/runtime": "^7.16.0", "@babel/runtime": "^7.16.0",
"@wordpress/hooks": "^3.25.0", "@wordpress/hooks": "^3.30.0",
"gettext-parser": "^1.3.1", "gettext-parser": "^1.3.1",
"memize": "^1.1.0", "memize": "^1.1.0",
"sprintf-js": "^1.1.1", "sprintf-js": "^1.1.1",
@ -20406,15 +20405,6 @@
"node": ">=8" "node": ">=8"
} }
}, },
"node_modules/bindings": {
"version": "1.5.0",
"dev": true,
"license": "MIT",
"optional": true,
"dependencies": {
"file-uri-to-path": "1.0.0"
}
},
"node_modules/bl": { "node_modules/bl": {
"version": "4.1.0", "version": "4.1.0",
"dev": true, "dev": true,
@ -27150,12 +27140,6 @@
"ramda": "^0.28.0" "ramda": "^0.28.0"
} }
}, },
"node_modules/file-uri-to-path": {
"version": "1.0.0",
"dev": true,
"license": "MIT",
"optional": true
},
"node_modules/filename-reserved-regex": { "node_modules/filename-reserved-regex": {
"version": "2.0.0", "version": "2.0.0",
"dev": true, "dev": true,
@ -28024,17 +28008,6 @@
"devOptional": true, "devOptional": true,
"license": "ISC" "license": "ISC"
}, },
"node_modules/fsevents": {
"version": "2.3.2",
"license": "MIT",
"optional": true,
"os": [
"darwin"
],
"engines": {
"node": "^8.16.0 || ^10.6.0 || >=11.0.0"
}
},
"node_modules/function-bind": { "node_modules/function-bind": {
"version": "1.1.1", "version": "1.1.1",
"license": "MIT" "license": "MIT"
@ -38336,11 +38309,6 @@
"dev": true, "dev": true,
"license": "ISC" "license": "ISC"
}, },
"node_modules/nan": {
"version": "2.16.0",
"license": "MIT",
"optional": true
},
"node_modules/nanoid": { "node_modules/nanoid": {
"version": "3.3.4", "version": "3.3.4",
"dev": true, "dev": true,
@ -38611,16 +38579,6 @@
"inherits": "2.0.3" "inherits": "2.0.3"
} }
}, },
"node_modules/node-pty": {
"version": "0.9.0",
"resolved": "https://registry.npmjs.org/node-pty/-/node-pty-0.9.0.tgz",
"integrity": "sha512-MBnCQl83FTYOu7B4xWw10AW77AAh7ThCE1VXEv+JeWj8mSpGo+0bwgsV+b23ljBFwEM9OmsOv3kM27iUPPm84g==",
"hasInstallScript": true,
"optional": true,
"dependencies": {
"nan": "^2.14.0"
}
},
"node_modules/node-releases": { "node_modules/node-releases": {
"version": "2.0.4", "version": "2.0.4",
"license": "MIT" "license": "MIT"
@ -48871,23 +48829,6 @@
"node": ">=0.10.0" "node": ">=0.10.0"
} }
}, },
"node_modules/watchpack-chokidar2/node_modules/fsevents": {
"version": "1.2.13",
"dev": true,
"hasInstallScript": true,
"license": "MIT",
"optional": true,
"os": [
"darwin"
],
"dependencies": {
"bindings": "^1.5.0",
"nan": "^2.12.1"
},
"engines": {
"node": ">= 4.0"
}
},
"node_modules/watchpack-chokidar2/node_modules/glob-parent": { "node_modules/watchpack-chokidar2/node_modules/glob-parent": {
"version": "3.1.0", "version": "3.1.0",
"dev": true, "dev": true,
@ -60752,39 +60693,39 @@
} }
}, },
"@wordpress/e2e-test-utils": { "@wordpress/e2e-test-utils": {
"version": "9.2.0", "version": "10.1.0",
"resolved": "https://registry.npmjs.org/@wordpress/e2e-test-utils/-/e2e-test-utils-9.2.0.tgz", "resolved": "https://registry.npmjs.org/@wordpress/e2e-test-utils/-/e2e-test-utils-10.1.0.tgz",
"integrity": "sha512-kfnIwgoo4fd1+h85btWFyoMcPBqYA4szwWI3GmrBny8ybyFljRed1XVleZ/oD6MaFgid4uB6V4+OKTlsw5mg/Q==", "integrity": "sha512-FybFtoN7qq+3ne+Sy8OThUBvBtm3Qd5Rh8BQ0hXdE3izIclwqPVePlDOhyz9AHvOajmgLn4v/YXs3D1uOOhVKA==",
"dev": true, "dev": true,
"requires": { "requires": {
"@babel/runtime": "^7.16.0", "@babel/runtime": "^7.16.0",
"@wordpress/api-fetch": "^6.22.0", "@wordpress/api-fetch": "^6.27.0",
"@wordpress/keycodes": "^3.25.0", "@wordpress/keycodes": "^3.30.0",
"@wordpress/url": "^3.26.0", "@wordpress/url": "^3.31.0",
"change-case": "^4.1.2", "change-case": "^4.1.2",
"form-data": "^4.0.0", "form-data": "^4.0.0",
"node-fetch": "^2.6.0" "node-fetch": "^2.6.0"
}, },
"dependencies": { "dependencies": {
"@wordpress/api-fetch": { "@wordpress/api-fetch": {
"version": "6.22.0", "version": "6.27.0",
"resolved": "https://registry.npmjs.org/@wordpress/api-fetch/-/api-fetch-6.22.0.tgz", "resolved": "https://registry.npmjs.org/@wordpress/api-fetch/-/api-fetch-6.27.0.tgz",
"integrity": "sha512-IO7Shv1Qz93bo/Rq20beAV+p1qSOCs4uUi98rzhhih7U0SF88Jo69mlNmQbpALWcG040a2DRQR8E18Mj7JwViQ==", "integrity": "sha512-5DAOOhvA4rmAGIoQX8gbut73Ls0nD5vKo4ImhaeMt+5o7JO7Mn+FU1t7GFy2MwzdBEu/toh/XuCHqF6F3HaooQ==",
"dev": true, "dev": true,
"requires": { "requires": {
"@babel/runtime": "^7.16.0", "@babel/runtime": "^7.16.0",
"@wordpress/i18n": "^4.25.0", "@wordpress/i18n": "^4.30.0",
"@wordpress/url": "^3.26.0" "@wordpress/url": "^3.31.0"
} }
}, },
"@wordpress/i18n": { "@wordpress/i18n": {
"version": "4.25.0", "version": "4.30.0",
"resolved": "https://registry.npmjs.org/@wordpress/i18n/-/i18n-4.25.0.tgz", "resolved": "https://registry.npmjs.org/@wordpress/i18n/-/i18n-4.30.0.tgz",
"integrity": "sha512-cKU5Ox1DKa3WShRu+QrCU+QzNvyoQhrNtS6kcvw17DfMBjPe7AsYjd7ZBb7Io327jP97Oqh5BtaYdUq/4S1cIw==", "integrity": "sha512-vIntwrTBSU2MXOBlpyFntPgimHP+RW+k7/Y00BMPL+xoxPr7J7sXX/GNoYlH1BNsAo7XOi5AY5FrUnQ7ZIYdtQ==",
"dev": true, "dev": true,
"requires": { "requires": {
"@babel/runtime": "^7.16.0", "@babel/runtime": "^7.16.0",
"@wordpress/hooks": "^3.25.0", "@wordpress/hooks": "^3.30.0",
"gettext-parser": "^1.3.1", "gettext-parser": "^1.3.1",
"memize": "^1.1.0", "memize": "^1.1.0",
"sprintf-js": "^1.1.1", "sprintf-js": "^1.1.1",
@ -60792,9 +60733,9 @@
} }
}, },
"@wordpress/url": { "@wordpress/url": {
"version": "3.26.0", "version": "3.31.0",
"resolved": "https://registry.npmjs.org/@wordpress/url/-/url-3.26.0.tgz", "resolved": "https://registry.npmjs.org/@wordpress/url/-/url-3.31.0.tgz",
"integrity": "sha512-oqIYWqUo1sr1qU4jxbRhzusSqMClSHn4bNtlR835VcqZoBnTM7/RwfrmTo6aCWDcSAd7LQVV1vykTjJsAYdxsA==", "integrity": "sha512-3sxbDKU8OQTeGat3Roef9dN/NR0Rb6ld9KN0618Ec+FHU05dI+7nolA0jfOAJka+Vvf7gfP0WQ7cJAZdlwfNuw==",
"dev": true, "dev": true,
"requires": { "requires": {
"@babel/runtime": "^7.16.0", "@babel/runtime": "^7.16.0",
@ -62265,9 +62206,9 @@
} }
}, },
"@wordpress/hooks": { "@wordpress/hooks": {
"version": "3.27.0", "version": "3.30.0",
"resolved": "https://registry.npmjs.org/@wordpress/hooks/-/hooks-3.27.0.tgz", "resolved": "https://registry.npmjs.org/@wordpress/hooks/-/hooks-3.30.0.tgz",
"integrity": "sha512-izhRvOJzc/VFsu59KC+et1/35GL0Op7I60RZj2lkTnEz1vGvtClY3okCbOtGN0Adc8ewbTf4kB6qgKMsLtW0Dg==", "integrity": "sha512-cvM5OWMQx0D2+wxvsTCI68LXy4cHz1Db97LliiQ+KprSBmYRG5Uy2PqtPv1sMlK8IOypKOlzmG5H5V1CwBN44A==",
"requires": { "requires": {
"@babel/runtime": "^7.16.0" "@babel/runtime": "^7.16.0"
} }
@ -62363,23 +62304,22 @@
} }
}, },
"@wordpress/keycodes": { "@wordpress/keycodes": {
"version": "3.25.0", "version": "3.30.0",
"resolved": "https://registry.npmjs.org/@wordpress/keycodes/-/keycodes-3.25.0.tgz", "resolved": "https://registry.npmjs.org/@wordpress/keycodes/-/keycodes-3.30.0.tgz",
"integrity": "sha512-y55wL9bj/XrW7Uyvg6kyQeVjPQOezG7HTI+L3nzI12waL50eGhqM1DSOv6PhMrcoHG4CN5Lg8bXNUF6TrAntfA==", "integrity": "sha512-rDZYk/t3a/WtOi8SrfVrHP63mT5NXw13kNf3+VL/jk+hcacb6TXImFEwH0F5nLHVYpvv0fPSoFUDo5bYqwbHZQ==",
"requires": { "requires": {
"@babel/runtime": "^7.16.0", "@babel/runtime": "^7.16.0",
"@wordpress/i18n": "^4.25.0", "@wordpress/i18n": "^4.30.0",
"change-case": "^4.1.2", "change-case": "^4.1.2"
"lodash": "^4.17.21"
}, },
"dependencies": { "dependencies": {
"@wordpress/i18n": { "@wordpress/i18n": {
"version": "4.25.0", "version": "4.30.0",
"resolved": "https://registry.npmjs.org/@wordpress/i18n/-/i18n-4.25.0.tgz", "resolved": "https://registry.npmjs.org/@wordpress/i18n/-/i18n-4.30.0.tgz",
"integrity": "sha512-cKU5Ox1DKa3WShRu+QrCU+QzNvyoQhrNtS6kcvw17DfMBjPe7AsYjd7ZBb7Io327jP97Oqh5BtaYdUq/4S1cIw==", "integrity": "sha512-vIntwrTBSU2MXOBlpyFntPgimHP+RW+k7/Y00BMPL+xoxPr7J7sXX/GNoYlH1BNsAo7XOi5AY5FrUnQ7ZIYdtQ==",
"requires": { "requires": {
"@babel/runtime": "^7.16.0", "@babel/runtime": "^7.16.0",
"@wordpress/hooks": "^3.25.0", "@wordpress/hooks": "^3.30.0",
"gettext-parser": "^1.3.1", "gettext-parser": "^1.3.1",
"memize": "^1.1.0", "memize": "^1.1.0",
"sprintf-js": "^1.1.1", "sprintf-js": "^1.1.1",
@ -65086,14 +65026,6 @@
"version": "2.2.0", "version": "2.2.0",
"devOptional": true "devOptional": true
}, },
"bindings": {
"version": "1.5.0",
"dev": true,
"optional": true,
"requires": {
"file-uri-to-path": "1.0.0"
}
},
"bl": { "bl": {
"version": "4.1.0", "version": "4.1.0",
"dev": true, "dev": true,
@ -69697,11 +69629,6 @@
"ramda": "^0.28.0" "ramda": "^0.28.0"
} }
}, },
"file-uri-to-path": {
"version": "1.0.0",
"dev": true,
"optional": true
},
"filename-reserved-regex": { "filename-reserved-regex": {
"version": "2.0.0", "version": "2.0.0",
"dev": true "dev": true
@ -70274,10 +70201,6 @@
"version": "1.0.0", "version": "1.0.0",
"devOptional": true "devOptional": true
}, },
"fsevents": {
"version": "2.3.2",
"optional": true
},
"function-bind": { "function-bind": {
"version": "1.1.1" "version": "1.1.1"
}, },
@ -77407,10 +77330,6 @@
"version": "0.0.8", "version": "0.0.8",
"dev": true "dev": true
}, },
"nan": {
"version": "2.16.0",
"optional": true
},
"nanoid": { "nanoid": {
"version": "3.3.4", "version": "3.3.4",
"dev": true "dev": true
@ -77613,15 +77532,6 @@
} }
} }
}, },
"node-pty": {
"version": "0.9.0",
"resolved": "https://registry.npmjs.org/node-pty/-/node-pty-0.9.0.tgz",
"integrity": "sha512-MBnCQl83FTYOu7B4xWw10AW77AAh7ThCE1VXEv+JeWj8mSpGo+0bwgsV+b23ljBFwEM9OmsOv3kM27iUPPm84g==",
"optional": true,
"requires": {
"nan": "^2.14.0"
}
},
"node-releases": { "node-releases": {
"version": "2.0.4" "version": "2.0.4"
}, },
@ -84541,15 +84451,6 @@
} }
} }
}, },
"fsevents": {
"version": "1.2.13",
"dev": true,
"optional": true,
"requires": {
"bindings": "^1.5.0",
"nan": "^2.12.1"
}
},
"glob-parent": { "glob-parent": {
"version": "3.1.0", "version": "3.1.0",
"dev": true, "dev": true,

View File

@ -148,7 +148,7 @@
"@wordpress/data-controls": "2.2.7", "@wordpress/data-controls": "2.2.7",
"@wordpress/dependency-extraction-webpack-plugin": "3.2.1", "@wordpress/dependency-extraction-webpack-plugin": "3.2.1",
"@wordpress/dom": "3.27.0", "@wordpress/dom": "3.27.0",
"@wordpress/e2e-test-utils": "9.2.0", "@wordpress/e2e-test-utils": "10.1.0",
"@wordpress/e2e-tests": "4.6.0", "@wordpress/e2e-tests": "4.6.0",
"@wordpress/element": "4.20.0", "@wordpress/element": "4.20.0",
"@wordpress/env": "^4.9.0", "@wordpress/env": "^4.9.0",

View File

@ -1,3 +1,8 @@
/**
* Internal dependencies
*/
import { getBlocksBySlug } from '../../utils.js';
expect.extend( { expect.extend( {
async toRenderBlock( page, block = {} ) { async toRenderBlock( page, block = {} ) {
const gutenbergNotFoundError = ( await page.content() ).match( const gutenbergNotFoundError = ( await page.content() ).match(
@ -39,11 +44,11 @@ expect.extend( {
}; };
} }
const blockElement = await page.$( block.class ); const blocks = await getBlocksBySlug( block.slug );
if ( blockElement === null ) { if ( blocks >= 1 ) {
return { return {
message: () => message: () =>
`the ${ block.name || 'block' } with classname \`${ `${ block.name || 'block' } with classname \`${
block.class block.class
}\` did not render.`, }\` did not render.`,
pass: false, pass: false,

View File

@ -12,6 +12,7 @@ import {
} from '@wordpress/e2e-test-utils'; } from '@wordpress/e2e-test-utils';
import { setDefaultOptions } from 'expect-puppeteer'; import { setDefaultOptions } from 'expect-puppeteer';
import { get } from 'lodash'; import { get } from 'lodash';
/** /**
* Internal dependencies * Internal dependencies
*/ */

View File

@ -2,16 +2,19 @@
* External dependencies * External dependencies
*/ */
import { import {
switchBlockInspectorTab,
switchUserToAdmin, switchUserToAdmin,
openDocumentSettingsSidebar,
} from '@wordpress/e2e-test-utils'; } from '@wordpress/e2e-test-utils';
import { import {
visitBlockPage, visitBlockPage,
selectBlockByName, selectBlockByName,
switchBlockInspectorTabWhenGutenbergIsInstalled,
} from '@woocommerce/blocks-test-utils'; } from '@woocommerce/blocks-test-utils';
/**
* Internal dependencies
*/
import { openSettingsSidebar } from '../../utils.js';
const block = { const block = {
name: 'Active Filters', name: 'Active Filters',
slug: 'woocommerce/active-filters', slug: 'woocommerce/active-filters',
@ -31,9 +34,9 @@ describe( `${ block.name } Block`, () => {
describe( 'attributes', () => { describe( 'attributes', () => {
beforeEach( async () => { beforeEach( async () => {
await openDocumentSettingsSidebar(); await openSettingsSidebar();
await switchBlockInspectorTabWhenGutenbergIsInstalled( 'Settings' );
await selectBlockByName( block.slug ); await selectBlockByName( block.slug );
await switchBlockInspectorTab( 'Settings' );
} ); } );
it( "allows changing the block's title", async () => { it( "allows changing the block's title", async () => {

View File

@ -2,17 +2,21 @@
* External dependencies * External dependencies
*/ */
import { import {
switchBlockInspectorTab,
switchUserToAdmin, switchUserToAdmin,
openDocumentSettingsSidebar,
} from '@wordpress/e2e-test-utils'; } from '@wordpress/e2e-test-utils';
import { import {
visitBlockPage, visitBlockPage,
saveOrPublish, saveOrPublish,
selectBlockByName, selectBlockByName,
switchBlockInspectorTabWhenGutenbergIsInstalled,
} from '@woocommerce/blocks-test-utils'; } from '@woocommerce/blocks-test-utils';
/**
* Internal dependencies
*/
import { openSettingsSidebar } from '../../utils.js';
const block = { const block = {
name: 'Filter by Attribute', name: 'Filter by Attribute',
slug: 'woocommerce/attribute-filter', slug: 'woocommerce/attribute-filter',
@ -63,9 +67,9 @@ describe( `${ block.name } Block`, () => {
describe( 'Attributes', () => { describe( 'Attributes', () => {
beforeEach( async () => { beforeEach( async () => {
await openDocumentSettingsSidebar(); await openSettingsSidebar();
await selectBlockByName( block.slug ); await selectBlockByName( block.slug );
await switchBlockInspectorTabWhenGutenbergIsInstalled( 'Settings' ); await switchBlockInspectorTab( 'Settings' );
} ); } );
it( "allows changing the block's title", async () => { it( "allows changing the block's title", async () => {

View File

@ -3,7 +3,6 @@
*/ */
import { import {
clickBlockToolbarButton, clickBlockToolbarButton,
openDocumentSettingsSidebar,
switchUserToAdmin, switchUserToAdmin,
searchForBlock, searchForBlock,
openGlobalBlockInserter, openGlobalBlockInserter,
@ -13,14 +12,17 @@ import {
findLabelWithText, findLabelWithText,
visitBlockPage, visitBlockPage,
selectBlockByName, selectBlockByName,
switchBlockInspectorTabWhenGutenbergIsInstalled,
} from '@woocommerce/blocks-test-utils'; } from '@woocommerce/blocks-test-utils';
import { merchant } from '@woocommerce/e2e-utils'; import { merchant } from '@woocommerce/e2e-utils';
/** /**
* Internal dependencies * Internal dependencies
*/ */
import { openWidgetEditor, closeModalIfExists } from '../../utils.js'; import {
openSettingsSidebar,
openWidgetEditor,
closeModalIfExists,
} from '../../utils.js';
const block = { const block = {
name: 'Cart', name: 'Cart',
@ -179,17 +181,14 @@ describe( `${ block.name } Block`, () => {
describe( 'attributes', () => { describe( 'attributes', () => {
beforeEach( async () => { beforeEach( async () => {
await openDocumentSettingsSidebar(); await openSettingsSidebar();
await switchBlockInspectorTabWhenGutenbergIsInstalled(
'Settings'
);
await selectBlockByName( await selectBlockByName(
'woocommerce/cart-order-summary-shipping-block' 'woocommerce/cart-order-summary-shipping-block'
); );
} ); } );
it( 'can toggle Shipping calculator', async () => { it( 'can toggle Shipping calculator', async () => {
const selector = ` .wc-block-components-totals-shipping__change-address__link`; const selector = `.wc-block-components-totals-shipping__change-address__link`;
const toggleLabel = await findLabelWithText( const toggleLabel = await findLabelWithText(
'Shipping calculator' 'Shipping calculator'
); );

View File

@ -2,7 +2,6 @@
* External dependencies * External dependencies
*/ */
import { import {
openDocumentSettingsSidebar,
switchUserToAdmin, switchUserToAdmin,
openGlobalBlockInserter, openGlobalBlockInserter,
insertBlock, insertBlock,
@ -11,7 +10,6 @@ import {
findLabelWithText, findLabelWithText,
visitBlockPage, visitBlockPage,
selectBlockByName, selectBlockByName,
switchBlockInspectorTabWhenGutenbergIsInstalled,
} from '@woocommerce/blocks-test-utils'; } from '@woocommerce/blocks-test-utils';
import { merchant } from '@woocommerce/e2e-utils'; import { merchant } from '@woocommerce/e2e-utils';
@ -20,6 +18,7 @@ import { merchant } from '@woocommerce/e2e-utils';
*/ */
import { import {
searchForBlock, searchForBlock,
openSettingsSidebar,
openWidgetEditor, openWidgetEditor,
closeModalIfExists, closeModalIfExists,
} from '../../utils.js'; } from '../../utils.js';
@ -125,10 +124,7 @@ describe( `${ block.name } Block`, () => {
describe( 'attributes', () => { describe( 'attributes', () => {
beforeEach( async () => { beforeEach( async () => {
await openDocumentSettingsSidebar(); await openSettingsSidebar();
await switchBlockInspectorTabWhenGutenbergIsInstalled(
'Settings'
);
await selectBlockByName( block.slug ); await selectBlockByName( block.slug );
} ); } );
@ -163,7 +159,7 @@ describe( `${ block.name } Block`, () => {
'.wc-block-checkout__shipping-method button', '.wc-block-checkout__shipping-method button',
{ text: 'Shipping' } { text: 'Shipping' }
); );
await openDocumentSettingsSidebar(); await openSettingsSidebar();
const toggleLabel = await findLabelWithText( const toggleLabel = await findLabelWithText(
'Hide shipping costs until an address is entered' 'Hide shipping costs until an address is entered'
); );
@ -225,10 +221,7 @@ describe( `${ block.name } Block`, () => {
describe( 'shipping address block attributes', () => { describe( 'shipping address block attributes', () => {
beforeEach( async () => { beforeEach( async () => {
await openDocumentSettingsSidebar(); await openSettingsSidebar();
await switchBlockInspectorTabWhenGutenbergIsInstalled(
'Settings'
);
await selectBlockByName( await selectBlockByName(
'woocommerce/checkout-shipping-address-block' 'woocommerce/checkout-shipping-address-block'
); );
@ -277,10 +270,7 @@ describe( `${ block.name } Block`, () => {
describe( 'action block attributes', () => { describe( 'action block attributes', () => {
beforeEach( async () => { beforeEach( async () => {
await openDocumentSettingsSidebar(); await openSettingsSidebar();
await switchBlockInspectorTabWhenGutenbergIsInstalled(
'Settings'
);
await selectBlockByName( 'woocommerce/checkout-actions-block' ); await selectBlockByName( 'woocommerce/checkout-actions-block' );
} ); } );

View File

@ -2,13 +2,15 @@
* External dependencies * External dependencies
*/ */
import { import {
switchBlockInspectorTab,
switchUserToAdmin, switchUserToAdmin,
openDocumentSettingsSidebar,
} from '@wordpress/e2e-test-utils'; } from '@wordpress/e2e-test-utils';
import { import { visitBlockPage } from '@woocommerce/blocks-test-utils';
visitBlockPage,
switchBlockInspectorTabWhenGutenbergIsInstalled, /**
} from '@woocommerce/blocks-test-utils'; * Internal dependencies
*/
import { openSettingsSidebar } from '../../utils.js';
const block = { const block = {
name: 'Customer account', name: 'Customer account',
@ -35,8 +37,8 @@ describe( `${ block.name } Block`, () => {
describe( 'attributes', () => { describe( 'attributes', () => {
beforeEach( async () => { beforeEach( async () => {
await openDocumentSettingsSidebar(); await openSettingsSidebar();
await switchBlockInspectorTabWhenGutenbergIsInstalled( 'Settings' ); await switchBlockInspectorTab( 'Settings' );
await page.click( block.class ); await page.click( block.class );
} ); } );

View File

@ -2,15 +2,19 @@
* External dependencies * External dependencies
*/ */
import { import {
openDocumentSettingsSidebar, switchBlockInspectorTab,
switchUserToAdmin, switchUserToAdmin,
} from '@wordpress/e2e-test-utils'; } from '@wordpress/e2e-test-utils';
import { import {
visitBlockPage, visitBlockPage,
selectBlockByName, selectBlockByName,
switchBlockInspectorTabWhenGutenbergIsInstalled,
} from '@woocommerce/blocks-test-utils'; } from '@woocommerce/blocks-test-utils';
/**
* Internal dependencies
*/
import { openSettingsSidebar } from '../../utils.js';
const block = { const block = {
name: 'Filter by Price', name: 'Filter by Price',
slug: 'woocommerce/price-filter', slug: 'woocommerce/price-filter',
@ -30,11 +34,9 @@ describe( `${ block.name } Block`, () => {
describe( 'Attributes', () => { describe( 'Attributes', () => {
beforeEach( async () => { beforeEach( async () => {
await openDocumentSettingsSidebar(); await openSettingsSidebar();
await switchBlockInspectorTabWhenGutenbergIsInstalled(
'Settings'
);
await selectBlockByName( block.slug ); await selectBlockByName( block.slug );
await switchBlockInspectorTab( 'Settings' );
} ); } );
it( "allows changing the block's title", async () => { it( "allows changing the block's title", async () => {

View File

@ -2,7 +2,6 @@
* External dependencies * External dependencies
*/ */
import { getAllBlocks, switchUserToAdmin } from '@wordpress/e2e-test-utils'; import { getAllBlocks, switchUserToAdmin } from '@wordpress/e2e-test-utils';
import { visitBlockPage } from '@woocommerce/blocks-test-utils'; import { visitBlockPage } from '@woocommerce/blocks-test-utils';
/** /**

View File

@ -5,13 +5,9 @@ import {
getAllBlocks, getAllBlocks,
switchUserToAdmin, switchUserToAdmin,
canvas, canvas,
openDocumentSettingsSidebar,
openListView, openListView,
} from '@wordpress/e2e-test-utils'; } from '@wordpress/e2e-test-utils';
import { import { visitBlockPage } from '@woocommerce/blocks-test-utils';
visitBlockPage,
switchBlockInspectorTabWhenGutenbergIsInstalled,
} from '@woocommerce/blocks-test-utils';
/** /**
* Internal dependencies * Internal dependencies
@ -20,6 +16,7 @@ import {
insertBlockDontWaitForInsertClose, insertBlockDontWaitForInsertClose,
GUTENBERG_EDITOR_CONTEXT, GUTENBERG_EDITOR_CONTEXT,
describeOrSkip, describeOrSkip,
openSettingsSidebar,
} from '../../utils'; } from '../../utils';
const block = { const block = {
@ -53,8 +50,7 @@ describeOrSkip( GUTENBERG_EDITOR_CONTEXT === 'gutenberg' )(
it.skip( 'Editor preview shows only on sale products after enabling `Show only products on sale`', async () => { it.skip( 'Editor preview shows only on sale products after enabling `Show only products on sale`', async () => {
await visitBlockPage( `${ block.name } Block` ); await visitBlockPage( `${ block.name } Block` );
const canvasEl = canvas(); const canvasEl = canvas();
await openDocumentSettingsSidebar(); await openSettingsSidebar();
await switchBlockInspectorTabWhenGutenbergIsInstalled( 'Settings' );
await openListView(); await openListView();
await page.click( await page.click(
'.block-editor-list-view-block__contents-container a.components-button' '.block-editor-list-view-block__contents-container a.components-button'

View File

@ -1,6 +1,7 @@
/** /**
* External dependencies * External dependencies
*/ */
import { ensureSidebarOpened, canvas } from '@wordpress/e2e-test-utils';
import { import {
saveOrPublish, saveOrPublish,
selectBlockByName, selectBlockByName,
@ -8,11 +9,9 @@ import {
getFixtureProductsData, getFixtureProductsData,
shopper, shopper,
getToggleIdByLabel, getToggleIdByLabel,
switchBlockInspectorTabWhenGutenbergIsInstalled,
} from '@woocommerce/blocks-test-utils'; } from '@woocommerce/blocks-test-utils';
import { ElementHandle } from 'puppeteer'; import { ElementHandle } from 'puppeteer';
import { setCheckbox } from '@woocommerce/e2e-utils'; import { setCheckbox } from '@woocommerce/e2e-utils';
import { ensureSidebarOpened, canvas } from '@wordpress/e2e-test-utils';
/** /**
* Internal dependencies * Internal dependencies
@ -48,7 +47,6 @@ describeOrSkip( GUTENBERG_EDITOR_CONTEXT === 'gutenberg' )(
await resetProductQueryBlockPage(); await resetProductQueryBlockPage();
await ensureSidebarOpened(); await ensureSidebarOpened();
await selectBlockByName( block.slug ); await selectBlockByName( block.slug );
await switchBlockInspectorTabWhenGutenbergIsInstalled( 'Settings' );
$productFiltersPanel = await findToolsPanelWithTitle( $productFiltersPanel = await findToolsPanelWithTitle(
'Advanced Filters' 'Advanced Filters'
); );

View File

@ -11,7 +11,6 @@ import {
selectBlockByName, selectBlockByName,
visitBlockPage, visitBlockPage,
saveOrPublish, saveOrPublish,
switchBlockInspectorTabWhenGutenbergIsInstalled,
} from '@woocommerce/blocks-test-utils'; } from '@woocommerce/blocks-test-utils';
/** /**
@ -29,7 +28,6 @@ import {
const getPopularFilterPanel = async () => { const getPopularFilterPanel = async () => {
await ensureSidebarOpened(); await ensureSidebarOpened();
await selectBlockByName( block.slug ); await selectBlockByName( block.slug );
await switchBlockInspectorTabWhenGutenbergIsInstalled( 'Settings' );
return await findSidebarPanelWithTitle( 'Popular Filters' ); return await findSidebarPanelWithTitle( 'Popular Filters' );
}; };

View File

@ -2,17 +2,15 @@
* External dependencies * External dependencies
*/ */
import { import {
switchBlockInspectorTab,
switchUserToAdmin, switchUserToAdmin,
openDocumentSettingsSidebar,
} from '@wordpress/e2e-test-utils'; } from '@wordpress/e2e-test-utils';
import { import { visitBlockPage } from '@woocommerce/blocks-test-utils';
visitBlockPage,
switchBlockInspectorTabWhenGutenbergIsInstalled,
} from '@woocommerce/blocks-test-utils';
/** /**
* Internal dependencies * Internal dependencies
*/ */
import { openSettingsSidebar } from '../../utils';
const block = { const block = {
name: 'Filter by Rating', name: 'Filter by Rating',
@ -32,9 +30,9 @@ describe( `${ block.name } Block`, () => {
describe( 'attributes', () => { describe( 'attributes', () => {
beforeEach( async () => { beforeEach( async () => {
await openDocumentSettingsSidebar(); await openSettingsSidebar();
await switchBlockInspectorTabWhenGutenbergIsInstalled( 'Settings' );
await page.click( block.class ); await page.click( block.class );
await switchBlockInspectorTab( 'Settings' );
} ); } );
it( 'product count can be toggled', async () => { it( 'product count can be toggled', async () => {

View File

@ -128,7 +128,7 @@ const SELECTORS = {
const CUSTOMIZED_STRING = 'My awesome customization'; const CUSTOMIZED_STRING = 'My awesome customization';
const WOOCOMMERCE_ID = 'woocommerce/woocommerce'; const WOOCOMMERCE_ID = 'woocommerce/woocommerce';
const WOOCOMMERCE_PARSED_ID = 'WooCommerce'; const WOOCOMMERCE_PARSED_ID = 'woocommerce/woocommerceCustomized';
describe( 'Store Editing Templates', () => { describe( 'Store Editing Templates', () => {
useTheme( 'emptytheme' ); useTheme( 'emptytheme' );

View File

@ -2,17 +2,18 @@
* External dependencies * External dependencies
*/ */
import { import {
switchBlockInspectorTab,
switchUserToAdmin, switchUserToAdmin,
openDocumentSettingsSidebar,
} from '@wordpress/e2e-test-utils'; } from '@wordpress/e2e-test-utils';
import { import { visitBlockPage } from '@woocommerce/blocks-test-utils';
visitBlockPage,
switchBlockInspectorTabWhenGutenbergIsInstalled,
} from '@woocommerce/blocks-test-utils';
/** /**
* Internal dependencies * Internal dependencies
*/ */
/**
* Internal dependencies
*/
import { openSettingsSidebar } from '../../utils';
import { findLabelWithText } from '../../../utils'; import { findLabelWithText } from '../../../utils';
const block = { const block = {
@ -33,9 +34,9 @@ describe( `${ block.name } Block`, () => {
describe( 'attributes', () => { describe( 'attributes', () => {
beforeEach( async () => { beforeEach( async () => {
await openDocumentSettingsSidebar(); await openSettingsSidebar();
await switchBlockInspectorTabWhenGutenbergIsInstalled( 'Settings' );
await page.click( block.class ); await page.click( block.class );
await switchBlockInspectorTab( 'Settings' );
} ); } );
it( 'product count can be toggled', async () => { it( 'product count can be toggled', async () => {

View File

@ -1,22 +1,17 @@
/** /**
* External dependencies * External dependencies
*/ */
import { import { merchant, setCheckbox, unsetCheckbox } from '@woocommerce/e2e-utils';
merchant,
openDocumentSettingsSidebar,
setCheckbox,
unsetCheckbox,
} from '@woocommerce/e2e-utils';
import { import {
visitBlockPage, visitBlockPage,
selectBlockByName, selectBlockByName,
saveOrPublish, saveOrPublish,
switchBlockInspectorTabWhenGutenbergIsInstalled,
} from '@woocommerce/blocks-test-utils'; } from '@woocommerce/blocks-test-utils';
/** /**
* Internal dependencies * Internal dependencies
*/ */
import { openSettingsSidebar } from '../../utils';
import { import {
shopper, shopper,
preventCompatibilityNotice, preventCompatibilityNotice,
@ -66,8 +61,7 @@ describe( 'Merchant → Checkout → Can adjust T&S and Privacy Policy options',
await preventCompatibilityNotice(); await preventCompatibilityNotice();
await merchant.login(); await merchant.login();
await visitBlockPage( 'Checkout Block' ); await visitBlockPage( 'Checkout Block' );
await openDocumentSettingsSidebar(); await openSettingsSidebar();
await switchBlockInspectorTabWhenGutenbergIsInstalled( 'Settings' );
await selectBlockByName( 'woocommerce/checkout-terms-block' ); await selectBlockByName( 'woocommerce/checkout-terms-block' );
const [ termsCheckboxLabel ] = await page.$x( const [ termsCheckboxLabel ] = await page.$x(
`//label[contains(text(), "Require checkbox") and contains(@class, "components-toggle-control__label")]` `//label[contains(text(), "Require checkbox") and contains(@class, "components-toggle-control__label")]`
@ -106,8 +100,7 @@ describe( 'Merchant → Checkout → Can adjust T&S and Privacy Policy options',
// Deactivate checkboxes for T&S and Privacy Policy links. // Deactivate checkboxes for T&S and Privacy Policy links.
await visitBlockPage( 'Checkout Block' ); await visitBlockPage( 'Checkout Block' );
await openDocumentSettingsSidebar(); await openSettingsSidebar();
await switchBlockInspectorTabWhenGutenbergIsInstalled( 'Settings' );
await selectBlockByName( 'woocommerce/checkout-terms-block' ); await selectBlockByName( 'woocommerce/checkout-terms-block' );
await unsetCheckbox( termsCheckboxId ); await unsetCheckbox( termsCheckboxId );
await saveOrPublish(); await saveOrPublish();

View File

@ -11,13 +11,13 @@ import {
} from '@wordpress/e2e-test-utils'; } from '@wordpress/e2e-test-utils';
import { SHOP_PAGE } from '@woocommerce/e2e-utils'; import { SHOP_PAGE } from '@woocommerce/e2e-utils';
import { Frame, Page } from 'puppeteer'; import { Frame, Page } from 'puppeteer';
import { insertBlockUsingSlash } from '@woocommerce/blocks-test-utils';
/** /**
* Internal dependencies * Internal dependencies
*/ */
import { import {
goToTemplateEditor, goToTemplateEditor,
insertAllProductsBlock,
useTheme, useTheme,
saveTemplate, saveTemplate,
waitForAllProductsBlockLoaded, waitForAllProductsBlockLoaded,
@ -96,7 +96,7 @@ describe( 'Shopper → Active Filters Block', () => {
} ); } );
await insertBlocks(); await insertBlocks();
await insertBlockUsingSlash( 'All Products' ); await insertAllProductsBlock();
await configureAttributeFilterBlock( page ); await configureAttributeFilterBlock( page );
await publishPost(); await publishPost();
@ -182,7 +182,7 @@ describe( 'Shopper → Active Filters Block', () => {
expect( isRefreshed ).not.toHaveBeenCalled(); expect( isRefreshed ).not.toHaveBeenCalled();
} ); } );
it( 'Clicking "Clear All" button removes all active filter', async () => { it( 'Clicking "Clear All" button removes all active filters', async () => {
const isRefreshed = jest.fn( () => void 0 ); const isRefreshed = jest.fn( () => void 0 );
await page.waitForSelector( block.class ); await page.waitForSelector( block.class );
await page.waitForSelector( await page.waitForSelector(
@ -317,7 +317,7 @@ describe( 'Shopper → Active Filters Block', () => {
await expect( page ).toMatch( SIMPLE_PHYSICAL_PRODUCT_NAME ); await expect( page ).toMatch( SIMPLE_PHYSICAL_PRODUCT_NAME );
} ); } );
it( 'Clicking "Clear All" button removes all active filter and the page redirects to the base URL', async () => { it( 'Clicking "Clear All" button removes all active filters and the page redirects to the base URL', async () => {
const isRefreshed = jest.fn( () => void 0 ); const isRefreshed = jest.fn( () => void 0 );
page.on( 'load', isRefreshed ); page.on( 'load', isRefreshed );
await page.waitForSelector( selectors.frontend.stockFilterBlock ); await page.waitForSelector( selectors.frontend.stockFilterBlock );

View File

@ -3,7 +3,6 @@
*/ */
import { import {
merchant, merchant,
openDocumentSettingsSidebar,
setCheckbox, setCheckbox,
unsetCheckbox, unsetCheckbox,
withRestApi, withRestApi,
@ -13,9 +12,9 @@ import {
selectBlockByName, selectBlockByName,
saveOrPublish, saveOrPublish,
getToggleIdByLabel, getToggleIdByLabel,
switchBlockInspectorTabWhenGutenbergIsInstalled,
} from '@woocommerce/blocks-test-utils'; } from '@woocommerce/blocks-test-utils';
import { visitAdminPage } from '@wordpress/e2e-test-utils'; import { visitAdminPage } from '@wordpress/e2e-test-utils';
/** /**
* Internal dependencies * Internal dependencies
*/ */
@ -30,7 +29,7 @@ import {
BASE_URL, BASE_URL,
} from '../../../../utils'; } from '../../../../utils';
import { merchant as merchantUtils } from '../../../../utils/merchant'; import { merchant as merchantUtils } from '../../../../utils/merchant';
import { createCoupon } from '../../../utils'; import { createCoupon, openSettingsSidebar } from '../../../utils';
let coupon; let coupon;
@ -154,8 +153,7 @@ describe( 'Shopper → Checkout', () => {
await preventCompatibilityNotice(); await preventCompatibilityNotice();
await merchant.login(); await merchant.login();
await visitBlockPage( 'Checkout Block' ); await visitBlockPage( 'Checkout Block' );
await openDocumentSettingsSidebar(); await openSettingsSidebar();
await switchBlockInspectorTabWhenGutenbergIsInstalled( 'Settings' );
await selectBlockByName( await selectBlockByName(
'woocommerce/checkout-shipping-address-block' 'woocommerce/checkout-shipping-address-block'
); );
@ -168,8 +166,7 @@ describe( 'Shopper → Checkout', () => {
afterAll( async () => { afterAll( async () => {
await shopper.block.emptyCart(); await shopper.block.emptyCart();
await visitBlockPage( 'Checkout Block' ); await visitBlockPage( 'Checkout Block' );
await openDocumentSettingsSidebar(); await openSettingsSidebar();
await switchBlockInspectorTabWhenGutenbergIsInstalled( 'Settings' );
await selectBlockByName( await selectBlockByName(
'woocommerce/checkout-shipping-address-block' 'woocommerce/checkout-shipping-address-block'
); );
@ -310,8 +307,7 @@ describe( 'Shopper → Checkout', () => {
afterAll( async () => { afterAll( async () => {
await merchant.login(); await merchant.login();
await visitBlockPage( 'Checkout Block' ); await visitBlockPage( 'Checkout Block' );
await openDocumentSettingsSidebar(); await openSettingsSidebar();
await switchBlockInspectorTabWhenGutenbergIsInstalled( 'Settings' );
await selectBlockByName( await selectBlockByName(
'woocommerce/checkout-shipping-methods-block' 'woocommerce/checkout-shipping-methods-block'
); );
@ -379,8 +375,7 @@ describe( 'Shopper → Checkout', () => {
await preventCompatibilityNotice(); await preventCompatibilityNotice();
await merchant.login(); await merchant.login();
await visitBlockPage( 'Checkout Block' ); await visitBlockPage( 'Checkout Block' );
await openDocumentSettingsSidebar(); await openSettingsSidebar();
await switchBlockInspectorTabWhenGutenbergIsInstalled( 'Settings' );
await selectBlockByName( await selectBlockByName(
'woocommerce/checkout-shipping-methods-block' 'woocommerce/checkout-shipping-methods-block'
); );
@ -438,8 +433,7 @@ describe( 'Shopper → Checkout', () => {
await preventCompatibilityNotice(); await preventCompatibilityNotice();
await merchant.login(); await merchant.login();
await visitBlockPage( 'Checkout Block' ); await visitBlockPage( 'Checkout Block' );
await openDocumentSettingsSidebar(); await openSettingsSidebar();
await switchBlockInspectorTabWhenGutenbergIsInstalled( 'Settings' );
await selectBlockByName( await selectBlockByName(
'woocommerce/checkout-shipping-methods-block' 'woocommerce/checkout-shipping-methods-block'
); );
@ -469,8 +463,7 @@ describe( 'Shopper → Checkout', () => {
await merchantUtils.enableLocalPickup(); await merchantUtils.enableLocalPickup();
await merchantUtils.addLocalPickupLocation(); await merchantUtils.addLocalPickupLocation();
await visitBlockPage( 'Checkout Block' ); await visitBlockPage( 'Checkout Block' );
await openDocumentSettingsSidebar(); await openSettingsSidebar();
await switchBlockInspectorTabWhenGutenbergIsInstalled( 'Settings' );
await selectBlockByName( await selectBlockByName(
'woocommerce/checkout-shipping-methods-block' 'woocommerce/checkout-shipping-methods-block'
); );
@ -514,8 +507,7 @@ describe( 'Shopper → Checkout', () => {
await preventCompatibilityNotice(); await preventCompatibilityNotice();
await merchant.login(); await merchant.login();
await visitBlockPage( 'Checkout Block' ); await visitBlockPage( 'Checkout Block' );
await openDocumentSettingsSidebar(); await openSettingsSidebar();
await switchBlockInspectorTabWhenGutenbergIsInstalled( 'Settings' );
await selectBlockByName( await selectBlockByName(
'woocommerce/checkout-shipping-methods-block' 'woocommerce/checkout-shipping-methods-block'
); );

View File

@ -8,23 +8,21 @@ import {
insertBlock, insertBlock,
switchUserToAdmin, switchUserToAdmin,
publishPost, publishPost,
ensureSidebarOpened,
} from '@wordpress/e2e-test-utils'; } from '@wordpress/e2e-test-utils';
import { import { selectBlockByName } from '@woocommerce/blocks-test-utils';
selectBlockByName,
insertBlockUsingSlash,
switchBlockInspectorTabWhenGutenbergIsInstalled,
} from '@woocommerce/blocks-test-utils';
/** /**
* Internal dependencies * Internal dependencies
*/ */
import { import {
BASE_URL, BASE_URL,
enableApplyFiltersButton,
goToTemplateEditor, goToTemplateEditor,
insertAllProductsBlock,
saveTemplate, saveTemplate,
useTheme, useTheme,
waitForAllProductsBlockLoaded, waitForAllProductsBlockLoaded,
waitForCanvas,
} from '../../utils'; } from '../../utils';
import { saveOrPublish } from '../../../utils'; import { saveOrPublish } from '../../../utils';
@ -36,8 +34,6 @@ const block = {
editor: { editor: {
firstAttributeInTheList: firstAttributeInTheList:
'.woocommerce-search-list__list > li > label > input.woocommerce-search-list__item-input', '.woocommerce-search-list__list > li > label > input.woocommerce-search-list__item-input',
filterButtonToggle:
'//label[text()="Show \'Apply filters\' button"]',
doneButton: '.wc-block-attribute-filter__selection > button', doneButton: '.wc-block-attribute-filter__selection > button',
}, },
frontend: { frontend: {
@ -71,7 +67,7 @@ describe( `${ block.name } Block`, () => {
title: block.name, title: block.name,
} ); } );
await insertBlockUsingSlash( 'All Products' ); await insertAllProductsBlock();
await insertBlock( block.name ); await insertBlock( block.name );
const canvasEl = canvas(); const canvasEl = canvas();
@ -190,14 +186,9 @@ describe( `${ block.name } Block`, () => {
postId: productCatalogTemplateId, postId: productCatalogTemplateId,
} ); } );
await ensureSidebarOpened(); await waitForCanvas();
await selectBlockByName( block.slug ); await selectBlockByName( block.slug );
await switchBlockInspectorTabWhenGutenbergIsInstalled( 'Settings' ); await enableApplyFiltersButton();
const [ filterButtonToggle ] = await page.$x(
block.selectors.editor.filterButtonToggle
);
await filterButtonToggle.click();
await saveTemplate(); await saveTemplate();
await goToShopPage(); await goToShopPage();
@ -309,14 +300,10 @@ describe( `${ block.name } Block`, () => {
it( 'should refresh the page only if the user clicks on button', async () => { it( 'should refresh the page only if the user clicks on button', async () => {
await page.goto( editorPageUrl ); await page.goto( editorPageUrl );
await ensureSidebarOpened();
await selectBlockByName( block.slug );
await switchBlockInspectorTabWhenGutenbergIsInstalled( 'Settings' );
const [ filterButtonToggle ] = await page.$x( await waitForCanvas();
block.selectors.editor.filterButtonToggle await selectBlockByName( block.slug );
); await enableApplyFiltersButton();
await filterButtonToggle.click();
await saveOrPublish(); await saveOrPublish();
await page.goto( frontedPageUrl ); await page.goto( frontedPageUrl );

View File

@ -7,22 +7,20 @@ import {
insertBlock, insertBlock,
switchUserToAdmin, switchUserToAdmin,
publishPost, publishPost,
ensureSidebarOpened,
} from '@wordpress/e2e-test-utils'; } from '@wordpress/e2e-test-utils';
import { import { selectBlockByName } from '@woocommerce/blocks-test-utils';
selectBlockByName,
insertBlockUsingSlash,
switchBlockInspectorTabWhenGutenbergIsInstalled,
} from '@woocommerce/blocks-test-utils';
/** /**
* Internal dependencies * Internal dependencies
*/ */
import { import {
BASE_URL, BASE_URL,
enableApplyFiltersButton,
goToTemplateEditor, goToTemplateEditor,
insertAllProductsBlock,
saveTemplate, saveTemplate,
useTheme, useTheme,
waitForCanvas,
waitForAllProductsBlockLoaded, waitForAllProductsBlockLoaded,
} from '../../utils'; } from '../../utils';
import { clickLink, saveOrPublish } from '../../../utils'; import { clickLink, saveOrPublish } from '../../../utils';
@ -32,10 +30,6 @@ const block = {
slug: 'woocommerce/price-filter', slug: 'woocommerce/price-filter',
class: '.wc-block-price-filter', class: '.wc-block-price-filter',
selectors: { selectors: {
editor: {
filterButtonToggle:
'//label[text()="Show \'Apply filters\' button"]',
},
frontend: { frontend: {
priceMaxAmount: '.wc-block-price-filter__amount--max', priceMaxAmount: '.wc-block-price-filter__amount--max',
productsList: '.wc-block-grid__products > li', productsList: '.wc-block-grid__products > li',
@ -75,7 +69,7 @@ describe( `${ block.name } Block`, () => {
} ); } );
await insertBlock( block.name ); await insertBlock( block.name );
await insertBlockUsingSlash( 'All Products' ); await insertAllProductsBlock();
await insertBlock( 'Active Filters' ); await insertBlock( 'Active Filters' );
await publishPost(); await publishPost();
@ -186,17 +180,9 @@ describe( `${ block.name } Block`, () => {
postId: productCatalogTemplateId, postId: productCatalogTemplateId,
} ); } );
await waitForCanvas();
await selectBlockByName( block.slug ); await selectBlockByName( block.slug );
await ensureSidebarOpened(); await enableApplyFiltersButton();
await switchBlockInspectorTabWhenGutenbergIsInstalled( 'Settings' );
await page.waitForXPath(
block.selectors.editor.filterButtonToggle
);
const [ filterButtonToggle ] = await page.$x(
block.selectors.editor.filterButtonToggle
);
await filterButtonToggle.click();
await saveTemplate(); await saveTemplate();
await goToShopPage(); await goToShopPage();
@ -298,17 +284,9 @@ describe( `${ block.name } Block`, () => {
it( 'should refresh the page only if the user click on button', async () => { it( 'should refresh the page only if the user click on button', async () => {
await page.goto( editorPageUrl ); await page.goto( editorPageUrl );
await ensureSidebarOpened(); await waitForCanvas();
await selectBlockByName( block.slug ); await selectBlockByName( block.slug );
await switchBlockInspectorTabWhenGutenbergIsInstalled( 'Settings' ); await enableApplyFiltersButton();
await page.waitForXPath(
block.selectors.editor.filterButtonToggle
);
const [ filterButtonToggle ] = await page.$x(
block.selectors.editor.filterButtonToggle
);
await filterButtonToggle.click();
await saveOrPublish(); await saveOrPublish();
await page.goto( frontedPageUrl ); await page.goto( frontedPageUrl );

View File

@ -5,16 +5,15 @@ import {
createNewPost, createNewPost,
deleteAllTemplates, deleteAllTemplates,
insertBlock, insertBlock,
switchBlockInspectorTab,
switchUserToAdmin, switchUserToAdmin,
publishPost, publishPost,
ensureSidebarOpened, ensureSidebarOpened,
} from '@wordpress/e2e-test-utils'; } from '@wordpress/e2e-test-utils';
import { import {
selectBlockByName, selectBlockByName,
insertBlockUsingSlash,
saveOrPublish, saveOrPublish,
getToggleIdByLabel, getToggleIdByLabel,
switchBlockInspectorTabWhenGutenbergIsInstalled,
} from '@woocommerce/blocks-test-utils'; } from '@woocommerce/blocks-test-utils';
import { setCheckbox } from '@woocommerce/e2e-utils'; import { setCheckbox } from '@woocommerce/e2e-utils';
@ -23,7 +22,9 @@ import { setCheckbox } from '@woocommerce/e2e-utils';
*/ */
import { import {
BASE_URL, BASE_URL,
enableApplyFiltersButton,
goToTemplateEditor, goToTemplateEditor,
insertAllProductsBlock,
saveTemplate, saveTemplate,
useTheme, useTheme,
waitForAllProductsBlockLoaded, waitForAllProductsBlockLoaded,
@ -35,10 +36,6 @@ const block = {
slug: 'woocommerce/rating-filter', slug: 'woocommerce/rating-filter',
class: '.wc-block-rating-filter', class: '.wc-block-rating-filter',
selectors: { selectors: {
editor: {
filterButtonToggle:
'//label[text()="Show \'Apply filters\' button"]',
},
frontend: { frontend: {
productsList: '.wc-block-grid__products > li', productsList: '.wc-block-grid__products > li',
queryProductsList: '.wp-block-post-template > li', queryProductsList: '.wp-block-post-template > li',
@ -70,7 +67,7 @@ describe( `${ block.name } Block`, () => {
} ); } );
await insertBlock( block.name ); await insertBlock( block.name );
await insertBlockUsingSlash( 'All Products' ); await insertAllProductsBlock();
await publishPost(); await publishPost();
link = await page.evaluate( () => link = await page.evaluate( () =>
@ -162,17 +159,7 @@ describe( `${ block.name } Block`, () => {
await waitForCanvas(); await waitForCanvas();
await selectBlockByName( block.slug ); await selectBlockByName( block.slug );
await ensureSidebarOpened(); await enableApplyFiltersButton();
await switchBlockInspectorTabWhenGutenbergIsInstalled( 'Settings' );
await page.waitForXPath(
block.selectors.editor.filterButtonToggle
);
const [ filterButtonToggle ] = await page.$x(
selectors.editor.filterButtonToggle
);
await filterButtonToggle.click();
await saveTemplate(); await saveTemplate();
await goToShopPage(); await goToShopPage();
@ -271,7 +258,7 @@ describe( `${ block.name } Block`, () => {
await waitForCanvas(); await waitForCanvas();
await ensureSidebarOpened(); await ensureSidebarOpened();
await selectBlockByName( block.slug ); await selectBlockByName( block.slug );
await switchBlockInspectorTabWhenGutenbergIsInstalled( 'Settings' ); await switchBlockInspectorTab( 'Settings' );
await setCheckbox( await setCheckbox(
await getToggleIdByLabel( "Show 'Apply filters' button", 1 ) await getToggleIdByLabel( "Show 'Apply filters' button", 1 )
); );

View File

@ -5,16 +5,15 @@ import {
createNewPost, createNewPost,
deleteAllTemplates, deleteAllTemplates,
insertBlock, insertBlock,
switchBlockInspectorTab,
switchUserToAdmin, switchUserToAdmin,
publishPost, publishPost,
ensureSidebarOpened, ensureSidebarOpened,
} from '@wordpress/e2e-test-utils'; } from '@wordpress/e2e-test-utils';
import { import {
selectBlockByName, selectBlockByName,
insertBlockUsingSlash,
getToggleIdByLabel, getToggleIdByLabel,
saveOrPublish, saveOrPublish,
switchBlockInspectorTabWhenGutenbergIsInstalled,
} from '@woocommerce/blocks-test-utils'; } from '@woocommerce/blocks-test-utils';
import { setCheckbox } from '@woocommerce/e2e-utils'; import { setCheckbox } from '@woocommerce/e2e-utils';
@ -23,7 +22,9 @@ import { setCheckbox } from '@woocommerce/e2e-utils';
*/ */
import { import {
BASE_URL, BASE_URL,
enableApplyFiltersButton,
goToTemplateEditor, goToTemplateEditor,
insertAllProductsBlock,
saveTemplate, saveTemplate,
useTheme, useTheme,
waitForAllProductsBlockLoaded, waitForAllProductsBlockLoaded,
@ -35,10 +36,6 @@ const block = {
slug: 'woocommerce/stock-filter', slug: 'woocommerce/stock-filter',
class: '.wc-block-stock-filter', class: '.wc-block-stock-filter',
selectors: { selectors: {
editor: {
filterButtonToggle:
'//label[text()="Show \'Apply filters\' button"]',
},
frontend: { frontend: {
productsList: '.wc-block-grid__products > li', productsList: '.wc-block-grid__products > li',
classicProductsList: '.products.columns-3 > li', classicProductsList: '.products.columns-3 > li',
@ -69,7 +66,7 @@ describe( `${ block.name } Block`, () => {
} ); } );
await insertBlock( block.name ); await insertBlock( block.name );
await insertBlockUsingSlash( 'All Products' ); await insertAllProductsBlock();
await publishPost(); await publishPost();
link = await page.evaluate( () => link = await page.evaluate( () =>
@ -168,16 +165,7 @@ describe( `${ block.name } Block`, () => {
await waitForCanvas(); await waitForCanvas();
await selectBlockByName( block.slug ); await selectBlockByName( block.slug );
await ensureSidebarOpened(); await enableApplyFiltersButton();
await switchBlockInspectorTabWhenGutenbergIsInstalled( 'Settings' );
await page.waitForXPath(
block.selectors.editor.filterButtonToggle
);
const [ filterButtonToggle ] = await page.$x(
selectors.editor.filterButtonToggle
);
await filterButtonToggle.click();
await saveTemplate(); await saveTemplate();
await goToShopPage(); await goToShopPage();
@ -276,7 +264,7 @@ describe( `${ block.name } Block`, () => {
await waitForCanvas(); await waitForCanvas();
await ensureSidebarOpened(); await ensureSidebarOpened();
await selectBlockByName( block.slug ); await selectBlockByName( block.slug );
await switchBlockInspectorTabWhenGutenbergIsInstalled( 'Settings' ); await switchBlockInspectorTab( 'Settings' );
await setCheckbox( await setCheckbox(
await getToggleIdByLabel( "Show 'Apply filters' button" ) await getToggleIdByLabel( "Show 'Apply filters' button" )
); );

View File

@ -6,8 +6,6 @@ import {
ensureSidebarOpened, ensureSidebarOpened,
} from '@wordpress/e2e-test-utils'; } from '@wordpress/e2e-test-utils';
import { switchBlockInspectorTabWhenGutenbergIsInstalled } from '@woocommerce/blocks-test-utils';
/** /**
* Internal dependencies * Internal dependencies
*/ */
@ -20,7 +18,6 @@ import {
import { import {
addProductQueryBlock, addProductQueryBlock,
block, block,
configureProductQueryBlock,
getProductsNameFromClassicTemplate, getProductsNameFromClassicTemplate,
getProductsNameFromProductQuery, getProductsNameFromProductQuery,
toggleInheritQueryFromTemplateSetting, toggleInheritQueryFromTemplateSetting,
@ -39,7 +36,6 @@ describe( `${ block.name } Block`, () => {
} ); } );
await ensureSidebarOpened(); await ensureSidebarOpened();
await addProductQueryBlock(); await addProductQueryBlock();
await switchBlockInspectorTabWhenGutenbergIsInstalled( 'Settings' );
} ); } );
it( 'when Inherit Query from template is disabled all the settings that customize the query should be hidden', async () => { it( 'when Inherit Query from template is disabled all the settings that customize the query should be hidden', async () => {
@ -55,7 +51,7 @@ describe( `${ block.name } Block`, () => {
} ); } );
it( 'when Inherit Query from template is enabled all the settings that customize the query should be hidden', async () => { it( 'when Inherit Query from template is enabled all the settings that customize the query should be hidden', async () => {
await configureProductQueryBlock(); await ensureSidebarOpened();
const popularFilterEl = await page.$( const popularFilterEl = await page.$(
block.selectors.editor.popularFilter block.selectors.editor.popularFilter
@ -78,7 +74,7 @@ describe( `${ block.name } Block`, () => {
postId: productCatalogTemplateId, postId: productCatalogTemplateId,
} ); } );
await addProductQueryBlock(); await addProductQueryBlock();
await configureProductQueryBlock(); await ensureSidebarOpened();
await page.waitForNetworkIdle(); await page.waitForNetworkIdle();
await saveTemplate(); await saveTemplate();
await page.waitForNetworkIdle(); await page.waitForNetworkIdle();
@ -107,7 +103,7 @@ describe( `${ block.name } Block`, () => {
postId: taxonomyProductCategory, postId: taxonomyProductCategory,
} ); } );
await addProductQueryBlock(); await addProductQueryBlock();
await configureProductQueryBlock(); await ensureSidebarOpened();
await page.waitForNetworkIdle(); await page.waitForNetworkIdle();
await saveTemplate(); await saveTemplate();
await page.waitForNetworkIdle(); await page.waitForNetworkIdle();
@ -139,7 +135,7 @@ describe( `${ block.name } Block`, () => {
postId: tagProductCategory, postId: tagProductCategory,
} ); } );
await addProductQueryBlock(); await addProductQueryBlock();
await configureProductQueryBlock(); await ensureSidebarOpened();
await page.waitForNetworkIdle(); await page.waitForNetworkIdle();
await saveTemplate(); await saveTemplate();
await page.waitForNetworkIdle(); await page.waitForNetworkIdle();
@ -171,7 +167,7 @@ describe( `${ block.name } Block`, () => {
postId: productSearchResults, postId: productSearchResults,
} ); } );
await addProductQueryBlock(); await addProductQueryBlock();
await configureProductQueryBlock(); await ensureSidebarOpened();
await page.waitForNetworkIdle(); await page.waitForNetworkIdle();
await saveTemplate(); await saveTemplate();
await page.waitForNetworkIdle(); await page.waitForNetworkIdle();

View File

@ -1,8 +1,7 @@
/** /**
* External dependencies * External dependencies
*/ */
import { insertBlock, ensureSidebarOpened } from '@wordpress/e2e-test-utils'; import { insertBlock } from '@wordpress/e2e-test-utils';
import { switchBlockInspectorTabWhenGutenbergIsInstalled } from '@woocommerce/blocks-test-utils';
/** /**
* Internal dependencies * Internal dependencies
@ -39,11 +38,6 @@ export const toggleInheritQueryFromTemplateSetting = async () => {
await button.click(); await button.click();
}; };
export const configureProductQueryBlock = async () => {
await ensureSidebarOpened();
await switchBlockInspectorTabWhenGutenbergIsInstalled( 'Settings' );
};
export const getProductsNameFromClassicTemplate = async () => { export const getProductsNameFromClassicTemplate = async () => {
const products = await page.$$( const products = await page.$$(
block.selectors.frontend.classicProductsListName block.selectors.frontend.classicProductsListName

View File

@ -4,13 +4,17 @@
import { Coupon, HTTPClientFactory } from '@woocommerce/api'; import { Coupon, HTTPClientFactory } from '@woocommerce/api';
import config from 'config'; import config from 'config';
import { import {
canvas,
disableSiteEditorWelcomeGuide, disableSiteEditorWelcomeGuide,
ensureSidebarOpened,
openGlobalBlockInserter, openGlobalBlockInserter,
switchBlockInspectorTab,
switchUserToAdmin, switchUserToAdmin,
visitAdminPage, visitAdminPage,
pressKeyWithModifier, pressKeyWithModifier,
searchForBlock as searchForFSEBlock, searchForBlock as searchForFSEBlock,
enterEditMode, enterEditMode,
getAllBlocks,
} from '@wordpress/e2e-test-utils'; } from '@wordpress/e2e-test-utils';
import { addQueryArgs } from '@wordpress/url'; import { addQueryArgs } from '@wordpress/url';
import { WP_ADMIN_DASHBOARD } from '@woocommerce/e2e-utils'; import { WP_ADMIN_DASHBOARD } from '@woocommerce/e2e-utils';
@ -69,6 +73,13 @@ const SELECTORS = {
editButton: editButton:
'.edit-site-site-hub__edit-button[aria-label="Open the editor"]', '.edit-site-site-hub__edit-button[aria-label="Open the editor"]',
}, },
editor: {
filterButtonToggle: '//label[text()="Show \'Apply filters\' button"]',
},
frontend: {
XPathSubmitButton:
"//*[contains(@class,'wc-block-components-filter-submit-button')]",
},
}; };
/** /**
@ -149,20 +160,17 @@ export const isBlockInsertedInWidgetsArea = async ( blockName ) => {
}; };
/** /**
* Visits site editor dependening on used WordPress version and how Gutenberg is installed. * Visits site editor depending on used WordPress version and how Gutenberg is installed.
* *
* @param {Object} params Query parameters to add to the URL. * @param {Object} params Query parameters to add to the URL.
* @param {string} [params.postId] ID of the template if we want to access template editor. * @param {string} [params.postId] ID of the template if we want to access template editor.
* @param {'wp_template' | 'wp_template_part'} [params.postType='wp_template'] Type of template. * @param {'wp_template' | 'wp_template_part'} [params.postType='wp_template'] Type of template.
* @param {string} [params.path] Navigation path.
*/ */
export async function goToSiteEditor( params = {} ) { export async function goToSiteEditor( params = {} ) {
await visitAdminPage( 'site-editor.php', addQueryArgs( '', params ) ); await visitAdminPage( 'site-editor.php', addQueryArgs( '', params ) );
// @todo Remove the Gutenberg guard clause in goToSiteEditor when WP 6.2 is released. if ( params?.postId || Object.keys( params ).length === 0 ) {
if (
GUTENBERG_EDITOR_CONTEXT === 'gutenberg' &&
( params?.postId || Object.keys( params ).length === 0 )
) {
await enterEditMode(); await enterEditMode();
} }
} }
@ -198,7 +206,12 @@ export async function goToTemplatesList( {
postType = 'wp_template', postType = 'wp_template',
waitFor = 'list', waitFor = 'list',
} = {} ) { } = {} ) {
await goToSiteEditor( { postType } ); await goToSiteEditor( {
postType,
// In WP 6.2, if postId is not defined, the route expects `path` instead
// of `postType`.
path: `/${ postType }/all`,
} );
if ( waitFor === 'actions' ) { if ( waitFor === 'actions' ) {
await page.waitForSelector( await page.waitForSelector(
@ -441,3 +454,97 @@ export const waitForAllProductsBlockLoaded = async () => {
*/ */
export const describeOrSkip = ( condition ) => export const describeOrSkip = ( condition ) =>
condition ? describe : describe.skip; condition ? describe : describe.skip;
/**
* Get all blocks in the document that match a certain slug.
*
* @param {string} slug Slug of the blocks to get.
*
* @return {Promise<{}>} Promise resolving with an array containing all blocks in
* the document that match a certain slug.
*/
export const getBlocksBySlug = async ( slug ) => {
const blocks = await getAllBlocks();
return blocks.filter( ( { name } ) => name === slug );
};
/**
* Insert the All Products block using the global inserter. This util is needed
* because inserting the All Products block using the `insertBlock()` util
* causes time outs.
*/
export const insertAllProductsBlock = async () => {
const searchTerm = 'All Products';
await searchForBlock( searchTerm );
// Wait for the default block list to disappear to prevent its items from
// being considered as search results. This is needed since we're debouncing
// search request.
await page.waitForSelector( '.block-editor-inserter__block-list', {
hidden: true,
} );
const insertButton = await page.waitForXPath(
`//*[@role='option' and contains(., '${ searchTerm }')]`
);
if ( ! insertButton ) {
throw new Error( `Could not find the "${ searchTerm }" block` );
}
insertButton?.click();
};
/**
* Clicks on the button in the header which opens Document Settings sidebar when it is closed.
* Based on https://github.com/WordPress/gutenberg/blob/trunk/packages/e2e-test-utils/src/open-document-settings-sidebar.js,
* but updates the selector so it works in WP 6.2 without GB.
*/
export async function openSettingsSidebar() {
const toggleButton = await page.waitForSelector(
'.edit-post-header__settings button[aria-label="Settings"]'
);
const isClosed = await page.evaluate(
( element ) => element.getAttribute( 'aria-expanded' ) === 'false',
toggleButton
);
if ( isClosed ) {
await toggleButton.click();
await page.waitForSelector( '.edit-post-sidebar' );
}
}
/**
* Enables the `Show 'Apply filters' button` toggle.
*/
export const enableApplyFiltersButton = async () => {
await ensureSidebarOpened();
await switchBlockInspectorTab( 'Settings' );
await page.waitForXPath( SELECTORS.editor.filterButtonToggle );
const [ filterButtonToggle ] = await page.$x(
SELECTORS.editor.filterButtonToggle
);
if ( ! filterButtonToggle ) {
throw new Error( "'Apply filters' toggle not found via XPath." );
}
await filterButtonToggle.click();
// If for some reason click didn't work (it seems to happen intermittently),
// click on the toggle via JS.
await page.evaluate( () => {
const toggle = document.querySelector(
'.components-toggle-control:last-child .components-form-toggle__input'
);
if ( ! toggle ) {
throw new Error( "'Apply filters' toggle not found via CSS." );
}
if ( ! toggle.checked ) {
toggle.click();
}
} );
await canvas().waitForXPath( SELECTORS.frontend.XPathSubmitButton );
};

View File

@ -22,6 +22,4 @@ export { findToolsPanelWithTitle } from './find-tools-panel-with-title';
export { getFormElementIdByLabel } from './get-form-element-id-by-label'; export { getFormElementIdByLabel } from './get-form-element-id-by-label';
export { getToggleIdByLabel } from './get-toggle-id-by-label'; export { getToggleIdByLabel } from './get-toggle-id-by-label';
export { insertBlockUsingQuickInserter } from './insert-block-using-quick-inserter'; export { insertBlockUsingQuickInserter } from './insert-block-using-quick-inserter';
export { insertBlockUsingSlash } from './insert-block-using-slash';
export { insertShortcodeBlock } from './insert-shortcode-block'; export { insertShortcodeBlock } from './insert-shortcode-block';
export { switchBlockInspectorTabWhenGutenbergIsInstalled } from './switch-block-inspector-tab-when-gutenberg-is-installed';

View File

@ -1,16 +0,0 @@
/**
* External dependencies
*/
import { canvas, insertBlock } from '@wordpress/e2e-test-utils';
/**
* Internal dependencies
*/
import SELECTORS from './selectors';
export const insertBlockUsingSlash = async ( blockTitle: string ) => {
await insertBlock( 'Paragraph' );
await canvas().keyboard.type( `/${ blockTitle }` );
await canvas().waitForSelector( SELECTORS.popover );
await canvas().keyboard.press( 'Enter' );
};

View File

@ -1,19 +0,0 @@
/**
* External dependencies
*/
import { switchBlockInspectorTab } from '@wordpress/e2e-test-utils';
/**
* Internal dependencies
*/
import { GUTENBERG_EDITOR_CONTEXT } from '../e2e/utils';
// @todo Remove this function when WP 6.2 is released. We can use the "switchBlockInspectorTab" function directly.
export const switchBlockInspectorTabWhenGutenbergIsInstalled = async (
tabName: string
) => {
if ( GUTENBERG_EDITOR_CONTEXT === 'core' ) {
return;
}
await switchBlockInspectorTab( tabName );
};