Skip to content

Commit

Permalink
test: add the ability to check if the chain permission is checked or …
Browse files Browse the repository at this point in the history
…unchecked
  • Loading branch information
EtherWizard33 committed Dec 18, 2024
1 parent 25375aa commit a81318b
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 24 deletions.
35 changes: 19 additions & 16 deletions app/components/UI/NetworkSelectorList/NetworkSelectorList.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Third party dependencies.
import React, { useCallback, useRef } from 'react';
import { ListRenderItem, ImageSourcePropType } from 'react-native';
import { ListRenderItem, ImageSourcePropType, View } from 'react-native';
import { FlatList } from 'react-native-gesture-handler';

// External dependencies.
Expand Down Expand Up @@ -53,23 +53,26 @@ const NetworkSelectorList = ({
if (selectedChainIds) {
isSelectedNetwork = selectedChainIds.includes(id);
}

return (
<Cell
variant={cellVariant}
isSelected={isSelectedNetwork}
title={name}
onPress={() => onSelectNetwork?.(id, isSelectedNetwork)}
avatarProps={{
variant: AvatarVariant.Network,
name,
imageSource: imageSource as ImageSourcePropType,
size: AvatarSize.Sm,
}}
disabled={isDisabled}
<View
testID={`${name}-${isSelectedNetwork ? 'selected' : 'not-selected'}`}
>
{renderRightAccessory?.(id, name)}
</Cell>
<Cell
variant={cellVariant}
isSelected={isSelectedNetwork}
title={name}
onPress={() => onSelectNetwork?.(id, isSelectedNetwork)}
avatarProps={{
variant: AvatarVariant.Network,
name,
imageSource: imageSource as ImageSourcePropType,
size: AvatarSize.Sm,
}}
disabled={isDisabled}
>
{renderRightAccessory?.(id, name)}
</Cell>
</View>
);
},
[
Expand Down
18 changes: 18 additions & 0 deletions e2e/pages/Browser/NetworkConnectMultiSelector.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,24 @@ class NetworkConnectMultiSelector {
async tapBackButton() {
await Gestures.waitAndTap(this.backButton);
}

async isNetworkChainPermissionSelected(chainName) {
const chainPermissionTestId = `${chainName}-selected`;

const element = await Matchers.getElementByID(chainPermissionTestId);
await waitFor(element).toBeVisible().withTimeout(10000);

return expect(element).toExist();
}

async isNetworkChainPermissionNotSelected(chainName) {
const chainPermissionTestId = `${chainName}-not-selected`;

const element = await Matchers.getElementByID(chainPermissionTestId);
await waitFor(element).toBeVisible().withTimeout(10000);

return expect(element).toExist();
}
}

export default new NetworkConnectMultiSelector();
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,11 @@ describe(SmokeMultiChain('Chain Permission Management'), () => {

// Verify changes were saved by checking chain permissions again
await ConnectedAccountsModal.tapNavigateToEditNetworksPermissionsButton();

// Deselect both networks to verify they were the only ones selected
await NetworkNonPemittedBottomSheet.tapEthereumMainNetNetworkName();
await NetworkNonPemittedBottomSheet.tapLineaSepoliaNetworkName();

// Verify the disconnect all button appears (indicating no chains are selected)
await Assertions.checkIfVisible(
ConnectedAccountsModal.disconnectNetworksButton,
await NetworkConnectMultiSelector.isNetworkChainPermissionSelected(
NetworkNonPemittedBottomSheetSelectorsText.ETHEREUM_MAIN_NET_NETWORK_NAME,
);
await NetworkConnectMultiSelector.isNetworkChainPermissionSelected(
NetworkNonPemittedBottomSheetSelectorsText.LINEA_SEPOLIA_NETWORK_NAME,
);
},
);
Expand Down

0 comments on commit a81318b

Please sign in to comment.