Changeset View
Changeset View
Standalone View
Standalone View
apps/marlin-wallet/web/cypress/e2e/main.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, | ||||
| visitFresh, | visitFresh, | ||||
| waitForMainLoaded, | waitForMainLoaded, | ||||
| FIRMA_FORMATTED_TICKER, | |||||
| } from '../fixture/common'; | } from '../fixture/common'; | ||||
| import { stubCoingeckoXecFiatPrices } from '../fixture/stubs'; | import { stubCoingeckoXecFiatPrices } from '../fixture/stubs'; | ||||
| describe('Main screen', () => { | describe('Main screen', () => { | ||||
| const returnToMainFromSettings = () => { | const returnToMainFromSettings = () => { | ||||
| cy.get('#settings-back-btn').click(); | cy.get('#settings-back-btn').click(); | ||||
| cy.get('#main-screen').should('be.visible'); | cy.get('#main-screen').should('be.visible'); | ||||
| }; | }; | ||||
| ▲ Show 20 Lines • Show All 165 Lines • ▼ Show 20 Lines | it('switches primary balance unit between XEC and Firma (zero balance)', () => { | ||||
| cy.get('#primary-balance') | cy.get('#primary-balance') | ||||
| .invoke('text') | .invoke('text') | ||||
| .then(t => normalizeBalanceText(t)) | .then(t => normalizeBalanceText(t)) | ||||
| .should('eq', '0.00 XEC'); | .should('eq', '0.00 XEC'); | ||||
| selectFirmaAsset(); | selectFirmaAsset(); | ||||
| cy.get('#primary-balance').should($el => { | cy.get('#primary-balance').should($el => { | ||||
| expect(normalizeBalanceText($el.text())).to.equal('0.0000 FIRMA'); | expect(normalizeBalanceText($el.text())).to.equal( | ||||
| `0.0000 ${FIRMA_FORMATTED_TICKER}`, | |||||
| ); | |||||
| }); | }); | ||||
| cy.get('#asset-picker-btn').click(); | cy.get('#asset-picker-btn').click(); | ||||
| cy.get('#asset-picker-menu').should('have.class', 'open'); | cy.get('#asset-picker-menu').should('have.class', 'open'); | ||||
| cy.get('#asset-picker-menu [data-asset="xec"]').click(); | cy.get('#asset-picker-menu [data-asset="xec"]').click(); | ||||
| cy.get('#asset-picker-menu').should('not.have.class', 'open'); | cy.get('#asset-picker-menu').should('not.have.class', 'open'); | ||||
| cy.get('#primary-balance').should($el => { | cy.get('#primary-balance').should($el => { | ||||
| expect(normalizeBalanceText($el.text())).to.equal('0.00 XEC'); | expect(normalizeBalanceText($el.text())).to.equal('0.00 XEC'); | ||||
| }); | }); | ||||
| }); | }); | ||||
| it('inverts primary and secondary balances with Firma selected (crypto vs fiat)', () => { | it('inverts primary and secondary balances with Firma selected (crypto vs fiat)', () => { | ||||
| visitFresh(); | visitFresh(); | ||||
| waitForMainLoaded(); | waitForMainLoaded(); | ||||
| selectFirmaAsset(); | selectFirmaAsset(); | ||||
| cy.get('#primary-balance').should($el => { | cy.get('#primary-balance').should($el => { | ||||
| expect(normalizeBalanceText($el.text())).to.equal('0.0000 FIRMA'); | expect(normalizeBalanceText($el.text())).to.equal( | ||||
| `0.0000 ${FIRMA_FORMATTED_TICKER}`, | |||||
| ); | |||||
| }); | }); | ||||
| cy.get('#secondary-balance').should($el => { | cy.get('#secondary-balance').should($el => { | ||||
| expect(normalizeBalanceText($el.text())).to.equal('$0.00'); | expect(normalizeBalanceText($el.text())).to.equal('$0.00'); | ||||
| }); | }); | ||||
| openSettingsFromMain(); | openSettingsFromMain(); | ||||
| cy.get('#primary-balance-toggle').should('not.be.checked'); | cy.get('#primary-balance-toggle').should('not.be.checked'); | ||||
| cy.get('#primary-balance-toggle').check({ force: true }); | cy.get('#primary-balance-toggle').check({ force: true }); | ||||
| cy.get('#primary-balance-toggle').should('be.checked'); | cy.get('#primary-balance-toggle').should('be.checked'); | ||||
| returnToMainFromSettings(); | returnToMainFromSettings(); | ||||
| cy.get('#primary-balance') | cy.get('#primary-balance') | ||||
| .invoke('text') | .invoke('text') | ||||
| .then(t => normalizeBalanceText(t)) | .then(t => normalizeBalanceText(t)) | ||||
| .should('eq', '$0.00'); | .should('eq', '$0.00'); | ||||
| cy.get('#secondary-balance') | cy.get('#secondary-balance') | ||||
| .should('be.visible') | .should('be.visible') | ||||
| .invoke('text') | .invoke('text') | ||||
| .then(t => normalizeBalanceText(t)) | .then(t => normalizeBalanceText(t)) | ||||
| .should('eq', '0.0000 FIRMA'); | .should('eq', `0.0000 ${FIRMA_FORMATTED_TICKER}`); | ||||
| openSettingsFromMain(); | openSettingsFromMain(); | ||||
| cy.get('#primary-balance-toggle').uncheck({ force: true }); | cy.get('#primary-balance-toggle').uncheck({ force: true }); | ||||
| cy.get('#primary-balance-toggle').should('not.be.checked'); | cy.get('#primary-balance-toggle').should('not.be.checked'); | ||||
| returnToMainFromSettings(); | returnToMainFromSettings(); | ||||
| cy.get('#primary-balance') | cy.get('#primary-balance') | ||||
| .invoke('text') | .invoke('text') | ||||
| .then(t => normalizeBalanceText(t)) | .then(t => normalizeBalanceText(t)) | ||||
| .should('eq', '0.0000 FIRMA'); | .should('eq', `0.0000 ${FIRMA_FORMATTED_TICKER}`); | ||||
| cy.get('#secondary-balance') | cy.get('#secondary-balance') | ||||
| .invoke('text') | .invoke('text') | ||||
| .then(t => normalizeBalanceText(t)) | .then(t => normalizeBalanceText(t)) | ||||
| .should('eq', '$0.00'); | .should('eq', '$0.00'); | ||||
| }); | }); | ||||
| }); | }); | ||||