Merge pull request #29313 from woocommerce/update/e2e-api-product-delete

delete vs trash product in e2e api
This commit is contained in:
Greg 2021-03-24 14:25:12 -06:00 committed by GitHub
commit 94cd20f16e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 22 additions and 6 deletions

2
package-lock.json generated
View File

@ -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

View File

@ -1,6 +1,6 @@
{
"name": "@woocommerce/api",
"version": "0.1.0",
"version": "0.1.1",
"lockfileVersion": 1,
"requires": true,
"dependencies": {

View File

@ -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.
*/

View File

@ -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 ),
);
}

View File

@ -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 ),
);
}

View File

@ -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 ),
);
}

View File

@ -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 ),
);
}

View File

@ -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 );
});
});
});
};