@assert-equals/dappdriver
Version:
DappDriver is an e2e testing framework designed for testing decentralized applications (dApps) using MetaMask, Rainbow or Zerion
68 lines (67 loc) • 2.03 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.ConfirmRecoveryPhrase = void 0;
const __1 = require("../..");
const controls_1 = require("../../../controls");
const page_1 = require("../../../page");
/**
*
*
* @export
* @class ConfirmRecoveryPhrase
* @extends {PageObject}
*/
class ConfirmRecoveryPhrase extends page_1.PageObject {
unansweredChip = (index) => new controls_1.HTMLElement(`[data-testid="recovery-phrase-quiz-unanswered-${index}"]`);
get srpChips() {
return new controls_1.HTMLElement('[data-testid="recovery-phrase-chips"]');
}
get confirmButton() {
return new controls_1.HTMLElement('[data-testid="recovery-phrase-confirm"]');
}
get modalButton() {
return new controls_1.HTMLElement('[data-testid="confirm-srp-modal-button"]');
}
/**
* Creates an instance of ConfirmRecoveryPhrase.
* @memberof ConfirmRecoveryPhrase
*/
constructor() {
super('/home.html#/onboarding/confirm-recovery-phrase', 'MetaMask');
}
/**
*
*
* @param {number} index
* @return {*} {Promise<void>}
* @memberof ConfirmRecoveryPhrase
*/
async confirmWord(index) {
return await this.unansweredChip(index).click();
}
/**
*
*
* @return {*} {Promise<void>}
* @memberof ConfirmRecoveryPhrase
*/
async confirmRequiredWords() {
const quizJson = await this.srpChips.getAttribute('data-quiz-words');
const quizWords = JSON.parse(quizJson);
const sortedIndices = quizWords.map((w) => w.index).sort((a, b) => a - b);
for (const index of sortedIndices) {
await this.confirmWord(index);
}
}
/**
*
*
* @return {*} {Promise<Metametrics>}
* @memberof ConfirmRecoveryPhrase
*/
async confirm() {
await this.confirmButton.click();
return await this.modalButton.click(__1.Metametrics);
}
}
exports.ConfirmRecoveryPhrase = ConfirmRecoveryPhrase;