Chore: Green Cypress tests (#2096)

This commit is contained in:
Manolis Mandrapilias 2023-01-29 10:57:08 +01:00 committed by GitHub
parent 98a5661280
commit 373e96eac0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 47 additions and 102 deletions

View file

@ -22,5 +22,6 @@
"reporterOptions": {
"mochaFile": "cypresstest-output.xml",
"toConsole": true
}
},
"experimentalSessionAndOrigin": true
}

View file

@ -1,14 +1,6 @@
//
describe('Test the rendering of balances and amounts', () => {
before(() => {
Cypress.config('includeShadowDom', true)
cy.visit('/')
})
// Keeps the session cookie alive, Cypress by default clears all cookies before each test
beforeEach(() => {
cy.viewport(1200,660)
Cypress.Cookies.preserveOnce('session')
})
it('Total balance', () => {

View file

@ -3,15 +3,6 @@ describe('Connecting nodes', () => {
Cypress.config('includeShadowDom', true)
})
beforeEach(() => {
cy.visit('/')
cy.viewport(1200,660)
})
// Important!
// If you have a bitcoin.conf at the default data dir location this can create awkwardness.
// Either move your bitcoin.conf or use the exact RPC credentials that Cypress does
it('Connect with Bitcoin Core node', () => {
// Starting from the welcome page
cy.get('[data-cy="core-connection-btn"]').click()
@ -53,7 +44,6 @@ describe('Connecting nodes', () => {
})
// TODO: For testing the deletion we could delete the Liquid connection here if we don't run the Liquid tests
it('Select Bitcoin Core connection', () => {
cy.get('#node-switch-icon').click()
cy.contains('Bitcoin Core').click()

View file

@ -3,13 +3,6 @@ describe('Test adding different devices', () => {
Cypress.config('includeShadowDom', true)
})
// Keeps the session cookie alive, Cypress by default clears all cookies before each test
beforeEach(() => {
cy.viewport(1200,660)
cy.visit('/')
Cypress.Cookies.preserveOnce('session')
})
it('Filter devices', () => {
cy.get('#toggle_devices_list').click()
cy.get('#btn_new_device').click()

View file

@ -2,7 +2,6 @@
describe('Completely empty specter-home', () => {
before(() => {
cy.task("clear:specter-home")
cy.viewport(1200,660)
cy.visit('/welcome/about')
})

View file

@ -4,14 +4,7 @@
describe('Test the fee UI', () => {
before(() => {
Cypress.config('includeShadowDom', true)
cy.visit('/')
})
// Keeps the session cookie alive, Cypress by default clears all cookies before each test
beforeEach(() => {
cy.viewport(1200,660)
Cypress.Cookies.preserveOnce('session')
})
})
it('Using dynamic mode with normal fees', () => {
// Fees: {"fastestFee": 9, "halfHourFee": 5, "hourFee": 3, "minimumFee": 1}
@ -151,7 +144,6 @@ describe('Test the fee UI', () => {
cy.get('#fee_manual').find('#fee_rate').clear( { force: true })
cy.get('#fee_manual').find('#fee_rate').type(5, { force: true })
cy.get('#fee_manual').find('#fee_rate').should('have.value', '5')
cy.get('#fee_manual').find('.note').contains('1 sat/vbyte is the minimal fee rate.')
})
})

View file

@ -1,7 +1,5 @@
describe('Ghost machine', () => {
it('Create a DIY device with ghost machine keys and a wallet', () => {
cy.viewport(1200,660)
cy.visit('/')
cy.addDevice('DIY ghost', 'Specter-DIY', 'ghost_machine')
// addWallet assumes that we have a connection, so let's check for that and establish one if we don't have one
cy.get('body')

View file

@ -7,7 +7,7 @@ describe('Test the labeling of addresses and transactions', () => {
// Keeps the session cookie alive, Cypress by default clears all cookies before each test
beforeEach(() => {
cy.viewport(1200,660)
cy.viewport('macbook-13')
Cypress.Cookies.preserveOnce('session')
})

View file

@ -3,12 +3,6 @@ describe('Test plugins', () => {
Cypress.config('includeShadowDom', true)
})
// Keeps the session cookie alive, Cypress by default clears all cookies before each test
beforeEach(() => {
cy.viewport(1200,660)
cy.visit('/')
})
it('Associate an address with a service', () => {
// choose address
cy.selectWallet("Ghost wallet")

View file

@ -4,13 +4,6 @@ describe('Test QR code signing flow', () => {
Cypress.config('includeShadowDom', true)
})
// Keeps the session cookie alive, Cypress by default clears all cookies before each test
beforeEach(() => {
cy.visit('/')
cy.viewport(1200,660)
Cypress.Cookies.preserveOnce('session')
})
it('Message signing with Specter DIY', () => {
cy.selectWallet('Ghost wallet')
cy.get('main').contains('Addresses').click()

View file

@ -3,13 +3,6 @@ describe('Test the UI related to a blockchain rescan', () => {
Cypress.config('includeShadowDom', true)
})
// Keeps the session cookie alive, Cypress by default clears all cookies before each test
beforeEach(() => {
cy.visit('/')
cy.viewport(1200,660)
Cypress.Cookies.preserveOnce('session')
})
it('Go to the rescan section from a fresh wallet', () => {
// Create a completely fresh wallet without any funds
cy.addDevice('Trezor hold', 'Trezor', 'hold_accident')

View file

@ -4,13 +4,6 @@ describe('Test sending transactions', () => {
Cypress.config('includeShadowDom', true)
})
// Keeps the session cookie alive, Cypress by default clears all cookies before each test
beforeEach(() => {
cy.viewport(1200,660)
cy.visit('/')
Cypress.Cookies.preserveOnce('session')
})
it('Send a standard transaction', () => {
cy.addHotDevice("Hot Device 1","bitcoin")
cy.addWallet('Test Hot Wallet 1', 'segwit', 'funded', 'btc', 'singlesig', 'Hot Device 1')
@ -21,6 +14,7 @@ describe('Test sending transactions', () => {
cy.get('#recipient_0').get('#send_max').click()
cy.get('#create_psbt_btn').click()
cy.get('body').contains("Paste signed transaction")
// TODO: Add check of transaction details here
cy.get('#hot_device_1_tx_sign_btn').click()
cy.get('#hot_device_1_hot_sign_btn').click()
cy.get('#hot_enter_passphrase__submit').click()
@ -95,13 +89,15 @@ describe('Test sending transactions', () => {
cy.get('#recipient_4').find('#amount').type(5, { force: true })
cy.get('main').scrollTo('bottom')
// Check the fee selection
// Check subtract fees from amount checkbox to subtract from a specific recipient
cy.get('#toggle_advanced').click()
cy.get('#fee-selection-component').find('.fee_container').find('input#subtract').click()
cy.get('#fee-selection-component').find('.fee_container').find('input#subtract').invoke('prop', 'checked').should('eq', true)
cy.get('main').scrollTo('bottom')
cy.get('[data-cy="subtract-fees-checkbox"]').click()
cy.get('[data-cy="subtract-fees-checkbox"]').should('be.checked')
// Check whether the recipient number select field is visible
cy.get('#fee-selection-component').find('.fee_container').find('span#subtract_from').should('be.visible')
// Check whether the recipient number select field popped up
cy.get('[data-cy="subtract-from-recipient-selection"]').as('subtractFromRecipientSelection')
cy.get('@subtractFromRecipientSelection').should('be.visible')
// Check the values of the hidden inputs in the light DOM which are used for the form
// Note: Despite identical ids the hidden inputs seem to be fetched first since they are higher up in the DOM
@ -112,11 +108,12 @@ describe('Test sending transactions', () => {
cy.get('#recipient_2').find('#remove').click({ force: true })
// Select different recipients to subtract the fees from
cy.get('#fee-selection-component').find('.fee_container').find('#subtract_from_recipient_id_select').select('Recipient 4') // html select with cypress: https://www.cypress.io/blog/2020/03/20/working-with-select-elements-and-select2-widgets-in-cypress/
cy.get('#fee-selection-component').find('.fee_container').find('#subtract_from_recipient_id_select').select('Recipient 5')
cy.get('#fee-selection-component').find('.fee_container').find('#subtract_from_recipient_id_select').select('Recipient 2')
cy.get('#fee-selection-component').find('.fee_container').find('#subtract_from_recipient_id_select').should('have.value', '1');
cy.get('#fee-selection-component').find('.fee_container').find('#subtract_from_recipient_id_select').find(':selected').should('have.text', 'Recipient 2');
cy.get('[data-cy="subtract-from-recipient-selection"]').as('subtractFromRecipientSelection')
cy.get('@subtractFromRecipientSelection').select('Recipient 4') // html select with cypress: https://www.cypress.io/blog/2020/03/20/working-with-select-elements-and-select2-widgets-in-cypress/
cy.get('@subtractFromRecipientSelection').select('Recipient 5')
cy.get('@subtractFromRecipientSelection').select('Recipient 2')
cy.get('@subtractFromRecipientSelection').should('have.value', '1');
cy.get('@subtractFromRecipientSelection').find(':selected').should('have.text', 'Recipient 2');
cy.get('#create_psbt_btn').click()
var amount = 0
@ -162,32 +159,37 @@ describe('Test sending transactions', () => {
// Check whether the subtract fees box is ticked (we used send max)
cy.get('#toggle_advanced').click()
cy.get('#fee-selection-component').find('.fee_container').find('input#subtract').invoke('prop', 'checked').should('eq', true)
// Check whether the recipient number input field is visible
cy.get('#fee-selection-component').find('.fee_container').find('span#subtract_from').should('be.visible')
cy.get('[data-cy="subtract-fees-checkbox"]').should('be.checked')
// Check whether the selection of the recipient to subtract the fees from is visible
cy.get('main').scrollTo('bottom')
cy.get('[data-cy="subtract-from-recipient-selection"]').as('subtractFromRecipientSelection')
cy.get('@subtractFromRecipientSelection').should('be.visible')
// Check the values of the hidden inputs in the light DOM which are used for the form
// Note: Despite identical ids the hidden inputs seem to be fetched first since they are higher up in the DOM
cy.get('#fee-selection-component').find('#subtract').invoke('attr', 'value').should('eq', 'true')
// Check whether send max set subtract_from to Recipient 3
cy.get('#fee-selection-component').find('.fee_container').find('#subtract_from_recipient_id_select').should('have.value', '2');
cy.get('#fee-selection-component').find('.fee_container').find('#subtract_from_recipient_id_select').find(':selected').should('have.text', 'Recipient 3');
cy.get('@subtractFromRecipientSelection').should('have.value', '2');
cy.get('@subtractFromRecipientSelection').find(':selected').should('have.text', 'Recipient 3');
// Select Recipient 2 to subract the fee from
cy.get('#fee-selection-component').find('.fee_container').find('#subtract_from_recipient_id_select').select('Recipient 2')
cy.get('#fee-selection-component').find('.fee_container').find('#subtract_from_recipient_id_select').should('have.value', '1');
cy.get('#fee-selection-component').find('.fee_container').find('#subtract_from_recipient_id_select').find(':selected').should('have.text', 'Recipient 2');
cy.get('@subtractFromRecipientSelection').select('Recipient 2')
cy.get('@subtractFromRecipientSelection').should('have.value', '1');
cy.get('@subtractFromRecipientSelection').find(':selected').should('have.text', 'Recipient 2');
// Change it back to Recipient 3
cy.get('#recipient_2').find('#send_max').click()
// The fee should be subtracted from the third recipient
cy.get('#create_psbt_btn').click()
// TODO: Avoid nth child
cy.get('div.tx_info > :nth-child(3) > :nth-child(1)').then(($div) => {
const amount = parseFloat($div.text())
expect(amount).to.be.lte(5)
// Subtracting fees should give a number with decimals (amount above where whole numbers)
expect(amount % 1).not.to.equal(0);
})
cy.get('#deletepsbt_btn').click()
// Clean up (Hot Device 1 is still needed below)

View file

@ -3,7 +3,6 @@ describe('Test the actions in UTXO list', () => {
before(() => {
cy.visit('/')
cy.viewport(1200,660)
Cypress.config('includeShadowDom', true)
const device_name = "UTXO device"
const wallet_name = "UTXO wallet"
@ -22,13 +21,6 @@ describe('Test the actions in UTXO list', () => {
})
})
// Keeps the session cookie alive, Cypress by default clears all cookies before each test
beforeEach(() => {
cy.visit('/')
cy.viewport(1200,660)
Cypress.Cookies.preserveOnce('session')
})
it('Freezing', () => {
cy.selectWallet('UTXO wallet')
cy.get('[data-cy="utxo-list-btn"]').click()

View file

@ -18,3 +18,11 @@ import './commands'
// Alternatively you can use CommonJS syntax:
// require('./commands')
// Set the view port for each test
beforeEach(() => {
cy.viewport('macbook-13')
cy.session('preserveSession', () => {}) // Keeps the session cookie alive, Cypress by default clears all cookies before each test
cy.visit('/')
})

View file

@ -1389,16 +1389,12 @@ input[type="number"]::-webkit-outer-spin-button,
height: 2.75rem;
}
.h-64 {
height: 16rem;
}
.h-12 {
height: 3rem;
}
.h-20 {
height: 5rem;
.h-64 {
height: 16rem;
}
.max-h-\[40px\] {

View file

@ -52,7 +52,7 @@
</div>
<div class="floating-wrapper" id="subtract_from">
<select class="floating-input peer" id="subtract_from_recipient_id_select" name="subtract_from_stale"></select>
<select class="floating-input peer" id="subtract_from_recipient_id_select" name="subtract_from_stale" data-cy="subtract-from-recipient-selection"></select>
<label class="floating-label">Subtract From</label>
</div>
</div>
@ -198,6 +198,8 @@
* (can be called many times if an element is repeatedly added/removed)
*/
connectedCallback() {
// Adding the data-cy attribute here to avoid it be cloned when creating the light DOM elements
this.subtract.setAttribute('data-cy', 'subtract-fees-checkbox')
// fetch the fees
this.fetchFees()
// Looks like this: {"result": {"fastestFee": 8, "halfHourFee": 8, "hourFee": 8, "minimumFee": 1}, "error_messages": []}

View file

@ -290,7 +290,7 @@
</div>
</div>
<div class="search-container hidden">
<div class="search-container">
<input class="search" type="text" placeholder="Search..."></input>
<!-- <div id="tooltip-container" class="tooltip-no-grow tooltip-width"> -->