{
  "name": "@woocommerce/e2e-utils",
  "version": "0.2.0",
  "description": "End-To-End (E2E) test utils for WooCommerce",
  "homepage": "https://github.com/woocommerce/woocommerce/tree/trunk/packages/js/e2e-utils/README.md",
  "repository": {
    "type": "git",
    "url": "https://github.com/woocommerce/woocommerce.git"
  },
  "license": "GPL-3.0+",
  "main": "build/index.js",
  "module": "build-module/index.js",
  "dependencies": {
    "@wordpress/deprecated": "^3.2.3",
    "@wordpress/e2e-test-utils": "^4.16.1",
    "config": "3.3.3",
    "faker": "^5.1.0",
    "fishery": "^1.2.0"
  },
  "devDependencies": {
    "@babel/cli": "7.12.8",
    "@babel/core": "7.12.9",
    "@babel/plugin-proposal-async-generator-functions": "^7.16.4",
    "@babel/plugin-proposal-object-rest-spread": "^7.16.0",
    "@babel/plugin-transform-react-jsx": "^7.16.0",
    "@babel/plugin-transform-runtime": "^7.16.4",
    "@babel/polyfill": "7.12.1",
    "@babel/preset-env": "7.12.7",
    "@typescript-eslint/eslint-plugin": "^5.3.0",
    "@typescript-eslint/parser": "^5.3.0",
    "@wordpress/babel-plugin-import-jsx-pragma": "1.1.3",
    "@wordpress/babel-preset-default": "3.0.2",
    "@wordpress/browserslist-config": "^4.1.0",
    "eslint": "^8.1.0"
  },
  "peerDependencies": {
    "@woocommerce/api": "^0.2.0"
  },
  "publishConfig": {
    "access": "public"
  },
  "scripts": {
    "clean": "rm -rf ./build ./build-module",
    "compile": "node ./../bin/build.js",
    "build": "pnpm run clean && pnpm run compile",
    "lint": "eslint src"
  },
  "readme": "# WooCommerce End to End Test Utilities\n\nThis package contains utilities to simplify writing e2e tests specific to WooCommmerce.\n\n\n## Installation\n\n```bash\nnpm install @woocommerce/e2e-utils --save\n```\n\n## Usage\n\nExample:\n~~~js\nimport {\n\tshopper,\n\tmerchant,\n\tcreateSimpleProduct\n} from '@woocommerce/e2e-utils';\n\ndescribe( 'Cart page', () => {\n\tbeforeAll( async () => {\n\t\tawait createSimpleProduct();\n\t} );\n\n\tit( 'should display no item in the cart', async () => {\n\t\tawait shopper.goToCart();\n\t\tawait expect( page ).toMatchElement( '.cart-empty', { text: 'Your cart is currently empty.' } );\n\t} );\n} );\n~~~\n\n### Retries\n\nThis package provides support for enabling retries in tests:\n\n- In the test environment set `E2E_RETEST=1`.\n- To add conditional logic to your tests use the boolean constant `IS_RETEST_MODE`.\n\n### Available constants\n\n#### Dashboard\n\n- `WP_ADMIN_LOGIN` - WordPress login\n- `WP_ADMIN_DASHBOARD` - WordPress dashboard\n- `WP_ADMIN_WP_UPDATES` - WordPress updates\n- `WP_ADMIN_PLUGINS` - Plugin list\n- `WP_ADMIN_PERMALINK_SETTINGS` - Permalink settings\n- `WP_ADMIN_ALL_USERS_VIEW` - WordPress user list\n- `WP_ADMIN_POST_TYPE` - Post listing\n- `WP_ADMIN_NEW_POST_TYPE` - New post\n- `WP_ADMIN_ALL_COUPONS_VIEW` - Coupons list\n- `WP_ADMIN_NEW_COUPON` - New coupon\n- `WP_ADMIN_ALL_ORDERS_VIEW` - Orders list\n- `WP_ADMIN_NEW_ORDER` - New Order\n- `WP_ADMIN_ALL_PRODUCTS_VIEW` - Products list\n- `WP_ADMIN_NEW_PRODUCT` - New product\n- `WP_ADMIN_IMPORT_PRODUCTS` - Import products\n- `WP_ADMIN_PLUGIN_PAGE` - Plugin settings page root\n- `WP_ADMIN_WC_HOME` - WooCommerce home screen\n- `WP_ADMIN_SETUP_WIZARD` - WooCommerce setup/onboarding wizard\n- `WP_ADMIN_ANALYTICS_PAGES` - WooCommerce analytics page root\n- `WP_ADMIN_WC_SETTINGS` - WooCommerce settings page root\n- `WP_ADMIN_NEW_SHIPPING_ZONE` - WooCommerce new shipping zone\n- `WP_ADMIN_WC_EXTENSIONS` - WooCommerce extensions page\n- `WP_ADMIN_PLUGIN_INSTALL` - WordPress plugin install page\n\n#### Front end\n\n- `SHOP_PAGE` - Shop page\n- `SHOP_PRODUCT_PAGE` - Single product page\n- `SHOP_CART_PAGE` - Cart page\n- `SHOP_CHECKOUT_PAGE` - Checkout page\n- `SHOP_MY_ACCOUNT_PAGE` - Customer account page\n- `MY_ACCOUNT_ORDERS` - Customer orders\n- `MY_ACCOUNT_DOWNLOADS` - Customer downloads\n- `MY_ACCOUNT_ADDRESSES` - Customer addresses\n- `MY_ACCOUNT_ACCOUNT_DETAILS` - Customer account details\n\n## Test Functions\n\n### Merchant `merchant`\n\n| Function | Parameters | Description |\n|----------|-------------|------------|\n| `collapseAdminMenu` | `collapse` | Collapse or expand the WP admin menu |\n| `dismissOnboardingWizard` |  | Dismiss the onboarding wizard if present |\n| `goToOrder` | `orderId` | Go to view a single order |\n| `goToProduct` | `productId` | Go to view a single product |\n| `login` | | Log in as merchant |\n| `logout` | | Log out of merchant account |\n| `openAllOrdersView` | | Go to the orders listing |\n| `openAllProductsView` | | Go to the products listing |\n| `openDashboard` | | Go to the WordPress dashboard  |\n| `openNewCoupon` | | Go to the new coupon editor |\n| `openNewOrder` | | Go to the new order editor |\n| `openNewProduct` | | Go to the new product editor |\n| `openPermalinkSettings` | | Go to Settings -> Permalinks |\n| `openPlugins` | | Go to the Plugins screen |\n| `openSettings` | | Go to WooCommerce -> Settings |\n| `runSetupWizard` | | Open the onboarding profiler |\n| `updateOrderStatus` | `orderId, status` | Update the status of an order |\n| `openEmailLog` | | Open the WP Mail Log page |\n| `openAnalyticsPage` | | Open any Analytics page |\n| `openAllUsersView` | | Open the All Users page |\n| `openImportProducts` | | Open the Import Products page |\n| `openExtensions` | | Go to WooCommerce -> Extensions |\n| `openWordPressUpdatesPage` | | Go to Dashboard -> Updates |\n| `installAllUpdates` | | Install all pending updates on Dashboard -> Updates|\n| `updateWordPress` | | Install pending WordPress updates on Dashboard -> Updates|\n| `updatePlugins` | | Install all pending plugin updates on Dashboard -> Updates|\n| `updateThemes` | | Install all pending theme updates on Dashboard -> Updates|\n| `runDatabaseUpdate` || Runs the database update if needed |\n\n### Shopper `shopper`\n\n| Function | Parameters | Description |\n|----------|------------|-------------|\n| `addToCart` | | Add an item to the cart from a single product page |\n| `addToCartFromShopPage` | `productIdOrTitle` | Add an item to the cart from the shop page |\n| `fillBillingDetails` | `customerBillingDetails` | Fill billing fields in checkout form using configured address |\n| `fillShippingDetails` | `customerShippingDetails` | Fill shipping fields in checkout form using configured address |\n| `goToAddresses` |  | Go to My Account -> Address Details |\n| `goToAccountDetails` |  | Go to My Account -> Details |\n| `goToCart` |  | Go to the cart page |\n| `goToCheckout` |  | Go to the checkout page |\n| `goToDownloads` |  | Go to My Account -> Downloads |\n| `goToMyAccount` |  | Go to the My Account page |\n| `goToOrders` |  | Go to My Account -> Orders |\n| `goToProduct` | `productId` | Go to a single product in the shop |\n| `goToShop` |  | Go to the shop page |\n| `login` |  | Log in as the shopper |\n| `logout` |  | Log out of the shopper account |\n| `placeOrder` |  | Place an order from the checkout page |\n| `productIsInCheckout` | `productTitle, quantity, total, cartSubtotal` | Verify product is in cart on checkout page |\n| `removeFromCart` | `productIdOrTitle` | Remove a product from the cart on the cart page |\n| `setCartQuantity` | `productTitle, quantityValue` | Change the quantity of a product on the cart page |\n| `searchForProduct` | | Searching for a product name and landing on its detail page |\n| `emptyCart` | | Removes any products and coupons that are in the cart |\n\n### REST API `withRestApi`\n\nPlease note: if you're using a non-SSL environment (such as a Docker container from [`wc-e2e`](https://www.npmjs.com/package/@woocommerce/e2e-environment)) you will need to use Basic Auth in order to authenticate with the API and use the `withRestApi` methods listed below. To do so, you will need to install the [the Basic Auth plugin](https://github.com/WP-API/Basic-Auth). One way this can be accomplished is by adding `wp plugin install https://github.com/WP-API/Basic-Auth/archive/master.zip --activate` to your `initialize.sh` script.\n\n| Function | Parameters | Description |\n|----------|------------|-------------|\n| `addShippingZoneAndMethod` | `zoneName`, `zoneLocation`, `zipCode`, `zoneMethod`, `cost`, `additionalZoneMethods`, `testResponse` | Adds a shipping zone along with a shipping method |\n| `batchCreateOrders` | `orders`, `testResponse` | Create a batch of orders using the \"Batch Create Order\" API endpoint |\n| `addTaxClasses` | `taxClasses` | Add an array of tax classes if they do not exist |\n| `addTaxRates` | `taxRates` | Add an array of tax rates if they do not exist |\n| `createProductCategory` | `categoryName` | Create a product category with the provided name |\n| `deleteAllCoupons` | | Permanently delete all coupons |\n| `deleteAllOrders` | | Permanently delete all orders |\n| `deleteAllProductAttributes` | `testResponse` | Permanently delete all product attributes |\n| `deleteAllProductCategories` | `testResponse` | Permanently delete all product categories |\n| `deleteAllProducts` | | Permanently delete all products |\n| `deleteAllProductTags` | `testResponse` | Permanently delete all product tags |\n| `deleteAllShippingClasses` | `testResponse` | Permanently delete all shipping classes |\n| `deleteAllShippingZones` | `testResponse` | Permanently delete all shipping zones except the default |\n| `deleteCoupon` | `couponId` | Permanently delete a coupon |\n| `deleteCustomerByEmail` | `emailAddress` | Delete customer user account. Posts are reassigned to user ID 1 |\n| `getSystemEnvironment` | | Get the current environment from the WooCommerce system status API. |\n| `resetOnboarding` | | Reset onboarding settings |\n| `resetSettingsGroupToDefault` | `settingsGroup`, `testResponse` | Reset settings in settings group to default except `select` fields |\n| `updateSettingOption` | `settingsGroup`, `settingID`, `payload` | Update a settings group |\n| `updatePaymentGateway`| `paymentGatewayId`, `payload`, `testResponse` | Update a payment gateway |\n\n### Classes\n\nThe package includes the following page specific utility class:\n\n#### AdminEdit\n\nThe `AdminEdit` class is the base classic custom post type post editor class. It contains the following functions:\n\n| Function | Parameters | Description |\n|----------|------------|-------------|\n| `verifyPublish` | `button, publishNotice, publishVerification` | Publish the post object currently being edited and verify publish status |\n| `getId` | | Get the ID of the post object being edited |\n\n### General Utilities\n\nThere is a general utilities object `utils` with the following functions:\n\n| Function | Parameters | Description |\n|----------|------------|-------------|\n| `getSlug` | `text` | Take a string name and generate the slug for it |\n| `describeIf` | `condition` | Return the `describe` or `describe.skip` function when the condition is true / false |\n| `it` | `condition` | Return the `it` or `it.skip` function when the condition is true / false |\n| `waitForTimeout` | `timeout` | Wait for a timeout in milliseconds |\n\n### Page Utilities\n\n| Function | Parameters | Description |\n|----------|------------|-------------|\n| `addProductToOrder` | `orderId, productName` | adds a product to an order using the product search |\n| `applyCoupon` | `couponName` | helper method which applies a coupon in cart or checkout |\n| `clearAndFillInput` | `selector, value` | Replace the contents of an input with the passed value |\n| `clickFilter` | `selector` | helper method that clicks on a list page filter |\n| `clickTab` | `tabName` | Click on a WooCommerce -> Settings tab |\n| `clickUpdateOrder` | `noticeText`, `waitForSave` | Helper method to click the Update button on the order details page |\n| `completeOnboardingWizard` | | completes the onboarding wizard with some default settings |\n| `createCoupon` | `couponAmount`, `couponType` | creates a basic coupon. Default amount is 5. Default coupon type is fixed discount. Returns the generated coupon code. |\n| `createGroupedProduct` | | creates a grouped product for the grouped product tests. Returns the product id. |\n| `createSimpleOrder` | `status` | creates a basic order with the provided status string |\n| `createSimpleProduct` | | creates the simple product configured in default.json. Returns the product id. |\n| `createSimpleProductWithCategory` | `name`, `price`,`categoryName` | creates a simple product used passed values. Returns the product id. |\n| `createVariableProduct` | | creates a variable product for the variable product tests. Returns the product id. |\n| `deleteAllEmailLogs` | | deletes the emails generated by WP Mail Logging plugin |\n| `evalAndClick` | `selector` | helper method that clicks an element inserted in the DOM by a script |\n| `moveAllItemsToTrash` | | helper method that checks every item in a list page and moves them to the trash |\n| `permalinkSettingsPageSaveChanges` |  | Save the current Permalink settings |\n| `removeCoupon` | | helper method that removes a single coupon within cart or checkout |\n| `selectOptionInSelect2` | `selector, value` | helper method that searchs for select2 type fields and select plus insert value inside |\n| `selectOrderAction` | `action` | Helper method to select an order action in the `Order Actions` postbox |\n| `setCheckbox` | `selector` | Check a checkbox |\n| `settingsPageSaveChanges` |  | Save the current WooCommerce settings page |\n| `uiUnblocked` |  | Wait until the page is unblocked |\n| `unsetCheckbox` | `selector` | Uncheck a checkbox |\n| `verifyAndPublish` | `noticeText` | Verify that an item can be published |\n| `verifyCheckboxIsSet` | `selector` | Verify that a checkbox is checked |\n| `verifyCheckboxIsUnset` | `selector` | Verify that a checkbox is unchecked |\n| `verifyPublishAndTrash` | `button, publishNotice, publishVerification, trashVerification` | Verify that an item can be published and trashed |\n| `verifyValueOfInputField` | `selector, value` | Verify an input contains the passed value |\n| `clickFilter` | `selector` | Click on a list page filter |\n| `moveAllItemsToTrash` |  | Moves all items in a list view to the Trash |\n| `verifyAndPublish` | `noticeText` | Verify that an item can be published |\n| `selectOptionInSelect2` | `selector, value` | helper method that searchs for select2 type fields and select plus insert value inside |\n| `searchForOrder` | `value, orderId, customerName` | helper method that searchs for an order via many different terms |\n| `addShippingZoneAndMethod` | `zoneName, zoneLocation, zipCode, zoneMethod` | util helper method for adding shipping zones with shipping methods |\n| `applyCoupon` | `couponName` | helper method which applies a coupon in cart or checkout |\n| `removeCoupon` | | helper method that removes a single coupon within cart or checkout |\n| `selectOrderAction` | `action` | Helper method to select an order action in the `Order Actions` postbox |\n| `clickUpdateOrder` | `noticeText`, `waitForSave` | Helper method to click the Update button on the order details page |\n| `deleteAllShippingZones` | | Delete all the existing shipping zones |\n| `waitForSelectorWithoutThrow` | `selector`, `timeoutInSeconds` | conditionally wait for a selector without throwing an error. Default timeout is 5 seconds |\n| `createOrder` | `orderOptions` | Creates an order using the API with the passed in details |\n| `clickAndWaitForSelector` | `buttonSelector`, `resultSelector`, `timeout` | Click a button and wait for response |\n\n### Test Utilities\n\nAs of version 0.1.3, all test utilities from [`@wordpress/e2e-test-utils`](https://www.npmjs.com/package/@wordpress/e2e-test-utils) are available through this package.\n"
}