@bigbinary/neeto-playwright-commons 2.0.0 → 2.0.2
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 +49 -37
- package/index.cjs.js.map +1 -1
- package/index.d.ts +7 -2
- package/index.js +50 -38
- package/index.js.map +1 -1
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -1594,10 +1594,14 @@ declare class MailerUtils {
|
|
|
1594
1594
|
*
|
|
1595
1595
|
* Generates a random Fastmail email based on the value of the FASTMAIL_DOMAIN_NAME environment variable.
|
|
1596
1596
|
*
|
|
1597
|
-
*
|
|
1597
|
+
* shouldUseBypassEmail (optional): A boolean value indicating whether to generate a bypass email. Defaults to false.
|
|
1598
|
+
*
|
|
1599
|
+
* Returns a random mixed-cased email ending with the FASTMAIL_DOMAIN_NAME. If shouldUseBypassEmail is true, it returns a random email to bypass OTP verification and log into
|
|
1600
|
+
*
|
|
1601
|
+
* neeto products.
|
|
1598
1602
|
*
|
|
1599
1603
|
*/
|
|
1600
|
-
generateRandomEmail: () => string;
|
|
1604
|
+
generateRandomEmail: (shouldUseBypassEmail?: boolean) => string;
|
|
1601
1605
|
/**
|
|
1602
1606
|
*
|
|
1603
1607
|
* This method is used to return the attachment based on the attachmentName of first email matching the search criteria. On top of the findMessage method, this method matches the attachment name with the attachments associated to the email. If any attachment matches then it will fetch the attachment details and return. If any attachment file name doesn't contain the substring attachmentName then it will throw an error saying No such attachment exists.
|
|
@@ -6093,6 +6097,7 @@ declare const COMMON_SELECTORS: {
|
|
|
6093
6097
|
profileSidebar: string;
|
|
6094
6098
|
selectOption: (label: string) => string;
|
|
6095
6099
|
radioLabel: (embedLabel: string) => string;
|
|
6100
|
+
neetoUiToastr: string;
|
|
6096
6101
|
toastMessage: (type: string) => string;
|
|
6097
6102
|
toastCloseButton: string;
|
|
6098
6103
|
windowAlert: string;
|
package/index.js
CHANGED
|
@@ -9,7 +9,7 @@ import path__default from 'path';
|
|
|
9
9
|
import test, { expect, test as test$1, chromium as chromium$1, defineConfig, devices } from '@playwright/test';
|
|
10
10
|
import { getI18nInstance, initI18n } from 'playwright-i18next-fixture';
|
|
11
11
|
import require$$0$4 from 'util';
|
|
12
|
-
import { curry, isNotNil, not, isEmpty, pluck, mergeDeepLeft, isNil
|
|
12
|
+
import { curry, isNotNil, not, isEmpty, pluck, mergeAll, mergeDeepLeft, isNil } from 'ramda';
|
|
13
13
|
import dayjs from 'dayjs';
|
|
14
14
|
import require$$0$8 from 'stream';
|
|
15
15
|
import require$$0$7 from 'node:buffer';
|
|
@@ -4874,6 +4874,7 @@ const COMMON_SELECTORS = {
|
|
|
4874
4874
|
profileSidebar: "profile-section",
|
|
4875
4875
|
selectOption: (label) => `${hyphenate(label)}-select-option`,
|
|
4876
4876
|
radioLabel: (embedLabel) => `${hyphenate(embedLabel)}-radio-label`,
|
|
4877
|
+
neetoUiToastr: ".neeto-ui-toastr",
|
|
4877
4878
|
toastMessage: (type) => `toastr-${type}-container`,
|
|
4878
4879
|
toastCloseButton: "toastr-close-button",
|
|
4879
4880
|
windowAlert: "#alert-box",
|
|
@@ -5922,11 +5923,19 @@ class CustomCommands {
|
|
|
5922
5923
|
return await this.recursiveMethod(callback, condition, timeout, startTime, 1);
|
|
5923
5924
|
};
|
|
5924
5925
|
verifyToast = async ({ message = "", toastType = "success", closeAfterVerification = true, timeout = 10_000, customPageContext = this.page, } = {}) => {
|
|
5925
|
-
|
|
5926
|
-
const toastrLocator =
|
|
5927
|
-
|
|
5928
|
-
|
|
5929
|
-
|
|
5926
|
+
// React-toastify does not support adding data-* attributes to toast DOM elements: https://github.com/fkhadra/react-toastify/issues/1106
|
|
5927
|
+
const toastrLocator = customPageContext
|
|
5928
|
+
.locator(COMMON_SELECTORS.neetoUiToastr)
|
|
5929
|
+
.filter({
|
|
5930
|
+
has: customPageContext.getByTestId(COMMON_SELECTORS.toastMessage(toastType)),
|
|
5931
|
+
});
|
|
5932
|
+
const filteredToastrLocator = (isEmpty(message)
|
|
5933
|
+
? toastrLocator
|
|
5934
|
+
: toastrLocator.filter({ hasText: message }))
|
|
5935
|
+
// eslint-disable-next-line playwright/no-nth-methods
|
|
5936
|
+
.first();
|
|
5937
|
+
await expect(filteredToastrLocator).toContainText(isEmpty(message) ? "👍" : message, { timeout });
|
|
5938
|
+
const toastrCloseButton = filteredToastrLocator.getByTestId(COMMON_SELECTORS.toastCloseButton);
|
|
5930
5939
|
if (!closeAfterVerification && (await toastrCloseButton.isHidden()))
|
|
5931
5940
|
return;
|
|
5932
5941
|
const buttonHandle = await toastrCloseButton.elementHandle();
|
|
@@ -57635,6 +57644,36 @@ const hexToRGB = (hex) => {
|
|
|
57635
57644
|
return `rgb(${Number(r)}, ${Number(g)}, ${Number(b)})`;
|
|
57636
57645
|
};
|
|
57637
57646
|
|
|
57647
|
+
const fillCredentialsAndSubmit = async ({ page, loginPath, email = CREDENTIALS.email, }) => {
|
|
57648
|
+
loginPath && (await page.goto(loginPath, { timeout: 30_000 }));
|
|
57649
|
+
await page.waitForLoadState("load", { timeout: 35_000 });
|
|
57650
|
+
await expect(page.getByTestId(COMMON_SELECTORS.pageLoader)).toBeHidden({
|
|
57651
|
+
timeout: 30_000,
|
|
57652
|
+
});
|
|
57653
|
+
const emailInput = page.getByTestId(LOGIN_SELECTORS.emailTextField);
|
|
57654
|
+
await emailInput.waitFor({ state: "visible", timeout: 30_000 });
|
|
57655
|
+
await emailInput.fill(email);
|
|
57656
|
+
await page
|
|
57657
|
+
.getByTestId(LOGIN_SELECTORS.passwordTextField)
|
|
57658
|
+
.fill(CREDENTIALS.password);
|
|
57659
|
+
const submitButton = page.getByTestId(LOGIN_SELECTORS.submitButton);
|
|
57660
|
+
await submitButton.click();
|
|
57661
|
+
await expect(submitButton).toBeHidden({ timeout: 20_000 });
|
|
57662
|
+
await expect(page.getByTestId(COMMON_SELECTORS.floatingActionMenuButton)).toBeVisible({ timeout: 60_000 });
|
|
57663
|
+
};
|
|
57664
|
+
const loginWithoutSSO = async ({ page, loginPath = "/", email = CREDENTIALS.email, }) => {
|
|
57665
|
+
if (shouldSkipSetupAndTeardown())
|
|
57666
|
+
return;
|
|
57667
|
+
await fillCredentialsAndSubmit({ page, loginPath, email });
|
|
57668
|
+
const userCredentials = readFileSyncIfExists();
|
|
57669
|
+
await page.context().storageState({ path: STORAGE_STATE });
|
|
57670
|
+
const mergedCredentials = mergeAll([readFileSyncIfExists(), userCredentials]);
|
|
57671
|
+
writeDataToFile(JSON.stringify(mergedCredentials, null, 2));
|
|
57672
|
+
updateCredentials({ key: "isLoggedIn", value: "true" });
|
|
57673
|
+
};
|
|
57674
|
+
const login = async ({ page, loginPath, email }) => IS_DEV_ENV && (await loginWithoutSSO({ page, loginPath, email }));
|
|
57675
|
+
const generateRandomBypassEmail = () => `cpt${process.env.OTP_BYPASS_KEY}+${faker.number.int()}@bigbinary.com`;
|
|
57676
|
+
|
|
57638
57677
|
class RailsEmailUtils {
|
|
57639
57678
|
neetoPlaywrightUtilities;
|
|
57640
57679
|
railsEmailRakeClient;
|
|
@@ -57950,7 +57989,9 @@ class MailerUtils {
|
|
|
57950
57989
|
const { html: { codes }, } = await this.findMessage({ to: email, subject: subjectSubstring }, { timeout, receivedAfter, expectedEmailCount });
|
|
57951
57990
|
return codes?.[0];
|
|
57952
57991
|
};
|
|
57953
|
-
generateRandomEmail = () =>
|
|
57992
|
+
generateRandomEmail = (shouldUseBypassEmail = false) => shouldUseBypassEmail
|
|
57993
|
+
? generateRandomBypassEmail()
|
|
57994
|
+
: faker.internet.email({ provider: process.env.FASTMAIL_DOMAIN_NAME });
|
|
57954
57995
|
getEmailAttachment = async (attachmentName, messageSearchCriteria = {}, { timeout = 10_000, receivedAfter = dateTimeOneHourAgo(), expectedEmailCount = 1, } = {}, shouldThrowErrorOnTimeout = true) => {
|
|
57955
57996
|
if (IS_DEV_ENV) {
|
|
57956
57997
|
return this.railsEmailUtils.getEmailAttachment(attachmentName, messageSearchCriteria, { receivedAfter, expectedEmailCount, timeout: timeout / 3 }, shouldThrowErrorOnTimeout);
|
|
@@ -117964,6 +118005,8 @@ class EditorPage {
|
|
|
117964
118005
|
verifyFontSize = async () => {
|
|
117965
118006
|
const fontsAndTexts = [];
|
|
117966
118007
|
const fontSizeDropdownButton = this.page.getByTestId(NEETO_EDITOR_SELECTORS.neetoEditorFixedMenuFontSize);
|
|
118008
|
+
await this.contentField.focus();
|
|
118009
|
+
await this.contentField.press("Enter");
|
|
117967
118010
|
await fontSizeDropdownButton.click();
|
|
117968
118011
|
const headingButtons = await this.page
|
|
117969
118012
|
.getByTestId(COMMON_SELECTORS.dropdownContainer)
|
|
@@ -118029,7 +118072,6 @@ class EditorPage {
|
|
|
118029
118072
|
isButtonInMoreMenu && (await this.moreMenuSelector.click());
|
|
118030
118073
|
await this.editorWrapper
|
|
118031
118074
|
.getByTestId(NEETO_TEXT_MODIFIER_SELECTORS["highlight"])
|
|
118032
|
-
.locator("svg")
|
|
118033
118075
|
.click();
|
|
118034
118076
|
await expect(this.page.getByTestId(COMMON_SELECTORS.customDropdownContainer())).toBeVisible({ timeout: 5_000 });
|
|
118035
118077
|
}).toPass({ timeout: 30_000 });
|
|
@@ -118787,36 +118829,6 @@ class TeamMembers {
|
|
|
118787
118829
|
};
|
|
118788
118830
|
}
|
|
118789
118831
|
|
|
118790
|
-
const fillCredentialsAndSubmit = async ({ page, loginPath, email = CREDENTIALS.email, }) => {
|
|
118791
|
-
loginPath && (await page.goto(loginPath, { timeout: 30_000 }));
|
|
118792
|
-
await page.waitForLoadState("load", { timeout: 35_000 });
|
|
118793
|
-
await expect(page.getByTestId(COMMON_SELECTORS.pageLoader)).toBeHidden({
|
|
118794
|
-
timeout: 30_000,
|
|
118795
|
-
});
|
|
118796
|
-
const emailInput = page.getByTestId(LOGIN_SELECTORS.emailTextField);
|
|
118797
|
-
await emailInput.waitFor({ state: "visible", timeout: 30_000 });
|
|
118798
|
-
await emailInput.fill(email);
|
|
118799
|
-
await page
|
|
118800
|
-
.getByTestId(LOGIN_SELECTORS.passwordTextField)
|
|
118801
|
-
.fill(CREDENTIALS.password);
|
|
118802
|
-
const submitButton = page.getByTestId(LOGIN_SELECTORS.submitButton);
|
|
118803
|
-
await submitButton.click();
|
|
118804
|
-
await expect(submitButton).toBeHidden({ timeout: 20_000 });
|
|
118805
|
-
await expect(page.getByTestId(COMMON_SELECTORS.floatingActionMenuButton)).toBeVisible({ timeout: 60_000 });
|
|
118806
|
-
};
|
|
118807
|
-
const loginWithoutSSO = async ({ page, loginPath = "/", email = CREDENTIALS.email, }) => {
|
|
118808
|
-
if (shouldSkipSetupAndTeardown())
|
|
118809
|
-
return;
|
|
118810
|
-
await fillCredentialsAndSubmit({ page, loginPath, email });
|
|
118811
|
-
const userCredentials = readFileSyncIfExists();
|
|
118812
|
-
await page.context().storageState({ path: STORAGE_STATE });
|
|
118813
|
-
const mergedCredentials = mergeAll([readFileSyncIfExists(), userCredentials]);
|
|
118814
|
-
writeDataToFile(JSON.stringify(mergedCredentials, null, 2));
|
|
118815
|
-
updateCredentials({ key: "isLoggedIn", value: "true" });
|
|
118816
|
-
};
|
|
118817
|
-
const login = async ({ page, loginPath, email }) => IS_DEV_ENV && (await loginWithoutSSO({ page, loginPath, email }));
|
|
118818
|
-
const generateRandomBypassEmail = () => `cpt${process.env.OTP_BYPASS_KEY}+${faker.number.int()}@bigbinary.com`;
|
|
118819
|
-
|
|
118820
118832
|
const extractSubdomainFromError = (errorString) => {
|
|
118821
118833
|
const regex = /cpt[a-zA-Z0-9-]+/g;
|
|
118822
118834
|
const matches = errorString.match(regex);
|