From f266f2010182a3af0dde5d69417dd698d10072f2 Mon Sep 17 00:00:00 2001 From: Ron Rennick Date: Tue, 9 Mar 2021 13:45:05 -0400 Subject: [PATCH 1/2] delete vs trash product in e2e api --- tests/e2e/api/src/models/products/abstract/common.ts | 8 ++++++++ .../src/repositories/rest/products/external-product.ts | 3 ++- .../api/src/repositories/rest/products/grouped-product.ts | 3 ++- .../api/src/repositories/rest/products/simple-product.ts | 3 ++- .../src/repositories/rest/products/variable-product.ts | 3 ++- 5 files changed, 16 insertions(+), 4 deletions(-) diff --git a/tests/e2e/api/src/models/products/abstract/common.ts b/tests/e2e/api/src/models/products/abstract/common.ts index 88601fa6ad0..d9a4a3525db 100644 --- a/tests/e2e/api/src/models/products/abstract/common.ts +++ b/tests/e2e/api/src/models/products/abstract/common.ts @@ -27,6 +27,14 @@ export const baseProductURL = () => '/wc/v3/products/'; */ export const buildProductURL = ( id: ModelID ) => baseProductURL() + id; +/** + * A common delete product URL builder. + * + * @param {ModelID} id the id of the product. + * @return {string} RESTful Url. + */ +export const deleteProductURL = ( id: ModelID ) => buildProductURL( id ) + '?force=true'; + /** * The base for all product types. */ diff --git a/tests/e2e/api/src/repositories/rest/products/external-product.ts b/tests/e2e/api/src/repositories/rest/products/external-product.ts index f2b323ad7b8..bd78edce17f 100644 --- a/tests/e2e/api/src/repositories/rest/products/external-product.ts +++ b/tests/e2e/api/src/repositories/rest/products/external-product.ts @@ -3,6 +3,7 @@ import { ModelRepository } from '../../../framework'; import { baseProductURL, buildProductURL, + deleteProductURL, ExternalProduct, CreatesExternalProducts, DeletesExternalProducts, @@ -61,6 +62,6 @@ export function externalProductRESTRepository( httpClient: HTTPClient ): ListsEx restCreate< ExternalProductRepositoryParams >( baseProductURL, ExternalProduct, httpClient, transformer ), restRead< ExternalProductRepositoryParams >( buildProductURL, ExternalProduct, httpClient, transformer ), restUpdate< ExternalProductRepositoryParams >( buildProductURL, ExternalProduct, httpClient, transformer ), - restDelete< ExternalProductRepositoryParams >( buildProductURL, httpClient ), + restDelete< ExternalProductRepositoryParams >( deleteProductURL, httpClient ), ); } diff --git a/tests/e2e/api/src/repositories/rest/products/grouped-product.ts b/tests/e2e/api/src/repositories/rest/products/grouped-product.ts index 94f1bef6a89..c2a9a4dd338 100644 --- a/tests/e2e/api/src/repositories/rest/products/grouped-product.ts +++ b/tests/e2e/api/src/repositories/rest/products/grouped-product.ts @@ -10,6 +10,7 @@ import { UpdatesGroupedProducts, baseProductURL, buildProductURL, + deleteProductURL, } from '../../../models'; import { createProductTransformer, @@ -55,6 +56,6 @@ export function groupedProductRESTRepository( httpClient: HTTPClient ): ListsGro restCreate< GroupedProductRepositoryParams >( baseProductURL, GroupedProduct, httpClient, transformer ), restRead< GroupedProductRepositoryParams >( buildProductURL, GroupedProduct, httpClient, transformer ), restUpdate< GroupedProductRepositoryParams >( buildProductURL, GroupedProduct, httpClient, transformer ), - restDelete< GroupedProductRepositoryParams >( buildProductURL, httpClient ), + restDelete< GroupedProductRepositoryParams >( deleteProductURL, httpClient ), ); } diff --git a/tests/e2e/api/src/repositories/rest/products/simple-product.ts b/tests/e2e/api/src/repositories/rest/products/simple-product.ts index b4f9b5d0d2d..fb83634b643 100644 --- a/tests/e2e/api/src/repositories/rest/products/simple-product.ts +++ b/tests/e2e/api/src/repositories/rest/products/simple-product.ts @@ -4,6 +4,7 @@ import { SimpleProduct, baseProductURL, buildProductURL, + deleteProductURL, CreatesSimpleProducts, DeletesSimpleProducts, ListsSimpleProducts, @@ -70,6 +71,6 @@ export function simpleProductRESTRepository( httpClient: HTTPClient ): ListsSimp restCreate< SimpleProductRepositoryParams >( baseProductURL, SimpleProduct, httpClient, transformer ), restRead< SimpleProductRepositoryParams >( buildProductURL, SimpleProduct, httpClient, transformer ), restUpdate< SimpleProductRepositoryParams >( buildProductURL, SimpleProduct, httpClient, transformer ), - restDelete< SimpleProductRepositoryParams >( buildProductURL, httpClient ), + restDelete< SimpleProductRepositoryParams >( deleteProductURL, httpClient ), ); } diff --git a/tests/e2e/api/src/repositories/rest/products/variable-product.ts b/tests/e2e/api/src/repositories/rest/products/variable-product.ts index 9133b4ccdee..2868ebfbeca 100644 --- a/tests/e2e/api/src/repositories/rest/products/variable-product.ts +++ b/tests/e2e/api/src/repositories/rest/products/variable-product.ts @@ -10,6 +10,7 @@ import { UpdatesVariableProducts, baseProductURL, buildProductURL, + deleteProductURL, } from '../../../models'; import { createProductTransformer, @@ -67,6 +68,6 @@ export function variableProductRESTRepository( httpClient: HTTPClient ): ListsVa restCreate< VariableProductRepositoryParams >( baseProductURL, VariableProduct, httpClient, transformer ), restRead< VariableProductRepositoryParams >( buildProductURL, VariableProduct, httpClient, transformer ), restUpdate< VariableProductRepositoryParams >( buildProductURL, VariableProduct, httpClient, transformer ), - restDelete< VariableProductRepositoryParams >( buildProductURL, httpClient ), + restDelete< VariableProductRepositoryParams >( deleteProductURL, httpClient ), ); } From 372b721b1c03553f60e379636f543b8505e36b61 Mon Sep 17 00:00:00 2001 From: Ron Rennick Date: Mon, 15 Mar 2021 14:04:37 -0300 Subject: [PATCH 2/2] package lock maintenance, remove simple products in group product test --- package-lock.json | 2 +- tests/e2e/api/package-lock.json | 2 +- tests/e2e/core-tests/specs/api/grouped-product.test.js | 4 ++++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index a23aaf9bbeb..2ec65648a08 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9307,7 +9307,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 diff --git a/tests/e2e/api/package-lock.json b/tests/e2e/api/package-lock.json index 17f36f2a80b..8fe554d6176 100644 --- a/tests/e2e/api/package-lock.json +++ b/tests/e2e/api/package-lock.json @@ -1,6 +1,6 @@ { "name": "@woocommerce/api", - "version": "0.1.0", + "version": "0.1.1", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/tests/e2e/core-tests/specs/api/grouped-product.test.js b/tests/e2e/core-tests/specs/api/grouped-product.test.js index d1f12567305..7ad4f2f2bd7 100644 --- a/tests/e2e/core-tests/specs/api/grouped-product.test.js +++ b/tests/e2e/core-tests/specs/api/grouped-product.test.js @@ -80,6 +80,10 @@ const runGroupedProductAPITest = () => { it('can delete a grouped product', async () => { const status = repository.delete( product.id ); expect( status ).toBeTruthy(); + // Delete the simple "child" products. + groupedProducts.forEach( ( productId ) => { + repository.delete( productId ); + }); }); }); };