-
Notifications
You must be signed in to change notification settings - Fork 5.4k
test: fix swap test flake #4135
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| describe('Swap', () => { | ||
| beforeEach(() => { | ||
| cy.visit('/swap').get('#swap-currency-input .token-amount-input') | ||
| before(() => { | ||
| cy.visit('/swap') | ||
| }) | ||
|
|
||
| it('starts with ETH selected by default', () => { | ||
|
|
@@ -11,73 +11,43 @@ describe('Swap', () => { | |
| }) | ||
|
|
||
| it('can enter an amount into input', () => { | ||
| cy.get('#swap-currency-input .token-amount-input') | ||
| .clear() | ||
| .type('0.001', { delay: 200 }) | ||
| .should('have.value', '0.001') | ||
| cy.get('#swap-currency-input .token-amount-input').clear().type('0.001').should('have.value', '0.001') | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. in a separate pr i will move all these selectors to |
||
| }) | ||
|
|
||
| it('zero swap amount', () => { | ||
| cy.get('#swap-currency-input .token-amount-input').clear().type('0.0', { delay: 200 }).should('have.value', '0.0') | ||
| cy.get('#swap-currency-input .token-amount-input').clear().type('0.0').should('have.value', '0.0') | ||
| }) | ||
|
|
||
| it('invalid swap amount', () => { | ||
| cy.get('#swap-currency-input .token-amount-input').clear().type('\\', { delay: 200 }).should('have.value', '') | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this allows us to avoid the delays, which is not something tests should have |
||
| cy.get('#swap-currency-input .token-amount-input').clear().type('\\').should('have.value', '') | ||
| }) | ||
|
|
||
| it('can enter an amount into output', () => { | ||
| cy.get('#swap-currency-output .token-amount-input').type('0.001', { delay: 200 }).should('have.value', '0.001') | ||
| cy.get('#swap-currency-output .token-amount-input').clear().type('0.001').should('have.value', '0.001') | ||
| }) | ||
|
|
||
| it('zero output amount', () => { | ||
| cy.get('#swap-currency-output .token-amount-input').type('0.0', { delay: 200 }).should('have.value', '0.0') | ||
| cy.get('#swap-currency-output .token-amount-input').clear().type('0.0').should('have.value', '0.0') | ||
| }) | ||
|
|
||
| it.skip('can swap ETH for DAI', () => { | ||
| cy.get('#swap-currency-output .open-currency-select-button').click() | ||
| cy.get('.token-item-0xc7AD46e0b8a400Bb3C915120d284AafbA8fc4735').should('be.visible') | ||
| cy.get('.token-item-0xc7AD46e0b8a400Bb3C915120d284AafbA8fc4735').click({ force: true }) | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. also can skip all the force clicks which also should be avoided |
||
| cy.get('#swap-currency-input .token-amount-input').should('be.visible') | ||
| cy.get('#swap-currency-input .token-amount-input').type('0.001', { force: true, delay: 200 }) | ||
| cy.get('.token-item-0xc7AD46e0b8a400Bb3C915120d284AafbA8fc4735').click() | ||
| cy.get('#swap-currency-input .token-amount-input').clear().type('0.0000001') | ||
| cy.get('#swap-currency-output .token-amount-input').should('not.equal', '') | ||
| cy.get('#swap-button').click() | ||
| cy.get('#confirm-swap-or-send').should('contain', 'Confirm Swap') | ||
| cy.get('[data-cy="confirmation-close-icon"]').click() | ||
| }) | ||
|
|
||
| it.skip('add a recipient does not exist unless in expert mode', () => { | ||
| it('add a recipient does not exist unless in expert mode', () => { | ||
| cy.get('#add-recipient-button').should('not.exist') | ||
| }) | ||
|
|
||
| it('ETH to wETH is same value (wrapped swaps have no price impact)', () => { | ||
| it.skip('ETH to wETH is same value (wrapped swaps have no price impact)', () => { | ||
| cy.get('#swap-currency-output .open-currency-select-button').click() | ||
| cy.get('.token-item-0xc778417E063141139Fce010982780140Aa0cD5Ab').click({ force: true }) | ||
| cy.get('#swap-currency-input .token-amount-input').type('0.01', { force: true, delay: 100 }) | ||
| cy.get('.token-item-0xc778417E063141139Fce010982780140Aa0cD5Ab').click() | ||
| cy.get('#swap-currency-input .token-amount-input').clear().type('0.01') | ||
| cy.get('#swap-currency-output .token-amount-input').should('have.value', '0.01') | ||
| }) | ||
|
|
||
| describe('expert mode', () => { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. these don't seem to be on right now and the UI is different enough that i didn't wanna work on this. we can re-write these back later if needed |
||
| beforeEach(() => { | ||
| cy.window().then((win) => { | ||
| cy.stub(win, 'prompt').returns('confirm') | ||
| }) | ||
| cy.get('#open-settings-dialog-button').click() | ||
| cy.get('#toggle-expert-mode-button').click() | ||
| cy.get('#confirm-expert-mode').click() | ||
| }) | ||
|
|
||
| it.skip('add a recipient is visible', () => { | ||
| cy.get('#add-recipient-button').should('be.visible') | ||
| }) | ||
|
|
||
| it.skip('add a recipient', () => { | ||
| cy.get('#add-recipient-button').click() | ||
| cy.get('#recipient').should('exist') | ||
| }) | ||
|
|
||
| it.skip('remove recipient', () => { | ||
| cy.get('#add-recipient-button').click() | ||
| cy.get('#remove-recipient-button').click() | ||
| cy.get('#recipient').should('not.exist') | ||
| }) | ||
| }) | ||
| }) | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this was causing a reload of the page, breaking the cypress
.getby removing element from DOM