@bigbinary/neeto-playwright-commons 1.8.37 → 1.8.38
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 +20 -2
- package/index.cjs.js.map +1 -1
- package/index.d.ts +10 -2
- package/index.js +20 -2
- package/index.js.map +1 -1
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as _playwright_test from '@playwright/test';
|
|
2
2
|
import { Page, APIRequestContext, Response, APIResponse, Fixtures, PlaywrightWorkerArgs, PlaywrightWorkerOptions, PlaywrightTestArgs, PlaywrightTestOptions, Browser, BrowserContext, FrameLocator, Locator, CDPSession } from '@playwright/test';
|
|
3
|
+
import * as mailosaur_lib_models from 'mailosaur/lib/models';
|
|
3
4
|
import MailosaurClient from 'mailosaur';
|
|
4
5
|
import { I18nPlaywrightFixture } from 'playwright-i18next-fixture';
|
|
5
6
|
import { TFunction } from 'i18next';
|
|
@@ -40,6 +41,11 @@ interface ApiRequestProps {
|
|
|
40
41
|
method?: HttpMethods;
|
|
41
42
|
params?: ParamProps;
|
|
42
43
|
}
|
|
44
|
+
interface WaitForPageLoadParams {
|
|
45
|
+
visiblityTimeout: number;
|
|
46
|
+
retryTimeout: number;
|
|
47
|
+
customPageContext: Page | undefined;
|
|
48
|
+
}
|
|
43
49
|
type ApiRequest = (props: ApiRequestProps & Record<string, unknown>) => Promise<APIResponse | undefined>;
|
|
44
50
|
interface FieldValue {
|
|
45
51
|
field: string;
|
|
@@ -67,22 +73,24 @@ declare class CustomCommands {
|
|
|
67
73
|
executeRecursively: ExecuteRecursively;
|
|
68
74
|
verifySuccessToast: ({ message, closeAfterVerification, }?: Partial<VerifySuccessToastParams>) => Promise<void>;
|
|
69
75
|
reloadAndWait: (requestCount: number, customPageContext?: Page, interceptMultipleResponsesProps?: Partial<Omit<InterceptMultipleResponsesParams, "times">>) => Promise<void>;
|
|
76
|
+
waitForPageLoad: ({ visiblityTimeout, customPageContext, }: WaitForPageLoadParams) => Promise<void>;
|
|
70
77
|
apiRequest: ApiRequest;
|
|
71
78
|
selectOptionFromDropdown: ({ selectValueContainer, selectMenu, value, options, }: SelectOptionFromDropdownParams) => Promise<void>;
|
|
72
79
|
verifyFieldValue: VerifyFieldValue;
|
|
73
80
|
}
|
|
74
81
|
|
|
75
|
-
interface
|
|
82
|
+
interface EmailContentParams {
|
|
76
83
|
email: string;
|
|
77
84
|
subjectSubstring?: string;
|
|
78
85
|
timeout?: number;
|
|
79
86
|
receivedAfter?: Date;
|
|
80
87
|
}
|
|
81
|
-
type FetchOtpFromEmail = (props:
|
|
88
|
+
type FetchOtpFromEmail = (props: EmailContentParams) => Promise<string | undefined>;
|
|
82
89
|
declare class MailosaurUtils {
|
|
83
90
|
mailosaur: MailosaurClient;
|
|
84
91
|
serverId: string;
|
|
85
92
|
constructor(mailosaur: MailosaurClient);
|
|
93
|
+
getEmailContent: ({ email, subjectSubstring, timeout, receivedAfter, }: EmailContentParams) => Promise<mailosaur_lib_models.Message>;
|
|
86
94
|
fetchOtpFromEmail: FetchOtpFromEmail;
|
|
87
95
|
generateRandomMailosaurEmail: () => string;
|
|
88
96
|
}
|
package/index.js
CHANGED
|
@@ -2517,6 +2517,18 @@ class CustomCommands {
|
|
|
2517
2517
|
await pageContext.reload();
|
|
2518
2518
|
await reloadRequests;
|
|
2519
2519
|
};
|
|
2520
|
+
this.waitForPageLoad = async ({ visiblityTimeout = 35000, customPageContext, }) => {
|
|
2521
|
+
const pageContext = customPageContext !== null && customPageContext !== void 0 ? customPageContext : this.page;
|
|
2522
|
+
await pageContext.waitForLoadState("load");
|
|
2523
|
+
await Promise.all([
|
|
2524
|
+
expect(pageContext.getByTestId(COMMON_SELECTORS.pageLoader)).toBeHidden({
|
|
2525
|
+
timeout: visiblityTimeout,
|
|
2526
|
+
}),
|
|
2527
|
+
expect(pageContext.getByTestId(COMMON_SELECTORS.spinner)).toBeHidden({
|
|
2528
|
+
timeout: visiblityTimeout,
|
|
2529
|
+
}),
|
|
2530
|
+
]);
|
|
2531
|
+
};
|
|
2520
2532
|
this.apiRequest = async ({ url, failOnStatusCode = true, headers: additionalHeaders, body: data, method = "get", params = {}, ...otherOptions }) => {
|
|
2521
2533
|
const csrfToken = await this.page
|
|
2522
2534
|
.locator("[name='csrf-token']")
|
|
@@ -2568,12 +2580,18 @@ class CustomCommands {
|
|
|
2568
2580
|
|
|
2569
2581
|
class MailosaurUtils {
|
|
2570
2582
|
constructor(mailosaur) {
|
|
2583
|
+
this.getEmailContent = ({ email, subjectSubstring = "", timeout = 2 * 60 * 1000, receivedAfter = new Date(), }) => this.mailosaur.messages.get(this.serverId, { sentTo: email, subject: subjectSubstring }, { timeout, receivedAfter });
|
|
2571
2584
|
this.fetchOtpFromEmail = async ({ email, subjectSubstring = OTP_EMAIL_PATTERN, timeout = 2 * 60 * 1000, receivedAfter = new Date(), }) => {
|
|
2572
2585
|
var _a, _b, _c;
|
|
2573
|
-
const receivedEmail = await this.
|
|
2586
|
+
const receivedEmail = await this.getEmailContent({
|
|
2587
|
+
email,
|
|
2588
|
+
subjectSubstring,
|
|
2589
|
+
timeout,
|
|
2590
|
+
receivedAfter,
|
|
2591
|
+
});
|
|
2574
2592
|
const otp = (_c = (_b = (_a = receivedEmail === null || receivedEmail === void 0 ? void 0 : receivedEmail.text) === null || _a === void 0 ? void 0 : _a.codes) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.value;
|
|
2575
2593
|
if (isNil(otp)) {
|
|
2576
|
-
throw new Error(`No codes found in the email with subject: ${receivedEmail.subject}. Please re-evaluate the filtering parameters.`);
|
|
2594
|
+
throw new Error(`No codes found in the email with subject: ${receivedEmail === null || receivedEmail === void 0 ? void 0 : receivedEmail.subject}. Please re-evaluate the filtering parameters.`);
|
|
2577
2595
|
}
|
|
2578
2596
|
return otp;
|
|
2579
2597
|
};
|