Skip to content

Commit

Permalink
chore(suite): update network symbol naming 12
Browse files Browse the repository at this point in the history
  • Loading branch information
adderpositive committed Dec 9, 2024
1 parent 07b8742 commit 3ec693e
Show file tree
Hide file tree
Showing 11 changed files with 61 additions and 59 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ export class DashboardActions {
this.window.getByTestId(`@switch-device/wallet-on-index/${index}/eject-button`);
readonly confirmDeviceEjectButton: Locator;
readonly addStandardWalletButton: Locator;
readonly balanceOfNetwork = (network: NetworkSymbol) =>
this.window.getByTestId(`@wallet/coin-balance/value-${network}`);
readonly balanceOfNetwork = (symbol: NetworkSymbol) =>
this.window.getByTestId(`@wallet/coin-balance/value-${symbol}`);

constructor(window: Page) {
this.window = window;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ export class SettingsActions {
readonly settingsCloseButton: Locator;
readonly modal: Locator;
//coin Advance settings
readonly coinNetworkButton = (coin: NetworkSymbol) =>
this.window.getByTestId(`@settings/wallet/network/${coin}`);
readonly coinAdvanceSettingsButton = (coin: NetworkSymbol) =>
this.window.getByTestId(`@settings/wallet/network/${coin}/advance`);
readonly coinNetworkButton = (symbol: NetworkSymbol) =>
this.window.getByTestId(`@settings/wallet/network/${symbol}`);
readonly coinAdvanceSettingsButton = (symbol: NetworkSymbol) =>
this.window.getByTestId(`@settings/wallet/network/${symbol}/advance`);
readonly coinBackendSelector: Locator;
readonly coinBackendSelectorOption = (backend: BackendType) =>
this.window.getByTestId(`@settings/advance/${backend}`);
Expand Down Expand Up @@ -67,24 +67,24 @@ export class SettingsActions {
await expect(this.debugTabButton).toBeVisible();
}

async openCoinAdvanceSettings(coin: NetworkSymbol) {
const isCoinActive = await this.coinNetworkButton(coin).getAttribute('data-active');
async openCoinAdvanceSettings(symbol: NetworkSymbol) {
const isCoinActive = await this.coinNetworkButton(symbol).getAttribute('data-active');
if (isCoinActive === 'false') {
await this.enableCoin(coin);
await this.enableCoin(symbol);
}
await this.coinNetworkButton(coin).hover();
await this.coinAdvanceSettingsButton(coin).click();
await this.coinNetworkButton(symbol).hover();
await this.coinAdvanceSettingsButton(symbol).click();
await expect(this.modal).toBeVisible();
}

async enableCoin(coin: NetworkSymbol) {
await this.coinNetworkButton(coin).click();
await expect(this.coinNetworkButton(coin)).toHaveAttribute('data-active', 'true');
async enableCoin(symbol: NetworkSymbol) {
await this.coinNetworkButton(symbol).click();
await expect(this.coinNetworkButton(symbol)).toHaveAttribute('data-active', 'true');
}

async disableCoin(coin: NetworkSymbol) {
await this.coinNetworkButton(coin).click();
await expect(this.coinNetworkButton(coin)).toHaveAttribute('data-active', 'false');
async disableCoin(symbol: NetworkSymbol) {
await this.coinNetworkButton(symbol).click();
await expect(this.coinNetworkButton(symbol)).toHaveAttribute('data-active', 'false');
}

async changeCoinBackend(backend: BackendType, backendUrl: string) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ export class WalletActions {
}
}

async getAccountsCount(network: NetworkSymbol) {
async getAccountsCount(symbol: NetworkSymbol) {
return await this.window
.locator(`[data-testid*="@account-menu/${network}"][tabindex]`)
.locator(`[data-testid*="@account-menu/${symbol}"][tabindex]`)
.count();
}
}
12 changes: 6 additions & 6 deletions packages/suite-web/e2e/support/pageObjects/accountsObject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ class AccountsPage {
cy.getTestElement(`@account-menu/btc/normal/${index}`).click();
}

applyCoinFilter(coin: NetworkSymbol) {
cy.getTestElement(`@account-menu/filter/${coin}`).as('account').click();
applyCoinFilter(symbol: NetworkSymbol) {
cy.getTestElement(`@account-menu/filter/${symbol}`).as('account').click();
cy.get('@account').invoke('attr', 'data-test-activated').should('eq', 'true');
}

Expand All @@ -21,10 +21,10 @@ class AccountsPage {
cy.getTestElement('@modal').should('be.visible');
}

activatNewCoin(coinName: NetworkSymbol) {
activatNewCoin(symbol: NetworkSymbol) {
this.openAddAccountsModal();
cy.getTestElement('@modal/account/activate_more_coins').click();
cy.getTestElement(`@settings/wallet/network/${coinName}`).click();
cy.getTestElement(`@settings/wallet/network/${symbol}`).click();
cy.contains('button', 'Find my').click();
cy.getTestElement('@modal').should('not.exist');
cy.discoveryShouldFinish();
Expand Down Expand Up @@ -84,8 +84,8 @@ class AccountsPage {
cy.getTestElement('@app').scrollTo('bottom');
}

clickOnDesiredAccount(coinName: NetworkSymbol) {
cy.getTestElement(`@account-menu/${coinName}/normal/0`).click('left');
clickOnDesiredAccount(symbol: NetworkSymbol) {
cy.getTestElement(`@account-menu/${symbol}/normal/0`).click('left');
}

exportDesiredTransactionType(typeOfExport: string) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import { NetworkSymbol } from '@suite-common/wallet-config';

class SettingsCrypto {
activateCoin(coin: NetworkSymbol) {
cy.getTestElement(`@settings/wallet/network/${coin}`).as('selectedCoin').click();
activateCoin(symbol: NetworkSymbol) {
cy.getTestElement(`@settings/wallet/network/${symbol}`).as('selectedCoin').click();
cy.get('@selectedCoin').invoke('attr', 'data-active').should('be.eq', 'true');
}
}
Expand Down
4 changes: 2 additions & 2 deletions packages/suite-web/e2e/support/pageObjects/topBarObject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import { NetworkSymbol } from '@suite-common/wallet-config';

class NavBar {
openDefaultAcccount(coin: NetworkSymbol = 'btc') {
cy.getTestElement(`@account-menu/${coin}/normal/0`).click();
openDefaultAcccount(symbol: NetworkSymbol = 'btc') {
cy.getTestElement(`@account-menu/${symbol}/normal/0`).click();
}

openSettings() {
Expand Down
16 changes: 8 additions & 8 deletions packages/suite-web/e2e/tests/wallet/add-account-types.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,37 +116,37 @@ describe('Account types suite', () => {
//
// Test execution
//
const coins: NetworkSymbol[] = ['ada', 'eth'];
const symbols: NetworkSymbol[] = ['ada', 'eth'];

// activate the coin
onNavBar.openSettings();
cy.getTestElement('@settings/menu/wallet').click();
coins.forEach((coin: NetworkSymbol) => {
onSettingsCryptoPage.activateCoin(coin);
symbols.forEach((symbol: NetworkSymbol) => {
onSettingsCryptoPage.activateCoin(symbol);
});

cy.getTestElement('@suite/menu/suite-index').click();
onNavBar.openDefaultAcccount();
cy.discoveryShouldFinish();
// cardano
coins.forEach((coin: NetworkSymbol) => {
onAccountsPage.applyCoinFilter(coin);
symbols.forEach((symbol: NetworkSymbol) => {
onAccountsPage.applyCoinFilter(symbol);
// get the element containing all accounts
cy.get(
`[data-testid="@account-menu/normal/group"] > [data-testid*="@account-menu/${coin}/normal"]`,
`[data-testid="@account-menu/normal/group"] > [data-testid*="@account-menu/${symbol}/normal"]`,
).then(currentAccounts => {
const numberOfAccounts1 = currentAccounts.length;

cy.getTestElement('@account-menu/add-account').click();
cy.getTestElement('@modal').should('be.visible');
cy.get(`[data-testid="@settings/wallet/network/${coin}"]`)
cy.get(`[data-testid="@settings/wallet/network/${symbol}"]`)
.should('be.visible')
.click();
cy.getTestElement('@add-account').click();
cy.discoveryShouldFinish();

cy.get(
`[data-testid="@account-menu/normal/group"] > [data-testid*="@account-menu/${coin}/normal"]`,
`[data-testid="@account-menu/normal/group"] > [data-testid*="@account-menu/${symbol}/normal"]`,
).then(newAccounts => {
const numberOfAccounts2 = newAccounts.length;
expect(numberOfAccounts2).to.be.equal(numberOfAccounts1 + 1);
Expand Down
14 changes: 7 additions & 7 deletions packages/suite-web/e2e/tests/wallet/check-coins-xpub.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ describe('Check coins XPUB', () => {
cy.task('stopEmu');
});

const coins: NetworkSymbol[] = ['btc', 'ltc', 'vtc', 'ada'];
const symbols: NetworkSymbol[] = ['btc', 'ltc', 'vtc', 'ada'];

/**
* 1. Start in Accounts section
Expand All @@ -36,17 +36,17 @@ describe('Check coins XPUB', () => {
* 6. Check that XPUB is present
* 7. Check XPUB prefix matches coin type
*/
coins.forEach(coin => {
it(`Check ${coin} XPUB`, () => {
if (coin !== 'btc') {
onAccountsPage.activatNewCoin(coin);
cy.getTestElement(`@account-menu/filter/${coin}`).click();
symbols.forEach(symbol => {
it(`Check ${symbol} XPUB`, () => {
if (symbol !== 'btc') {
onAccountsPage.activatNewCoin(symbol);
cy.getTestElement(`@account-menu/filter/${symbol}`).click();
}

cy.getTestElement('@wallet/menu/wallet-details').click();
cy.getTestElement('@wallets/details/show-xpub-button').click();
cy.getTestElement('@device-display/paginated-text').should('exist');
if (coin !== 'ada') {
if (symbol !== 'ada') {
cy.getTestElement('@device-display/paginated-text')
.should('be.visible')
.invoke('text')
Expand Down
12 changes: 6 additions & 6 deletions packages/suite-web/e2e/tests/wallet/export-transactions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { onAccountsPage } from '../../support/pageObjects/accountsObject';
import { onSettingsCryptoPage } from '../../support/pageObjects/settings/settingsCryptoObject';

const downloadsFolder = Cypress.config('downloadsFolder');
const coins: NetworkSymbol[] = ['btc', 'ltc', 'eth', 'ada'];
const symbols: NetworkSymbol[] = ['btc', 'ltc', 'eth', 'ada'];

describe('Export transactions', () => {
beforeEach(() => {
Expand Down Expand Up @@ -40,16 +40,16 @@ describe('Export transactions', () => {
*/
it('Go to account and try to export all possible variants (pdf, csv, json)', () => {
cy.prefixedVisit('/settings/coins');
coins.forEach((coin: NetworkSymbol) => {
if (coin !== 'btc') {
onSettingsCryptoPage.activateCoin(coin);
symbols.forEach((symbol: NetworkSymbol) => {
if (symbol !== 'btc') {
onSettingsCryptoPage.activateCoin(symbol);
}
});
cy.getTestElement('@suite/menu/suite-index').click();
cy.discoveryShouldFinish();

coins.forEach((coin: NetworkSymbol) => {
onAccountsPage.clickOnDesiredAccount(coin);
symbols.forEach((symbol: NetworkSymbol) => {
onAccountsPage.clickOnDesiredAccount(symbol);
cy.task('rmDir', { dir: downloadsFolder, recursive: true, force: true });
const typesOfExport: Array<string> = ['pdf', 'csv', 'json'];

Expand Down
4 changes: 2 additions & 2 deletions suite-common/suite-utils/src/__fixtures__/protocol.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { Protocol } from '@suite-common/suite-constants';
import { NetworkSymbol } from '@suite-common/wallet-config';

type getNetworkSymbolForProtocolFixture = {
type GetNetworkSymbolForProtocolFixture = {
description: string;
scheme: Protocol;
result: NetworkSymbol | undefined;
};

export const getNetworkSymbolForProtocol: getNetworkSymbolForProtocolFixture[] = [
export const getNetworkSymbolForProtocol: GetNetworkSymbolForProtocolFixture[] = [
{
description: 'should return network symbol for bitcoin protocol',
scheme: 'bitcoin',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@ type SelectableAssetListProps = {

const NetworkItemSection = ({
title,
networks,
symbols,
onSelectItem,
}: {
title: ReactNode;
networks: NetworkSymbol[];
symbols: NetworkSymbol[];
onSelectItem: SelectableAssetListProps['onSelectItem'];
}) => {
return (
<HeaderedCard title={title}>
<VStack spacing="sp24">
{networks.map(symbol => (
{symbols.map(symbol => (
<SelectableNetworkItem key={symbol} symbol={symbol} onPress={onSelectItem} />
))}
</VStack>
Expand All @@ -35,19 +35,21 @@ const NetworkItemSection = ({
};

export const SelectableNetworkList = ({ onSelectItem }: SelectableAssetListProps) => {
const portfolioMainnets = useSelector(selectPortfolioTrackerMainnetNetworkSymbols);
const portfolioTestnets = useSelector(selectPortfolioTrackerTestnetNetworkSymbols);
const portfolioMainnetNetworkSymbols = useSelector(selectPortfolioTrackerMainnetNetworkSymbols);
const portfolioTestnetsNetworkSymbols = useSelector(
selectPortfolioTrackerTestnetNetworkSymbols,
);

return (
<VStack spacing="sp24">
<NetworkItemSection
title={<Translation id="moduleAccountImport.coinList.mainnets" />}
networks={portfolioMainnets}
symbols={portfolioMainnetNetworkSymbols}
onSelectItem={onSelectItem}
/>
<NetworkItemSection
title={<Translation id="moduleAccountImport.coinList.testnets" />}
networks={portfolioTestnets}
symbols={portfolioTestnetsNetworkSymbols}
onSelectItem={onSelectItem}
/>
</VStack>
Expand Down

0 comments on commit 3ec693e

Please sign in to comment.