2023-06-06 18:57:04 +03:00
|
|
|
import { getTestSelector } from '../../utils'
|
2023-07-07 00:01:13 +03:00
|
|
|
import { DISCONNECTED_WALLET_USER_STATE } from '../../utils/user-state'
|
2023-06-06 18:57:04 +03:00
|
|
|
|
2023-06-08 02:17:58 +03:00
|
|
|
describe('disconnect wallet', () => {
|
2023-08-02 08:13:19 +03:00
|
|
|
it('should clear state', () => {
|
|
|
|
cy.visit('/swap')
|
2023-06-06 18:57:04 +03: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-08 02:17:58 +03:00
|
|
|
cy.get(getTestSelector('wallet-disconnect')).contains('Disconnect')
|
|
|
|
cy.get(getTestSelector('wallet-disconnect')).click()
|
2023-06-06 18:57:04 +03:00
|
|
|
|
|
|
|
// Verify wallet has disconnected
|
|
|
|
cy.contains('Connect a wallet').should('exist')
|
|
|
|
cy.get(getTestSelector('navbar-connect-wallet')).contains('Connect')
|
|
|
|
cy.contains('Connect Wallet')
|
|
|
|
|
|
|
|
// Verify swap input is cleared
|
2023-07-28 23:45:58 +03:00
|
|
|
cy.get('#swap-currency-input .token-amount-input').should('have.value', '1')
|
2023-06-06 18:57:04 +03:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
describe('connect wallet', () => {
|
|
|
|
it('should load state', () => {
|
2023-08-02 08:13:19 +03:00
|
|
|
cy.visit('/swap', { userState: DISCONNECTED_WALLET_USER_STATE })
|
2023-06-06 18:57:04 +03: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:')
|
|
|
|
})
|
|
|
|
})
|