Skip to content

Commit

Permalink
test(3598): fixing some failing e2e tests possibly due to flakiness i…
Browse files Browse the repository at this point in the history
…ntroduced by toast sticking around longer than should (#12695)

<!--
Please submit this PR as a draft initially.
Do not mark it as "Ready for review" until the template has been
completely filled out, and PR status checks have passed at least once.
-->

## **Description**
WIP
<!--
Write a short description of the changes included in this pull request,
also include relevant motivation and context. Have in mind the following
questions:
1. What is the reason for the change?
2. What is the improvement/solution?
-->

## **Related issues**

Fixes:

## **Manual testing steps**

1. Go to this page...
2.
3.

## **Screenshots/Recordings**

<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->

### **Before**

<!-- [screenshots/recordings] -->

### **After**

<!-- [screenshots/recordings] -->

## **Pre-merge author checklist**

- [ ] I’ve followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile
Coding
Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md).
- [ ] I've completed the PR template to the best of my ability
- [ ] I’ve included tests if applicable
- [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [ ] I’ve applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.

## **Pre-merge reviewer checklist**

- [ ] I've manually tested the PR (e.g. pull and build branch, run the
app, test code being changed).
- [ ] I confirm that this PR addresses all acceptance criteria described
in the ticket it closes and includes the necessary testing evidence such
as recordings and or screenshots.
  • Loading branch information
EtherWizard33 authored Dec 13, 2024
1 parent d967a76 commit 8aece87
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,16 @@ const NetworkConnectMultiSelector = ({
if (onNetworksSelected) {
onNetworksSelected(selectedChainIds);
} else {
// Check if current network is being removed from permissions
if (!selectedChainIds.includes(currentChainId)) {
// Check if current network was originally permitted and is now being removed
const wasCurrentNetworkOriginallyPermitted =
originalChainIds.includes(currentChainId);
const isCurrentNetworkStillPermitted =
selectedChainIds.includes(currentChainId);

if (
wasCurrentNetworkOriginallyPermitted &&
!isCurrentNetworkStillPermitted
) {
// Find the network configuration for the first permitted chain
const networkToSwitch = Object.entries(networkConfigurations).find(
([, { chainId }]) => chainId === selectedChainIds[0],
Expand Down Expand Up @@ -124,7 +132,6 @@ const NetworkConnectMultiSelector = ({
} catch (e) {
Logger.error(e as Error, 'Error checking for permitted chains caveat');
}

if (hasPermittedChains) {
Engine.context.PermissionController.updateCaveat(
hostname,
Expand Down Expand Up @@ -153,6 +160,7 @@ const NetworkConnectMultiSelector = ({
}
}, [
selectedChainIds,
originalChainIds,
hostname,
onUserAction,
onNetworksSelected,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ describe(
// Select Sepolia from permitted networks
await NetworkNonPemittedBottomSheet.tapSepoliaNetworkName();
await NetworkEducationModal.tapGotItButton();
await TestHelpers.delay(3000); // another toast to wait for, after switching to Sepolia

// Verify network switched to Sepolia
await TabBarComponent.tapWallet();
Expand Down Expand Up @@ -219,7 +220,8 @@ describe(
// Select Linea Sepolia from network selector and update permissions
await NetworkNonPemittedBottomSheet.tapLineaSepoliaNetworkName();
await NetworkConnectMultiSelector.tapUpdateButton();
await NetworkEducationModal.tapGotItButton();
// await NetworkEducationModal.tapGotItButton(); // commeting this line for now, for some reason the e2e recordings dont currently show a got it modal here
await TestHelpers.delay(3000); // Wait for the toast to disappear

// Select Linea Sepolia from permitted networks
await NetworkNonPemittedBottomSheet.tapLineaSepoliaNetworkName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ describe(SmokeMultiChain('MultiChain Permissions System:'), () => {
);
});

it('should fallback to Sepolia when removing permission for active Ethereum Mainnet, verifying fallback priority by having both Sepolia and Linea Sepolia as alternative permitted networks', async () => {
fit('should fallback to Sepolia when removing permission for active Ethereum Mainnet, verifying fallback priority by having both Sepolia and Linea Sepolia as alternative permitted networks', async () => {
await withFixtures(
{
dapp: true,
Expand All @@ -87,6 +87,10 @@ describe(SmokeMultiChain('MultiChain Permissions System:'), () => {
await TestHelpers.delay(3000);
await Browser.navigateToTestDApp();

// adding delay,
// on artifact recording it shows the toast is stuck, and looks like tapNetworkAvatar is tapped but bottom sheet not coming up yet grey overlay usually behind the bottom sheet was showing, and recording stopped there, yet toast was stuck on screen for 15 seconds anduntil end of recording
await TestHelpers.delay(3000);

// Open network permissions menu
await Browser.tapNetworkAvatarButtonOnBrowser();
await ConnectedAccountsModal.tapManagePermissionsButton();
Expand Down

0 comments on commit 8aece87

Please sign in to comment.