@shopware-ag/acceptance-test-suite 2.5.0 → 2.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +78 -6
- package/dist/index.d.ts +78 -6
- package/dist/index.mjs +152 -99
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -195,6 +195,17 @@ type Product = Omit<components['schemas']['Product'], 'price' | 'prices'> & {
|
|
|
195
195
|
name: string;
|
|
196
196
|
};
|
|
197
197
|
};
|
|
198
|
+
type OrderDelivery = Omit<components['schemas']['OrderDelivery'], 'shippingOrderAddress' | 'shippingCosts'> & {
|
|
199
|
+
id: string;
|
|
200
|
+
shippingOrderAddress: Partial<components['schemas']['OrderAddress']>;
|
|
201
|
+
shippingCosts: {
|
|
202
|
+
unitPrice: number;
|
|
203
|
+
totalPrice: number;
|
|
204
|
+
quantity: number;
|
|
205
|
+
calculatedTaxes: CalculatedTaxes[];
|
|
206
|
+
taxRules: TaxRules[];
|
|
207
|
+
};
|
|
208
|
+
};
|
|
198
209
|
type Manufacturer = components['schemas']['ProductManufacturer'] & {
|
|
199
210
|
id: string;
|
|
200
211
|
};
|
|
@@ -216,7 +227,16 @@ type Rule = components['schemas']['Rule'] & {
|
|
|
216
227
|
type Currency$1 = components['schemas']['Currency'] & {
|
|
217
228
|
id: string;
|
|
218
229
|
};
|
|
219
|
-
|
|
230
|
+
interface CalculatedTaxes {
|
|
231
|
+
tax: number;
|
|
232
|
+
taxRate: number;
|
|
233
|
+
price: number;
|
|
234
|
+
}
|
|
235
|
+
interface TaxRules {
|
|
236
|
+
taxRate: number;
|
|
237
|
+
percentage: number;
|
|
238
|
+
}
|
|
239
|
+
type Order = Omit<components['schemas']['Order'], 'deliveries' | 'price'> & {
|
|
220
240
|
id: string;
|
|
221
241
|
orderCustomer: {
|
|
222
242
|
firstName: string;
|
|
@@ -229,7 +249,10 @@ type Order = components['schemas']['Order'] & {
|
|
|
229
249
|
rawTotal: number;
|
|
230
250
|
taxStatus: string;
|
|
231
251
|
totalPrice: number;
|
|
252
|
+
calculatedTaxes: CalculatedTaxes[];
|
|
253
|
+
taxRules: TaxRules[];
|
|
232
254
|
};
|
|
255
|
+
deliveries: Record<string, unknown>[];
|
|
233
256
|
};
|
|
234
257
|
type ShippingMethod = components['schemas']['ShippingMethod'] & {
|
|
235
258
|
id: string;
|
|
@@ -243,7 +266,19 @@ type StateMachine = components['schemas']['StateMachine'] & {
|
|
|
243
266
|
type StateMachineState = components['schemas']['StateMachineState'] & {
|
|
244
267
|
id: string;
|
|
245
268
|
};
|
|
246
|
-
type Promotion = components['schemas']['Promotion'] & {
|
|
269
|
+
type Promotion = Omit<components['schemas']['Promotion'], 'discounts'> & {
|
|
270
|
+
id: string;
|
|
271
|
+
discounts: [
|
|
272
|
+
{
|
|
273
|
+
id?: string;
|
|
274
|
+
scope: string;
|
|
275
|
+
type: string;
|
|
276
|
+
value: number;
|
|
277
|
+
considerAdvancedRules: boolean;
|
|
278
|
+
}
|
|
279
|
+
];
|
|
280
|
+
};
|
|
281
|
+
type PromotionDiscount = components['schemas']['PromotionDiscount'] & {
|
|
247
282
|
id: string;
|
|
248
283
|
};
|
|
249
284
|
|
|
@@ -252,7 +287,7 @@ interface CreatedRecord {
|
|
|
252
287
|
payload: Record<string, string>;
|
|
253
288
|
}
|
|
254
289
|
interface SimpleLineItem {
|
|
255
|
-
product: Product;
|
|
290
|
+
product: Product | Promotion;
|
|
256
291
|
quantity?: number;
|
|
257
292
|
position?: number;
|
|
258
293
|
}
|
|
@@ -410,12 +445,12 @@ declare class TestDataService {
|
|
|
410
445
|
*
|
|
411
446
|
* @param lineItems - Products that should be added to the order.
|
|
412
447
|
* @param customer - The customer to which the order should be assigned.
|
|
413
|
-
* @param salesChannel - The sales channel in which the order should be created.
|
|
414
448
|
* @param overrides - Specific data overrides that will be applied to the order data struct.
|
|
449
|
+
* @param salesChannel - The sales channel in which the order should be created.
|
|
415
450
|
*/
|
|
416
451
|
createOrder(lineItems: SimpleLineItem[], customer: Customer, overrides?: Partial<Order>, salesChannel?: SalesChannel): Promise<Order>;
|
|
417
452
|
/**
|
|
418
|
-
* Creates a new promotion with a promotion code.
|
|
453
|
+
* Creates a new promotion with a promotion code and only single discount option.
|
|
419
454
|
*
|
|
420
455
|
* @param overrides - Specific data overrides that will be applied to the promotion data struct.
|
|
421
456
|
* @param salesChannelId - The uuid of the sales channel in which the promotion should be active.
|
|
@@ -563,6 +598,9 @@ declare class TestDataService {
|
|
|
563
598
|
active: boolean;
|
|
564
599
|
} & Partial<Category$1>;
|
|
565
600
|
getBasicCustomerStruct(salesChannelId: string, customerGroupId: string, languageId: string, countryId: string, defaultPaymentMethodId: string, salutationId: string, overrides?: Partial<Customer>): Partial<Customer>;
|
|
601
|
+
getBasicOrderDeliveryStruct(deliveryState: StateMachineState, shippingMethod: ShippingMethod, customerAddress: CustomerAddress): Partial<OrderDelivery>;
|
|
602
|
+
isProduct(item: Product | Promotion): item is Product;
|
|
603
|
+
isPromotion(item: Product | Promotion): item is Promotion;
|
|
566
604
|
getBasicOrderStruct(lineItems: SimpleLineItem[], languageId: string, currency: Currency$1, paymentMethod: PaymentMethod, shippingMethod: ShippingMethod, orderState: StateMachineState, deliveryState: StateMachineState, transactionState: StateMachineState, customer: Customer, customerAddress: CustomerAddress, salesChannelId?: string, overrides?: Partial<Order>): Partial<Order>;
|
|
567
605
|
getBasicProductLineItemStruct(lineItem: SimpleLineItem): {
|
|
568
606
|
productId: string;
|
|
@@ -602,6 +640,36 @@ declare class TestDataService {
|
|
|
602
640
|
referencePriceDefinition: null;
|
|
603
641
|
};
|
|
604
642
|
};
|
|
643
|
+
getBasicPromotionLineItemStruct(lineItem: SimpleLineItem): {
|
|
644
|
+
payload: {
|
|
645
|
+
code: string | undefined;
|
|
646
|
+
};
|
|
647
|
+
identifier: string | undefined;
|
|
648
|
+
type: string;
|
|
649
|
+
label: string;
|
|
650
|
+
description: string;
|
|
651
|
+
quantity: number;
|
|
652
|
+
position: number;
|
|
653
|
+
price: {
|
|
654
|
+
unitPrice: number;
|
|
655
|
+
totalPrice: number;
|
|
656
|
+
quantity: number | undefined;
|
|
657
|
+
calculatedTaxes: {
|
|
658
|
+
tax: number;
|
|
659
|
+
taxRate: number;
|
|
660
|
+
price: number;
|
|
661
|
+
}[];
|
|
662
|
+
taxRules: {
|
|
663
|
+
taxRate: number;
|
|
664
|
+
percentage: number;
|
|
665
|
+
}[];
|
|
666
|
+
};
|
|
667
|
+
priceDefinition: {
|
|
668
|
+
type: string;
|
|
669
|
+
price: number;
|
|
670
|
+
percentage: number | null;
|
|
671
|
+
};
|
|
672
|
+
};
|
|
605
673
|
getBasicPromotionStruct(salesChannelId?: string, overrides?: Partial<Promotion>): Partial<Promotion>;
|
|
606
674
|
}
|
|
607
675
|
|
|
@@ -1107,6 +1175,10 @@ declare const getMediaId: (fileName: string, adminApiContext: AdminApiContext) =
|
|
|
1107
1175
|
declare function extractIdFromUrl(url: string): string | null;
|
|
1108
1176
|
type OrderStatus = 'cancel' | 'complete' | 'reopen' | 'process';
|
|
1109
1177
|
declare const setOrderStatus: (orderId: string, orderStatus: OrderStatus, adminApiContext: AdminApiContext) => Promise<APIResponse>;
|
|
1178
|
+
/**
|
|
1179
|
+
* Return a single promotion entity with a fetched single discount entity
|
|
1180
|
+
*/
|
|
1181
|
+
declare const getPromotionWithDiscount: (promotionId: string, adminApiContext: AdminApiContext) => Promise<Promotion>;
|
|
1110
1182
|
|
|
1111
1183
|
declare const isSaaSInstance: (adminApiContext: AdminApiContext) => Promise<boolean>;
|
|
1112
1184
|
declare const isThemeCompiled: (context: AdminApiContext, storefrontUrl: string) => Promise<boolean>;
|
|
@@ -1149,4 +1221,4 @@ declare const test: _playwright_test.TestType<_playwright_test.PlaywrightTestArg
|
|
|
1149
1221
|
ValidateAccessibility: (pageName: string, assertViolations?: number | boolean | undefined, createReport?: boolean | undefined, ruleTags?: string[] | undefined, outputDir?: string | undefined) => () => Promise<axe_core.Result[]>;
|
|
1150
1222
|
}, _playwright_test.PlaywrightWorkerArgs & _playwright_test.PlaywrightWorkerOptions & FixtureTypes>;
|
|
1151
1223
|
|
|
1152
|
-
export { AdminPageObjects, type Category$1 as Category, type CreatedRecord, type Currency$1 as Currency, type Customer, type CustomerAddress, type DataServiceOptions, type FixtureTypes, type Manufacturer, type Media, type Order, type PageObject, type PaymentMethod, type Price, type Product, type ProductPrice, type Promotion, type PropertyGroup, type Rule, type SalesChannel, type Salutation, type ShippingMethod, type SimpleLineItem, type StateMachine, type StateMachineState, StorefrontPageObjects, type SyncApiOperation, type Tag, type Task, TestDataService, createRandomImage, extractIdFromUrl, getCountryId, getCurrency, getDefaultShippingMethodId, getFlowId, getLanguageData, getMediaId, getOrderTransactionId, getPaymentMethodId, getSalutationId, getSnippetSetId, getStateMachineId, getStateMachineStateId, getTaxId, getThemeId, isSaaSInstance, isThemeCompiled, setOrderStatus, test };
|
|
1224
|
+
export { AdminPageObjects, type CalculatedTaxes, type Category$1 as Category, type CreatedRecord, type Currency$1 as Currency, type Customer, type CustomerAddress, type DataServiceOptions, type FixtureTypes, type Manufacturer, type Media, type Order, type OrderDelivery, type PageObject, type PaymentMethod, type Price, type Product, type ProductPrice, type Promotion, type PromotionDiscount, type PropertyGroup, type Rule, type SalesChannel, type Salutation, type ShippingMethod, type SimpleLineItem, type StateMachine, type StateMachineState, StorefrontPageObjects, type SyncApiOperation, type Tag, type Task, type TaxRules, TestDataService, createRandomImage, extractIdFromUrl, getCountryId, getCurrency, getDefaultShippingMethodId, getFlowId, getLanguageData, getMediaId, getOrderTransactionId, getPaymentMethodId, getPromotionWithDiscount, getSalutationId, getSnippetSetId, getStateMachineId, getStateMachineStateId, getTaxId, getThemeId, isSaaSInstance, isThemeCompiled, setOrderStatus, test };
|
package/dist/index.d.ts
CHANGED
|
@@ -195,6 +195,17 @@ type Product = Omit<components['schemas']['Product'], 'price' | 'prices'> & {
|
|
|
195
195
|
name: string;
|
|
196
196
|
};
|
|
197
197
|
};
|
|
198
|
+
type OrderDelivery = Omit<components['schemas']['OrderDelivery'], 'shippingOrderAddress' | 'shippingCosts'> & {
|
|
199
|
+
id: string;
|
|
200
|
+
shippingOrderAddress: Partial<components['schemas']['OrderAddress']>;
|
|
201
|
+
shippingCosts: {
|
|
202
|
+
unitPrice: number;
|
|
203
|
+
totalPrice: number;
|
|
204
|
+
quantity: number;
|
|
205
|
+
calculatedTaxes: CalculatedTaxes[];
|
|
206
|
+
taxRules: TaxRules[];
|
|
207
|
+
};
|
|
208
|
+
};
|
|
198
209
|
type Manufacturer = components['schemas']['ProductManufacturer'] & {
|
|
199
210
|
id: string;
|
|
200
211
|
};
|
|
@@ -216,7 +227,16 @@ type Rule = components['schemas']['Rule'] & {
|
|
|
216
227
|
type Currency$1 = components['schemas']['Currency'] & {
|
|
217
228
|
id: string;
|
|
218
229
|
};
|
|
219
|
-
|
|
230
|
+
interface CalculatedTaxes {
|
|
231
|
+
tax: number;
|
|
232
|
+
taxRate: number;
|
|
233
|
+
price: number;
|
|
234
|
+
}
|
|
235
|
+
interface TaxRules {
|
|
236
|
+
taxRate: number;
|
|
237
|
+
percentage: number;
|
|
238
|
+
}
|
|
239
|
+
type Order = Omit<components['schemas']['Order'], 'deliveries' | 'price'> & {
|
|
220
240
|
id: string;
|
|
221
241
|
orderCustomer: {
|
|
222
242
|
firstName: string;
|
|
@@ -229,7 +249,10 @@ type Order = components['schemas']['Order'] & {
|
|
|
229
249
|
rawTotal: number;
|
|
230
250
|
taxStatus: string;
|
|
231
251
|
totalPrice: number;
|
|
252
|
+
calculatedTaxes: CalculatedTaxes[];
|
|
253
|
+
taxRules: TaxRules[];
|
|
232
254
|
};
|
|
255
|
+
deliveries: Record<string, unknown>[];
|
|
233
256
|
};
|
|
234
257
|
type ShippingMethod = components['schemas']['ShippingMethod'] & {
|
|
235
258
|
id: string;
|
|
@@ -243,7 +266,19 @@ type StateMachine = components['schemas']['StateMachine'] & {
|
|
|
243
266
|
type StateMachineState = components['schemas']['StateMachineState'] & {
|
|
244
267
|
id: string;
|
|
245
268
|
};
|
|
246
|
-
type Promotion = components['schemas']['Promotion'] & {
|
|
269
|
+
type Promotion = Omit<components['schemas']['Promotion'], 'discounts'> & {
|
|
270
|
+
id: string;
|
|
271
|
+
discounts: [
|
|
272
|
+
{
|
|
273
|
+
id?: string;
|
|
274
|
+
scope: string;
|
|
275
|
+
type: string;
|
|
276
|
+
value: number;
|
|
277
|
+
considerAdvancedRules: boolean;
|
|
278
|
+
}
|
|
279
|
+
];
|
|
280
|
+
};
|
|
281
|
+
type PromotionDiscount = components['schemas']['PromotionDiscount'] & {
|
|
247
282
|
id: string;
|
|
248
283
|
};
|
|
249
284
|
|
|
@@ -252,7 +287,7 @@ interface CreatedRecord {
|
|
|
252
287
|
payload: Record<string, string>;
|
|
253
288
|
}
|
|
254
289
|
interface SimpleLineItem {
|
|
255
|
-
product: Product;
|
|
290
|
+
product: Product | Promotion;
|
|
256
291
|
quantity?: number;
|
|
257
292
|
position?: number;
|
|
258
293
|
}
|
|
@@ -410,12 +445,12 @@ declare class TestDataService {
|
|
|
410
445
|
*
|
|
411
446
|
* @param lineItems - Products that should be added to the order.
|
|
412
447
|
* @param customer - The customer to which the order should be assigned.
|
|
413
|
-
* @param salesChannel - The sales channel in which the order should be created.
|
|
414
448
|
* @param overrides - Specific data overrides that will be applied to the order data struct.
|
|
449
|
+
* @param salesChannel - The sales channel in which the order should be created.
|
|
415
450
|
*/
|
|
416
451
|
createOrder(lineItems: SimpleLineItem[], customer: Customer, overrides?: Partial<Order>, salesChannel?: SalesChannel): Promise<Order>;
|
|
417
452
|
/**
|
|
418
|
-
* Creates a new promotion with a promotion code.
|
|
453
|
+
* Creates a new promotion with a promotion code and only single discount option.
|
|
419
454
|
*
|
|
420
455
|
* @param overrides - Specific data overrides that will be applied to the promotion data struct.
|
|
421
456
|
* @param salesChannelId - The uuid of the sales channel in which the promotion should be active.
|
|
@@ -563,6 +598,9 @@ declare class TestDataService {
|
|
|
563
598
|
active: boolean;
|
|
564
599
|
} & Partial<Category$1>;
|
|
565
600
|
getBasicCustomerStruct(salesChannelId: string, customerGroupId: string, languageId: string, countryId: string, defaultPaymentMethodId: string, salutationId: string, overrides?: Partial<Customer>): Partial<Customer>;
|
|
601
|
+
getBasicOrderDeliveryStruct(deliveryState: StateMachineState, shippingMethod: ShippingMethod, customerAddress: CustomerAddress): Partial<OrderDelivery>;
|
|
602
|
+
isProduct(item: Product | Promotion): item is Product;
|
|
603
|
+
isPromotion(item: Product | Promotion): item is Promotion;
|
|
566
604
|
getBasicOrderStruct(lineItems: SimpleLineItem[], languageId: string, currency: Currency$1, paymentMethod: PaymentMethod, shippingMethod: ShippingMethod, orderState: StateMachineState, deliveryState: StateMachineState, transactionState: StateMachineState, customer: Customer, customerAddress: CustomerAddress, salesChannelId?: string, overrides?: Partial<Order>): Partial<Order>;
|
|
567
605
|
getBasicProductLineItemStruct(lineItem: SimpleLineItem): {
|
|
568
606
|
productId: string;
|
|
@@ -602,6 +640,36 @@ declare class TestDataService {
|
|
|
602
640
|
referencePriceDefinition: null;
|
|
603
641
|
};
|
|
604
642
|
};
|
|
643
|
+
getBasicPromotionLineItemStruct(lineItem: SimpleLineItem): {
|
|
644
|
+
payload: {
|
|
645
|
+
code: string | undefined;
|
|
646
|
+
};
|
|
647
|
+
identifier: string | undefined;
|
|
648
|
+
type: string;
|
|
649
|
+
label: string;
|
|
650
|
+
description: string;
|
|
651
|
+
quantity: number;
|
|
652
|
+
position: number;
|
|
653
|
+
price: {
|
|
654
|
+
unitPrice: number;
|
|
655
|
+
totalPrice: number;
|
|
656
|
+
quantity: number | undefined;
|
|
657
|
+
calculatedTaxes: {
|
|
658
|
+
tax: number;
|
|
659
|
+
taxRate: number;
|
|
660
|
+
price: number;
|
|
661
|
+
}[];
|
|
662
|
+
taxRules: {
|
|
663
|
+
taxRate: number;
|
|
664
|
+
percentage: number;
|
|
665
|
+
}[];
|
|
666
|
+
};
|
|
667
|
+
priceDefinition: {
|
|
668
|
+
type: string;
|
|
669
|
+
price: number;
|
|
670
|
+
percentage: number | null;
|
|
671
|
+
};
|
|
672
|
+
};
|
|
605
673
|
getBasicPromotionStruct(salesChannelId?: string, overrides?: Partial<Promotion>): Partial<Promotion>;
|
|
606
674
|
}
|
|
607
675
|
|
|
@@ -1107,6 +1175,10 @@ declare const getMediaId: (fileName: string, adminApiContext: AdminApiContext) =
|
|
|
1107
1175
|
declare function extractIdFromUrl(url: string): string | null;
|
|
1108
1176
|
type OrderStatus = 'cancel' | 'complete' | 'reopen' | 'process';
|
|
1109
1177
|
declare const setOrderStatus: (orderId: string, orderStatus: OrderStatus, adminApiContext: AdminApiContext) => Promise<APIResponse>;
|
|
1178
|
+
/**
|
|
1179
|
+
* Return a single promotion entity with a fetched single discount entity
|
|
1180
|
+
*/
|
|
1181
|
+
declare const getPromotionWithDiscount: (promotionId: string, adminApiContext: AdminApiContext) => Promise<Promotion>;
|
|
1110
1182
|
|
|
1111
1183
|
declare const isSaaSInstance: (adminApiContext: AdminApiContext) => Promise<boolean>;
|
|
1112
1184
|
declare const isThemeCompiled: (context: AdminApiContext, storefrontUrl: string) => Promise<boolean>;
|
|
@@ -1149,4 +1221,4 @@ declare const test: _playwright_test.TestType<_playwright_test.PlaywrightTestArg
|
|
|
1149
1221
|
ValidateAccessibility: (pageName: string, assertViolations?: number | boolean | undefined, createReport?: boolean | undefined, ruleTags?: string[] | undefined, outputDir?: string | undefined) => () => Promise<axe_core.Result[]>;
|
|
1150
1222
|
}, _playwright_test.PlaywrightWorkerArgs & _playwright_test.PlaywrightWorkerOptions & FixtureTypes>;
|
|
1151
1223
|
|
|
1152
|
-
export { AdminPageObjects, type Category$1 as Category, type CreatedRecord, type Currency$1 as Currency, type Customer, type CustomerAddress, type DataServiceOptions, type FixtureTypes, type Manufacturer, type Media, type Order, type PageObject, type PaymentMethod, type Price, type Product, type ProductPrice, type Promotion, type PropertyGroup, type Rule, type SalesChannel, type Salutation, type ShippingMethod, type SimpleLineItem, type StateMachine, type StateMachineState, StorefrontPageObjects, type SyncApiOperation, type Tag, type Task, TestDataService, createRandomImage, extractIdFromUrl, getCountryId, getCurrency, getDefaultShippingMethodId, getFlowId, getLanguageData, getMediaId, getOrderTransactionId, getPaymentMethodId, getSalutationId, getSnippetSetId, getStateMachineId, getStateMachineStateId, getTaxId, getThemeId, isSaaSInstance, isThemeCompiled, setOrderStatus, test };
|
|
1224
|
+
export { AdminPageObjects, type CalculatedTaxes, type Category$1 as Category, type CreatedRecord, type Currency$1 as Currency, type Customer, type CustomerAddress, type DataServiceOptions, type FixtureTypes, type Manufacturer, type Media, type Order, type OrderDelivery, type PageObject, type PaymentMethod, type Price, type Product, type ProductPrice, type Promotion, type PromotionDiscount, type PropertyGroup, type Rule, type SalesChannel, type Salutation, type ShippingMethod, type SimpleLineItem, type StateMachine, type StateMachineState, StorefrontPageObjects, type SyncApiOperation, type Tag, type Task, type TaxRules, TestDataService, createRandomImage, extractIdFromUrl, getCountryId, getCurrency, getDefaultShippingMethodId, getFlowId, getLanguageData, getMediaId, getOrderTransactionId, getPaymentMethodId, getPromotionWithDiscount, getSalutationId, getSnippetSetId, getStateMachineId, getStateMachineStateId, getTaxId, getThemeId, isSaaSInstance, isThemeCompiled, setOrderStatus, test };
|
package/dist/index.mjs
CHANGED
|
@@ -202,6 +202,28 @@ function extractIdFromUrl(url) {
|
|
|
202
202
|
const setOrderStatus = async (orderId, orderStatus, adminApiContext) => {
|
|
203
203
|
return await adminApiContext.post(`./_action/order/${orderId}/state/${orderStatus}`);
|
|
204
204
|
};
|
|
205
|
+
const getPromotionWithDiscount = async (promotionId, adminApiContext) => {
|
|
206
|
+
const resp = await adminApiContext.post("search/promotion", {
|
|
207
|
+
data: {
|
|
208
|
+
limit: 1,
|
|
209
|
+
associations: {
|
|
210
|
+
discounts: {
|
|
211
|
+
limit: 10,
|
|
212
|
+
type: "equals",
|
|
213
|
+
field: "promotionId",
|
|
214
|
+
value: promotionId
|
|
215
|
+
}
|
|
216
|
+
},
|
|
217
|
+
filter: [{
|
|
218
|
+
type: "equals",
|
|
219
|
+
field: "id",
|
|
220
|
+
value: promotionId
|
|
221
|
+
}]
|
|
222
|
+
}
|
|
223
|
+
});
|
|
224
|
+
const { data: promotion } = await resp.json();
|
|
225
|
+
return promotion[0];
|
|
226
|
+
};
|
|
205
227
|
|
|
206
228
|
const test$b = test$d.extend({
|
|
207
229
|
SalesChannelBaseConfig: [
|
|
@@ -247,51 +269,6 @@ const test$b = test$d.extend({
|
|
|
247
269
|
const { uuid: customerUuid } = IdProvider.getWorkerDerivedStableId("customer");
|
|
248
270
|
const baseUrl = `${SalesChannelBaseConfig.appUrl}test-${uuid}/`;
|
|
249
271
|
await AdminApiContext.delete(`./customer/${customerUuid}`);
|
|
250
|
-
const ordersResp = await AdminApiContext.post(`./search/order`, {
|
|
251
|
-
data: {
|
|
252
|
-
filter: [{
|
|
253
|
-
type: "equals",
|
|
254
|
-
field: "salesChannelId",
|
|
255
|
-
value: uuid
|
|
256
|
-
}]
|
|
257
|
-
}
|
|
258
|
-
});
|
|
259
|
-
const orders = await ordersResp.json();
|
|
260
|
-
if (orders.data) {
|
|
261
|
-
for (const order of orders.data) {
|
|
262
|
-
const deleteOrderResp = await AdminApiContext.delete(`./order/${order.id}`);
|
|
263
|
-
expect(deleteOrderResp.ok()).toBeTruthy();
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
const versionsResp = await AdminApiContext.post(`./search/version`);
|
|
267
|
-
expect(versionsResp.ok()).toBeTruthy();
|
|
268
|
-
const versions = await versionsResp.json();
|
|
269
|
-
const versionIds = versions.data.map((v) => v.id);
|
|
270
|
-
for (const versionId of versionIds) {
|
|
271
|
-
const ordersResp2 = await AdminApiContext.post(`./search/order`, {
|
|
272
|
-
data: {
|
|
273
|
-
filter: [
|
|
274
|
-
{
|
|
275
|
-
type: "equals",
|
|
276
|
-
field: "salesChannelId",
|
|
277
|
-
value: uuid
|
|
278
|
-
}
|
|
279
|
-
]
|
|
280
|
-
},
|
|
281
|
-
headers: {
|
|
282
|
-
"sw-version-id": versionId
|
|
283
|
-
}
|
|
284
|
-
});
|
|
285
|
-
const orders2 = await ordersResp2.json();
|
|
286
|
-
if (orders2.data) {
|
|
287
|
-
for (const order of orders2.data) {
|
|
288
|
-
const deleteOrderResp = await AdminApiContext.post(
|
|
289
|
-
`./_action/version/${versionId}/order/${order.id}`
|
|
290
|
-
);
|
|
291
|
-
expect(deleteOrderResp.ok()).toBeTruthy();
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
272
|
const syncResp = await AdminApiContext.post("./_action/sync", {
|
|
296
273
|
data: {
|
|
297
274
|
"write-sales-channel": {
|
|
@@ -1223,8 +1200,8 @@ class TestDataService {
|
|
|
1223
1200
|
*
|
|
1224
1201
|
* @param lineItems - Products that should be added to the order.
|
|
1225
1202
|
* @param customer - The customer to which the order should be assigned.
|
|
1226
|
-
* @param salesChannel - The sales channel in which the order should be created.
|
|
1227
1203
|
* @param overrides - Specific data overrides that will be applied to the order data struct.
|
|
1204
|
+
* @param salesChannel - The sales channel in which the order should be created.
|
|
1228
1205
|
*/
|
|
1229
1206
|
async createOrder(lineItems, customer, overrides = {}, salesChannel = this.defaultSalesChannel) {
|
|
1230
1207
|
const orderStateMachine = await this.getOrderStateMachine();
|
|
@@ -1260,7 +1237,7 @@ class TestDataService {
|
|
|
1260
1237
|
return order;
|
|
1261
1238
|
}
|
|
1262
1239
|
/**
|
|
1263
|
-
* Creates a new promotion with a promotion code.
|
|
1240
|
+
* Creates a new promotion with a promotion code and only single discount option.
|
|
1264
1241
|
*
|
|
1265
1242
|
* @param overrides - Specific data overrides that will be applied to the promotion data struct.
|
|
1266
1243
|
* @param salesChannelId - The uuid of the sales channel in which the promotion should be active.
|
|
@@ -1271,8 +1248,9 @@ class TestDataService {
|
|
|
1271
1248
|
data: basicPromotion
|
|
1272
1249
|
});
|
|
1273
1250
|
const { data: promotion } = await promotionResponse.json();
|
|
1251
|
+
const promotionWithDiscount = await getPromotionWithDiscount(promotion.id, this.AdminApiClient);
|
|
1274
1252
|
this.addCreatedRecord("promotion", promotion.id);
|
|
1275
|
-
return
|
|
1253
|
+
return promotionWithDiscount;
|
|
1276
1254
|
}
|
|
1277
1255
|
/**
|
|
1278
1256
|
* Assigns a media resource as the download of a digital product.
|
|
@@ -1763,18 +1741,84 @@ class TestDataService {
|
|
|
1763
1741
|
};
|
|
1764
1742
|
return Object.assign({}, basicCustomer, overrides);
|
|
1765
1743
|
}
|
|
1744
|
+
getBasicOrderDeliveryStruct(deliveryState, shippingMethod, customerAddress) {
|
|
1745
|
+
const date = /* @__PURE__ */ new Date();
|
|
1746
|
+
const shippingDate = new Date(date);
|
|
1747
|
+
shippingDate.setDate(shippingDate.getDate() + 3);
|
|
1748
|
+
const shippingDateTime = this.convertDateTime(shippingDate);
|
|
1749
|
+
const shippingCosts = 8.99;
|
|
1750
|
+
return {
|
|
1751
|
+
stateId: deliveryState.id,
|
|
1752
|
+
shippingMethodId: shippingMethod.id,
|
|
1753
|
+
shippingOrderAddress: {
|
|
1754
|
+
id: customerAddress.id,
|
|
1755
|
+
salutationId: customerAddress.salutationId,
|
|
1756
|
+
firstName: customerAddress.firstName,
|
|
1757
|
+
lastName: customerAddress.lastName,
|
|
1758
|
+
street: customerAddress.street,
|
|
1759
|
+
zipcode: customerAddress.zipcode,
|
|
1760
|
+
city: customerAddress.city,
|
|
1761
|
+
countryId: customerAddress.countryId,
|
|
1762
|
+
phoneNumber: customerAddress.phoneNumber
|
|
1763
|
+
},
|
|
1764
|
+
shippingDateEarliest: shippingDateTime,
|
|
1765
|
+
shippingDateLatest: shippingDateTime,
|
|
1766
|
+
shippingCosts: {
|
|
1767
|
+
unitPrice: shippingCosts,
|
|
1768
|
+
totalPrice: shippingCosts,
|
|
1769
|
+
quantity: 1,
|
|
1770
|
+
calculatedTaxes: [
|
|
1771
|
+
{
|
|
1772
|
+
tax: 0,
|
|
1773
|
+
taxRate: 0,
|
|
1774
|
+
price: shippingCosts
|
|
1775
|
+
}
|
|
1776
|
+
],
|
|
1777
|
+
taxRules: [
|
|
1778
|
+
{
|
|
1779
|
+
taxRate: 0,
|
|
1780
|
+
percentage: 100
|
|
1781
|
+
}
|
|
1782
|
+
]
|
|
1783
|
+
}
|
|
1784
|
+
};
|
|
1785
|
+
}
|
|
1786
|
+
isProduct(item) {
|
|
1787
|
+
return item.productNumber !== void 0;
|
|
1788
|
+
}
|
|
1789
|
+
isPromotion(item) {
|
|
1790
|
+
return item.code !== void 0;
|
|
1791
|
+
}
|
|
1766
1792
|
getBasicOrderStruct(lineItems, languageId, currency, paymentMethod, shippingMethod, orderState, deliveryState, transactionState, customer, customerAddress, salesChannelId = this.defaultSalesChannel.id, overrides = {}) {
|
|
1767
1793
|
const date = /* @__PURE__ */ new Date();
|
|
1768
1794
|
const orderDateTime = this.convertDateTime(date);
|
|
1769
|
-
const shippingDate = new Date(date.getDate() + 3);
|
|
1770
|
-
const shippingDateTime = this.convertDateTime(shippingDate);
|
|
1771
1795
|
let totalPrice = 0;
|
|
1772
|
-
const
|
|
1796
|
+
const orderLineItems = [];
|
|
1773
1797
|
lineItems.forEach((lineItem) => {
|
|
1774
|
-
|
|
1775
|
-
|
|
1798
|
+
if (this.isProduct(lineItem.product)) {
|
|
1799
|
+
const product = lineItem.product;
|
|
1800
|
+
orderLineItems.push(this.getBasicProductLineItemStruct(lineItem));
|
|
1801
|
+
totalPrice += product.price[0].gross * (lineItem.quantity || 1);
|
|
1802
|
+
}
|
|
1803
|
+
if (this.isPromotion(lineItem.product)) {
|
|
1804
|
+
const promotion = lineItem.product;
|
|
1805
|
+
orderLineItems.push(this.getBasicPromotionLineItemStruct(lineItem));
|
|
1806
|
+
const promotionDiscountValue = promotion.discounts[0].value;
|
|
1807
|
+
const promotionDiscountType = promotion.discounts[0].type;
|
|
1808
|
+
if (promotionDiscountType === "absolute") {
|
|
1809
|
+
totalPrice -= (promotionDiscountValue || 10) * (lineItem.quantity || 1);
|
|
1810
|
+
} else if (promotionDiscountType === "percentage") {
|
|
1811
|
+
totalPrice -= promotionDiscountValue * totalPrice / 100 * (lineItem.quantity || 1);
|
|
1812
|
+
} else if (promotionDiscountType === "fixed_unit") {
|
|
1813
|
+
totalPrice = (promotionDiscountValue || 10) * (lineItem.quantity || 1);
|
|
1814
|
+
}
|
|
1815
|
+
}
|
|
1776
1816
|
});
|
|
1777
|
-
const
|
|
1817
|
+
const orderDelivery = this.getBasicOrderDeliveryStruct(deliveryState, shippingMethod, customerAddress);
|
|
1818
|
+
let shippingCosts = 0;
|
|
1819
|
+
if (orderDelivery.shippingCosts != null) {
|
|
1820
|
+
shippingCosts = orderDelivery.shippingCosts.totalPrice;
|
|
1821
|
+
}
|
|
1778
1822
|
totalPrice += shippingCosts;
|
|
1779
1823
|
const basicOrder = {
|
|
1780
1824
|
orderNumber: this.IdProvider.getIdPair().id,
|
|
@@ -1832,44 +1876,8 @@ class TestDataService {
|
|
|
1832
1876
|
percentage: 100
|
|
1833
1877
|
}]
|
|
1834
1878
|
},
|
|
1835
|
-
lineItems:
|
|
1836
|
-
deliveries: [
|
|
1837
|
-
{
|
|
1838
|
-
stateId: deliveryState.id,
|
|
1839
|
-
shippingMethodId: shippingMethod.id,
|
|
1840
|
-
shippingOrderAddress: {
|
|
1841
|
-
id: customerAddress.id,
|
|
1842
|
-
salutationId: customerAddress.salutationId,
|
|
1843
|
-
firstName: customerAddress.firstName,
|
|
1844
|
-
lastName: customerAddress.lastName,
|
|
1845
|
-
street: customerAddress.street,
|
|
1846
|
-
zipcode: customerAddress.zipcode,
|
|
1847
|
-
city: customerAddress.city,
|
|
1848
|
-
countryId: customerAddress.countryId,
|
|
1849
|
-
phoneNumber: customerAddress.phoneNumber
|
|
1850
|
-
},
|
|
1851
|
-
shippingDateEarliest: shippingDateTime,
|
|
1852
|
-
shippingDateLatest: shippingDateTime,
|
|
1853
|
-
shippingCosts: {
|
|
1854
|
-
unitPrice: shippingCosts,
|
|
1855
|
-
totalPrice: shippingCosts,
|
|
1856
|
-
quantity: 1,
|
|
1857
|
-
calculatedTaxes: [
|
|
1858
|
-
{
|
|
1859
|
-
tax: 0,
|
|
1860
|
-
taxRate: 0,
|
|
1861
|
-
price: shippingCosts
|
|
1862
|
-
}
|
|
1863
|
-
],
|
|
1864
|
-
taxRules: [
|
|
1865
|
-
{
|
|
1866
|
-
taxRate: 0,
|
|
1867
|
-
percentage: 100
|
|
1868
|
-
}
|
|
1869
|
-
]
|
|
1870
|
-
}
|
|
1871
|
-
}
|
|
1872
|
-
],
|
|
1879
|
+
lineItems: orderLineItems,
|
|
1880
|
+
deliveries: [orderDelivery],
|
|
1873
1881
|
transactions: [
|
|
1874
1882
|
{
|
|
1875
1883
|
paymentMethodId: paymentMethod.id,
|
|
@@ -1898,17 +1906,21 @@ class TestDataService {
|
|
|
1898
1906
|
return Object.assign({}, basicOrder, overrides);
|
|
1899
1907
|
}
|
|
1900
1908
|
getBasicProductLineItemStruct(lineItem) {
|
|
1901
|
-
|
|
1909
|
+
if (!this.isProduct(lineItem.product)) {
|
|
1910
|
+
console.error("Error: Object is not of type Product");
|
|
1911
|
+
}
|
|
1912
|
+
const product = lineItem.product;
|
|
1913
|
+
const unitPrice = product.price[0].gross || 10;
|
|
1902
1914
|
const totalPrice = unitPrice * (lineItem.quantity || 1);
|
|
1903
1915
|
return {
|
|
1904
|
-
productId:
|
|
1905
|
-
referencedId:
|
|
1916
|
+
productId: product.id,
|
|
1917
|
+
referencedId: product.id,
|
|
1906
1918
|
payload: {
|
|
1907
|
-
productNumber:
|
|
1919
|
+
productNumber: product.productNumber
|
|
1908
1920
|
},
|
|
1909
|
-
identifier:
|
|
1921
|
+
identifier: product.id,
|
|
1910
1922
|
type: "product",
|
|
1911
|
-
label:
|
|
1923
|
+
label: product.name,
|
|
1912
1924
|
quantity: lineItem.quantity || 1,
|
|
1913
1925
|
position: lineItem.position || 1,
|
|
1914
1926
|
price: {
|
|
@@ -1939,6 +1951,47 @@ class TestDataService {
|
|
|
1939
1951
|
}
|
|
1940
1952
|
};
|
|
1941
1953
|
}
|
|
1954
|
+
getBasicPromotionLineItemStruct(lineItem) {
|
|
1955
|
+
if (!this.isPromotion(lineItem.product)) {
|
|
1956
|
+
console.error("Error: Object is not of type Promotion");
|
|
1957
|
+
}
|
|
1958
|
+
const promotion = lineItem.product;
|
|
1959
|
+
const promotionDiscountValue = promotion.discounts[0].value;
|
|
1960
|
+
const promotionDiscountType = promotion.discounts[0].type;
|
|
1961
|
+
const promotionDiscountId = promotion.discounts[0].id;
|
|
1962
|
+
const unitPrice = -Math.abs(promotionDiscountValue || 10);
|
|
1963
|
+
const totalPrice = unitPrice * (lineItem.quantity || 1);
|
|
1964
|
+
return {
|
|
1965
|
+
payload: {
|
|
1966
|
+
code: promotion.code
|
|
1967
|
+
},
|
|
1968
|
+
identifier: promotionDiscountId,
|
|
1969
|
+
type: "promotion",
|
|
1970
|
+
label: promotion.name,
|
|
1971
|
+
description: promotion.name,
|
|
1972
|
+
quantity: lineItem.quantity || 1,
|
|
1973
|
+
position: lineItem.position || 1,
|
|
1974
|
+
price: {
|
|
1975
|
+
unitPrice,
|
|
1976
|
+
totalPrice,
|
|
1977
|
+
quantity: lineItem.quantity,
|
|
1978
|
+
calculatedTaxes: [{
|
|
1979
|
+
tax: 0,
|
|
1980
|
+
taxRate: 0,
|
|
1981
|
+
price: totalPrice
|
|
1982
|
+
}],
|
|
1983
|
+
taxRules: [{
|
|
1984
|
+
taxRate: 0,
|
|
1985
|
+
percentage: 100
|
|
1986
|
+
}]
|
|
1987
|
+
},
|
|
1988
|
+
priceDefinition: {
|
|
1989
|
+
type: promotionDiscountType,
|
|
1990
|
+
price: totalPrice,
|
|
1991
|
+
percentage: promotionDiscountType === "percentage" ? promotionDiscountValue : null
|
|
1992
|
+
}
|
|
1993
|
+
};
|
|
1994
|
+
}
|
|
1942
1995
|
getBasicPromotionStruct(salesChannelId = this.defaultSalesChannel.id, overrides = {}) {
|
|
1943
1996
|
const promotionCode = `${this.IdProvider.getIdPair().id}`;
|
|
1944
1997
|
const promotionName = `${this.namePrefix}Promotion-${promotionCode}${this.nameSuffix}`;
|
|
@@ -3782,4 +3835,4 @@ const test = mergeTests(
|
|
|
3782
3835
|
test$1
|
|
3783
3836
|
);
|
|
3784
3837
|
|
|
3785
|
-
export { AdminPageObjects, StorefrontPageObjects, TestDataService, createRandomImage, extractIdFromUrl, getCountryId, getCurrency, getDefaultShippingMethodId, getFlowId, getLanguageData, getMediaId, getOrderTransactionId, getPaymentMethodId, getSalutationId, getSnippetSetId, getStateMachineId, getStateMachineStateId, getTaxId, getThemeId, isSaaSInstance, isThemeCompiled, setOrderStatus, test };
|
|
3838
|
+
export { AdminPageObjects, StorefrontPageObjects, TestDataService, createRandomImage, extractIdFromUrl, getCountryId, getCurrency, getDefaultShippingMethodId, getFlowId, getLanguageData, getMediaId, getOrderTransactionId, getPaymentMethodId, getPromotionWithDiscount, getSalutationId, getSnippetSetId, getStateMachineId, getStateMachineStateId, getTaxId, getThemeId, isSaaSInstance, isThemeCompiled, setOrderStatus, test };
|