@bigbinary/neeto-playwright-commons 1.26.11 → 1.26.13
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 +47 -17
- package/index.cjs.js.map +1 -1
- package/index.d.ts +2 -2
- package/index.js +48 -18
- package/index.js.map +1 -1
- package/package.json +1 -1
package/index.cjs.js
CHANGED
|
@@ -4907,7 +4907,7 @@ const removeCredentialFile = () => {
|
|
|
4907
4907
|
require$$0__namespace.unlink(STORAGE_STATE, error => {
|
|
4908
4908
|
if (!error)
|
|
4909
4909
|
return;
|
|
4910
|
-
console.
|
|
4910
|
+
console.error(error);
|
|
4911
4911
|
});
|
|
4912
4912
|
};
|
|
4913
4913
|
const clearCredentials = () => {
|
|
@@ -4976,7 +4976,43 @@ const getListCount = async ({ page, countSelector, }) => {
|
|
|
4976
4976
|
return Number(countText === null || countText === void 0 ? void 0 : countText.trim().split(" ")[0]);
|
|
4977
4977
|
};
|
|
4978
4978
|
const getGlobalUserProps = async (page) => (await page.evaluate(() => window.globalProps.user));
|
|
4979
|
-
const
|
|
4979
|
+
const createTextareaAndEvaluateCopiedText = async (page) => {
|
|
4980
|
+
const textareaHandle = await page.evaluateHandle(() => {
|
|
4981
|
+
const textarea = document.createElement("textarea");
|
|
4982
|
+
Object.assign(textarea.style, {
|
|
4983
|
+
position: "fixed",
|
|
4984
|
+
top: "0",
|
|
4985
|
+
left: "0",
|
|
4986
|
+
opacity: "0",
|
|
4987
|
+
pointerEvents: "none",
|
|
4988
|
+
zIndex: "9999",
|
|
4989
|
+
});
|
|
4990
|
+
document.body.appendChild(textarea);
|
|
4991
|
+
textarea.focus();
|
|
4992
|
+
return textarea;
|
|
4993
|
+
});
|
|
4994
|
+
try {
|
|
4995
|
+
await page.keyboard.press("ControlOrMeta+v");
|
|
4996
|
+
return await page.evaluate(el => el.value, textareaHandle);
|
|
4997
|
+
}
|
|
4998
|
+
finally {
|
|
4999
|
+
await textareaHandle.evaluate(el => el.remove());
|
|
5000
|
+
await textareaHandle.dispose();
|
|
5001
|
+
}
|
|
5002
|
+
};
|
|
5003
|
+
const getClipboardContent = async (page) => {
|
|
5004
|
+
// Attempt 1: Native Clipboard API
|
|
5005
|
+
const clipboardText = await page.evaluate(async () => {
|
|
5006
|
+
var _a;
|
|
5007
|
+
if (!((_a = navigator.clipboard) === null || _a === void 0 ? void 0 : _a.readText))
|
|
5008
|
+
return null;
|
|
5009
|
+
return await navigator.clipboard.readText();
|
|
5010
|
+
});
|
|
5011
|
+
if (ramda.isNotNil(clipboardText))
|
|
5012
|
+
return clipboardText;
|
|
5013
|
+
// Attempt 2: Keyboard paste fallback
|
|
5014
|
+
return createTextareaAndEvaluateCopiedText(page);
|
|
5015
|
+
};
|
|
4980
5016
|
const grantClipboardPermissions = (context) => context.grantPermissions(["clipboard-read", "clipboard-write"]);
|
|
4981
5017
|
const getFullUrl = (path) => shouldSkipCustomDomainSetup() ? path : `${process.env.BASE_URL}${path}`;
|
|
4982
5018
|
const globalShortcuts = (t) => [
|
|
@@ -116412,11 +116448,8 @@ class GooglePage extends IntegrationBase {
|
|
|
116412
116448
|
.getByRole("link", { name: GOOGLE_LOGIN_TEXTS.neetoAutomation })
|
|
116413
116449
|
.click();
|
|
116414
116450
|
await test.expect(chooseAnAccountHeading).toBeHidden({ timeout: 10000 });
|
|
116415
|
-
const verificationCode = this.page
|
|
116416
|
-
.locator("form")
|
|
116417
|
-
.getByText(GOOGLE_LOGIN_TEXTS.verificationCode);
|
|
116418
116451
|
this.page.url().includes(THIRD_PARTY_ROUTES.google.totpChallenge) &&
|
|
116419
|
-
(await this.enterTotpCode(
|
|
116452
|
+
(await this.enterTotpCode());
|
|
116420
116453
|
await this.handleNotVerifiedPage();
|
|
116421
116454
|
const signInHeading = this.page.getByRole("heading", {
|
|
116422
116455
|
name: GOOGLE_LOGIN_TEXTS.signInHeading(appName),
|
|
@@ -116455,32 +116488,29 @@ class GooglePage extends IntegrationBase {
|
|
|
116455
116488
|
.click());
|
|
116456
116489
|
await this.page.waitForLoadState("load", { timeout: 25000 });
|
|
116457
116490
|
await this.page.waitForURL(new RegExp(THIRD_PARTY_ROUTES.google.totpChallenge));
|
|
116458
|
-
|
|
116459
|
-
name: GOOGLE_LOGIN_TEXTS.twoStepVerification,
|
|
116460
|
-
level: 2,
|
|
116461
|
-
exact: true,
|
|
116462
|
-
});
|
|
116463
|
-
await test.expect(twoStepVerification).toBeVisible({ timeout: 15000 });
|
|
116464
|
-
await this.enterTotpCode(twoStepVerification);
|
|
116491
|
+
await this.enterTotpCode();
|
|
116465
116492
|
await this.page.waitForLoadState("load", { timeout: 25000 });
|
|
116466
116493
|
await this.page.waitForURL(new RegExp(THIRD_PARTY_ROUTES.google.myAccount));
|
|
116467
116494
|
};
|
|
116468
|
-
this.enterTotpCode = async (
|
|
116495
|
+
this.enterTotpCode = async () => {
|
|
116469
116496
|
let previousToken = null;
|
|
116497
|
+
const codeInput = this.page.getByLabel(GOOGLE_LOGIN_TEXTS.enterCode);
|
|
116498
|
+
await test.expect(codeInput).toBeVisible({ timeout: 20000 });
|
|
116470
116499
|
await test.expect(async () => {
|
|
116471
116500
|
let totpToken = this.totp.generate({ timestamp: Date.now() });
|
|
116472
116501
|
if (totpToken === previousToken) {
|
|
116473
116502
|
const remainingTime = this.totp.remaining({ timestamp: Date.now() });
|
|
116503
|
+
// Wait for the remaining time plus a small buffer to ensure new token is generated
|
|
116474
116504
|
// eslint-disable-next-line playwright/no-wait-for-timeout
|
|
116475
|
-
await this.page.waitForTimeout(remainingTime + 500);
|
|
116505
|
+
await this.page.waitForTimeout(remainingTime + 500);
|
|
116476
116506
|
totpToken = this.totp.generate({ timestamp: Date.now() });
|
|
116477
116507
|
}
|
|
116478
116508
|
previousToken = totpToken;
|
|
116479
|
-
await
|
|
116509
|
+
await codeInput.fill(totpToken);
|
|
116480
116510
|
test.expect(this.totp.validate({ token: totpToken })).not.toBeNull();
|
|
116481
116511
|
await this.page.locator(GOOGLE_LOGIN_SELECTORS.totpNext).click();
|
|
116482
116512
|
await test.expect(this.page.getByText(GOOGLE_LOGIN_TEXTS.wrongCode)).toBeHidden({ timeout: 10000 });
|
|
116483
|
-
await test.expect(
|
|
116513
|
+
await test.expect(codeInput).toBeHidden({ timeout: 15000 });
|
|
116484
116514
|
}).toPass({ timeout: 2 * 60 * 1000 });
|
|
116485
116515
|
};
|
|
116486
116516
|
this.logoutFromGoogle = async () => {
|