Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(suite): update network symbol naming 12 #15841

Merged
merged 1 commit into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -35,10 +35,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 networkButton = (symbol: NetworkSymbol) =>
this.window.getByTestId(`@settings/wallet/network/${symbol}`);
readonly networkSymbolAdvanceSettingsButton = (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 @@ -92,24 +92,24 @@ export class SettingsActions {
await expect(this.debugTabButton).toBeVisible();
}

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

async enableCoin(coin: NetworkSymbol) {
await this.coinNetworkButton(coin).click();
await expect(this.coinNetworkButton(coin)).toBeEnabledCoin();
async enableNetwork(symbol: NetworkSymbol) {
await this.networkButton(symbol).click();
await expect(this.networkButton(symbol)).toBeEnabledCoin();
}

async disableCoin(coin: NetworkSymbol) {
await this.coinNetworkButton(coin).click();
await expect(this.coinNetworkButton(coin)).toBeDisabledCoin();
async disableNetwork(symbol: NetworkSymbol) {
await this.networkButton(symbol).click();
await expect(this.networkButton(symbol)).toBeDisabledCoin();
}

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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ test(
async ({ dashboardPage, settingsPage, walletPage }) => {
await settingsPage.navigateTo();
await settingsPage.coinsTabButton.click();
await settingsPage.enableCoin('ada');
await settingsPage.disableCoin('btc');
await settingsPage.enableNetwork('ada');
await settingsPage.disableNetwork('btc');

await dashboardPage.navigateTo();
await dashboardPage.discoveryShouldFinish();
Expand Down
8 changes: 4 additions & 4 deletions packages/suite-desktop-core/e2e/tests/settings/coins.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ test.describe('Coin Settings', { tag: ['@group=settings'] }, () => {
'dsol',
];

await expect(settingsPage.coinNetworkButton('btc')).toBeEnabledCoin();
await expect(settingsPage.networkButton('btc')).toBeEnabledCoin();
for (const network of defaultUnchecked) {
await expect(settingsPage.coinNetworkButton(network)).toBeDisabledCoin();
await expect(settingsPage.networkButton(network)).toBeDisabledCoin();
}

await settingsPage.disableCoin('btc');
await settingsPage.disableNetwork('btc');

// check dashboard with all coins disabled
await dashboardPage.navigateTo();
Expand All @@ -57,7 +57,7 @@ test.describe('Coin Settings', { tag: ['@group=settings'] }, () => {
await settingsPage.coinsTabButton.click();
// just do some clicking on switches and check result
for (const network of ['btc', ...defaultUnchecked] as NetworkSymbol[]) {
await settingsPage.enableCoin(network);
await settingsPage.enableNetwork(network);
}

//TODO: #15811 this is just not useful validation. To be refactored
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ test.describe.serial(

await settingsPage.navigateTo();
await settingsPage.coinsTabButton.click();
await settingsPage.openCoinAdvanceSettings('regtest');
await settingsPage.openNetworkAdvanceSettings('regtest');
await settingsPage.changeCoinBackend('electrum', electrumUrl);

await dashboardPage.navigateTo();
Expand Down
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
4 changes: 2 additions & 2 deletions suite-common/validators/src/schemas/xpubSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { isAddressValid, isAddressBasedNetwork } from '@suite-common/wallet-util

import { yup } from '../config';

export type XpubFormContext = { networkSymbol?: NetworkSymbol };
export type XpubFormContext = { symbol?: NetworkSymbol };

export const xpubFormValidationSchema = yup.object({
xpubAddress: yup
Expand All @@ -15,7 +15,7 @@ export const xpubFormValidationSchema = yup.object({
'is-invalid-address',
'Address is not valid',
(value, { options: { context } }: yup.TestContext<XpubFormContext>) => {
const symbol = context?.networkSymbol;
const symbol = context?.symbol;

if (!symbol) return false;

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
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export const XpubScanScreen = ({

const form = useForm<XpubFormValues, XpubFormContext>({
validation: xpubFormValidationSchema,
context: { networkSymbol },
context: { symbol: networkSymbol },
});
const { handleSubmit, setValue, watch } = form;
const watchXpubAddress = watch('xpubAddress');
Expand Down
Loading