mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-22 09:57:02 +01:00
feature(19457): fix encrypt-decrypt.spec.js flaky tests (#19725)
* feature(19457): fix encrypt-decrypt.spec.js flaky tests * feature(19457): refactor more of findElement and getText
This commit is contained in:
parent
98c571e90d
commit
c0483e118d
@ -2,7 +2,7 @@ const { strict: assert } = require('assert');
|
|||||||
const { convertToHexValue, withFixtures, openDapp } = require('../helpers');
|
const { convertToHexValue, withFixtures, openDapp } = require('../helpers');
|
||||||
const FixtureBuilder = require('../fixture-builder');
|
const FixtureBuilder = require('../fixture-builder');
|
||||||
|
|
||||||
async function getEncryptionKey(driver) {
|
async function validateEncryptionKey(driver, encryptionKey) {
|
||||||
await driver.clickElement('#getEncryptionKeyButton');
|
await driver.clickElement('#getEncryptionKeyButton');
|
||||||
await driver.waitUntilXWindowHandles(3);
|
await driver.waitUntilXWindowHandles(3);
|
||||||
let windowHandles = await driver.getAllWindowHandles();
|
let windowHandles = await driver.getAllWindowHandles();
|
||||||
@ -15,7 +15,10 @@ async function getEncryptionKey(driver) {
|
|||||||
await driver.waitUntilXWindowHandles(2);
|
await driver.waitUntilXWindowHandles(2);
|
||||||
windowHandles = await driver.getAllWindowHandles();
|
windowHandles = await driver.getAllWindowHandles();
|
||||||
await driver.switchToWindowWithTitle('E2E Test Dapp', windowHandles);
|
await driver.switchToWindowWithTitle('E2E Test Dapp', windowHandles);
|
||||||
return await driver.findElement('#encryptionKeyDisplay');
|
await driver.findElement({
|
||||||
|
css: '#encryptionKeyDisplay',
|
||||||
|
text: encryptionKey,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async function encryptMessage(driver, message) {
|
async function encryptMessage(driver, message) {
|
||||||
@ -51,8 +54,10 @@ async function verifyDecryptedMessageMM(driver, message) {
|
|||||||
async function verifyDecryptedMessageDapp(driver, message) {
|
async function verifyDecryptedMessageDapp(driver, message) {
|
||||||
const windowHandles = await driver.getAllWindowHandles();
|
const windowHandles = await driver.getAllWindowHandles();
|
||||||
await driver.switchToWindowWithTitle('E2E Test Dapp', windowHandles);
|
await driver.switchToWindowWithTitle('E2E Test Dapp', windowHandles);
|
||||||
const clearTextLabel = await driver.findElement('#cleartextDisplay');
|
await driver.findElement({
|
||||||
assert.equal(await clearTextLabel.getText(), message);
|
css: '#cleartextDisplay',
|
||||||
|
text: message,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
describe('Encrypt Decrypt', function () {
|
describe('Encrypt Decrypt', function () {
|
||||||
@ -67,6 +72,7 @@ describe('Encrypt Decrypt', function () {
|
|||||||
};
|
};
|
||||||
const encryptionKey = 'fxYXfCbun026g5zcCQh7Ia+O0urAEVZWLG8H4Jzu7Xs=';
|
const encryptionKey = 'fxYXfCbun026g5zcCQh7Ia+O0urAEVZWLG8H4Jzu7Xs=';
|
||||||
const message = 'Hello, Bob!';
|
const message = 'Hello, Bob!';
|
||||||
|
|
||||||
it('should decrypt an encrypted message', async function () {
|
it('should decrypt an encrypted message', async function () {
|
||||||
await withFixtures(
|
await withFixtures(
|
||||||
{
|
{
|
||||||
@ -84,8 +90,7 @@ describe('Encrypt Decrypt', function () {
|
|||||||
await openDapp(driver);
|
await openDapp(driver);
|
||||||
|
|
||||||
// ------ Get Encryption key ------
|
// ------ Get Encryption key ------
|
||||||
const encryptionKeyLabel = await getEncryptionKey(driver);
|
await validateEncryptionKey(driver, encryptionKey);
|
||||||
assert.equal(await encryptionKeyLabel.getText(), encryptionKey);
|
|
||||||
|
|
||||||
// ------ Encrypt ------
|
// ------ Encrypt ------
|
||||||
await encryptMessage(driver, message);
|
await encryptMessage(driver, message);
|
||||||
@ -126,8 +131,7 @@ describe('Encrypt Decrypt', function () {
|
|||||||
await openDapp(driver);
|
await openDapp(driver);
|
||||||
|
|
||||||
// ------ Get Encryption key ------
|
// ------ Get Encryption key ------
|
||||||
const encryptionKeyLabel = await getEncryptionKey(driver);
|
await validateEncryptionKey(driver, encryptionKey);
|
||||||
assert.equal(await encryptionKeyLabel.getText(), encryptionKey);
|
|
||||||
|
|
||||||
// ------ Encrypt Message 1------
|
// ------ Encrypt Message 1------
|
||||||
await encryptMessage(driver, message);
|
await encryptMessage(driver, message);
|
||||||
|
Loading…
Reference in New Issue
Block a user