@bigbinary/neeto-playwright-commons 3.1.0 → 3.1.1
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/index.cjs.js +19 -8
- package/index.cjs.js.map +1 -1
- package/index.d.ts +90 -30
- package/index.js +19 -8
- package/index.js.map +1 -1
- package/package.json +1 -1
package/index.cjs.js
CHANGED
|
@@ -60529,7 +60529,7 @@ class RailsEmailUtils {
|
|
|
60529
60529
|
});
|
|
60530
60530
|
return otp || undefined;
|
|
60531
60531
|
};
|
|
60532
|
-
getEmailAttachment = async (
|
|
60532
|
+
getEmailAttachment = async ({ name, type }, messageSearchCriteria = {}, { receivedAfter = new Date(new Date().valueOf() - 60 * 60 * 1000), expectedEmailCount = 1, timeout = 10_000, } = {}, shouldThrowErrorOnTimeout = true) => {
|
|
60533
60533
|
const attachmentDetails = (await this.neetoPlaywrightUtilities.executeRecursively({
|
|
60534
60534
|
callback: async () => {
|
|
60535
60535
|
const railsEmail = await this.railsEmailClient.getLatestEmail({
|
|
@@ -60538,7 +60538,11 @@ class RailsEmailUtils {
|
|
|
60538
60538
|
});
|
|
60539
60539
|
if (!railsEmail)
|
|
60540
60540
|
return null;
|
|
60541
|
-
const attachment = railsEmail.attachments?.find(att =>
|
|
60541
|
+
const attachment = railsEmail.attachments?.find(att => {
|
|
60542
|
+
const matchesName = name ? att.name?.includes(name) : true;
|
|
60543
|
+
const matchesType = type ? att.type?.startsWith(type) : true;
|
|
60544
|
+
return matchesName && matchesType;
|
|
60545
|
+
});
|
|
60542
60546
|
if (!attachment)
|
|
60543
60547
|
return null;
|
|
60544
60548
|
return {
|
|
@@ -60722,19 +60726,26 @@ class MailerUtils {
|
|
|
60722
60726
|
return codes?.[0];
|
|
60723
60727
|
};
|
|
60724
60728
|
generateRandomEmail = () => faker.faker.internet.email({ provider: process.env.FASTMAIL_DOMAIN_NAME });
|
|
60725
|
-
getEmailAttachment = async (
|
|
60726
|
-
if (IS_DEV_ENV)
|
|
60727
|
-
return this.railsEmailUtils.getEmailAttachment(
|
|
60728
|
-
}
|
|
60729
|
+
getEmailAttachment = async ({ name, type }, messageSearchCriteria = {}, { timeout = 10_000, receivedAfter = dateTimeOneHourAgo(), expectedEmailCount = 1, } = {}, shouldThrowErrorOnTimeout = true) => {
|
|
60730
|
+
if (IS_DEV_ENV)
|
|
60731
|
+
return this.railsEmailUtils.getEmailAttachment({ name, type }, messageSearchCriteria, { receivedAfter, expectedEmailCount, timeout: timeout / 3 }, shouldThrowErrorOnTimeout);
|
|
60729
60732
|
const { blobId, attachments: attachmentNameAndTypes } = await this.findMessage(messageSearchCriteria, { expectedEmailCount, receivedAfter, timeout }, shouldThrowErrorOnTimeout);
|
|
60730
|
-
const attachment = attachmentNameAndTypes.find(
|
|
60733
|
+
const attachment = attachmentNameAndTypes.find(att => {
|
|
60734
|
+
const matchesName = name ? att.name?.includes(name) : true;
|
|
60735
|
+
const matchesType = type ? att.type?.startsWith(type) : true;
|
|
60736
|
+
return matchesName && matchesType;
|
|
60737
|
+
});
|
|
60731
60738
|
if (!attachment)
|
|
60732
60739
|
throw new Error("No such attachment exists");
|
|
60733
60740
|
const emailAttachment = await this.fastmailApi.fetchAttachments(blobId, attachment.name);
|
|
60734
60741
|
const buffer = await emailAttachment.body();
|
|
60735
60742
|
const parsedEmail = await mailparserExports.simpleParser(buffer);
|
|
60736
60743
|
const attachments = parsedEmail.attachments;
|
|
60737
|
-
return attachments.find(
|
|
60744
|
+
return attachments.find(att => {
|
|
60745
|
+
const matchesName = name ? att.filename?.includes(name) : true;
|
|
60746
|
+
const matchesType = type ? att.contentType?.startsWith(type) : true;
|
|
60747
|
+
return matchesName && matchesType;
|
|
60748
|
+
});
|
|
60738
60749
|
};
|
|
60739
60750
|
}
|
|
60740
60751
|
|