1 import { HttpTypes } from "@medusajs/framework/types"
2
3 export const getProductFixture = (
4 overrides: Partial<HttpTypes.AdminCreateProduct>
5 ) => ({
6 title: "Test fixture",
7 description: "test-product-description",
8 status: "draft",
9 // BREAKING: Images input changed from string[] to {url: string}[]
10 images: [{ url: "test-image.png" }, { url: "test-image-2.png" }],
11 // BREAKING: Options input changed from {title: string}[] to {title: string, values: string[]}[]
12 options: [
13 { title: "size", values: ["large", "small"] },
14 { title: "color", values: ["green"] },
15 ],
16 variants: [
17 {
18 title: "Test variant",
19 prices: [
20 {
21 currency_code: "usd",
22 amount: 100,
23 },
24 {
25 currency_code: "eur",
26 amount: 45,
27 },
28 {
29 currency_code: "dkk",
30 amount: 30,
31 },
32 ],
33 // BREAKING: Options input changed from {value: string}[] to {[optionTitle]: optionValue} map
34 options: {
35 size: "large",
36 color: "green",
37 },
38 },
39 ],
40 ...(overrides ?? {}),
41 })
42
43 export const getPricelistFixture = (overrides: Partial<any>) => {
44 return {
45 // BREAKING: `name` field was renamed to `title`
46 title: "Winter sales",
47 description: "Winter sale. 25% off selected items.",
48 type: "sale",
49 status: "active",
50 starts_at: "2022-07-01T00:00:00.000Z",
51 ends_at: "2022-07-31T00:00:00.000Z",
52 // BREAKING: There is no explicit customer_groups field in v2, we use rules instead
53 // BREAKING: Variant ID is required in prices
54 // BREAKING: Currency code is required in prices
55 prices: [],
56 ...overrides,
57 }
58 }