@bigbinary/neeto-playwright-commons 4.2.2 → 4.2.4
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.d.ts +13 -1
- package/index.js +60 -9
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -898,6 +898,7 @@ interface RailsEmail {
|
|
|
898
898
|
htmlBody?: string;
|
|
899
899
|
textBody?: string;
|
|
900
900
|
receivedAt: string;
|
|
901
|
+
messageId?: string;
|
|
901
902
|
attachments?: RailsEmailAttachment[];
|
|
902
903
|
}
|
|
903
904
|
interface BaseRailsEmailSearchParams {
|
|
@@ -1249,6 +1250,7 @@ interface FormattedList$1 {
|
|
|
1249
1250
|
subject: string;
|
|
1250
1251
|
attachments: Attachment$1[];
|
|
1251
1252
|
blobId: string;
|
|
1253
|
+
messageId?: string;
|
|
1252
1254
|
}
|
|
1253
1255
|
interface AttachmentDetails$1 {
|
|
1254
1256
|
filename: string | null;
|
|
@@ -1263,7 +1265,7 @@ declare class RailsEmailUtils {
|
|
|
1263
1265
|
private convertRailsEmailToFormattedList;
|
|
1264
1266
|
clearEmails: () => Promise<unknown>;
|
|
1265
1267
|
clearStaleEmails: () => Promise<unknown>;
|
|
1266
|
-
getLatestEmail: (searchParams: RailsEmailSearchParams) => Promise<
|
|
1268
|
+
getLatestEmail: (searchParams: RailsEmailSearchParams) => Promise<RailsEmail | null>;
|
|
1267
1269
|
listEmails: (searchParams?: RailsEmailSearchParams) => Promise<RailsEmail[]>;
|
|
1268
1270
|
/**
|
|
1269
1271
|
*
|
|
@@ -1403,6 +1405,10 @@ declare class RailsEmailUtils {
|
|
|
1403
1405
|
receivedAfter,
|
|
1404
1406
|
expectedEmailCount
|
|
1405
1407
|
}?: Partial<FindMessageFilterOptions$1> | undefined, shouldThrowErrorOnTimeout?: boolean) => Promise<FormattedList$1 | Record<string, never>>;
|
|
1408
|
+
getLatestMessageId: (subject: string, {
|
|
1409
|
+
timeout,
|
|
1410
|
+
receivedAfter
|
|
1411
|
+
}?: Partial<FindMessageFilterOptions$1> | undefined) => Promise<string | undefined>;
|
|
1406
1412
|
/**
|
|
1407
1413
|
*
|
|
1408
1414
|
* A helper method that is used to find the first code value from the matching email body. This method has been built to match the Neeto OTP emails.
|
|
@@ -1615,6 +1621,7 @@ interface FormattedList {
|
|
|
1615
1621
|
subject: string;
|
|
1616
1622
|
attachments: Attachment[];
|
|
1617
1623
|
blobId: string;
|
|
1624
|
+
messageId?: string;
|
|
1618
1625
|
}
|
|
1619
1626
|
declare class MailerUtils {
|
|
1620
1627
|
private neetoPlaywrightUtilities;
|
|
@@ -1800,6 +1807,10 @@ declare class MailerUtils {
|
|
|
1800
1807
|
*
|
|
1801
1808
|
*/
|
|
1802
1809
|
generateRandomEmail: () => string;
|
|
1810
|
+
getLatestMessageId: (subject: string, {
|
|
1811
|
+
timeout,
|
|
1812
|
+
receivedAfter
|
|
1813
|
+
}?: Partial<FindMessageFilterOptions> | undefined) => Promise<string | undefined>;
|
|
1803
1814
|
/**
|
|
1804
1815
|
*
|
|
1805
1816
|
* This method is used to return an attachment from the first email matching the search criteria. It supports filtering attachments by name, by MIME content-type, or both. If no matching attachment is found, an error is thrown.
|
|
@@ -6867,6 +6878,7 @@ declare const NEETO_EDITOR_SELECTORS: {
|
|
|
6867
6878
|
neetoEditorHighlightTextColor: (textColorIndex: number) => string;
|
|
6868
6879
|
neetoEditorHighlightBgColor: (bgColorIndex: number) => string;
|
|
6869
6880
|
todoList: string;
|
|
6881
|
+
selectedText: string;
|
|
6870
6882
|
commandListItem: (index: number) => string;
|
|
6871
6883
|
itemBlockHeading: string;
|
|
6872
6884
|
};
|
package/index.js
CHANGED
|
@@ -351,6 +351,7 @@ class RailsEmailApiClient {
|
|
|
351
351
|
htmlBody: raw.html_body,
|
|
352
352
|
textBody: raw.text_body,
|
|
353
353
|
receivedAt: raw.received_at,
|
|
354
|
+
...(raw.message_id && { messageId: raw.message_id }),
|
|
354
355
|
attachments: raw.attachments?.map(({ filename, mime_type, data }) => ({
|
|
355
356
|
name: filename,
|
|
356
357
|
type: mime_type,
|
|
@@ -1377,6 +1378,7 @@ const NEETO_EDITOR_SELECTORS = {
|
|
|
1377
1378
|
neetoEditorHighlightTextColor: (textColorIndex) => `neeto-editor-highlight-text-color-dot-${textColorIndex}`,
|
|
1378
1379
|
neetoEditorHighlightBgColor: (bgColorIndex) => `neeto-editor-highlight-background-color-dot-${bgColorIndex}`,
|
|
1379
1380
|
todoList: "[data-type='todoList']",
|
|
1381
|
+
selectedText: ".selected-text",
|
|
1380
1382
|
commandListItem: (index) => `neeto-editor-command-list-item-${index}`,
|
|
1381
1383
|
itemBlockHeading: "neeto-editor-command-list-item-block-heading",
|
|
1382
1384
|
};
|
|
@@ -2385,11 +2387,12 @@ class CustomCommands {
|
|
|
2385
2387
|
const isMacOS = os.platform() === "darwin";
|
|
2386
2388
|
const rightArrowKey = isMacOS ? "Meta+ArrowRight" : "End";
|
|
2387
2389
|
const downArrowKey = isMacOS ? "Meta+ArrowDown" : "PageDown";
|
|
2388
|
-
await
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
|
|
2390
|
+
await expect(async () => {
|
|
2391
|
+
await this.page.keyboard.press(rightArrowKey);
|
|
2392
|
+
await this.page.keyboard.press(rightArrowKey);
|
|
2393
|
+
await this.page.keyboard.press(downArrowKey);
|
|
2394
|
+
await expect(this.page.locator(NEETO_EDITOR_SELECTORS.selectedText)).toHaveCount(0, { timeout: 2_000 });
|
|
2395
|
+
}).toPass({ timeout: 15_000 });
|
|
2393
2396
|
await this.page.keyboard.press("Enter");
|
|
2394
2397
|
};
|
|
2395
2398
|
}
|
|
@@ -69651,6 +69654,7 @@ class RailsEmailUtils {
|
|
|
69651
69654
|
type: att.type,
|
|
69652
69655
|
})) || [],
|
|
69653
69656
|
blobId: "",
|
|
69657
|
+
...(railsEmail.messageId && { messageId: railsEmail.messageId }),
|
|
69654
69658
|
};
|
|
69655
69659
|
};
|
|
69656
69660
|
clearEmails = () => this.railsEmailClient.clearEmails();
|
|
@@ -69660,7 +69664,7 @@ class RailsEmailUtils {
|
|
|
69660
69664
|
};
|
|
69661
69665
|
getLatestEmail = async (searchParams) => {
|
|
69662
69666
|
await this.clearStaleEmails();
|
|
69663
|
-
|
|
69667
|
+
return this.railsEmailClient.getLatestEmail(searchParams);
|
|
69664
69668
|
};
|
|
69665
69669
|
listEmails = (searchParams) => this.railsEmailClient.listEmails(searchParams);
|
|
69666
69670
|
listMessages = async (messageSearchCriteria = {}, { receivedAfter = new Date(new Date().valueOf() - 60 * 60 * 1000), } = {}) => {
|
|
@@ -69700,6 +69704,12 @@ class RailsEmailUtils {
|
|
|
69700
69704
|
}
|
|
69701
69705
|
return email;
|
|
69702
69706
|
};
|
|
69707
|
+
getLatestMessageId = async (subject, { timeout = 10_000, receivedAfter = new Date(new Date().valueOf() - 60 * 1000), } = {}) => {
|
|
69708
|
+
const email = await this.findMessage({ subject }, { timeout, receivedAfter }, false);
|
|
69709
|
+
if (!("messageId" in email) || !email.messageId)
|
|
69710
|
+
return undefined;
|
|
69711
|
+
return email.messageId.replace(/^<|>$/g, "");
|
|
69712
|
+
};
|
|
69703
69713
|
findOtpFromEmail = async ({ email, subjectSubstring = OTP_EMAIL_PATTERN, timeout = 10_000, receivedAfter = new Date(), expectedEmailCount = 1, }) => {
|
|
69704
69714
|
const otp = await this.neetoPlaywrightUtilities.executeRecursively({
|
|
69705
69715
|
callback: async () => {
|
|
@@ -69813,7 +69823,7 @@ class MailerUtils {
|
|
|
69813
69823
|
};
|
|
69814
69824
|
const { methodResponses: [[, { list }]], } = await this.fastmailApi.apiRequest("Email/get", messageDetailsBody);
|
|
69815
69825
|
const formattedList = list.map((listItem) => {
|
|
69816
|
-
const { id, from, to, bodyValues, cc, bcc, replyTo, receivedAt, subject, attachments, blobId, } = listItem;
|
|
69826
|
+
const { id, from, to, bodyValues, cc, bcc, replyTo, receivedAt, subject, messageId, attachments, blobId, } = listItem;
|
|
69817
69827
|
const emailBody = Object.values(pluck("value", bodyValues)).join(" ");
|
|
69818
69828
|
const emailBodyWithStrippedHead = emailBody.split("</head>").at(-1);
|
|
69819
69829
|
const links = emailBodyWithStrippedHead.match(LINK_REGEX);
|
|
@@ -69844,6 +69854,7 @@ class MailerUtils {
|
|
|
69844
69854
|
subject,
|
|
69845
69855
|
attachments,
|
|
69846
69856
|
blobId,
|
|
69857
|
+
...(messageId?.[0] && { messageId: messageId[0] }),
|
|
69847
69858
|
};
|
|
69848
69859
|
});
|
|
69849
69860
|
return formattedList;
|
|
@@ -69864,10 +69875,10 @@ class MailerUtils {
|
|
|
69864
69875
|
return ids;
|
|
69865
69876
|
},
|
|
69866
69877
|
condition: async () => {
|
|
69867
|
-
const {
|
|
69878
|
+
const { ids } = await this.queryEmail(messageSearchCriteria, {
|
|
69868
69879
|
receivedAfter,
|
|
69869
69880
|
});
|
|
69870
|
-
return
|
|
69881
|
+
return ids.length >= expectedEmailCount;
|
|
69871
69882
|
},
|
|
69872
69883
|
timeout,
|
|
69873
69884
|
}));
|
|
@@ -69924,6 +69935,46 @@ class MailerUtils {
|
|
|
69924
69935
|
return codes?.[0];
|
|
69925
69936
|
};
|
|
69926
69937
|
generateRandomEmail = () => faker.internet.email({ provider: process.env.FASTMAIL_DOMAIN_NAME });
|
|
69938
|
+
getLatestMessageId = async (subject, { timeout = 10_000, receivedAfter = dateTimeOneHourAgo(), } = {}) => {
|
|
69939
|
+
if (IS_DEV_ENV) {
|
|
69940
|
+
return this.railsEmailUtils.getLatestMessageId(subject, {
|
|
69941
|
+
timeout: timeout / 3,
|
|
69942
|
+
receivedAfter,
|
|
69943
|
+
});
|
|
69944
|
+
}
|
|
69945
|
+
if (!this.accountId) {
|
|
69946
|
+
await this.fastmailApi.authorizeAndSetAccountId();
|
|
69947
|
+
}
|
|
69948
|
+
const messageId = (await this.neetoPlaywrightUtilities.executeRecursively({
|
|
69949
|
+
callback: async () => {
|
|
69950
|
+
const { methodResponses: [[, { ids }]], } = await this.fastmailApi.apiRequest("Email/query", {
|
|
69951
|
+
filter: { subject, after: receivedAfter.toISOString() },
|
|
69952
|
+
sort: [{ property: "receivedAt", isAscending: false }],
|
|
69953
|
+
limit: 1,
|
|
69954
|
+
});
|
|
69955
|
+
const emailId = ids?.[0];
|
|
69956
|
+
if (!emailId)
|
|
69957
|
+
return null;
|
|
69958
|
+
const { methodResponses: [[, { list }]], } = await this.fastmailApi.apiRequest("Email/get", {
|
|
69959
|
+
ids: [emailId],
|
|
69960
|
+
properties: ["messageId"],
|
|
69961
|
+
});
|
|
69962
|
+
const rawMessageId = list?.[0]?.messageId?.[0];
|
|
69963
|
+
if (!rawMessageId)
|
|
69964
|
+
return null;
|
|
69965
|
+
return rawMessageId.replace(/^<|>$/g, "");
|
|
69966
|
+
},
|
|
69967
|
+
condition: async () => {
|
|
69968
|
+
const { methodResponses: [[, { ids }]], } = await this.fastmailApi.apiRequest("Email/query", {
|
|
69969
|
+
filter: { subject, after: receivedAfter.toISOString() },
|
|
69970
|
+
limit: 1,
|
|
69971
|
+
});
|
|
69972
|
+
return ids.length >= 1;
|
|
69973
|
+
},
|
|
69974
|
+
timeout,
|
|
69975
|
+
}));
|
|
69976
|
+
return messageId || undefined;
|
|
69977
|
+
};
|
|
69927
69978
|
getEmailAttachment = async ({ name, type }, messageSearchCriteria = {}, { timeout = 10_000, receivedAfter = dateTimeOneHourAgo(), expectedEmailCount = 1, } = {}, shouldThrowErrorOnTimeout = true) => {
|
|
69928
69979
|
if (IS_DEV_ENV)
|
|
69929
69980
|
return this.railsEmailUtils.getEmailAttachment({ name, type }, messageSearchCriteria, { receivedAfter, expectedEmailCount, timeout: timeout / 3 }, shouldThrowErrorOnTimeout);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bigbinary/neeto-playwright-commons",
|
|
3
|
-
"version": "4.2.
|
|
3
|
+
"version": "4.2.4",
|
|
4
4
|
"description": "A package encapsulating common playwright code across neeto projects.",
|
|
5
5
|
"repository": "git@github.com:bigbinary/neeto-playwright-commons.git",
|
|
6
6
|
"license": "apache-2.0",
|