The test below aims to scan and authenticate a QR code, then utilize the received authentication token. However, for some reason, the last two commands (.type) are not being executed. I've been stuck at this point for quite some time now. Any insights on why this might be happening?
getUrlVars is a helper function that returns the string used to generate the token.
Thank you.
/// <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("<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="a1d5c4d2d5fe909791999093939393959799978fcacad7c3d7d7cad2e1ccc0c8cdced2c0d4d38fc8ce">[email protected]</a>", "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);
});
});
});
});