以下のテストは、QR コードをスキャンして認証し、受け取った認証トークンを使用することになっています。最後の 2 つのコマンド (.type) はスキップされています。誰かが理由を知っていますか?私はすでにしばらくここで立ち往生しています。
getUrlVars は、トークンの生成に使用する文字列を返すヘルパー関数です。私
ありがとう
/// <reference types='Cypress' />
import { Decoder } from "@nuintun/qrcode";
const qrcode = new Decoder();
const OTPAuth = require("otpauth");
import Navbar from "../page-objects/components/Navbar";
import UserProfileNav from "../page-objects/components/UserProfileNav";
import BasePage from "../page-objects/pages/BasePage";
import LoginPage from "../page-objects/pages/LoginPage";
import RegistrationPage from "../page-objects/pages/RegistrationPage";
import { createEmail, getUrlVars } from "../utils/utils";
describe("test", () => {
it("ttest", () => {
cy.visit("/");
LoginPage.login("test_1608122224686.kkvbvvks@mailosaur.io", "P@ssword1");
Navbar.navigateToProfile();
UserProfileNav.twoStepVerificationTab();
cy.findAllByAltText("2FA QR kód").then(function ($img) {
qrcode.scan($img.prop("src")).then((result) => {
const totp = new OTPAuth.TOTP({
algorithm: "SHA1",
digits: 6,
period: 30,
secret: getUrlVars(result.data)["secret"],
});
const token = totp.generate();
console.log(token);
cy.findByLabelText("Jednorázový kód").type(token);
});
});
});
});