@shopware-ag/acceptance-test-suite 2.8.1 → 3.0.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
  }
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
  }
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 = {
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.0.0",
4
4
  "description": "Shopware Acceptance Test Suite",
5
5
  "author": "shopware AG",
6
6
  "license": "MIT",