Skip to content

Commit

Permalink
feat(19726): fix flaky test in Dapp interactions caused by home-conta…
Browse files Browse the repository at this point in the history
…iner rerender (#19997)
  • Loading branch information
DDDDDanica authored Jul 13, 2023
1 parent 30a77d0 commit 2f03c0d
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 57 deletions.
67 changes: 19 additions & 48 deletions test/e2e/tests/dapp-interactions.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@ const {
openDapp,
DAPP_URL,
DAPP_ONE_URL,
unlockWallet,
WINDOW_TITLES,
} = require('../helpers');
const FixtureBuilder = require('../fixture-builder');

describe('Dapp interactions', function () {
let windowHandles;
let extension;
let popup;
const ganacheOptions = {
accounts: [
{
Expand All @@ -34,30 +33,13 @@ describe('Dapp interactions', function () {
},
async ({ driver }) => {
await driver.navigate();
await driver.fill('#password', 'correct horse battery staple');
await driver.press('#password', driver.Key.ENTER);

await openDapp(driver);
windowHandles = await driver.getAllWindowHandles();
extension = windowHandles[0];

// Lock Account
await driver.switchToWindow(extension);
await driver.clickElement(
'[data-testid="account-options-menu-button"]',
);
await driver.clickElement({ text: 'Lock', tag: 'div' });

// Trigger Notification
await driver.switchToWindowWithTitle('E2E Test Dapp', windowHandles);
await driver.clickElement('#addEthereumChain');
await driver.waitUntilXWindowHandles(3);
await driver.switchToWindowWithTitle(
'MetaMask Notification',
windowHandles,
);
await driver.fill('#password', 'correct horse battery staple');
await driver.press('#password', driver.Key.ENTER);
await driver.switchToWindowWithTitle('MetaMask Notification');
await unlockWallet(driver);
const notification = await driver.isElementPresent({
text: 'Allow this site to add a network?',
tag: 'h3',
Expand All @@ -81,45 +63,34 @@ describe('Dapp interactions', function () {
},
async ({ driver }) => {
await driver.navigate();
await driver.fill('#password', 'correct horse battery staple');
await driver.press('#password', driver.Key.ENTER);

await openDapp(driver);
windowHandles = await driver.getAllWindowHandles();
extension = windowHandles[0];

// Lock Account
await driver.switchToWindow(extension);
await driver.clickElement(
'[data-testid="account-options-menu-button"]',
);
await driver.clickElement({ text: 'Lock', tag: 'div' });

// Connect to Dapp1
// Connect to 2nd dapp => DAPP_ONE
await openDapp(driver, null, DAPP_ONE_URL);
await driver.clickElement({ text: 'Connect', tag: 'button' });
await driver.waitUntilXWindowHandles(4);
windowHandles = await driver.getAllWindowHandles();
await driver.waitUntilXWindowHandles(3);

popup = await driver.switchToWindowWithTitle(
'MetaMask Notification',
windowHandles,
);
await driver.switchToWindowWithTitle(WINDOW_TITLES.Notification);

await driver.switchToWindow(popup);
await driver.fill('#password', 'correct horse battery staple');
await driver.press('#password', driver.Key.ENTER);
await unlockWallet(driver);
await driver.clickElement({ text: 'Next', tag: 'button' });
await driver.clickElement({ text: 'Connect', tag: 'button' });
await driver.switchToWindowWithTitle(WINDOW_TITLES.TestDApp);
await driver.waitForSelector({
css: '#accounts',
text: '0x5cfe73b6021e818b776b421b1c4db2474086a7e1',
});

// Assert Connection
await driver.switchToWindow(extension);
await driver.fill('#password', 'correct horse battery staple');
await driver.press('#password', driver.Key.ENTER);
await driver.switchToWindowWithTitle(
WINDOW_TITLES.ExtensionInFullScreenView,
);
await unlockWallet(driver);
await driver.clickElement(
'[data-testid ="account-options-menu-button"]',
);

await driver.clickElement({ text: 'Connected sites', tag: 'div' });

const connectedDapp1 = await driver.isElementPresent({
text: DAPP_URL,
tag: 'bdi',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,8 @@ const InteractiveReplacementTokenNotification = ({ isVisible }) => {
};

handleShowNotification();
}, [
dispatch,
address,
interactiveReplacementToken,
isUnlocked,
keyring,
mmiActions,
]);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [address, interactiveReplacementToken.oldRefreshToken, isUnlocked]);

return showNotification ? (
<Box
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { useContext, useState } from 'react';
import { useDispatch, useSelector } from 'react-redux';
import { useHistory } from 'react-router-dom';
import isEqual from 'lodash/isEqual';
import PulseLoader from '../../../components/ui/pulse-loader';
import { CUSTODY_ACCOUNT_ROUTE } from '../../../helpers/constants/routes';
import {
Expand Down Expand Up @@ -38,7 +39,7 @@ const ConfirmAddCustodianToken = () => {
const mmiActions = mmiActionsFactory();

const mostRecentOverviewPage = useSelector(getMostRecentOverviewPage);
const connectRequests = useSelector(getInstitutionalConnectRequests);
const connectRequests = useSelector(getInstitutionalConnectRequests, isEqual);
const isComplianceActivated = useSelector(complianceActivated);
const [showMore, setShowMore] = useState(false);
const [isLoading, setIsLoading] = useState(false);
Expand Down

0 comments on commit 2f03c0d

Please sign in to comment.