Merge pull request #30696 from woocommerce/fix/30371
Delete coupons instead of trashing them
This commit is contained in:
commit
982fec1ffe
|
@ -9315,7 +9315,7 @@
|
|||
"dev": true,
|
||||
"requires": {
|
||||
"dotenv": "^10.0.0",
|
||||
"jest": "^27.0.6",
|
||||
"jest": "^25.1.0",
|
||||
"jest-runner-groups": "^2.1.0",
|
||||
"postman-collection": "^4.1.0",
|
||||
"supertest": "^6.1.4"
|
||||
|
@ -11793,7 +11793,7 @@
|
|||
}
|
||||
},
|
||||
"prettier": {
|
||||
"version": "npm:wp-prettier@1.19.1",
|
||||
"version": "npm:prettier@1.19.1",
|
||||
"resolved": "https://registry.npmjs.org/wp-prettier/-/wp-prettier-1.19.1.tgz",
|
||||
"integrity": "sha512-mqAC2r1NDmRjG+z3KCJ/i61tycKlmADIjxnDhQab+KBxSAGbF/W7/zwB2guy/ypIeKrrftNsIYkNZZQKf3vJcg==",
|
||||
"dev": true
|
||||
|
@ -32151,6 +32151,16 @@
|
|||
"integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
|
||||
"requires": {
|
||||
"color-name": "~1.1.4"
|
||||
},
|
||||
"dependencies": {
|
||||
"supports-color": {
|
||||
"version": "8.1.1",
|
||||
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz",
|
||||
"integrity": "sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==",
|
||||
"requires": {
|
||||
"has-flag": "^4.0.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"color-name": {
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
# Unreleased
|
||||
|
||||
## Changed
|
||||
|
||||
- New coupon test deletes the coupon instead of trashing it.
|
||||
|
||||
# 0.1.6
|
||||
|
||||
## Fixed
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
/* eslint-disable jest/no-export, jest/no-disabled-tests */
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
const {
|
||||
merchant,
|
||||
clickTab,
|
||||
verifyPublishAndTrash
|
||||
AdminEdit,
|
||||
factories,
|
||||
} = require( '@woocommerce/e2e-utils' );
|
||||
const { Coupon } = require( '@woocommerce/api' );
|
||||
|
||||
/**
|
||||
* External dependencies
|
||||
|
@ -39,14 +40,19 @@ const runCreateCouponTest = () => {
|
|||
await expect(page).toSelect('#discount_type', 'Fixed cart discount');
|
||||
await expect(page).toFill('#coupon_amount', '100');
|
||||
|
||||
// Publish coupon, verify that it was published. Trash coupon, verify that it was trashed.
|
||||
await verifyPublishAndTrash(
|
||||
// Publish coupon, verify that it was published.
|
||||
const adminEdit = new AdminEdit();
|
||||
await adminEdit.verifyPublish(
|
||||
'#publish',
|
||||
'.notice',
|
||||
'Coupon updated.',
|
||||
'1 coupon moved to the Trash.'
|
||||
);
|
||||
|
||||
// Delete the coupon
|
||||
const couponId = await adminEdit.getId();
|
||||
if ( couponId ) {
|
||||
const repository = Coupon.restRepository( factories.api.withDefaultPermalinks );
|
||||
await repository.delete( couponId );
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
/* eslint-disable jest/no-export, jest/no-disabled-tests */
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
const {
|
||||
merchant,
|
||||
verifyPublishAndTrash,
|
||||
uiUnblocked
|
||||
uiUnblocked,
|
||||
AdminEdit,
|
||||
} = require('@woocommerce/e2e-utils');
|
||||
const config = require('config');
|
||||
const {
|
||||
|
@ -201,11 +200,19 @@ const runCreateOrderTest = () => {
|
|||
await expect(page).toFill('input[name=order_date_minute]', '55');
|
||||
|
||||
// Create order, verify that it was created. Trash order, verify that it was trashed.
|
||||
await verifyPublishAndTrash(
|
||||
const orderEdit = new AdminEdit();
|
||||
await orderEdit.verifyPublish(
|
||||
'.order_actions li .save_order',
|
||||
'#message',
|
||||
'Order updated.',
|
||||
'1 order moved to the Trash.'
|
||||
);
|
||||
|
||||
await expect( page ).toMatchElement( '#select2-order_status-container', { text: 'Processing' } );
|
||||
await expect( page ).toMatchElement(
|
||||
'#woocommerce-order-notes .note_content',
|
||||
{
|
||||
text: 'Order status changed from Pending payment to Processing.',
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
|
|
|
@ -1,5 +1,10 @@
|
|||
# Unreleased
|
||||
|
||||
## Added
|
||||
|
||||
- `utils.waitForTimeout( delay )` pause processing for `delay` milliseconds
|
||||
- `AdminEdit` class with utility functions for the respective edit screens
|
||||
|
||||
# 0.1.6
|
||||
|
||||
## Added
|
||||
|
|
|
@ -78,7 +78,7 @@ This package provides support for enabling retries in tests:
|
|||
- `MY_ACCOUNT_ADDRESSES` - Customer addresses
|
||||
- `MY_ACCOUNT_ACCOUNT_DETAILS` - Customer account details
|
||||
|
||||
## Test Function
|
||||
## Test Functions
|
||||
|
||||
### Merchant `merchant`
|
||||
|
||||
|
@ -153,6 +153,30 @@ This package provides support for enabling retries in tests:
|
|||
| `updatePaymentGateway`| `paymentGatewayId`, `payload` | Update a payment gateway |
|
||||
| `getSystemEnvironment` | | Get the current environment from the WooCommerce system status API.
|
||||
|
||||
### Classes
|
||||
|
||||
The package includes the following page specific utility class:
|
||||
|
||||
#### AdminEdit
|
||||
|
||||
The `AdminEdit` class is the base classic custom post type post editor class. It contains the following functions:
|
||||
|
||||
| Function | Parameters | Description |
|
||||
|----------|------------|-------------|
|
||||
| `verifyPublish` | `button, publishNotice, publishVerification` | Publish the post object currently being edited and verify publish status |
|
||||
| `getId` | | Get the ID of the post object being edited |
|
||||
|
||||
### General Utilities
|
||||
|
||||
There is a general utilities object `utils` with the following functions:
|
||||
|
||||
| Function | Parameters | Description |
|
||||
|----------|------------|-------------|
|
||||
| `getSlug` | `text` | Take a string name and generate the slug for it |
|
||||
| `describeIf` | `condition` | Return the `describe` or `describe.skip` function when the condition is true / false |
|
||||
| `it` | `condition` | Return the `it` or `it.skip` function when the condition is true / false |
|
||||
| `waitForTimeout` | `timeout` | Wait for a timeout in milliseconds |
|
||||
|
||||
### Page Utilities
|
||||
|
||||
| Function | Parameters | Description |
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@woocommerce/e2e-utils",
|
||||
"version": "0.1.5",
|
||||
"version": "0.1.6",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
|
@ -49,15 +49,25 @@
|
|||
}
|
||||
},
|
||||
"@wordpress/e2e-test-utils": {
|
||||
"version": "4.6.0",
|
||||
"resolved": "https://registry.npmjs.org/@wordpress/e2e-test-utils/-/e2e-test-utils-4.6.0.tgz",
|
||||
"integrity": "sha512-oqnFEOuWkUFwzSVGeKZOfs9YhWVyCKdsOtJKnXd6Vv5Q1quq2fmbDp6HL+dIUI2DlJZISUmOWG4B37mMVA0DLg==",
|
||||
"version": "4.16.1",
|
||||
"resolved": "https://registry.npmjs.org/@wordpress/e2e-test-utils/-/e2e-test-utils-4.16.1.tgz",
|
||||
"integrity": "sha512-Dpsq5m0VSvjIhro2MjACSzkOkOf1jGEryzgEMW1ikbT6YI+motspHfGtisKXgYhZJOnjV4PwuEg+9lPVnd971g==",
|
||||
"requires": {
|
||||
"@babel/runtime": "^7.9.2",
|
||||
"@wordpress/keycodes": "^2.12.0",
|
||||
"@wordpress/url": "^2.14.0",
|
||||
"lodash": "^4.17.15",
|
||||
"node-fetch": "^1.7.3"
|
||||
"@babel/runtime": "^7.12.5",
|
||||
"@wordpress/keycodes": "^2.18.0",
|
||||
"@wordpress/url": "^2.21.0",
|
||||
"lodash": "^4.17.19",
|
||||
"node-fetch": "^2.6.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@babel/runtime": {
|
||||
"version": "7.15.4",
|
||||
"resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.15.4.tgz",
|
||||
"integrity": "sha512-99catp6bHCaxr4sJ/DbTGgHS4+Rs2RVd2g7iOap6SLGPDknRK9ztKNsE/Fg6QhSeh1FGE5f6gHGQmvvn3I3xhw==",
|
||||
"requires": {
|
||||
"regenerator-runtime": "^0.13.4"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"@wordpress/hooks": {
|
||||
|
@ -69,51 +79,89 @@
|
|||
}
|
||||
},
|
||||
"@wordpress/i18n": {
|
||||
"version": "3.15.0",
|
||||
"resolved": "https://registry.npmjs.org/@wordpress/i18n/-/i18n-3.15.0.tgz",
|
||||
"integrity": "sha512-AawJgHEGPyMoPATl8a3Qa+cCZV3S6azPfvqeStbN2pSc7v0HqYhJhWaw80WToHkN4kyOsfu1PUVf1wefuoMNEA==",
|
||||
"version": "3.20.0",
|
||||
"resolved": "https://registry.npmjs.org/@wordpress/i18n/-/i18n-3.20.0.tgz",
|
||||
"integrity": "sha512-SIoOJFB4UrrYAScS4H91CYCLW9dX3Ghv8pBKc/yHGculb1AdGr6gRMlmJxZV62Cn3CZ4Ga86c+FfR+GiBu0JPg==",
|
||||
"requires": {
|
||||
"@babel/runtime": "^7.9.2",
|
||||
"@babel/runtime": "^7.13.10",
|
||||
"@wordpress/hooks": "^2.12.3",
|
||||
"gettext-parser": "^1.3.1",
|
||||
"lodash": "^4.17.19",
|
||||
"memize": "^1.1.0",
|
||||
"sprintf-js": "^1.1.1",
|
||||
"tannin": "^1.2.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@babel/runtime": {
|
||||
"version": "7.15.4",
|
||||
"resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.15.4.tgz",
|
||||
"integrity": "sha512-99catp6bHCaxr4sJ/DbTGgHS4+Rs2RVd2g7iOap6SLGPDknRK9ztKNsE/Fg6QhSeh1FGE5f6gHGQmvvn3I3xhw==",
|
||||
"requires": {
|
||||
"regenerator-runtime": "^0.13.4"
|
||||
}
|
||||
},
|
||||
"@wordpress/hooks": {
|
||||
"version": "2.12.3",
|
||||
"resolved": "https://registry.npmjs.org/@wordpress/hooks/-/hooks-2.12.3.tgz",
|
||||
"integrity": "sha512-LmKiwKldZt6UYqOxV/a6+eUFXdvALFnB/pQx3RmrMvO64sgFhfR6dhrlv+uVbuuezSuv8dce1jx8lUWAT0krMA==",
|
||||
"requires": {
|
||||
"@babel/runtime": "^7.13.10"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"@wordpress/keycodes": {
|
||||
"version": "2.15.0",
|
||||
"resolved": "https://registry.npmjs.org/@wordpress/keycodes/-/keycodes-2.15.0.tgz",
|
||||
"integrity": "sha512-XHyBmhzWjp0svzwiGLOwovlQHH42KkACKTfakDizB5OaaAzlmgZ34Fdl03S7pWl+HUBa7MqItRhGsd4kxdo0bQ==",
|
||||
"version": "2.19.3",
|
||||
"resolved": "https://registry.npmjs.org/@wordpress/keycodes/-/keycodes-2.19.3.tgz",
|
||||
"integrity": "sha512-8rNdmP5M1ifTgLIL0dt/N1uTGsq/Rx1ydCXy+gg24WdxBRhyu5sudNVCtascVXo26aIfOH9OJRdqRZZTEORhog==",
|
||||
"requires": {
|
||||
"@babel/runtime": "^7.9.2",
|
||||
"@wordpress/i18n": "^3.15.0",
|
||||
"@babel/runtime": "^7.13.10",
|
||||
"@wordpress/i18n": "^3.20.0",
|
||||
"lodash": "^4.17.19"
|
||||
},
|
||||
"dependencies": {
|
||||
"@babel/runtime": {
|
||||
"version": "7.15.4",
|
||||
"resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.15.4.tgz",
|
||||
"integrity": "sha512-99catp6bHCaxr4sJ/DbTGgHS4+Rs2RVd2g7iOap6SLGPDknRK9ztKNsE/Fg6QhSeh1FGE5f6gHGQmvvn3I3xhw==",
|
||||
"requires": {
|
||||
"regenerator-runtime": "^0.13.4"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"@wordpress/url": {
|
||||
"version": "2.18.0",
|
||||
"resolved": "https://registry.npmjs.org/@wordpress/url/-/url-2.18.0.tgz",
|
||||
"integrity": "sha512-FX6CYVG8vYgQnxjA9SsWTDAWPHarPSBIGk2shZ3I+cq+LV31dDaAz8OhvVMD6rvUoQW0INlWe1t2JKXoHhcTcw==",
|
||||
"version": "2.22.2",
|
||||
"resolved": "https://registry.npmjs.org/@wordpress/url/-/url-2.22.2.tgz",
|
||||
"integrity": "sha512-aqpYKQXzyzkCOm+GzZRYlLb+wh58g0cwR1PaKAl0UXaBS4mdS+X6biMriylb4P8CVC/RR7CSw5XI20JC24KDwQ==",
|
||||
"requires": {
|
||||
"@babel/runtime": "^7.9.2",
|
||||
"@babel/runtime": "^7.13.10",
|
||||
"lodash": "^4.17.19",
|
||||
"qs": "^6.5.2",
|
||||
"react-native-url-polyfill": "^1.1.2"
|
||||
},
|
||||
"dependencies": {
|
||||
"@babel/runtime": {
|
||||
"version": "7.15.4",
|
||||
"resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.15.4.tgz",
|
||||
"integrity": "sha512-99catp6bHCaxr4sJ/DbTGgHS4+Rs2RVd2g7iOap6SLGPDknRK9ztKNsE/Fg6QhSeh1FGE5f6gHGQmvvn3I3xhw==",
|
||||
"requires": {
|
||||
"regenerator-runtime": "^0.13.4"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"base64-js": {
|
||||
"version": "1.3.1",
|
||||
"resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.3.1.tgz",
|
||||
"integrity": "sha512-mLQ4i2QO1ytvGWFWmcngKO//JXAQueZvwEKtjgQFM4jIK0kU+ytMfplL8j+n5mspOfjHwoAg+9yhb7BwAHm36g=="
|
||||
"version": "1.5.1",
|
||||
"resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz",
|
||||
"integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA=="
|
||||
},
|
||||
"buffer": {
|
||||
"version": "5.6.0",
|
||||
"resolved": "https://registry.npmjs.org/buffer/-/buffer-5.6.0.tgz",
|
||||
"integrity": "sha512-/gDYp/UtU0eA1ys8bOs9J6a+E/KWIY+DZ+Q2WESNUA0jFRsJOc0SNUO6xJ5SGA1xueg3NL65W6s+NY5l9cunuw==",
|
||||
"version": "5.7.1",
|
||||
"resolved": "https://registry.npmjs.org/buffer/-/buffer-5.7.1.tgz",
|
||||
"integrity": "sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==",
|
||||
"requires": {
|
||||
"base64-js": "^1.0.2",
|
||||
"ieee754": "^1.1.4"
|
||||
"base64-js": "^1.3.1",
|
||||
"ieee754": "^1.1.13"
|
||||
}
|
||||
},
|
||||
"config": {
|
||||
|
@ -155,22 +203,17 @@
|
|||
}
|
||||
},
|
||||
"iconv-lite": {
|
||||
"version": "0.6.2",
|
||||
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.2.tgz",
|
||||
"integrity": "sha512-2y91h5OpQlolefMPmUlivelittSWy0rP+oYVpn6A7GwVHNE8AWzoYOBNmlwks3LobaJxgHCYZAnyNo2GgpNRNQ==",
|
||||
"version": "0.6.3",
|
||||
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz",
|
||||
"integrity": "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==",
|
||||
"requires": {
|
||||
"safer-buffer": ">= 2.1.2 < 3.0.0"
|
||||
}
|
||||
},
|
||||
"ieee754": {
|
||||
"version": "1.1.13",
|
||||
"resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.1.13.tgz",
|
||||
"integrity": "sha512-4vf7I2LYV/HaWerSo3XmlMkp5eZ83i+/CDluXi/IGTs/O1sejBNhTtnxzmRZfvOUqj7lZjqHkeTvpgSFDlWZTg=="
|
||||
},
|
||||
"is-stream": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz",
|
||||
"integrity": "sha1-EtSj3U5o4Lec6428hBc66A2RykQ="
|
||||
"version": "1.2.1",
|
||||
"resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz",
|
||||
"integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA=="
|
||||
},
|
||||
"json5": {
|
||||
"version": "2.2.0",
|
||||
|
@ -201,12 +244,11 @@
|
|||
"integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw=="
|
||||
},
|
||||
"node-fetch": {
|
||||
"version": "1.7.3",
|
||||
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-1.7.3.tgz",
|
||||
"integrity": "sha512-NhZ4CsKx7cYm2vSrBAr2PvFOe6sWDf0UYLRqA6svUYg7+/TSfVAu49jYC4BvQ4Sms9SZgdqGBgroqfDhJdTyKQ==",
|
||||
"version": "2.6.5",
|
||||
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.5.tgz",
|
||||
"integrity": "sha512-mmlIVHJEu5rnIxgEgez6b9GgWXbkZj5YZ7fx+2r94a2E+Uirsp6HsPTPlomfdHtpt/B0cdKviwkoaM6pyvUOpQ==",
|
||||
"requires": {
|
||||
"encoding": "^0.1.11",
|
||||
"is-stream": "^1.0.1"
|
||||
"whatwg-url": "^5.0.0"
|
||||
}
|
||||
},
|
||||
"punycode": {
|
||||
|
@ -214,15 +256,10 @@
|
|||
"resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz",
|
||||
"integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A=="
|
||||
},
|
||||
"qs": {
|
||||
"version": "6.9.4",
|
||||
"resolved": "https://registry.npmjs.org/qs/-/qs-6.9.4.tgz",
|
||||
"integrity": "sha512-A1kFqHekCTM7cz0udomYUoYNWjBebHm/5wzU/XqrBRBNWectVH0QIiN+NEcZ0Dte5hvzHwbr8+XQmguPhJ6WdQ=="
|
||||
},
|
||||
"react-native-url-polyfill": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/react-native-url-polyfill/-/react-native-url-polyfill-1.2.0.tgz",
|
||||
"integrity": "sha512-hpLZ8RyS3oGVyTOe/HjoqVoCOSkeJvrCoEB3bJsY7t9uh7kpQDV6kgvdlECEafYpxe3RzMrKLVcmWRbPU7CuAw==",
|
||||
"version": "1.3.0",
|
||||
"resolved": "https://registry.npmjs.org/react-native-url-polyfill/-/react-native-url-polyfill-1.3.0.tgz",
|
||||
"integrity": "sha512-w9JfSkvpqqlix9UjDvJjm1EjSt652zVQ6iwCIj1cVVkwXf4jQhQgTNXY6EVTwuAmUjg6BC6k9RHCBynoLFo3IQ==",
|
||||
"requires": {
|
||||
"whatwg-url-without-unicode": "8.0.0-3"
|
||||
}
|
||||
|
@ -255,11 +292,32 @@
|
|||
"@tannin/plural-forms": "^1.1.0"
|
||||
}
|
||||
},
|
||||
"tr46": {
|
||||
"version": "0.0.3",
|
||||
"resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz",
|
||||
"integrity": "sha1-gYT9NH2snNwYWZLzpmIuFLnZq2o="
|
||||
},
|
||||
"webidl-conversions": {
|
||||
"version": "5.0.0",
|
||||
"resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-5.0.0.tgz",
|
||||
"integrity": "sha512-VlZwKPCkYKxQgeSbH5EyngOmRp7Ww7I9rQLERETtf5ofd9pGeswWiOtogpEO850jziPRarreGxn5QIiTqpb2wA=="
|
||||
},
|
||||
"whatwg-url": {
|
||||
"version": "5.0.0",
|
||||
"resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz",
|
||||
"integrity": "sha1-lmRU6HZUYuN2RNNib2dCzotwll0=",
|
||||
"requires": {
|
||||
"tr46": "~0.0.3",
|
||||
"webidl-conversions": "^3.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"webidl-conversions": {
|
||||
"version": "3.0.1",
|
||||
"resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz",
|
||||
"integrity": "sha1-JFNCdeKnvGvnvIZhHMFq4KVlSHE="
|
||||
}
|
||||
}
|
||||
},
|
||||
"whatwg-url-without-unicode": {
|
||||
"version": "8.0.0-3",
|
||||
"resolved": "https://registry.npmjs.org/whatwg-url-without-unicode/-/whatwg-url-without-unicode-8.0.0-3.tgz",
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
/**
|
||||
* Take a string name and generate the slug for it.
|
||||
* Example: 'My plugin' => 'my-plugin'
|
||||
* @param text string to convert to a slug
|
||||
*
|
||||
* Sourced from: https://gist.github.com/spyesx/561b1d65d4afb595f295
|
||||
**/
|
||||
|
@ -31,3 +32,12 @@ export const describeIf = ( condition ) =>
|
|||
// Conditionally determine whether or not to skip a test case
|
||||
export const itIf = ( condition ) =>
|
||||
condition ? it : it.skip;
|
||||
|
||||
/**
|
||||
* Wait for a timeout in milliseconds
|
||||
* @param timeout delay time in milliseconds
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
export const waitForTimeout = async ( timeout ) => {
|
||||
await new Promise( ( resolve ) => setTimeout( resolve, timeout ) );
|
||||
};
|
||||
|
|
|
@ -12,3 +12,4 @@ export * from './old-flows';
|
|||
export * from './components';
|
||||
export * from './page-utils';
|
||||
export * from './system-environment';
|
||||
export * from './pages/admin-edit';
|
||||
|
|
|
@ -3,6 +3,11 @@
|
|||
*/
|
||||
import { pressKeyWithModifier } from '@wordpress/e2e-test-utils';
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
import { AdminEdit } from './pages/admin-edit';
|
||||
|
||||
/**
|
||||
* Perform a "select all" and then fill a input.
|
||||
*
|
||||
|
@ -117,24 +122,8 @@ export const waitForSelectorWithoutThrow = async ( selector, timeoutInSeconds =
|
|||
* @param {string} trashVerification
|
||||
*/
|
||||
export const verifyPublishAndTrash = async ( button, publishNotice, publishVerification, trashVerification ) => {
|
||||
// Wait for auto save
|
||||
await page.waitFor( 2000 );
|
||||
|
||||
// Publish
|
||||
await expect( page ).toClick( button );
|
||||
await page.waitForSelector( publishNotice );
|
||||
|
||||
// Verify
|
||||
await expect( page ).toMatchElement( publishNotice, { text: publishVerification } );
|
||||
if ( button === '.order_actions li .save_order' ) {
|
||||
await expect( page ).toMatchElement( '#select2-order_status-container', { text: 'Processing' } );
|
||||
await expect( page ).toMatchElement(
|
||||
'#woocommerce-order-notes .note_content',
|
||||
{
|
||||
text: 'Order status changed from Pending payment to Processing.',
|
||||
}
|
||||
);
|
||||
}
|
||||
const adminEdit = new AdminEdit();
|
||||
await adminEdit.verifyPublish( button, publishNotice, publishVerification );
|
||||
|
||||
// Trash
|
||||
await page.focus( 'a.submitdelete' );
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
import { waitForTimeout } from '../flows/utils';
|
||||
|
||||
|
||||
export class AdminEdit {
|
||||
/**
|
||||
* Publish the object being edited and verify published status
|
||||
*
|
||||
* @param button Publish button selector
|
||||
* @param publishNotice Publish notice selector
|
||||
* @param publishVerification Expected notice on successful publish
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
async verifyPublish( button, publishNotice, publishVerification ) {
|
||||
// Wait for auto save
|
||||
await waitForTimeout( 2000 );
|
||||
|
||||
// Publish and verify
|
||||
await expect( page ).toClick( button );
|
||||
await page.waitForSelector( publishNotice );
|
||||
await expect( page ).toMatchElement( publishNotice, { text: publishVerification } );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the ID of the object being edited
|
||||
*
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
async getId() {
|
||||
let postId = await page.$( '#post_ID' );
|
||||
let objectID = await page.evaluate( element => element.value, postId );
|
||||
return objectID;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue