@shopware-ag/acceptance-test-suite 3.0.0 → 3.2.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
@@ -285,6 +285,9 @@ type Promotion = Omit<components['schemas']['Promotion'], 'discounts'> & {
285
285
  type PromotionDiscount = components['schemas']['PromotionDiscount'] & {
286
286
  id: string;
287
287
  };
288
+ type OrderLineItem = components['schemas']['OrderLineItem'] & {
289
+ id: string;
290
+ };
288
291
 
289
292
  interface CreatedRecord {
290
293
  resource: string;
@@ -294,6 +297,7 @@ interface SimpleLineItem {
294
297
  product: Product | Promotion;
295
298
  quantity?: number;
296
299
  position?: number;
300
+ overrides?: Partial<OrderLineItem>;
297
301
  }
298
302
  interface SyncApiOperation {
299
303
  entity: string;
@@ -460,6 +464,25 @@ declare class TestDataService {
460
464
  * @param salesChannelId - The uuid of the sales channel in which the promotion should be active.
461
465
  */
462
466
  createPromotionWithCode(overrides?: Partial<Promotion>, salesChannelId?: string): Promise<Promotion>;
467
+ /**
468
+ * Creates a new basic payment method.
469
+ *
470
+ * @param overrides - Specific data overrides that will be applied to the payment method data struct.
471
+ */
472
+ createBasicPaymentMethod(overrides?: Partial<PaymentMethod>): Promise<PaymentMethod>;
473
+ /**
474
+ * Creates a payment method with one randomly generated image.
475
+ *
476
+ * @param overrides - Specific data overrides that will be applied to the payment method data struct.
477
+ */
478
+ createPaymentMethodWithImage(overrides?: Partial<PaymentMethod>): Promise<PaymentMethod>;
479
+ /**
480
+ * Assigns a media resource to a payment method as a logo.
481
+ *
482
+ * @param paymentMethodId - The uuid of the payment method.
483
+ * @param mediaId - The uuid of the media resource.
484
+ */
485
+ assignPaymentMethodMedia(paymentMethodId: string, mediaId: string): Promise<any>;
463
486
  /**
464
487
  * Assigns a media resource as the download of a digital product.
465
488
  *
@@ -591,6 +614,12 @@ declare class TestDataService {
591
614
  getBasicProductStruct(taxId?: string, currencyId?: string, overrides?: Partial<Product>): Partial<Product>;
592
615
  getProductPriceRangeStruct(currencyId: string, ruleId: string): Partial<Product>;
593
616
  getBasicManufacturerStruct(overrides?: Partial<Manufacturer>): Partial<Manufacturer>;
617
+ getBasicPaymentMethodStruct(overrides?: Partial<PaymentMethod>): {
618
+ id: string;
619
+ name: string;
620
+ technicalName: string;
621
+ active: boolean;
622
+ } & Partial<PaymentMethod>;
594
623
  getBasicCategoryStruct(overrides?: Partial<Category$1>, parentId?: string): {
595
624
  id: string;
596
625
  name: string;
@@ -643,8 +672,10 @@ declare class TestDataService {
643
672
  isCalculated: boolean;
644
673
  referencePriceDefinition: null;
645
674
  };
646
- };
675
+ } & Partial<OrderLineItem>;
647
676
  getBasicPromotionLineItemStruct(lineItem: SimpleLineItem): {
677
+ promotionId: string;
678
+ referencedId: string | undefined;
648
679
  payload: {
649
680
  code: string | undefined;
650
681
  };
@@ -673,7 +704,7 @@ declare class TestDataService {
673
704
  price: number;
674
705
  percentage: number | null;
675
706
  };
676
- };
707
+ } & Partial<OrderLineItem>;
677
708
  getBasicPromotionStruct(salesChannelId?: string, overrides?: Partial<Promotion>): Partial<Promotion>;
678
709
  }
679
710
 
@@ -1247,4 +1278,4 @@ declare const test: _playwright_test.TestType<_playwright_test.PlaywrightTestArg
1247
1278
  ValidateAccessibility: (pageName: string, assertViolations?: number | boolean | undefined, createReport?: boolean | undefined, ruleTags?: string[] | undefined, outputDir?: string | undefined) => () => Promise<axe_core.Result[]>;
1248
1279
  }, _playwright_test.PlaywrightWorkerArgs & _playwright_test.PlaywrightWorkerOptions & FixtureTypes>;
1249
1280
 
1250
- 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 };
1281
+ 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 OrderLineItem, 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
@@ -285,6 +285,9 @@ type Promotion = Omit<components['schemas']['Promotion'], 'discounts'> & {
285
285
  type PromotionDiscount = components['schemas']['PromotionDiscount'] & {
286
286
  id: string;
287
287
  };
288
+ type OrderLineItem = components['schemas']['OrderLineItem'] & {
289
+ id: string;
290
+ };
288
291
 
289
292
  interface CreatedRecord {
290
293
  resource: string;
@@ -294,6 +297,7 @@ interface SimpleLineItem {
294
297
  product: Product | Promotion;
295
298
  quantity?: number;
296
299
  position?: number;
300
+ overrides?: Partial<OrderLineItem>;
297
301
  }
298
302
  interface SyncApiOperation {
299
303
  entity: string;
@@ -460,6 +464,25 @@ declare class TestDataService {
460
464
  * @param salesChannelId - The uuid of the sales channel in which the promotion should be active.
461
465
  */
462
466
  createPromotionWithCode(overrides?: Partial<Promotion>, salesChannelId?: string): Promise<Promotion>;
467
+ /**
468
+ * Creates a new basic payment method.
469
+ *
470
+ * @param overrides - Specific data overrides that will be applied to the payment method data struct.
471
+ */
472
+ createBasicPaymentMethod(overrides?: Partial<PaymentMethod>): Promise<PaymentMethod>;
473
+ /**
474
+ * Creates a payment method with one randomly generated image.
475
+ *
476
+ * @param overrides - Specific data overrides that will be applied to the payment method data struct.
477
+ */
478
+ createPaymentMethodWithImage(overrides?: Partial<PaymentMethod>): Promise<PaymentMethod>;
479
+ /**
480
+ * Assigns a media resource to a payment method as a logo.
481
+ *
482
+ * @param paymentMethodId - The uuid of the payment method.
483
+ * @param mediaId - The uuid of the media resource.
484
+ */
485
+ assignPaymentMethodMedia(paymentMethodId: string, mediaId: string): Promise<any>;
463
486
  /**
464
487
  * Assigns a media resource as the download of a digital product.
465
488
  *
@@ -591,6 +614,12 @@ declare class TestDataService {
591
614
  getBasicProductStruct(taxId?: string, currencyId?: string, overrides?: Partial<Product>): Partial<Product>;
592
615
  getProductPriceRangeStruct(currencyId: string, ruleId: string): Partial<Product>;
593
616
  getBasicManufacturerStruct(overrides?: Partial<Manufacturer>): Partial<Manufacturer>;
617
+ getBasicPaymentMethodStruct(overrides?: Partial<PaymentMethod>): {
618
+ id: string;
619
+ name: string;
620
+ technicalName: string;
621
+ active: boolean;
622
+ } & Partial<PaymentMethod>;
594
623
  getBasicCategoryStruct(overrides?: Partial<Category$1>, parentId?: string): {
595
624
  id: string;
596
625
  name: string;
@@ -643,8 +672,10 @@ declare class TestDataService {
643
672
  isCalculated: boolean;
644
673
  referencePriceDefinition: null;
645
674
  };
646
- };
675
+ } & Partial<OrderLineItem>;
647
676
  getBasicPromotionLineItemStruct(lineItem: SimpleLineItem): {
677
+ promotionId: string;
678
+ referencedId: string | undefined;
648
679
  payload: {
649
680
  code: string | undefined;
650
681
  };
@@ -673,7 +704,7 @@ declare class TestDataService {
673
704
  price: number;
674
705
  percentage: number | null;
675
706
  };
676
- };
707
+ } & Partial<OrderLineItem>;
677
708
  getBasicPromotionStruct(salesChannelId?: string, overrides?: Partial<Promotion>): Partial<Promotion>;
678
709
  }
679
710
 
@@ -1247,4 +1278,4 @@ declare const test: _playwright_test.TestType<_playwright_test.PlaywrightTestArg
1247
1278
  ValidateAccessibility: (pageName: string, assertViolations?: number | boolean | undefined, createReport?: boolean | undefined, ruleTags?: string[] | undefined, outputDir?: string | undefined) => () => Promise<axe_core.Result[]>;
1248
1279
  }, _playwright_test.PlaywrightWorkerArgs & _playwright_test.PlaywrightWorkerOptions & FixtureTypes>;
1249
1280
 
1250
- 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 };
1281
+ 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 OrderLineItem, 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
@@ -1039,7 +1039,7 @@ class TestDataService {
1039
1039
  data: basicManufacturer
1040
1040
  });
1041
1041
  const { data: manufacturer } = await manufacturerResponse.json();
1042
- this.addCreatedRecord("product-manufacturer", manufacturer.id);
1042
+ this.addCreatedRecord("product_manufacturer", manufacturer.id);
1043
1043
  return manufacturer;
1044
1044
  }
1045
1045
  /**
@@ -1210,7 +1210,13 @@ class TestDataService {
1210
1210
  const response = await this.AdminApiClient.post("customer?_response=detail", {
1211
1211
  data: basicCustomerStruct
1212
1212
  });
1213
- const { data: customer } = await response.json();
1213
+ const customerData = await response.json();
1214
+ let customer;
1215
+ if (typeof basicCustomerStruct.password !== "string") {
1216
+ customer = { ...customerData.data };
1217
+ } else {
1218
+ customer = { ...customerData.data, password: basicCustomerStruct.password };
1219
+ }
1214
1220
  this.addCreatedRecord("customer", customer.id);
1215
1221
  return customer;
1216
1222
  }
@@ -1271,6 +1277,46 @@ class TestDataService {
1271
1277
  this.addCreatedRecord("promotion", promotion.id);
1272
1278
  return promotionWithDiscount;
1273
1279
  }
1280
+ /**
1281
+ * Creates a new basic payment method.
1282
+ *
1283
+ * @param overrides - Specific data overrides that will be applied to the payment method data struct.
1284
+ */
1285
+ async createBasicPaymentMethod(overrides = {}) {
1286
+ const basicPaymentMethod = this.getBasicPaymentMethodStruct(overrides);
1287
+ const paymentMethodResponse = await this.AdminApiClient.post("payment-method?_response=detail", {
1288
+ data: basicPaymentMethod
1289
+ });
1290
+ const { data: paymentMethod } = await paymentMethodResponse.json();
1291
+ this.addCreatedRecord("payment_method", paymentMethod.id);
1292
+ return paymentMethod;
1293
+ }
1294
+ /**
1295
+ * Creates a payment method with one randomly generated image.
1296
+ *
1297
+ * @param overrides - Specific data overrides that will be applied to the payment method data struct.
1298
+ */
1299
+ async createPaymentMethodWithImage(overrides = {}) {
1300
+ const paymentMethod = await this.createBasicPaymentMethod(overrides);
1301
+ const media = await this.createMediaPNG();
1302
+ await this.assignPaymentMethodMedia(paymentMethod.id, media.id);
1303
+ return paymentMethod;
1304
+ }
1305
+ /**
1306
+ * Assigns a media resource to a payment method as a logo.
1307
+ *
1308
+ * @param paymentMethodId - The uuid of the payment method.
1309
+ * @param mediaId - The uuid of the media resource.
1310
+ */
1311
+ async assignPaymentMethodMedia(paymentMethodId, mediaId) {
1312
+ const paymentMethodResponse = await this.AdminApiClient.patch(`payment-method/${paymentMethodId}?_response=basic`, {
1313
+ data: {
1314
+ mediaId
1315
+ }
1316
+ });
1317
+ const { data: paymentMethodMedia } = await paymentMethodResponse.json();
1318
+ return paymentMethodMedia;
1319
+ }
1274
1320
  /**
1275
1321
  * Assigns a media resource as the download of a digital product.
1276
1322
  *
@@ -1708,6 +1754,17 @@ class TestDataService {
1708
1754
  };
1709
1755
  return Object.assign({}, basicManufacturer, overrides);
1710
1756
  }
1757
+ getBasicPaymentMethodStruct(overrides = {}) {
1758
+ const { id: paymentMethodId, uuid: paymentMethodUuid } = this.IdProvider.getIdPair();
1759
+ const paymentMethodName = `${this.namePrefix}PaymentMethod-${paymentMethodId}${this.nameSuffix}`;
1760
+ const basicPaymentMethod = {
1761
+ id: paymentMethodUuid,
1762
+ name: paymentMethodName,
1763
+ technicalName: paymentMethodName.toLowerCase(),
1764
+ active: true
1765
+ };
1766
+ return Object.assign({}, basicPaymentMethod, overrides);
1767
+ }
1711
1768
  getBasicCategoryStruct(overrides = {}, parentId = this.defaultCategoryId) {
1712
1769
  const { id: categoryId, uuid: categoryUuid } = this.IdProvider.getIdPair();
1713
1770
  const categoryName = `${this.namePrefix}Category-${categoryId}${this.nameSuffix}`;
@@ -1834,10 +1891,7 @@ class TestDataService {
1834
1891
  }
1835
1892
  });
1836
1893
  const orderDelivery = this.getBasicOrderDeliveryStruct(deliveryState, shippingMethod, customerAddress);
1837
- let shippingCosts = 0;
1838
- if (orderDelivery.shippingCosts != null) {
1839
- shippingCosts = orderDelivery.shippingCosts.totalPrice;
1840
- }
1894
+ const shippingCosts = orderDelivery.shippingCosts?.totalPrice ?? 0;
1841
1895
  totalPrice += shippingCosts;
1842
1896
  const basicOrder = {
1843
1897
  orderNumber: this.IdProvider.getIdPair().id,
@@ -1931,7 +1985,7 @@ class TestDataService {
1931
1985
  const product = lineItem.product;
1932
1986
  const unitPrice = product.price[0].gross || 10;
1933
1987
  const totalPrice = unitPrice * (lineItem.quantity || 1);
1934
- return {
1988
+ const basicProductLineItemStruct = {
1935
1989
  productId: product.id,
1936
1990
  referencedId: product.id,
1937
1991
  payload: {
@@ -1969,6 +2023,7 @@ class TestDataService {
1969
2023
  referencePriceDefinition: null
1970
2024
  }
1971
2025
  };
2026
+ return Object.assign({}, basicProductLineItemStruct, lineItem.overrides);
1972
2027
  }
1973
2028
  getBasicPromotionLineItemStruct(lineItem) {
1974
2029
  if (!this.isPromotion(lineItem.product)) {
@@ -1980,7 +2035,9 @@ class TestDataService {
1980
2035
  const promotionDiscountId = promotion.discounts[0].id;
1981
2036
  const unitPrice = -Math.abs(promotionDiscountValue || 10);
1982
2037
  const totalPrice = unitPrice * (lineItem.quantity || 1);
1983
- return {
2038
+ const basicPromotionLineItemStruct = {
2039
+ promotionId: promotion.id,
2040
+ referencedId: promotion.code,
1984
2041
  payload: {
1985
2042
  code: promotion.code
1986
2043
  },
@@ -2010,6 +2067,7 @@ class TestDataService {
2010
2067
  percentage: promotionDiscountType === "percentage" ? promotionDiscountValue : null
2011
2068
  }
2012
2069
  };
2070
+ return Object.assign({}, basicPromotionLineItemStruct, lineItem.overrides);
2013
2071
  }
2014
2072
  getBasicPromotionStruct(salesChannelId = this.defaultSalesChannel.id, overrides = {}) {
2015
2073
  const promotionCode = `${this.IdProvider.getIdPair().id}`;
@@ -3590,9 +3648,9 @@ const test$3 = mergeTests(
3590
3648
 
3591
3649
  const Login = test$e.extend({
3592
3650
  Login: async ({ ShopCustomer, DefaultSalesChannel, StorefrontAccountLogin, StorefrontAccount }, use) => {
3593
- const task = () => {
3651
+ const task = (customCustomer) => {
3594
3652
  return async function Login2() {
3595
- const { customer } = DefaultSalesChannel;
3653
+ const customer = customCustomer ? customCustomer : DefaultSalesChannel.customer;
3596
3654
  await ShopCustomer.goesTo(StorefrontAccountLogin.url());
3597
3655
  await StorefrontAccountLogin.emailInput.fill(customer.email);
3598
3656
  await StorefrontAccountLogin.passwordInput.fill(customer.password);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shopware-ag/acceptance-test-suite",
3
- "version": "3.0.0",
3
+ "version": "3.2.0",
4
4
  "description": "Shopware Acceptance Test Suite",
5
5
  "author": "shopware AG",
6
6
  "license": "MIT",