Skip to content

Commit c810b43

Browse files
authored
Update fixture schemas, abstract test fixtures API client (#2371)
* Update fixture schemas * Abstract test fixtures API client * Refactor http client and errors
1 parent 2de3c51 commit c810b43

24 files changed

Lines changed: 866 additions & 802 deletions

File tree

core/tests/fixtures/catalog/index.ts

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,16 @@
11
import { testEnv } from '~/tests/environment';
22
import { Fixture } from '~/tests/fixtures/fixture';
3-
import { apiResponseSchema } from '~/tests/fixtures/utils/api/schema';
4-
5-
import { Product } from './product';
3+
import { Product } from '~/tests/fixtures/utils/api/catalog';
64

75
export class CatalogFixture extends Fixture {
8-
async getDefaultProduct(): Promise<Product> {
6+
getDefaultProduct(): Promise<Product> {
97
if (!testEnv.DEFAULT_PRODUCT_ID) {
108
throw new Error(
119
`DEFAULT_PRODUCT_ID is not set in the test environment variables and is required for the current test [${this.test.title}]`,
1210
);
1311
}
1412

15-
const resp = await this.api
16-
.get(`/v3/catalog/products/${testEnv.DEFAULT_PRODUCT_ID}`)
17-
.parse(apiResponseSchema(Product.schema));
18-
19-
return Product.fromApiResponse(resp.data);
20-
}
21-
22-
async getProductById(id: number): Promise<Product> {
23-
const resp = await this.api
24-
.get(`/v3/catalog/products/${id}`)
25-
.parse(apiResponseSchema(Product.schema));
26-
27-
return Product.fromApiResponse(resp.data);
13+
return this.api.catalog.getProductById(testEnv.DEFAULT_PRODUCT_ID);
2814
}
2915

3016
async cleanup() {

core/tests/fixtures/catalog/product.ts

Lines changed: 0 additions & 37 deletions
This file was deleted.

core/tests/fixtures/customer/address.ts

Lines changed: 0 additions & 97 deletions
This file was deleted.

core/tests/fixtures/customer/customer.ts

Lines changed: 0 additions & 86 deletions
This file was deleted.

0 commit comments

Comments
 (0)