2023-06-06 08:57:04 -07:00
|
|
|
import { getTestSelector } from '../../utils'
|
2023-07-06 14:01:13 -07:00
|
|
|
import { DISCONNECTED_WALLET_USER_STATE } from '../../utils/user-state'
|
2023-06-06 08:57:04 -07:00
|
|
|
|
2023-06-07 13:17:58 -10:00
|
|
|
describe('disconnect wallet', () => {
|
2023-08-01 22:13:19 -07:00
|
|
|
it('should clear state', () => {
|
|
|
|
cy.visit('/swap')
|
2023-06-06 08:57:04 -07:00
|
|
|
cy.get('#swap-currency-input .token-amount-input').clear().type('1')
|
|
|
|
|
|
|
|
// Verify wallet is connected
|
|
|
|
cy.hardhat().then((hardhat) => cy.contains(hardhat.wallet.address.substring(0, 6)))
|
|
|
|
cy.contains('Balance:')
|
|
|
|
|
|
|
|
// Disconnect the wallet
|
|
|
|
cy.hardhat().then((hardhat) => cy.contains(hardhat.wallet.address.substring(0, 6)).click())
|
|
|
|
cy.get(getTestSelector('wallet-disconnect')).click()
|
2023-06-07 13:17:58 -10:00
|
|
|
cy.get(getTestSelector('wallet-disconnect')).contains('Disconnect')
|
|
|
|
cy.get(getTestSelector('wallet-disconnect')).click()
|
2023-06-06 08:57:04 -07:00
|
|
|
|
|
|
|
// Verify wallet has disconnected
|
|
|
|
cy.contains('Connect a wallet').should('exist')
|
|
|
|
cy.get(getTestSelector('navbar-connect-wallet')).contains('Connect')
|
2023-09-27 12:46:09 -04:00
|
|
|
cy.contains('Connect wallet')
|
2023-06-06 08:57:04 -07:00
|
|
|
|
|
|
|
// Verify swap input is cleared
|
2023-07-28 16:45:58 -04:00
|
|
|
cy.get('#swap-currency-input .token-amount-input').should('have.value', '1')
|
2023-06-06 08:57:04 -07:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
describe('connect wallet', () => {
|
|
|
|
it('should load state', () => {
|
2023-08-01 22:13:19 -07:00
|
|
|
cy.visit('/swap', { userState: DISCONNECTED_WALLET_USER_STATE })
|
2023-06-06 08:57:04 -07:00
|
|
|
|
|
|
|
// Connect the wallet
|
|
|
|
cy.get(getTestSelector('navbar-connect-wallet')).contains('Connect').click()
|
|
|
|
cy.contains('MetaMask').click()
|
|
|
|
|
|
|
|
// Verify wallet is connected
|
|
|
|
cy.hardhat().then((hardhat) => cy.contains(hardhat.wallet.address.substring(0, 6)))
|
|
|
|
cy.contains('Balance:')
|
|
|
|
})
|
|
|
|
})
|