@shopware-ag/acceptance-test-suite 2.8.1 → 3.1.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
@@ -89,35 +89,39 @@ declare class MailpitApiContext {
89
89
  */
90
90
  getEmailHeaders(email: string): Promise<Email>;
91
91
  /**
92
- * Retrieves the body content of the latest email as an HTML string.
93
- * @returns The HTML content of the latest email.
92
+ * Retrieves the body content of the email as an HTML string.
93
+ * @param email - The email address of the recipient.
94
+ * @returns A promise that resolves to the HTML content of the email.
94
95
  */
95
- getEmailBody(): Promise<string>;
96
+ getEmailBody(email: string): Promise<string>;
96
97
  /**
97
98
  * Generates the full email content, combining headers and body.
98
99
  * @param email - The email address to fetch headers for.
99
- * @returns The full email content as a string.
100
+ * @returns A promise that resolves to the full email content as a string.
100
101
  */
101
102
  generateEmailContent(email: string): Promise<string>;
102
103
  /**
103
- * Retrieves the plain text content of the latest email.
104
- * @returns The plain text content of the latest email.
104
+ * Retrieves the plain text content of the email.
105
+ * @param email - The email address of the recipient.
106
+ * @returns A promise that resolves to the plain text content of the email.
105
107
  */
106
- getRenderMessageTxt(): Promise<string>;
108
+ getRenderMessageTxt(email: string): Promise<string>;
107
109
  /**
108
110
  * Extracts the first URL found in the plain text content of the latest email.
109
- * @returns The first URL found in the email content.
111
+ * @param email - The email address of the recipient.
112
+ * @returns A promise that resolves to the first URL found in the email content.
110
113
  * @throws An error if no URL is found in the email content.
111
114
  */
112
- getLinkFromMail(): Promise<string>;
115
+ getLinkFromMail(email: string): Promise<string>;
113
116
  /**
114
117
  * Deletes a specific email by ID if provided, or deletes all emails if no ID is provided.
115
118
  * @param emailId - The ID of the email to delete (optional).
116
119
  */
117
120
  deleteMail(emailId?: string): Promise<void>;
118
121
  /**
119
- * Creates a new EmailApiContext instance with the appropriate configuration.
120
- * @returns A promise that resolves to an EmailApiContext instance.
122
+ * Creates a new MailpitApiContext instance with the appropriate configuration.
123
+ * @param baseURL - The base URL for the API.
124
+ * @returns A promise that resolves to a MailpitApiContext instance.
121
125
  */
122
126
  static create(baseURL: string): Promise<MailpitApiContext>;
123
127
  }
@@ -281,6 +285,9 @@ type Promotion = Omit<components['schemas']['Promotion'], 'discounts'> & {
281
285
  type PromotionDiscount = components['schemas']['PromotionDiscount'] & {
282
286
  id: string;
283
287
  };
288
+ type OrderLineItem = components['schemas']['OrderLineItem'] & {
289
+ id: string;
290
+ };
284
291
 
285
292
  interface CreatedRecord {
286
293
  resource: string;
@@ -290,6 +297,7 @@ interface SimpleLineItem {
290
297
  product: Product | Promotion;
291
298
  quantity?: number;
292
299
  position?: number;
300
+ overrides?: Partial<OrderLineItem>;
293
301
  }
294
302
  interface SyncApiOperation {
295
303
  entity: string;
@@ -639,7 +647,7 @@ declare class TestDataService {
639
647
  isCalculated: boolean;
640
648
  referencePriceDefinition: null;
641
649
  };
642
- };
650
+ } & Partial<OrderLineItem>;
643
651
  getBasicPromotionLineItemStruct(lineItem: SimpleLineItem): {
644
652
  payload: {
645
653
  code: string | undefined;
@@ -669,7 +677,7 @@ declare class TestDataService {
669
677
  price: number;
670
678
  percentage: number | null;
671
679
  };
672
- };
680
+ } & Partial<OrderLineItem>;
673
681
  getBasicPromotionStruct(salesChannelId?: string, overrides?: Partial<Promotion>): Partial<Promotion>;
674
682
  }
675
683
 
@@ -1243,4 +1251,4 @@ declare const test: _playwright_test.TestType<_playwright_test.PlaywrightTestArg
1243
1251
  ValidateAccessibility: (pageName: string, assertViolations?: number | boolean | undefined, createReport?: boolean | undefined, ruleTags?: string[] | undefined, outputDir?: string | undefined) => () => Promise<axe_core.Result[]>;
1244
1252
  }, _playwright_test.PlaywrightWorkerArgs & _playwright_test.PlaywrightWorkerOptions & FixtureTypes>;
1245
1253
 
1246
- 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 };
1254
+ 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
@@ -89,35 +89,39 @@ declare class MailpitApiContext {
89
89
  */
90
90
  getEmailHeaders(email: string): Promise<Email>;
91
91
  /**
92
- * Retrieves the body content of the latest email as an HTML string.
93
- * @returns The HTML content of the latest email.
92
+ * Retrieves the body content of the email as an HTML string.
93
+ * @param email - The email address of the recipient.
94
+ * @returns A promise that resolves to the HTML content of the email.
94
95
  */
95
- getEmailBody(): Promise<string>;
96
+ getEmailBody(email: string): Promise<string>;
96
97
  /**
97
98
  * Generates the full email content, combining headers and body.
98
99
  * @param email - The email address to fetch headers for.
99
- * @returns The full email content as a string.
100
+ * @returns A promise that resolves to the full email content as a string.
100
101
  */
101
102
  generateEmailContent(email: string): Promise<string>;
102
103
  /**
103
- * Retrieves the plain text content of the latest email.
104
- * @returns The plain text content of the latest email.
104
+ * Retrieves the plain text content of the email.
105
+ * @param email - The email address of the recipient.
106
+ * @returns A promise that resolves to the plain text content of the email.
105
107
  */
106
- getRenderMessageTxt(): Promise<string>;
108
+ getRenderMessageTxt(email: string): Promise<string>;
107
109
  /**
108
110
  * Extracts the first URL found in the plain text content of the latest email.
109
- * @returns The first URL found in the email content.
111
+ * @param email - The email address of the recipient.
112
+ * @returns A promise that resolves to the first URL found in the email content.
110
113
  * @throws An error if no URL is found in the email content.
111
114
  */
112
- getLinkFromMail(): Promise<string>;
115
+ getLinkFromMail(email: string): Promise<string>;
113
116
  /**
114
117
  * Deletes a specific email by ID if provided, or deletes all emails if no ID is provided.
115
118
  * @param emailId - The ID of the email to delete (optional).
116
119
  */
117
120
  deleteMail(emailId?: string): Promise<void>;
118
121
  /**
119
- * Creates a new EmailApiContext instance with the appropriate configuration.
120
- * @returns A promise that resolves to an EmailApiContext instance.
122
+ * Creates a new MailpitApiContext instance with the appropriate configuration.
123
+ * @param baseURL - The base URL for the API.
124
+ * @returns A promise that resolves to a MailpitApiContext instance.
121
125
  */
122
126
  static create(baseURL: string): Promise<MailpitApiContext>;
123
127
  }
@@ -281,6 +285,9 @@ type Promotion = Omit<components['schemas']['Promotion'], 'discounts'> & {
281
285
  type PromotionDiscount = components['schemas']['PromotionDiscount'] & {
282
286
  id: string;
283
287
  };
288
+ type OrderLineItem = components['schemas']['OrderLineItem'] & {
289
+ id: string;
290
+ };
284
291
 
285
292
  interface CreatedRecord {
286
293
  resource: string;
@@ -290,6 +297,7 @@ interface SimpleLineItem {
290
297
  product: Product | Promotion;
291
298
  quantity?: number;
292
299
  position?: number;
300
+ overrides?: Partial<OrderLineItem>;
293
301
  }
294
302
  interface SyncApiOperation {
295
303
  entity: string;
@@ -639,7 +647,7 @@ declare class TestDataService {
639
647
  isCalculated: boolean;
640
648
  referencePriceDefinition: null;
641
649
  };
642
- };
650
+ } & Partial<OrderLineItem>;
643
651
  getBasicPromotionLineItemStruct(lineItem: SimpleLineItem): {
644
652
  payload: {
645
653
  code: string | undefined;
@@ -669,7 +677,7 @@ declare class TestDataService {
669
677
  price: number;
670
678
  percentage: number | null;
671
679
  };
672
- };
680
+ } & Partial<OrderLineItem>;
673
681
  getBasicPromotionStruct(salesChannelId?: string, overrides?: Partial<Promotion>): Partial<Promotion>;
674
682
  }
675
683
 
@@ -1243,4 +1251,4 @@ declare const test: _playwright_test.TestType<_playwright_test.PlaywrightTestArg
1243
1251
  ValidateAccessibility: (pageName: string, assertViolations?: number | boolean | undefined, createReport?: boolean | undefined, ruleTags?: string[] | undefined, outputDir?: string | undefined) => () => Promise<axe_core.Result[]>;
1244
1252
  }, _playwright_test.PlaywrightWorkerArgs & _playwright_test.PlaywrightWorkerOptions & FixtureTypes>;
1245
1253
 
1246
- 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 };
1254
+ 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
@@ -579,33 +579,35 @@ class MailpitApiContext {
579
579
  }
580
580
  });
581
581
  const responseJson = await response.json();
582
+ const message = responseJson.messages[0];
582
583
  return {
583
- fromName: responseJson.messages[0].From.Name,
584
- fromAddress: responseJson.messages[0].From.Address,
585
- toName: responseJson.messages[0].To[0].Name,
586
- toAddress: responseJson.messages[0].To[0].Address,
587
- subject: responseJson.messages[0].Subject,
588
- emailId: responseJson.messages[0].ID
584
+ fromName: message.From.Name,
585
+ fromAddress: message.From.Address,
586
+ toName: message.To[0].Name,
587
+ toAddress: message.To[0].Address,
588
+ subject: message.Subject,
589
+ emailId: message.ID
589
590
  };
590
591
  }
591
592
  /**
592
- * Retrieves the body content of the latest email as an HTML string.
593
- * @returns The HTML content of the latest email.
593
+ * Retrieves the body content of the email as an HTML string.
594
+ * @param email - The email address of the recipient.
595
+ * @returns A promise that resolves to the HTML content of the email.
594
596
  */
595
- async getEmailBody() {
596
- const response = await this.context.get("view/latest.html");
597
+ async getEmailBody(email) {
598
+ const emailId = (await this.getEmailHeaders(email)).emailId;
599
+ const response = await this.context.get(`view/${emailId}.html`);
597
600
  const buffer = await response.body();
598
- const htmlString = buffer.toString("utf-8");
599
- return htmlString;
601
+ return buffer.toString("utf-8");
600
602
  }
601
603
  /**
602
604
  * Generates the full email content, combining headers and body.
603
605
  * @param email - The email address to fetch headers for.
604
- * @returns The full email content as a string.
606
+ * @returns A promise that resolves to the full email content as a string.
605
607
  */
606
608
  async generateEmailContent(email) {
607
609
  const headers = await this.getEmailHeaders(email);
608
- const htmlTemplate = await this.getEmailBody();
610
+ const htmlTemplate = await this.getEmailBody(email);
609
611
  const headerSection = `
610
612
  <div style="font-family:arial; font-size:16px;" id="email-container">
611
613
  <p id="from"><strong>From:</strong> ${headers.fromName} &lt;${headers.fromAddress}&gt;</p>
@@ -613,28 +615,29 @@ class MailpitApiContext {
613
615
  <p id="subject"><strong>Subject:</strong> ${headers.subject}</p>
614
616
  </div>
615
617
  `;
616
- const emailContent = headerSection + htmlTemplate;
617
- return emailContent;
618
+ return headerSection + htmlTemplate;
618
619
  }
619
620
  /**
620
- * Retrieves the plain text content of the latest email.
621
- * @returns The plain text content of the latest email.
621
+ * Retrieves the plain text content of the email.
622
+ * @param email - The email address of the recipient.
623
+ * @returns A promise that resolves to the plain text content of the email.
622
624
  */
623
- async getRenderMessageTxt() {
624
- const response = await this.context.get("view/latest.txt");
625
+ async getRenderMessageTxt(email) {
626
+ const emailId = (await this.getEmailHeaders(email)).emailId;
627
+ const response = await this.context.get(`view/${emailId}.txt`);
625
628
  const buffer = await response.body();
626
- const text = buffer.toString("utf-8");
627
- return text;
629
+ return buffer.toString("utf-8");
628
630
  }
629
631
  /**
630
632
  * Extracts the first URL found in the plain text content of the latest email.
631
- * @returns The first URL found in the email content.
633
+ * @param email - The email address of the recipient.
634
+ * @returns A promise that resolves to the first URL found in the email content.
632
635
  * @throws An error if no URL is found in the email content.
633
636
  */
634
- async getLinkFromMail() {
635
- const textContent = await this.getRenderMessageTxt();
637
+ async getLinkFromMail(email) {
638
+ const textContent = await this.getRenderMessageTxt(email);
636
639
  const urlMatch = textContent.match(/https?:\/\/[^\s]+/);
637
- if (urlMatch && urlMatch.length > 0) {
640
+ if (urlMatch) {
638
641
  return urlMatch[0];
639
642
  }
640
643
  throw new Error("No URL found in the email content");
@@ -648,8 +651,9 @@ class MailpitApiContext {
648
651
  await this.context.delete(`api/v1/messages`, { data });
649
652
  }
650
653
  /**
651
- * Creates a new EmailApiContext instance with the appropriate configuration.
652
- * @returns A promise that resolves to an EmailApiContext instance.
654
+ * Creates a new MailpitApiContext instance with the appropriate configuration.
655
+ * @param baseURL - The base URL for the API.
656
+ * @returns A promise that resolves to a MailpitApiContext instance.
653
657
  */
654
658
  static async create(baseURL) {
655
659
  const extraHTTPHeaders = {
@@ -1927,7 +1931,7 @@ class TestDataService {
1927
1931
  const product = lineItem.product;
1928
1932
  const unitPrice = product.price[0].gross || 10;
1929
1933
  const totalPrice = unitPrice * (lineItem.quantity || 1);
1930
- return {
1934
+ const basicProductLineItemStruct = {
1931
1935
  productId: product.id,
1932
1936
  referencedId: product.id,
1933
1937
  payload: {
@@ -1965,6 +1969,7 @@ class TestDataService {
1965
1969
  referencePriceDefinition: null
1966
1970
  }
1967
1971
  };
1972
+ return Object.assign({}, basicProductLineItemStruct, lineItem.overrides);
1968
1973
  }
1969
1974
  getBasicPromotionLineItemStruct(lineItem) {
1970
1975
  if (!this.isPromotion(lineItem.product)) {
@@ -1976,7 +1981,7 @@ class TestDataService {
1976
1981
  const promotionDiscountId = promotion.discounts[0].id;
1977
1982
  const unitPrice = -Math.abs(promotionDiscountValue || 10);
1978
1983
  const totalPrice = unitPrice * (lineItem.quantity || 1);
1979
- return {
1984
+ const basicPromotionLineItemStruct = {
1980
1985
  payload: {
1981
1986
  code: promotion.code
1982
1987
  },
@@ -2006,6 +2011,7 @@ class TestDataService {
2006
2011
  percentage: promotionDiscountType === "percentage" ? promotionDiscountValue : null
2007
2012
  }
2008
2013
  };
2014
+ return Object.assign({}, basicPromotionLineItemStruct, lineItem.overrides);
2009
2015
  }
2010
2016
  getBasicPromotionStruct(salesChannelId = this.defaultSalesChannel.id, overrides = {}) {
2011
2017
  const promotionCode = `${this.IdProvider.getIdPair().id}`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shopware-ag/acceptance-test-suite",
3
- "version": "2.8.1",
3
+ "version": "3.1.0",
4
4
  "description": "Shopware Acceptance Test Suite",
5
5
  "author": "shopware AG",
6
6
  "license": "MIT",