From f266f2010182a3af0dde5d69417dd698d10072f2 Mon Sep 17 00:00:00 2001 From: Ron Rennick Date: Tue, 9 Mar 2021 13:45:05 -0400 Subject: [PATCH] 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 ), ); }