diff --git a/test/e2e/fixture-builder.js b/test/e2e/fixture-builder.js index 020c4db1c64b..7db23024bff1 100644 --- a/test/e2e/fixture-builder.js +++ b/test/e2e/fixture-builder.js @@ -1509,6 +1509,14 @@ class FixtureBuilder { }); } + withUseNativeCurrencyAsPrimaryCurrency() { + return this.withPreferencesController({ + preferences: { + useNativeCurrencyAsPrimaryCurrency: true, + }, + }); + } + build() { this.fixture.meta = { version: FIXTURE_STATE_METADATA_VERSION, diff --git a/test/e2e/flask/solana/check-balance.spec.ts b/test/e2e/flask/solana/check-balance.spec.ts index 6b4c9c09cbe6..1634104f36e8 100644 --- a/test/e2e/flask/solana/check-balance.spec.ts +++ b/test/e2e/flask/solana/check-balance.spec.ts @@ -5,39 +5,26 @@ import AccountListPage from '../../page-objects/pages/account-list-page'; import { SOL_BALANCE, USD_BALANCE, withSolanaAccountSnap } from './common-solana'; import { logging } from 'selenium-webdriver'; import SettingsPage from '../../page-objects/pages/settings/settings-page'; +import { ACCOUNT_TYPE } from '../../page-objects/common'; +import HomePage from '../../page-objects/pages/home/homepage'; +import SolanaHomepage from '../../page-objects/pages/home/solana-homepage'; const EXPECTED_MAINNET_BALANCE_USD = `$${USD_BALANCE}`; describe('Switching between account from different networks', function (this: Suite) { + this.timeout(120000) it.only('Switch from Solana account to another Network account', async function () { await withSolanaAccountSnap( - { title: this.test?.fullTitle() }, + { title: this.test?.fullTitle(),}, async (driver) => { const headerNavbar = new HeaderNavbar(driver); await headerNavbar.check_pageIsLoaded(); - await headerNavbar.check_accountLabel('Solana 1'); - const accountListPage = new AccountListPage(driver); - await accountListPage.check_accountValueAndSuffixDisplayed( - "0.00011294SOL", - ); + const homePage = new SolanaHomepage(driver) + const balanceText = await homePage.getSolanaBalance() + console.log('BalanceText ', balanceText) + console.log('xpectedText ', "0 SOL") + assert.equal(balanceText, "0 SOL"); }, ); - - it('Show native token as main balance', async function () { - await withSolanaAccountSnap( - { title: this.test?.fullTitle() }, - async (driver) => { - const headerNavbar = new HeaderNavbar(driver); - await headerNavbar.check_pageIsLoaded(); - await headerNavbar.check_accountLabel('Solana 1'); - const accountListPage = new AccountListPage(driver); - await headerNavbar.openSettingsPage(); - const settingsPage = new SettingsPage(driver); - await settingsPage.toggleBalanceSetting(); - await settingsPage.closeSettingsPage() - - }, - ); - }); }); }); diff --git a/test/e2e/flask/solana/common-solana.ts b/test/e2e/flask/solana/common-solana.ts index e3eb2b0ab336..0884ae076086 100644 --- a/test/e2e/flask/solana/common-solana.ts +++ b/test/e2e/flask/solana/common-solana.ts @@ -1,5 +1,5 @@ import { Mockttp } from 'mockttp'; -import { withFixtures, unlockWallet } from '../../helpers'; +import { withFixtures } from '../../helpers'; import { Driver } from '../../webdriver/driver'; import HeaderNavbar from '../../page-objects/pages/header-navbar'; import AccountListPage from '../../page-objects/pages/account-list-page'; @@ -26,12 +26,24 @@ export const USD_BALANCE = SOL_BALANCE * SOL_TO_USD_RATE; export async function mockSolanaBalanceQuote(mockServer: Mockttp) { return await mockServer - .forPost(SOLANA_URL_REGEX) + .forPost('https://api.devnet.solana.com/') .withJsonBodyIncluding({ method: 'getBalance', }) .thenCallback(() => { - console.log('Entra?'); + console.log('Entra y returning ', { + statusCode: 200, + json: { + result: { + context: { + apiVersion: '2.0.18', + slot: 308460925, + }, + value: SOL_BALANCE, + }, + id: 1337, + }, + }); return { statusCode: 200, json: { @@ -42,6 +54,84 @@ export async function mockSolanaBalanceQuote(mockServer: Mockttp) { }, value: SOL_BALANCE, }, + id: 1337, + }, + }; + }); +} +export async function mockGetSignaturesForAddress(mockServer: Mockttp) { + return await mockServer + .forGet(SOLANA_URL_REGEX) + .withBodyIncluding('getSignaturesForAddress') + .thenCallback(() => { + return { + statusCode: 200, + json: { + result: [ + { + blockTime: 1734620122, + confirmationStatus: 'finalized', + err: null, + memo: null, + signature: + '5THAXC3pHCRwwwrMHR6PJiSqFfgSkZrBhn59C7YEbTMVbiAnjZhqpPvJYs4v5aRcqUiokunfbdTgo9HLfv6bogNR', + slot: 348093552, + }, + { + blockTime: 1734619950, + confirmationStatus: 'finalized', + err: null, + memo: null, + signature: + '5KHuDsTMjre6rWU5Qkf8ugG31PjWoZ8NbV21ThY8RwcHpn3dKbTafdizUkEj4sU2AfrRzVxgyGkX8MLxK5nWHJ6J', + slot: 348093088, + }, + { + blockTime: 1734619916, + confirmationStatus: 'finalized', + err: null, + memo: null, + signature: + '2RcW9iJCGnYuGVbDbaDi93t2f2347a6gzjoQf9idDdfFTjHsC7yMYcUvGqNzouKgA8T8tdYqjNUtDf4vR4e9iUoF', + slot: 348092996, + }, + { + blockTime: 1734619899, + confirmationStatus: 'finalized', + err: null, + memo: null, + signature: + '2kCcoXZxe14384c8JTvq1g63pSjmmyuDnye9y3ReBMEiaZeGWspsmooEdC4RoyzP6uTfaDyFpCupBAKXnZwXCKMg', + slot: 348092952, + }, + { + blockTime: 1734619885, + confirmationStatus: 'finalized', + err: null, + memo: null, + signature: + '4fzwGY4Tw5C4nYMaVAY7e3ZMwz691CbT7By4F4YFdukzBxd7yspmZEHhBtuPhFrqLj1yBn6zpc4kh1GLzgcovEbx', + slot: 348092914, + }, + { + blockTime: 1734619758, + confirmationStatus: 'finalized', + err: null, + memo: null, + signature: + '2vgL59tfVa2VJkf7kmsGhbdBFjHdspLa1wfL72zZqHfJuzhmKfqS4YoLofpMTnZzzZfiA6712pwURheMUh5S2RXd', + slot: 348092568, + }, + { + blockTime: 1734619697, + confirmationStatus: 'finalized', + err: null, + memo: null, + signature: + '32fqeHudeNBuDmyCrmRemFppVPpWmXwT4cbfai5D7G2Vzah1BvVguLqkNuk9Pdu4xVyBD32dhnSV8AN9k4qnffSB', + slot: 348092404, + }, + ], }, }; }); @@ -93,16 +183,15 @@ export async function withSolanaAccountSnap( .withPreferencesControllerAndFeatureFlag({ solanaSupportEnabled: solanaSupportEnabled ?? true, }) + .withUseNativeCurrencyAsPrimaryCurrency() .build(), title, dapp: true, - testSpecificMock: async (mockServer: Mockttp) => { - console.log('Setting up test-specific mocks'); - return [ - await mockSolanaBalanceQuote(mockServer), - await mockSolanaRatesCall(mockServer), - ]; - }, + testSpecificMock: async (mockServer: Mockttp) => [ + /*await mockSolanaBalanceQuote(mockServer), + await mockSolanaRatesCall(mockServer), + await mockGetSignaturesForAddress(mockServer),*/ + ], }, async ({ driver, mockServer }: { driver: Driver; mockServer: Mockttp }) => { await loginWithBalanceValidation(driver); diff --git a/test/e2e/page-objects/flows/login.flow.ts b/test/e2e/page-objects/flows/login.flow.ts index 0e5f2dd6281c..e1642d490461 100644 --- a/test/e2e/page-objects/flows/login.flow.ts +++ b/test/e2e/page-objects/flows/login.flow.ts @@ -43,6 +43,7 @@ export const loginWithBalanceValidation = async ( localBlockchainServer, ); } else { - await homePage.check_expectedBalanceIsDisplayed(); + console.log('Entra aqui') + await homePage.check_expectedBalanceIsDisplayed('0', 'SOL'); } }; diff --git a/test/e2e/page-objects/pages/account-list-page.ts b/test/e2e/page-objects/pages/account-list-page.ts index 5fe05ef03d15..9779ec79d7f1 100644 --- a/test/e2e/page-objects/pages/account-list-page.ts +++ b/test/e2e/page-objects/pages/account-list-page.ts @@ -418,15 +418,16 @@ class AccountListPage { ); const solBalanceValue = await this.driver.findElement( this.accountValueAndSuffix, + 200000, ); - console.log(solBalanceValue.getText()); + console.log(await solBalanceValue.getText()); await this.driver.waitForSelector( { css: this.accountValueAndSuffix, text: expectedValueAndSuffix, }, { - timeout: 60000, + timeout: 20000, }, ); } diff --git a/test/e2e/page-objects/pages/home/asset-list.ts b/test/e2e/page-objects/pages/home/asset-list.ts index 9db896e3a035..aa786c77c48c 100644 --- a/test/e2e/page-objects/pages/home/asset-list.ts +++ b/test/e2e/page-objects/pages/home/asset-list.ts @@ -86,6 +86,7 @@ class AssetListPage { const allNetworksValueElement = await this.driver.findElement( this.currentNetworksTotal, ); + console.log('Aqui llega o no?') const value = await allNetworksValueElement.getText(); return value; } diff --git a/test/e2e/page-objects/pages/home/homepage.ts b/test/e2e/page-objects/pages/home/homepage.ts index b4b79846fb06..7a5cbe3a9398 100644 --- a/test/e2e/page-objects/pages/home/homepage.ts +++ b/test/e2e/page-objects/pages/home/homepage.ts @@ -211,6 +211,14 @@ class HomePage { } await this.check_expectedBalanceIsDisplayed(expectedBalance); } + + async getBalanceText(): Promise { + const balanceValue = await this.driver.waitForSelector(this.balance, { + timeout: 120000, + }); + const singleBalanceText = await balanceValue.getText(); + return singleBalanceText; + } } export default HomePage; diff --git a/test/e2e/page-objects/pages/home/solana-homepage.ts b/test/e2e/page-objects/pages/home/solana-homepage.ts new file mode 100644 index 000000000000..38a8b7b98a25 --- /dev/null +++ b/test/e2e/page-objects/pages/home/solana-homepage.ts @@ -0,0 +1,69 @@ +import HomePage from './homepage'; + +class SolanaHomepage extends HomePage { + protected readonly solanaBalance = + '.coin-overview__primary-balance'; + + private readonly bridgeButton = { + text: 'Bridge', + tag: 'button', + }; + + private readonly buySellButton = '[data-testid="coin-overview-buy"]'; + + private readonly receiveButton = '[data-testid="coin-overview-receive"]'; + + protected readonly sendButton = '[data-testid="coin-overview-send"]'; + + private readonly swapButton = { + text: 'Swap', + tag: 'button', + }; + + /** + * Checks if the expected solana balance is displayed on homepage. + * + * @param expectedBalance - The expected bitcoin balance to be displayed. Defaults to '0'. + */ + async getSolanaBalance( + expectedBalance: number = 0, + ): Promise { + console.log( + `Check if expected Solana balance is displayed: ${expectedBalance} SOL`, + ); + const balanceValue = await this.driver.waitForSelector(this.solanaBalance, { timeout: 120000 }) + const singleBalanceText = await balanceValue.getText(); + const trimmedBalance = singleBalanceText.replaceAll(/\s+/g, ' ').trim() + return singleBalanceText.replaceAll(/\s+/g, ' ').trim() + } + + /** + * Checks if the receive button is enabled on bitcoin account homepage. + */ + async check_isReceiveButtonEnabled(): Promise { + try { + await this.driver.findClickableElement(this.receiveButton, 1000); + } catch (e) { + console.log('Receive button not enabled', e); + return false; + } + console.log('Receive button is enabled'); + return true; + } + + /** + * Checks if the swap button is enabled on bitcoin account homepage. + */ + async check_isSwapButtonEnabled(): Promise { + try { + await this.driver.findClickableElement(this.swapButton, 1000); + } catch (e) { + console.log('Swap button not enabled', e); + return false; + } + console.log('Swap button is enabled'); + return true; + } +} + +export default SolanaHomepage;