|
| 1 | +/* eslint-disable ui-testing/no-disabled-tests */ |
| 2 | +describe('Swap Tokens Tests', () => { |
| 3 | + it(`should connect with Agoric Chain on https;//wallet.agoric.app`, () => { |
| 4 | + cy.origin('https://wallet.agoric.app/', () => { |
| 5 | + cy.visit('/'); |
| 6 | + }); |
| 7 | + cy.acceptAccess().then(taskCompleted => { |
| 8 | + expect(taskCompleted).to.be.true; |
| 9 | + }); |
| 10 | + |
| 11 | + cy.origin('https://wallet.agoric.app/', () => { |
| 12 | + cy.visit('/wallet/'); |
| 13 | + |
| 14 | + cy.get('input.PrivateSwitchBase-input').click(); |
| 15 | + cy.contains('Proceed').click(); |
| 16 | + |
| 17 | + cy.get('button[aria-label="Settings"]').click(); |
| 18 | + |
| 19 | + cy.get('#demo-simple-select').click(); |
| 20 | + cy.get('li[data-value="local"]').click(); |
| 21 | + cy.contains('button', 'Connect').click(); |
| 22 | + }); |
| 23 | + |
| 24 | + cy.acceptAccess().then(taskCompleted => { |
| 25 | + expect(taskCompleted).to.be.true; |
| 26 | + }); |
| 27 | + }); |
| 28 | + |
| 29 | + it('should connect with wallet', () => { |
| 30 | + cy.visit('/'); |
| 31 | + |
| 32 | + // Switch to local network |
| 33 | + cy.get('button').contains('Agoric Mainnet').click(); |
| 34 | + cy.get('button').contains('Local Network').click(); |
| 35 | + |
| 36 | + // Click the connect button |
| 37 | + cy.get('button').contains('Connect Keplr').click(); |
| 38 | + cy.get('input[type="checkbox"]').click(); |
| 39 | + cy.get('button:enabled').contains('Proceed').click(); |
| 40 | + |
| 41 | + // Accept access and confirm |
| 42 | + cy.acceptAccess(); |
| 43 | + cy.get('button').contains('Keplr Connected').should('be.visible'); |
| 44 | + }); |
| 45 | + |
| 46 | + it('should swap tokens from IST to stable', () => { |
| 47 | + let ISTbalance; |
| 48 | + |
| 49 | + // Connect wallet |
| 50 | + cy.visit('/'); |
| 51 | + cy.get('button').contains('Connect Keplr').click(); |
| 52 | + |
| 53 | + cy.addNewTokensFound(); |
| 54 | + cy.getTokenAmount('IST').then(amount => (ISTbalance = amount)); |
| 55 | + |
| 56 | + // Select asset and swap positions |
| 57 | + cy.get('button').contains('Select asset').click(); |
| 58 | + cy.get('button').contains('USDC_axl').click(); |
| 59 | + cy.get('svg.transform.rotate-90').click(); |
| 60 | + |
| 61 | + // Swap 1 IST |
| 62 | + cy.get('input[type="number"]').first().type(1); |
| 63 | + cy.get('button').contains('Swap').click(); |
| 64 | + |
| 65 | + // Confirm transactions |
| 66 | + cy.confirmTransaction(); |
| 67 | + cy.get('div').contains('Swap Completed').should('be.visible'); |
| 68 | + |
| 69 | + cy.getTokenAmount('IST').then(amount => |
| 70 | + expect(amount).to.equal(ISTbalance - 1) |
| 71 | + ); |
| 72 | + }); |
| 73 | + |
| 74 | + it('should swap tokens from stable to IST', () => { |
| 75 | + let ISTbalance; |
| 76 | + |
| 77 | + // Connect wallet |
| 78 | + cy.visit('/'); |
| 79 | + cy.get('button').contains('Connect Keplr').click(); |
| 80 | + |
| 81 | + cy.getTokenAmount('IST').then(amount => (ISTbalance = amount)); |
| 82 | + |
| 83 | + // Select asset |
| 84 | + cy.get('button').contains('Select asset').click(); |
| 85 | + cy.get('button').contains('USDC_axl').click(); |
| 86 | + |
| 87 | + // Swap 1 USDC_axl |
| 88 | + cy.get('input[type="number"]').first().type(1); |
| 89 | + cy.get('button').contains('Swap').click(); |
| 90 | + |
| 91 | + // Confirm transactions |
| 92 | + cy.confirmTransaction(); |
| 93 | + cy.get('div').contains('Swap Completed').should('be.visible'); |
| 94 | + |
| 95 | + cy.getTokenAmount('IST').then(amount => |
| 96 | + expect(amount).to.equal(ISTbalance + 1) |
| 97 | + ); |
| 98 | + }); |
| 99 | +}); |
0 commit comments