Refresh HiveGrid Cloud reference snapshot
This commit is contained in:
1 parent
5e99e14772
commit
7f88026f79
5955 files changed
+1177325
-188362
No files matched your search
@@ -0,0 +1,25 @@
|
||||
import { expect, type Page } from "./test";
|
||||
|
||||
const captchaTokenSelector = 'input[name="cap-token"], input[name="mcaptcha__token"]';
|
||||
|
||||
export async function solveCaptchaIfPresent(page: Page): Promise<void> {
|
||||
const mount = page.locator('[data-ui-id="ui.captcha.mount"]');
|
||||
if ((await mount.count()) === 0) return;
|
||||
|
||||
if (await hasCaptchaToken(page)) return;
|
||||
|
||||
const verify = mount.getByRole("button", {
|
||||
name: /^(Click to verify you're a human|Verify you're human|Ich bin ein Mensch|Klicken, um zu bestätigen, dass Sie ein Mensch sind)$/iu,
|
||||
});
|
||||
await expect(verify).toBeVisible({ timeout: 10_000 });
|
||||
await verify.click();
|
||||
await expect.poll(() => hasCaptchaToken(page), { message: "self-hosted captcha did not produce a token", timeout: 60_000 }).toBe(true);
|
||||
}
|
||||
|
||||
async function hasCaptchaToken(page: Page): Promise<boolean> {
|
||||
const tokens = page.locator(captchaTokenSelector);
|
||||
for (let index = 0; index < (await tokens.count()); index += 1) {
|
||||
if ((await tokens.nth(index).inputValue()).trim().length > 0) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
Reference in new issue
Block a user