Changeset View
Changeset View
Standalone View
Standalone View
apps/marlin-wallet/web/cypress/e2e/transitional-balance.cy.ts
| Show All 12 Lines | |||||
| import { atomsToUnit, unitToAtoms } from '../../src/amount'; | import { atomsToUnit, unitToAtoms } from '../../src/amount'; | ||||
| import { FIRMA_TOKEN, XEC_ASSET } from '../../src/supported-assets'; | import { FIRMA_TOKEN, XEC_ASSET } from '../../src/supported-assets'; | ||||
| import { | import { | ||||
| normalizeBalanceText, | normalizeBalanceText, | ||||
| openSettingsFromMain, | openSettingsFromMain, | ||||
| selectFirmaAsset, | selectFirmaAsset, | ||||
| visitWithWalletMnemonic, | visitWithWalletMnemonic, | ||||
| waitForMainLoaded, | waitForMainLoaded, | ||||
| formatFirmaAmount, | |||||
| } from '../fixture/common'; | } from '../fixture/common'; | ||||
| import { | import { | ||||
| installChronikWebSocketStub, | installChronikWebSocketStub, | ||||
| runWithChronik, | runWithChronik, | ||||
| stubCoingeckoXecFiatPrices, | stubCoingeckoXecFiatPrices, | ||||
| type ChronikWebSocketStub, | type ChronikWebSocketStub, | ||||
| type WindowWithChronikWebSocketStub, | type WindowWithChronikWebSocketStub, | ||||
| } from '../fixture/stubs'; | } from '../fixture/stubs'; | ||||
| ▲ Show 20 Lines • Show All 239 Lines • ▼ Show 20 Lines | it('shows receive transitional in Firma then available balance after mempool and finalization WS', () => { | ||||
| }); | }); | ||||
| waitForMainLoaded(); | waitForMainLoaded(); | ||||
| selectFirmaAsset(); | selectFirmaAsset(); | ||||
| cy.get('#primary-balance').should($el => { | cy.get('#primary-balance').should($el => { | ||||
| const t = normalizeBalanceText($el.text()); | const t = normalizeBalanceText($el.text()); | ||||
| expect(t).to.equal( | expect(t).to.equal( | ||||
| formatPrice( | formatFirmaAmount( | ||||
| atomsToUnit( | atomsToUnit( | ||||
| STUB_AVAILABLE_FIRMA_ATOMS, | STUB_AVAILABLE_FIRMA_ATOMS, | ||||
| FIRMA_TOKEN.decimals, | FIRMA_TOKEN.decimals, | ||||
| ), | ), | ||||
| new CryptoTicker(FIRMA_TOKEN.ticker.toLowerCase()), | |||||
| { | |||||
| locale: DEFAULT_LOCALE, | |||||
| decimals: FIRMA_TOKEN.decimals, | |||||
| }, | |||||
| ), | ), | ||||
| ); | ); | ||||
| }); | }); | ||||
| const syntheticTxid = | const syntheticTxid = | ||||
| 'e2e000000000000000000000000000000000000000000000000000000000f1ea'; | 'e2e000000000000000000000000000000000000000000000000000000000f1ea'; | ||||
| const receiveAtoms = 10_000; | const receiveAtoms = 10_000; | ||||
| const mempoolTx = receiveFirmaTx( | const mempoolTx = receiveFirmaTx( | ||||
| syntheticTxid, | syntheticTxid, | ||||
| String(receiveAtoms), | String(receiveAtoms), | ||||
| ); | ); | ||||
| const expectedTransitionalFirma = formatPrice( | const expectedTransitionalFirma = formatFirmaAmount( | ||||
| atomsToUnit(receiveAtoms, FIRMA_TOKEN.decimals), | atomsToUnit(receiveAtoms, FIRMA_TOKEN.decimals), | ||||
| new CryptoTicker(FIRMA_TOKEN.ticker.toLowerCase()), | { alwaysShowSign: true }, | ||||
| { | |||||
| locale: DEFAULT_LOCALE, | |||||
| decimals: FIRMA_TOKEN.decimals, | |||||
| alwaysShowSign: true, | |||||
| }, | |||||
| ); | ); | ||||
| cy.window().then(win => { | cy.window().then(win => { | ||||
| const stub = ensureWebsocketStub(win); | const stub = ensureWebsocketStub(win); | ||||
| stub.emitTxWebsocket(TxMsgType.TX_ADDED_TO_MEMPOOL, mempoolTx); | stub.emitTxWebsocket(TxMsgType.TX_ADDED_TO_MEMPOOL, mempoolTx); | ||||
| }); | }); | ||||
| cy.get('#transitional-balance') | cy.get('#transitional-balance') | ||||
| Show All 13 Lines | it('shows receive transitional in Firma then available balance after mempool and finalization WS', () => { | ||||
| ); | ); | ||||
| }); | }); | ||||
| cy.get('#transitional-balance').should('have.class', 'hidden'); | cy.get('#transitional-balance').should('have.class', 'hidden'); | ||||
| cy.get('#primary-balance').should($el => { | cy.get('#primary-balance').should($el => { | ||||
| const t = normalizeBalanceText($el.text()); | const t = normalizeBalanceText($el.text()); | ||||
| expect(t).to.equal( | expect(t).to.equal( | ||||
| formatPrice( | formatFirmaAmount( | ||||
| atomsToUnit( | atomsToUnit( | ||||
| STUB_AVAILABLE_FIRMA_ATOMS + receiveAtoms, | STUB_AVAILABLE_FIRMA_ATOMS + receiveAtoms, | ||||
| FIRMA_TOKEN.decimals, | FIRMA_TOKEN.decimals, | ||||
| ), | ), | ||||
| new CryptoTicker(FIRMA_TOKEN.ticker.toLowerCase()), | |||||
| { | |||||
| locale: DEFAULT_LOCALE, | |||||
| decimals: FIRMA_TOKEN.decimals, | |||||
| }, | |||||
| ), | ), | ||||
| ); | ); | ||||
| }); | }); | ||||
| }); | }); | ||||
| }); | }); | ||||
| it('shows spend transitional then available balance after mempool and finalization WS', () => { | it('shows spend transitional then available balance after mempool and finalization WS', () => { | ||||
| runWithChronik(CHRONIK_STUB, () => { | runWithChronik(CHRONIK_STUB, () => { | ||||
| ▲ Show 20 Lines • Show All 606 Lines • Show Last 20 Lines | |||||