@shopware-ag/acceptance-test-suite 3.1.0 → 3.3.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
@@ -464,6 +464,31 @@ declare class TestDataService {
464
464
  * @param salesChannelId - The uuid of the sales channel in which the promotion should be active.
465
465
  */
466
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 new basic rule with the condition cart amount >= 1.
475
+ *
476
+ * @param overrides - Specific data overrides that will be applied to the payment method data struct.
477
+ */
478
+ createBasicRule(overrides?: Partial<Rule>): Promise<Rule>;
479
+ /**
480
+ * Creates a payment method with one randomly generated image.
481
+ *
482
+ * @param overrides - Specific data overrides that will be applied to the payment method data struct.
483
+ */
484
+ createPaymentMethodWithImage(overrides?: Partial<PaymentMethod>): Promise<PaymentMethod>;
485
+ /**
486
+ * Assigns a media resource to a payment method as a logo.
487
+ *
488
+ * @param paymentMethodId - The uuid of the payment method.
489
+ * @param mediaId - The uuid of the media resource.
490
+ */
491
+ assignPaymentMethodMedia(paymentMethodId: string, mediaId: string): Promise<any>;
467
492
  /**
468
493
  * Assigns a media resource as the download of a digital product.
469
494
  *
@@ -593,8 +618,15 @@ declare class TestDataService {
593
618
  */
594
619
  convertDateTime(date: Date): string;
595
620
  getBasicProductStruct(taxId?: string, currencyId?: string, overrides?: Partial<Product>): Partial<Product>;
621
+ getBasicRuleStruct(overrides?: Partial<Rule>, conditionType?: string, operator?: string, amount?: number): Partial<Rule>;
596
622
  getProductPriceRangeStruct(currencyId: string, ruleId: string): Partial<Product>;
597
623
  getBasicManufacturerStruct(overrides?: Partial<Manufacturer>): Partial<Manufacturer>;
624
+ getBasicPaymentMethodStruct(overrides?: Partial<PaymentMethod>): {
625
+ id: string;
626
+ name: string;
627
+ technicalName: string;
628
+ active: boolean;
629
+ } & Partial<PaymentMethod>;
598
630
  getBasicCategoryStruct(overrides?: Partial<Category$1>, parentId?: string): {
599
631
  id: string;
600
632
  name: string;
@@ -649,6 +681,8 @@ declare class TestDataService {
649
681
  };
650
682
  } & Partial<OrderLineItem>;
651
683
  getBasicPromotionLineItemStruct(lineItem: SimpleLineItem): {
684
+ promotionId: string;
685
+ referencedId: string | undefined;
652
686
  payload: {
653
687
  code: string | undefined;
654
688
  };
package/dist/index.d.ts CHANGED
@@ -464,6 +464,31 @@ declare class TestDataService {
464
464
  * @param salesChannelId - The uuid of the sales channel in which the promotion should be active.
465
465
  */
466
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 new basic rule with the condition cart amount >= 1.
475
+ *
476
+ * @param overrides - Specific data overrides that will be applied to the payment method data struct.
477
+ */
478
+ createBasicRule(overrides?: Partial<Rule>): Promise<Rule>;
479
+ /**
480
+ * Creates a payment method with one randomly generated image.
481
+ *
482
+ * @param overrides - Specific data overrides that will be applied to the payment method data struct.
483
+ */
484
+ createPaymentMethodWithImage(overrides?: Partial<PaymentMethod>): Promise<PaymentMethod>;
485
+ /**
486
+ * Assigns a media resource to a payment method as a logo.
487
+ *
488
+ * @param paymentMethodId - The uuid of the payment method.
489
+ * @param mediaId - The uuid of the media resource.
490
+ */
491
+ assignPaymentMethodMedia(paymentMethodId: string, mediaId: string): Promise<any>;
467
492
  /**
468
493
  * Assigns a media resource as the download of a digital product.
469
494
  *
@@ -593,8 +618,15 @@ declare class TestDataService {
593
618
  */
594
619
  convertDateTime(date: Date): string;
595
620
  getBasicProductStruct(taxId?: string, currencyId?: string, overrides?: Partial<Product>): Partial<Product>;
621
+ getBasicRuleStruct(overrides?: Partial<Rule>, conditionType?: string, operator?: string, amount?: number): Partial<Rule>;
596
622
  getProductPriceRangeStruct(currencyId: string, ruleId: string): Partial<Product>;
597
623
  getBasicManufacturerStruct(overrides?: Partial<Manufacturer>): Partial<Manufacturer>;
624
+ getBasicPaymentMethodStruct(overrides?: Partial<PaymentMethod>): {
625
+ id: string;
626
+ name: string;
627
+ technicalName: string;
628
+ active: boolean;
629
+ } & Partial<PaymentMethod>;
598
630
  getBasicCategoryStruct(overrides?: Partial<Category$1>, parentId?: string): {
599
631
  id: string;
600
632
  name: string;
@@ -649,6 +681,8 @@ declare class TestDataService {
649
681
  };
650
682
  } & Partial<OrderLineItem>;
651
683
  getBasicPromotionLineItemStruct(lineItem: SimpleLineItem): {
684
+ promotionId: string;
685
+ referencedId: string | undefined;
652
686
  payload: {
653
687
  code: string | undefined;
654
688
  };
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,60 @@ 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 new basic rule with the condition cart amount >= 1.
1296
+ *
1297
+ * @param overrides - Specific data overrides that will be applied to the payment method data struct.
1298
+ */
1299
+ async createBasicRule(overrides = {}) {
1300
+ const basicRule = this.getBasicRuleStruct(overrides);
1301
+ const ruleResponse = await this.AdminApiClient.post("rule?_response=detail", {
1302
+ data: basicRule
1303
+ });
1304
+ const { data: rule } = await ruleResponse.json();
1305
+ this.addCreatedRecord("rule", rule.id);
1306
+ return rule;
1307
+ }
1308
+ /**
1309
+ * Creates a payment method with one randomly generated image.
1310
+ *
1311
+ * @param overrides - Specific data overrides that will be applied to the payment method data struct.
1312
+ */
1313
+ async createPaymentMethodWithImage(overrides = {}) {
1314
+ const paymentMethod = await this.createBasicPaymentMethod(overrides);
1315
+ const media = await this.createMediaPNG();
1316
+ await this.assignPaymentMethodMedia(paymentMethod.id, media.id);
1317
+ return paymentMethod;
1318
+ }
1319
+ /**
1320
+ * Assigns a media resource to a payment method as a logo.
1321
+ *
1322
+ * @param paymentMethodId - The uuid of the payment method.
1323
+ * @param mediaId - The uuid of the media resource.
1324
+ */
1325
+ async assignPaymentMethodMedia(paymentMethodId, mediaId) {
1326
+ const paymentMethodResponse = await this.AdminApiClient.patch(`payment-method/${paymentMethodId}?_response=basic`, {
1327
+ data: {
1328
+ mediaId
1329
+ }
1330
+ });
1331
+ const { data: paymentMethodMedia } = await paymentMethodResponse.json();
1332
+ return paymentMethodMedia;
1333
+ }
1274
1334
  /**
1275
1335
  * Assigns a media resource as the download of a digital product.
1276
1336
  *
@@ -1658,6 +1718,41 @@ class TestDataService {
1658
1718
  }
1659
1719
  return Object.assign({}, basicProduct, overrides);
1660
1720
  }
1721
+ getBasicRuleStruct(overrides = {}, conditionType = "cartCartAmount", operator = ">=", amount = 1) {
1722
+ const { id: ruleId, uuid: ruleUuid } = this.IdProvider.getIdPair();
1723
+ const ruleName = `${this.namePrefix}Rule-${ruleId}${this.nameSuffix}`;
1724
+ const description = `
1725
+ Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.
1726
+ At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
1727
+ Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.
1728
+ At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.`.trim();
1729
+ const basicRuleStruct = {
1730
+ id: ruleUuid,
1731
+ name: ruleName,
1732
+ priority: 1,
1733
+ description,
1734
+ conditions: [
1735
+ {
1736
+ type: "orContainer",
1737
+ children: [
1738
+ {
1739
+ type: "andContainer",
1740
+ children: [
1741
+ {
1742
+ type: conditionType,
1743
+ value: {
1744
+ operator,
1745
+ amount
1746
+ }
1747
+ }
1748
+ ]
1749
+ }
1750
+ ]
1751
+ }
1752
+ ]
1753
+ };
1754
+ return Object.assign({}, basicRuleStruct, overrides);
1755
+ }
1661
1756
  getProductPriceRangeStruct(currencyId, ruleId) {
1662
1757
  const p = (gross, net) => [
1663
1758
  {
@@ -1708,6 +1803,17 @@ class TestDataService {
1708
1803
  };
1709
1804
  return Object.assign({}, basicManufacturer, overrides);
1710
1805
  }
1806
+ getBasicPaymentMethodStruct(overrides = {}) {
1807
+ const { id: paymentMethodId, uuid: paymentMethodUuid } = this.IdProvider.getIdPair();
1808
+ const paymentMethodName = `${this.namePrefix}PaymentMethod-${paymentMethodId}${this.nameSuffix}`;
1809
+ const basicPaymentMethod = {
1810
+ id: paymentMethodUuid,
1811
+ name: paymentMethodName,
1812
+ technicalName: paymentMethodName.toLowerCase(),
1813
+ active: true
1814
+ };
1815
+ return Object.assign({}, basicPaymentMethod, overrides);
1816
+ }
1711
1817
  getBasicCategoryStruct(overrides = {}, parentId = this.defaultCategoryId) {
1712
1818
  const { id: categoryId, uuid: categoryUuid } = this.IdProvider.getIdPair();
1713
1819
  const categoryName = `${this.namePrefix}Category-${categoryId}${this.nameSuffix}`;
@@ -1834,10 +1940,7 @@ class TestDataService {
1834
1940
  }
1835
1941
  });
1836
1942
  const orderDelivery = this.getBasicOrderDeliveryStruct(deliveryState, shippingMethod, customerAddress);
1837
- let shippingCosts = 0;
1838
- if (orderDelivery.shippingCosts != null) {
1839
- shippingCosts = orderDelivery.shippingCosts.totalPrice;
1840
- }
1943
+ const shippingCosts = orderDelivery.shippingCosts?.totalPrice ?? 0;
1841
1944
  totalPrice += shippingCosts;
1842
1945
  const basicOrder = {
1843
1946
  orderNumber: this.IdProvider.getIdPair().id,
@@ -1982,6 +2085,8 @@ class TestDataService {
1982
2085
  const unitPrice = -Math.abs(promotionDiscountValue || 10);
1983
2086
  const totalPrice = unitPrice * (lineItem.quantity || 1);
1984
2087
  const basicPromotionLineItemStruct = {
2088
+ promotionId: promotion.id,
2089
+ referencedId: promotion.code,
1985
2090
  payload: {
1986
2091
  code: promotion.code
1987
2092
  },
@@ -3592,9 +3697,9 @@ const test$3 = mergeTests(
3592
3697
 
3593
3698
  const Login = test$e.extend({
3594
3699
  Login: async ({ ShopCustomer, DefaultSalesChannel, StorefrontAccountLogin, StorefrontAccount }, use) => {
3595
- const task = () => {
3700
+ const task = (customCustomer) => {
3596
3701
  return async function Login2() {
3597
- const { customer } = DefaultSalesChannel;
3702
+ const customer = customCustomer ? customCustomer : DefaultSalesChannel.customer;
3598
3703
  await ShopCustomer.goesTo(StorefrontAccountLogin.url());
3599
3704
  await StorefrontAccountLogin.emailInput.fill(customer.email);
3600
3705
  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.1.0",
3
+ "version": "3.3.0",
4
4
  "description": "Shopware Acceptance Test Suite",
5
5
  "author": "shopware AG",
6
6
  "license": "MIT",