diff --git a/tests/e2e/api/src/models/products/abstract/common.ts b/tests/e2e/api/src/models/products/abstract/common.ts index 25b02201028..e2766ba9d75 100644 --- a/tests/e2e/api/src/models/products/abstract/common.ts +++ b/tests/e2e/api/src/models/products/abstract/common.ts @@ -1,4 +1,4 @@ -import { Model } from '../../model'; +import { Model, ModelID } from '../../model'; import { MetaData, PostStatus } from '../../shared-types'; import { CatalogVisibility, @@ -13,6 +13,14 @@ import { */ export type ProductSearchParams = { search: string }; +/** + * A common URL builder. + * + * @param {ModelID} id the id of the product. + * @return {string} RESTful Url. + */ +export const buildProductURL = ( id: ModelID ) => '/wc/v3/products/' + id; + /** * 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 01138a08157..69a0245acf6 100644 --- a/tests/e2e/api/src/repositories/rest/products/external-product.ts +++ b/tests/e2e/api/src/repositories/rest/products/external-product.ts @@ -1,8 +1,8 @@ import { HTTPClient } from '../../../http'; import { ModelRepository } from '../../../framework'; import { + buildProductURL, ExternalProduct, - ModelID, CreatesExternalProducts, DeletesExternalProducts, ListsExternalProducts, @@ -41,8 +41,6 @@ export function externalProductRESTRepository( httpClient: HTTPClient ): ListsEx & ReadsExternalProducts & UpdatesExternalProducts & DeletesExternalProducts { - const buildURL = ( id: ModelID ) => '/wc/v3/products/' + id; - const external = createProductExternalTransformation(); const salesTax = createProductSalesTaxTransformation(); const upsells = createProductUpSellsTransformation(); @@ -57,8 +55,8 @@ export function externalProductRESTRepository( httpClient: HTTPClient ): ListsEx return new ModelRepository( restList< ExternalProductRepositoryParams >( () => '/wc/v3/products', ExternalProduct, httpClient, transformer ), restCreate< ExternalProductRepositoryParams >( () => '/wc/v3/products', ExternalProduct, httpClient, transformer ), - restRead< ExternalProductRepositoryParams >( buildURL, ExternalProduct, httpClient, transformer ), - restUpdate< ExternalProductRepositoryParams >( buildURL, ExternalProduct, httpClient, transformer ), - restDelete< ExternalProductRepositoryParams >( buildURL, httpClient ), + restRead< ExternalProductRepositoryParams >( buildProductURL, ExternalProduct, httpClient, transformer ), + restUpdate< ExternalProductRepositoryParams >( buildProductURL, ExternalProduct, httpClient, transformer ), + restDelete< ExternalProductRepositoryParams >( buildProductURL, 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 e619c608f75..a1aa2f44040 100644 --- a/tests/e2e/api/src/repositories/rest/products/simple-product.ts +++ b/tests/e2e/api/src/repositories/rest/products/simple-product.ts @@ -2,7 +2,7 @@ import { HTTPClient } from '../../../http'; import { ModelRepository } from '../../../framework'; import { SimpleProduct, - ModelID, + buildProductURL, CreatesSimpleProducts, DeletesSimpleProducts, ListsSimpleProducts, @@ -44,8 +44,6 @@ export function simpleProductRESTRepository( httpClient: HTTPClient ): ListsSimp & ReadsSimpleProducts & UpdatesSimpleProducts & DeletesSimpleProducts { - const buildURL = ( id: ModelID ) => '/wc/v3/products/' + id; - const crossSells = createProductCrossSellsTransformation(); const delivery = createProductDeliveryTransformation(); const inventory = createProductInventoryTransformation(); @@ -66,8 +64,8 @@ export function simpleProductRESTRepository( httpClient: HTTPClient ): ListsSimp return new ModelRepository( restList< SimpleProductRepositoryParams >( () => '/wc/v3/products', SimpleProduct, httpClient, transformer ), restCreate< SimpleProductRepositoryParams >( () => '/wc/v3/products', SimpleProduct, httpClient, transformer ), - restRead< SimpleProductRepositoryParams >( buildURL, SimpleProduct, httpClient, transformer ), - restUpdate< SimpleProductRepositoryParams >( buildURL, SimpleProduct, httpClient, transformer ), - restDelete< SimpleProductRepositoryParams >( buildURL, httpClient ), + restRead< SimpleProductRepositoryParams >( buildProductURL, SimpleProduct, httpClient, transformer ), + restUpdate< SimpleProductRepositoryParams >( buildProductURL, SimpleProduct, httpClient, transformer ), + restDelete< SimpleProductRepositoryParams >( buildProductURL, httpClient ), ); }