From c27e70b87cc3bd0b77c980d0d6ab38ee5da32273 Mon Sep 17 00:00:00 2001 From: Jack Short Date: Wed, 8 Nov 2023 13:11:41 -0500 Subject: [PATCH] chore: e2e insufficient liquidity test (#7075) * chore: e2e insufficient liquidity test * Update cypress/e2e/swap/errors.test.ts Co-authored-by: Zach Pomerantz * fixing lint * waiting for quote * stubbing insufficient liquidity response * req reply * trying full url * maybe cors * moving before visit * adding back timeout * Revert "adding back timeout" This reverts commit 89cff3afb815f5e5db005347f20812b83e047057. * in describe block * moving to new file * moving to errors test file * moving comment * removing extra describe --------- Co-authored-by: Zach Pomerantz --- cypress/e2e/swap/errors.test.ts | 13 +++++++++++++ cypress/fixtures/insufficientLiquidity.json | 5 +++++ 2 files changed, 18 insertions(+) create mode 100644 cypress/fixtures/insufficientLiquidity.json diff --git a/cypress/e2e/swap/errors.test.ts b/cypress/e2e/swap/errors.test.ts index cdb6f04cd5..da28dc2c7a 100644 --- a/cypress/e2e/swap/errors.test.ts +++ b/cypress/e2e/swap/errors.test.ts @@ -116,4 +116,17 @@ describe('Swap errors', () => { getBalance(DAI).should('be.closeTo', initialBalance + 200, 1) }) }) + + it('no liquidity', () => { + // The API response is too variable so stubbing a 404. + cy.intercept('POST', 'https://api.uniswap.org/v2/quote', { + statusCode: 404, + fixture: 'insufficientLiquidity.json', + }) + + cy.visit(`/swap?inputCurrency=${USDC_MAINNET.address}&outputCurrency=${DAI.address}`) + cy.get('#swap-currency-output .token-amount-input').type('100000000000000').should('have.value', '100000000000000') // 100 trillion + cy.contains('Insufficient liquidity for this trade.') + cy.get('#swap-button').should('not.exist') + }) }) diff --git a/cypress/fixtures/insufficientLiquidity.json b/cypress/fixtures/insufficientLiquidity.json new file mode 100644 index 0000000000..ff36da9d06 --- /dev/null +++ b/cypress/fixtures/insufficientLiquidity.json @@ -0,0 +1,5 @@ +{ + "errorCode": "QUOTE_ERROR", + "detail": "No quotes available", + "id": "63363cc1-d474-4584-b386-7c356814b79f" +} \ No newline at end of file