Code review feedback

This commit is contained in:
Greg 2021-07-21 10:22:50 -06:00
parent f31693aaec
commit d062a76a2c
5 changed files with 24 additions and 3 deletions

View File

@ -40,5 +40,5 @@ jobs:
E2E_SLACK_CHANNEL: ${{ secrets.SMOKE_TEST_SLACK_CHANNEL }}
UPDATE_WC: 1
run: |
npx wc-e2e test:e2e ./tests/e2e/specs/smoke-tests/update-woocommerce.test.js
npx wc-e2e test:e2e ./tests/e2e/specs/smoke-tests/update-woocommerce.js
npx wc-e2e test:e2e

View File

@ -3,6 +3,9 @@
- `updateReadyPageStatus` utility to update the status of the ready page
- Added plugin upload functionality util that provides a method to pull a plugin zip from a remote location
- `getRemotePluginZip( fileUrl )` to get the remote zip. Returns the filepath of the zip location.
- Added plugin zip utility functions:
- `checkNestedZip( zipFilePath, savePath )` checks a plugin zip file for any nested zip files. If one is found, it is extracted. Returns the path where the zip file is located.
- `downloadZip( fileUrl, downloadPath )` downloads a plugin zip file from a remote location to the provided path.
# 0.2.2

View File

@ -180,6 +180,22 @@ To implement the Slackbot in your CI:
To test your setup, create a pull request that triggers an error in the E2E tests.
## Plugin functions
Depending on the testing scenario, you may wish to upload a plugin that can be used in the tests from a remote location.
To download a zip file, you can use `getRemotePluginZip( fileUrl )` to get the remote zip. This returns the filepath of the location where the zip file was downloaded to. For example, you could use this method to download the latest nightly version of WooCommerce:
```javascript
const pluginZipUrl = 'https://github.com/woocommerce/woocommerce/releases/download/nightly/woocommerce-trunk-nightly.zip';
await getRemotePluginZip( pluginZipUrl );
```
The above method also makes use of the following utility methods which can also be used:
- `checkNestedZip( zipFilePath, savePath )` used to check a plugin zip file for any nested zip files. If one is found, it is extracted. Returns the path where the zip file is located.
- `downloadZip( fileUrl, downloadPath )` can be used to directly download a plugin zip file from a remote location to the provided path.
## Additional information
Refer to [`tests/e2e/core-tests`](https://github.com/woocommerce/woocommerce/tree/trunk/tests/e2e/core-tests) for some test examples, and [`tests/e2e`](https://github.com/woocommerce/woocommerce/tree/trunk/tests/e2e) for general information on e2e tests.

View File

@ -24,7 +24,7 @@ const getRemotePluginZip = async ( fileUrl ) => {
await downloadZip( fileUrl, filePath );
// Check for a nested zip and update the filepath
filePath = await checkZip( filePath, savePath );
filePath = await checkNestedZip( filePath, savePath );
return filePath;
};
@ -36,7 +36,7 @@ const getRemotePluginZip = async ( fileUrl ) => {
* @param {string} savePath The location where to save a nested zip if found.
* @returns {string} The path where the zip file is located.
*/
const checkZip = async ( zipFilePath, savePath ) => {
const checkNestedZip = async ( zipFilePath, savePath ) => {
const zip = new StreamZip.async( { file: zipFilePath } );
const entries = await zip.entries();
@ -80,4 +80,6 @@ const downloadZip = async ( fileUrl, downloadPath ) => {
module.exports = {
getRemotePluginZip,
checkNestedZip,
downloadZip,
};