@shopware-ag/acceptance-test-suite 2.5.0 → 2.7.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 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
- type Order = components['schemas']['Order'] & {
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
 
@@ -661,6 +729,7 @@ declare class ProductDetail$1 implements PageObject {
661
729
  readonly addToCartButton: Locator;
662
730
  readonly quantitySelect: Locator;
663
731
  readonly productSingleImage: Locator;
732
+ readonly productSinglePrice: Locator;
664
733
  readonly offCanvasCartTitle: Locator;
665
734
  readonly offCanvasCart: Locator;
666
735
  readonly offCanvasCartGoToCheckoutButton: Locator;
@@ -1107,6 +1176,10 @@ declare const getMediaId: (fileName: string, adminApiContext: AdminApiContext) =
1107
1176
  declare function extractIdFromUrl(url: string): string | null;
1108
1177
  type OrderStatus = 'cancel' | 'complete' | 'reopen' | 'process';
1109
1178
  declare const setOrderStatus: (orderId: string, orderStatus: OrderStatus, adminApiContext: AdminApiContext) => Promise<APIResponse>;
1179
+ /**
1180
+ * Return a single promotion entity with a fetched single discount entity
1181
+ */
1182
+ declare const getPromotionWithDiscount: (promotionId: string, adminApiContext: AdminApiContext) => Promise<Promotion>;
1110
1183
 
1111
1184
  declare const isSaaSInstance: (adminApiContext: AdminApiContext) => Promise<boolean>;
1112
1185
  declare const isThemeCompiled: (context: AdminApiContext, storefrontUrl: string) => Promise<boolean>;
@@ -1149,4 +1222,4 @@ declare const test: _playwright_test.TestType<_playwright_test.PlaywrightTestArg
1149
1222
  ValidateAccessibility: (pageName: string, assertViolations?: number | boolean | undefined, createReport?: boolean | undefined, ruleTags?: string[] | undefined, outputDir?: string | undefined) => () => Promise<axe_core.Result[]>;
1150
1223
  }, _playwright_test.PlaywrightWorkerArgs & _playwright_test.PlaywrightWorkerOptions & FixtureTypes>;
1151
1224
 
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 };
1225
+ 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
- type Order = components['schemas']['Order'] & {
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
 
@@ -661,6 +729,7 @@ declare class ProductDetail$1 implements PageObject {
661
729
  readonly addToCartButton: Locator;
662
730
  readonly quantitySelect: Locator;
663
731
  readonly productSingleImage: Locator;
732
+ readonly productSinglePrice: Locator;
664
733
  readonly offCanvasCartTitle: Locator;
665
734
  readonly offCanvasCart: Locator;
666
735
  readonly offCanvasCartGoToCheckoutButton: Locator;
@@ -1107,6 +1176,10 @@ declare const getMediaId: (fileName: string, adminApiContext: AdminApiContext) =
1107
1176
  declare function extractIdFromUrl(url: string): string | null;
1108
1177
  type OrderStatus = 'cancel' | 'complete' | 'reopen' | 'process';
1109
1178
  declare const setOrderStatus: (orderId: string, orderStatus: OrderStatus, adminApiContext: AdminApiContext) => Promise<APIResponse>;
1179
+ /**
1180
+ * Return a single promotion entity with a fetched single discount entity
1181
+ */
1182
+ declare const getPromotionWithDiscount: (promotionId: string, adminApiContext: AdminApiContext) => Promise<Promotion>;
1110
1183
 
1111
1184
  declare const isSaaSInstance: (adminApiContext: AdminApiContext) => Promise<boolean>;
1112
1185
  declare const isThemeCompiled: (context: AdminApiContext, storefrontUrl: string) => Promise<boolean>;
@@ -1149,4 +1222,4 @@ declare const test: _playwright_test.TestType<_playwright_test.PlaywrightTestArg
1149
1222
  ValidateAccessibility: (pageName: string, assertViolations?: number | boolean | undefined, createReport?: boolean | undefined, ruleTags?: string[] | undefined, outputDir?: string | undefined) => () => Promise<axe_core.Result[]>;
1150
1223
  }, _playwright_test.PlaywrightWorkerArgs & _playwright_test.PlaywrightWorkerOptions & FixtureTypes>;
1151
1224
 
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 };
1225
+ 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": {
@@ -819,6 +796,21 @@ const test$9 = test$d.extend({
819
796
  }
820
797
  await page.getByRole("button", { name: "Log in" }).click();
821
798
  await Promise.all(jsLoadingPromises);
799
+ const originalReload = page.reload.bind(page);
800
+ page.reload = async () => {
801
+ const res = await originalReload();
802
+ await page.addStyleTag({
803
+ content: `
804
+ .sf-toolbar {
805
+ width: 0 !important;
806
+ height: 0 !important;
807
+ display: none !important;
808
+ pointer-events: none !important;
809
+ }
810
+ `.trim()
811
+ });
812
+ return res;
813
+ };
822
814
  await use(page);
823
815
  await page.close();
824
816
  await context.close();
@@ -1223,8 +1215,8 @@ class TestDataService {
1223
1215
  *
1224
1216
  * @param lineItems - Products that should be added to the order.
1225
1217
  * @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
1218
  * @param overrides - Specific data overrides that will be applied to the order data struct.
1219
+ * @param salesChannel - The sales channel in which the order should be created.
1228
1220
  */
1229
1221
  async createOrder(lineItems, customer, overrides = {}, salesChannel = this.defaultSalesChannel) {
1230
1222
  const orderStateMachine = await this.getOrderStateMachine();
@@ -1260,7 +1252,7 @@ class TestDataService {
1260
1252
  return order;
1261
1253
  }
1262
1254
  /**
1263
- * Creates a new promotion with a promotion code.
1255
+ * Creates a new promotion with a promotion code and only single discount option.
1264
1256
  *
1265
1257
  * @param overrides - Specific data overrides that will be applied to the promotion data struct.
1266
1258
  * @param salesChannelId - The uuid of the sales channel in which the promotion should be active.
@@ -1271,8 +1263,9 @@ class TestDataService {
1271
1263
  data: basicPromotion
1272
1264
  });
1273
1265
  const { data: promotion } = await promotionResponse.json();
1266
+ const promotionWithDiscount = await getPromotionWithDiscount(promotion.id, this.AdminApiClient);
1274
1267
  this.addCreatedRecord("promotion", promotion.id);
1275
- return promotion;
1268
+ return promotionWithDiscount;
1276
1269
  }
1277
1270
  /**
1278
1271
  * Assigns a media resource as the download of a digital product.
@@ -1763,18 +1756,84 @@ class TestDataService {
1763
1756
  };
1764
1757
  return Object.assign({}, basicCustomer, overrides);
1765
1758
  }
1759
+ getBasicOrderDeliveryStruct(deliveryState, shippingMethod, customerAddress) {
1760
+ const date = /* @__PURE__ */ new Date();
1761
+ const shippingDate = new Date(date);
1762
+ shippingDate.setDate(shippingDate.getDate() + 3);
1763
+ const shippingDateTime = this.convertDateTime(shippingDate);
1764
+ const shippingCosts = 8.99;
1765
+ return {
1766
+ stateId: deliveryState.id,
1767
+ shippingMethodId: shippingMethod.id,
1768
+ shippingOrderAddress: {
1769
+ id: customerAddress.id,
1770
+ salutationId: customerAddress.salutationId,
1771
+ firstName: customerAddress.firstName,
1772
+ lastName: customerAddress.lastName,
1773
+ street: customerAddress.street,
1774
+ zipcode: customerAddress.zipcode,
1775
+ city: customerAddress.city,
1776
+ countryId: customerAddress.countryId,
1777
+ phoneNumber: customerAddress.phoneNumber
1778
+ },
1779
+ shippingDateEarliest: shippingDateTime,
1780
+ shippingDateLatest: shippingDateTime,
1781
+ shippingCosts: {
1782
+ unitPrice: shippingCosts,
1783
+ totalPrice: shippingCosts,
1784
+ quantity: 1,
1785
+ calculatedTaxes: [
1786
+ {
1787
+ tax: 0,
1788
+ taxRate: 0,
1789
+ price: shippingCosts
1790
+ }
1791
+ ],
1792
+ taxRules: [
1793
+ {
1794
+ taxRate: 0,
1795
+ percentage: 100
1796
+ }
1797
+ ]
1798
+ }
1799
+ };
1800
+ }
1801
+ isProduct(item) {
1802
+ return item.productNumber !== void 0;
1803
+ }
1804
+ isPromotion(item) {
1805
+ return item.code !== void 0;
1806
+ }
1766
1807
  getBasicOrderStruct(lineItems, languageId, currency, paymentMethod, shippingMethod, orderState, deliveryState, transactionState, customer, customerAddress, salesChannelId = this.defaultSalesChannel.id, overrides = {}) {
1767
1808
  const date = /* @__PURE__ */ new Date();
1768
1809
  const orderDateTime = this.convertDateTime(date);
1769
- const shippingDate = new Date(date.getDate() + 3);
1770
- const shippingDateTime = this.convertDateTime(shippingDate);
1771
1810
  let totalPrice = 0;
1772
- const lineItemProducts = [];
1811
+ const orderLineItems = [];
1773
1812
  lineItems.forEach((lineItem) => {
1774
- lineItemProducts.push(this.getBasicProductLineItemStruct(lineItem));
1775
- totalPrice += lineItem.product.price[0].gross * (lineItem.quantity || 1);
1813
+ if (this.isProduct(lineItem.product)) {
1814
+ const product = lineItem.product;
1815
+ orderLineItems.push(this.getBasicProductLineItemStruct(lineItem));
1816
+ totalPrice += product.price[0].gross * (lineItem.quantity || 1);
1817
+ }
1818
+ if (this.isPromotion(lineItem.product)) {
1819
+ const promotion = lineItem.product;
1820
+ orderLineItems.push(this.getBasicPromotionLineItemStruct(lineItem));
1821
+ const promotionDiscountValue = promotion.discounts[0].value;
1822
+ const promotionDiscountType = promotion.discounts[0].type;
1823
+ if (promotionDiscountType === "absolute") {
1824
+ totalPrice -= (promotionDiscountValue || 10) * (lineItem.quantity || 1);
1825
+ } else if (promotionDiscountType === "percentage") {
1826
+ totalPrice -= promotionDiscountValue * totalPrice / 100 * (lineItem.quantity || 1);
1827
+ } else if (promotionDiscountType === "fixed_unit") {
1828
+ totalPrice = (promotionDiscountValue || 10) * (lineItem.quantity || 1);
1829
+ }
1830
+ }
1776
1831
  });
1777
- const shippingCosts = 8.99;
1832
+ const orderDelivery = this.getBasicOrderDeliveryStruct(deliveryState, shippingMethod, customerAddress);
1833
+ let shippingCosts = 0;
1834
+ if (orderDelivery.shippingCosts != null) {
1835
+ shippingCosts = orderDelivery.shippingCosts.totalPrice;
1836
+ }
1778
1837
  totalPrice += shippingCosts;
1779
1838
  const basicOrder = {
1780
1839
  orderNumber: this.IdProvider.getIdPair().id,
@@ -1832,44 +1891,8 @@ class TestDataService {
1832
1891
  percentage: 100
1833
1892
  }]
1834
1893
  },
1835
- lineItems: lineItemProducts,
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
- ],
1894
+ lineItems: orderLineItems,
1895
+ deliveries: [orderDelivery],
1873
1896
  transactions: [
1874
1897
  {
1875
1898
  paymentMethodId: paymentMethod.id,
@@ -1898,17 +1921,21 @@ class TestDataService {
1898
1921
  return Object.assign({}, basicOrder, overrides);
1899
1922
  }
1900
1923
  getBasicProductLineItemStruct(lineItem) {
1901
- const unitPrice = lineItem.product.price[0].gross || 10;
1924
+ if (!this.isProduct(lineItem.product)) {
1925
+ console.error("Error: Object is not of type Product");
1926
+ }
1927
+ const product = lineItem.product;
1928
+ const unitPrice = product.price[0].gross || 10;
1902
1929
  const totalPrice = unitPrice * (lineItem.quantity || 1);
1903
1930
  return {
1904
- productId: lineItem.product.id,
1905
- referencedId: lineItem.product.id,
1931
+ productId: product.id,
1932
+ referencedId: product.id,
1906
1933
  payload: {
1907
- productNumber: lineItem.product.productNumber
1934
+ productNumber: product.productNumber
1908
1935
  },
1909
- identifier: lineItem.product.id,
1936
+ identifier: product.id,
1910
1937
  type: "product",
1911
- label: lineItem.product.name,
1938
+ label: product.name,
1912
1939
  quantity: lineItem.quantity || 1,
1913
1940
  position: lineItem.position || 1,
1914
1941
  price: {
@@ -1939,6 +1966,47 @@ class TestDataService {
1939
1966
  }
1940
1967
  };
1941
1968
  }
1969
+ getBasicPromotionLineItemStruct(lineItem) {
1970
+ if (!this.isPromotion(lineItem.product)) {
1971
+ console.error("Error: Object is not of type Promotion");
1972
+ }
1973
+ const promotion = lineItem.product;
1974
+ const promotionDiscountValue = promotion.discounts[0].value;
1975
+ const promotionDiscountType = promotion.discounts[0].type;
1976
+ const promotionDiscountId = promotion.discounts[0].id;
1977
+ const unitPrice = -Math.abs(promotionDiscountValue || 10);
1978
+ const totalPrice = unitPrice * (lineItem.quantity || 1);
1979
+ return {
1980
+ payload: {
1981
+ code: promotion.code
1982
+ },
1983
+ identifier: promotionDiscountId,
1984
+ type: "promotion",
1985
+ label: promotion.name,
1986
+ description: promotion.name,
1987
+ quantity: lineItem.quantity || 1,
1988
+ position: lineItem.position || 1,
1989
+ price: {
1990
+ unitPrice,
1991
+ totalPrice,
1992
+ quantity: lineItem.quantity,
1993
+ calculatedTaxes: [{
1994
+ tax: 0,
1995
+ taxRate: 0,
1996
+ price: totalPrice
1997
+ }],
1998
+ taxRules: [{
1999
+ taxRate: 0,
2000
+ percentage: 100
2001
+ }]
2002
+ },
2003
+ priceDefinition: {
2004
+ type: promotionDiscountType,
2005
+ price: totalPrice,
2006
+ percentage: promotionDiscountType === "percentage" ? promotionDiscountValue : null
2007
+ }
2008
+ };
2009
+ }
1942
2010
  getBasicPromotionStruct(salesChannelId = this.defaultSalesChannel.id, overrides = {}) {
1943
2011
  const promotionCode = `${this.IdProvider.getIdPair().id}`;
1944
2012
  const promotionName = `${this.namePrefix}Promotion-${promotionCode}${this.nameSuffix}`;
@@ -2086,6 +2154,7 @@ let ProductDetail$1 = class ProductDetail {
2086
2154
  __publicField$m(this, "addToCartButton");
2087
2155
  __publicField$m(this, "quantitySelect");
2088
2156
  __publicField$m(this, "productSingleImage");
2157
+ __publicField$m(this, "productSinglePrice");
2089
2158
  __publicField$m(this, "offCanvasCartTitle");
2090
2159
  __publicField$m(this, "offCanvasCart");
2091
2160
  __publicField$m(this, "offCanvasCartGoToCheckoutButton");
@@ -2095,6 +2164,7 @@ let ProductDetail$1 = class ProductDetail {
2095
2164
  this.addToCartButton = page.getByRole("button", { name: "Add to shopping cart" });
2096
2165
  this.quantitySelect = page.getByLabel("Quantity", { exact: true });
2097
2166
  this.productSingleImage = page.locator(".gallery-slider-single-image");
2167
+ this.productSinglePrice = page.locator(".product-detail-price");
2098
2168
  this.offCanvas = page.locator("offcanvas-body");
2099
2169
  this.offCanvasCartTitle = page.getByText("Shopping cart", { exact: true });
2100
2170
  this.offCanvasCart = page.getByRole("dialog");
@@ -3782,4 +3852,4 @@ const test = mergeTests(
3782
3852
  test$1
3783
3853
  );
3784
3854
 
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 };
3855
+ 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 };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shopware-ag/acceptance-test-suite",
3
- "version": "2.5.0",
3
+ "version": "2.7.0",
4
4
  "description": "Shopware Acceptance Test Suite",
5
5
  "author": "shopware AG",
6
6
  "license": "MIT",