Changeset View
Changeset View
Standalone View
Standalone View
apps/marlin-wallet/web/cypress/e2e/history.cy.ts
| // Copyright (c) 2026 The Bitcoin developers | // Copyright (c) 2026 The Bitcoin developers | ||||
| // Distributed under the MIT software license, see the accompanying | // Distributed under the MIT software license, see the accompanying | ||||
| // file COPYING or http://www.opensource.org/licenses/mit-license.php. | // file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
| import { | import { | ||||
| normalizeBalanceText, | normalizeBalanceText, | ||||
| openSettingsFromMain, | openSettingsFromMain, | ||||
| selectFirmaAsset, | selectFirmaAsset, | ||||
| visitWithWalletMnemonic, | visitWithWalletMnemonic, | ||||
| waitForMainLoaded, | waitForMainLoaded, | ||||
| FIRMA_FORMATTED_TICKER, | |||||
| } from '../fixture/common'; | } from '../fixture/common'; | ||||
| import type { ChronikStub } from '../fixture/chronik-json-protobuf'; | import type { ChronikStub } from '../fixture/chronik-json-protobuf'; | ||||
| import { runWithChronik, stubCoingeckoXecFiatPrices } from '../fixture/stubs'; | import { runWithChronik, stubCoingeckoXecFiatPrices } from '../fixture/stubs'; | ||||
| import { VISIBLE_BATCH_TARGET } from '../../src/transaction-history'; | import { VISIBLE_BATCH_TARGET } from '../../src/transaction-history'; | ||||
| /** Same mnemonic as mnemonic.cy.ts / cashtab vectors; matches Chronik stubs. */ | /** Same mnemonic as mnemonic.cy.ts / cashtab vectors; matches Chronik stubs. */ | ||||
| const TEST_MNEMONIC = | const TEST_MNEMONIC = | ||||
| 'beauty shoe decline spend still weird slot snack coach flee between paper'; | 'beauty shoe decline spend still weird slot snack coach flee between paper'; | ||||
| ▲ Show 20 Lines • Show All 209 Lines • ▼ Show 20 Lines | describe('Transaction history', () => { | ||||
| it('shows Firma amounts in history when Firma is selected', () => { | it('shows Firma amounts in history when Firma is selected', () => { | ||||
| runWithChronik(CHRONIK_STUB_FIRMA_WALLET, () => { | runWithChronik(CHRONIK_STUB_FIRMA_WALLET, () => { | ||||
| visitWithWalletMnemonic(FIRMA_WALLET_MNEMONIC); | visitWithWalletMnemonic(FIRMA_WALLET_MNEMONIC); | ||||
| waitForMainLoaded(); | waitForMainLoaded(); | ||||
| selectFirmaAsset(); | selectFirmaAsset(); | ||||
| cy.get('#primary-balance').should($el => { | cy.get('#primary-balance').should($el => { | ||||
| expect(normalizeBalanceText($el.text())).to.eq('0.5000 FIRMA'); | expect(normalizeBalanceText($el.text())).to.eq( | ||||
| `0.5000 ${FIRMA_FORMATTED_TICKER}`, | |||||
| ); | |||||
| }); | }); | ||||
| openHistoryFromMain(); | openHistoryFromMain(); | ||||
| cy.get('#transaction-list').should($el => { | cy.get('#transaction-list').should($el => { | ||||
| expect($el.html()).to.not.include('loading-transactions'); | expect($el.html()).to.not.include('loading-transactions'); | ||||
| }); | }); | ||||
| // Stub has two XEC txs but only one Firma token movement for this wallet. | // Stub has two XEC txs but only one Firma token movement for this wallet. | ||||
| cy.get('#transaction-list .transaction-item').should( | cy.get('#transaction-list .transaction-item').should( | ||||
| 'have.length', | 'have.length', | ||||
| 1, | 1, | ||||
| ); | ); | ||||
| cy.get('#transaction-list .transaction-item') | cy.get('#transaction-list .transaction-item') | ||||
| .first() | .first() | ||||
| .find('.transaction-amount-primary') | .find('.transaction-amount-primary') | ||||
| .should($el => { | .should($el => { | ||||
| expect(normalizeBalanceText($el.text())).to.eq( | expect(normalizeBalanceText($el.text())).to.eq( | ||||
| '+0.5000 FIRMA', | `+0.5000 ${FIRMA_FORMATTED_TICKER}`, | ||||
| ); | ); | ||||
| }); | }); | ||||
| cy.get('#transaction-list .transaction-item') | cy.get('#transaction-list .transaction-item') | ||||
| .first() | .first() | ||||
| .find('.transaction-amount-secondary') | .find('.transaction-amount-secondary') | ||||
| .should($el => { | .should($el => { | ||||
| expect(normalizeBalanceText($el.text())).to.eq('+$0.50'); | expect(normalizeBalanceText($el.text())).to.eq('+$0.50'); | ||||
| }); | }); | ||||
| }); | }); | ||||
| }); | }); | ||||
| it('inverts Firma vs fiat amount columns in history when fiat is primary', () => { | it('inverts Firma vs fiat amount columns in history when fiat is primary', () => { | ||||
| runWithChronik(CHRONIK_STUB_FIRMA_WALLET, () => { | runWithChronik(CHRONIK_STUB_FIRMA_WALLET, () => { | ||||
| visitWithWalletMnemonic(FIRMA_WALLET_MNEMONIC); | visitWithWalletMnemonic(FIRMA_WALLET_MNEMONIC); | ||||
| waitForMainLoaded(); | waitForMainLoaded(); | ||||
| selectFirmaAsset(); | selectFirmaAsset(); | ||||
| cy.get('#primary-balance').should($el => { | cy.get('#primary-balance').should($el => { | ||||
| expect(normalizeBalanceText($el.text())).to.eq('0.5000 FIRMA'); | expect(normalizeBalanceText($el.text())).to.eq( | ||||
| `0.5000 ${FIRMA_FORMATTED_TICKER}`, | |||||
| ); | |||||
| }); | }); | ||||
| openHistoryFromMain(); | openHistoryFromMain(); | ||||
| cy.get('#transaction-list').should($el => { | cy.get('#transaction-list').should($el => { | ||||
| expect($el.html()).to.not.include('loading-transactions'); | expect($el.html()).to.not.include('loading-transactions'); | ||||
| }); | }); | ||||
| cy.get('#transaction-list .transaction-item') | cy.get('#transaction-list .transaction-item') | ||||
| .first() | .first() | ||||
| .find('.transaction-amount-primary') | .find('.transaction-amount-primary') | ||||
| .should($el => { | .should($el => { | ||||
| expect(normalizeBalanceText($el.text())).to.eq( | expect(normalizeBalanceText($el.text())).to.eq( | ||||
| '+0.5000 FIRMA', | `+0.5000 ${FIRMA_FORMATTED_TICKER}`, | ||||
| ); | ); | ||||
| }); | }); | ||||
| cy.get('#transaction-list .transaction-item') | cy.get('#transaction-list .transaction-item') | ||||
| .first() | .first() | ||||
| .find('.transaction-amount-secondary') | .find('.transaction-amount-secondary') | ||||
| .should($el => { | .should($el => { | ||||
| expect(normalizeBalanceText($el.text())).to.eq('+$0.50'); | expect(normalizeBalanceText($el.text())).to.eq('+$0.50'); | ||||
| }); | }); | ||||
| Show All 18 Lines | it('inverts Firma vs fiat amount columns in history when fiat is primary', () => { | ||||
| .should($el => { | .should($el => { | ||||
| expect(normalizeBalanceText($el.text())).to.eq('+$0.50'); | expect(normalizeBalanceText($el.text())).to.eq('+$0.50'); | ||||
| }); | }); | ||||
| cy.get('#transaction-list .transaction-item') | cy.get('#transaction-list .transaction-item') | ||||
| .first() | .first() | ||||
| .find('.transaction-amount-secondary') | .find('.transaction-amount-secondary') | ||||
| .should($el => { | .should($el => { | ||||
| expect(normalizeBalanceText($el.text())).to.eq( | expect(normalizeBalanceText($el.text())).to.eq( | ||||
| '+0.5000 FIRMA', | `+0.5000 ${FIRMA_FORMATTED_TICKER}`, | ||||
| ); | ); | ||||
| }); | }); | ||||
| }); | }); | ||||
| }); | }); | ||||
| it('inverts primary and secondary amounts when fiat is the primary balance', () => { | it('inverts primary and secondary amounts when fiat is the primary balance', () => { | ||||
| runWithChronik(CHRONIK_STUB, ({ stub }) => { | runWithChronik(CHRONIK_STUB, ({ stub }) => { | ||||
| visitWithWalletMnemonic(TEST_MNEMONIC); | visitWithWalletMnemonic(TEST_MNEMONIC); | ||||
| ▲ Show 20 Lines • Show All 52 Lines • ▼ Show 20 Lines | it('shows Firma history when Firma txs are buried after XEC-only pages', () => { | ||||
| 'have.length', | 'have.length', | ||||
| 1, | 1, | ||||
| ); | ); | ||||
| cy.get('#transaction-list .transaction-item') | cy.get('#transaction-list .transaction-item') | ||||
| .first() | .first() | ||||
| .find('.transaction-amount-primary') | .find('.transaction-amount-primary') | ||||
| .should($el => { | .should($el => { | ||||
| expect(normalizeBalanceText($el.text())).to.eq( | expect(normalizeBalanceText($el.text())).to.eq( | ||||
| '+0.5000 FIRMA', | `+0.5000 ${FIRMA_FORMATTED_TICKER}`, | ||||
| ); | ); | ||||
| }); | }); | ||||
| }); | }); | ||||
| }); | }); | ||||
| it('loads more Firma transactions when scrolling after multi-page fetch', () => { | it('loads more Firma transactions when scrolling after multi-page fetch', () => { | ||||
| runWithChronik(CHRONIK_STUB_FIRMA_PAGINATED, ({ stub }) => { | runWithChronik(CHRONIK_STUB_FIRMA_PAGINATED, ({ stub }) => { | ||||
| expect(stub.meta.historyNumPages).to.equal(3); | expect(stub.meta.historyNumPages).to.equal(3); | ||||
| ▲ Show 20 Lines • Show All 59 Lines • Show Last 20 Lines | |||||