diff --git a/cypress/e2e/pages/limit-order.po.cy.ts b/cypress/e2e/pages/limit-order.po.cy.ts index 9f69cdadc2..708437da71 100644 --- a/cypress/e2e/pages/limit-order.po.cy.ts +++ b/cypress/e2e/pages/limit-order.po.cy.ts @@ -22,6 +22,10 @@ export const LimitOder = { cy.getContent(LimitOrderLocators.dropdownTokenBuy, text) }, + setAmountIn(value: string) { + cy.get(LimitOrderLocators.txtTokenSellAmount).type(value) + }, + setSellingRate(text: string) { cy.get(LimitOrderLocators.txtSellingRate).click().type(text) }, @@ -30,5 +34,13 @@ export const LimitOder = { return cy.get(LimitOrderLocators.txtSellingRate).invoke('val').then(value => { return value }) + }, + + getBalanceIn(text: myCallbackType) { + cy.getContent(LimitOrderLocators.lblBalanceIn, text) + }, + + getInsufficientErrorMessage() { + return cy.get(LimitOrderLocators.lblErrorMessage) } } diff --git a/cypress/e2e/selectors/selectors.cy.ts b/cypress/e2e/selectors/selectors.cy.ts index 1d10220820..b36d6b9868 100644 --- a/cypress/e2e/selectors/selectors.cy.ts +++ b/cypress/e2e/selectors/selectors.cy.ts @@ -22,10 +22,13 @@ export const SwapPageLocators = { } export const LimitOrderLocators = { + txtTokenSellAmount: '[data-testid=limit-order-input-tokena] [data-testid=token-amount-input]', dropdownTokenSell: '[data-testid=limit-order-input-tokena] [data-testid=token-symbol-container]', dropdownTokenBuy: '[data-testid=limit-order-input-tokenb] [data-testid=token-symbol-container]', btnLimit: '[data-testid=limit-button]', - txtSellingRate: '[data-testid=input-selling-rate]' + txtSellingRate: '[data-testid=input-selling-rate]', + lblBalanceIn: '[data-testid=limit-order-input-tokena] [data-testid=balance]', + lblErrorMessage: '[data-testid=error-message]' } export const WalletLocators = { diff --git a/cypress/e2e/specs/limit-order.e2e.cy.ts b/cypress/e2e/specs/limit-order.e2e.cy.ts index 4f069997a8..5bd9d4e22c 100644 --- a/cypress/e2e/specs/limit-order.e2e.cy.ts +++ b/cypress/e2e/specs/limit-order.e2e.cy.ts @@ -8,7 +8,7 @@ const tokenSymbols = TOKEN_SYMBOLS[NETWORK] const tokenCatalog = new TokenCatalog(); -describe(`Token Catalog on ${NETWORK}`, { tags: TAG.regression }, () => { +describe(`Limit Order on ${NETWORK}`, { tags: TAG.regression }, () => { beforeEach(() => { SwapPage.open(DEFAULT_URL) SwapPage.goToLimitOrder() @@ -88,4 +88,13 @@ describe(`Token Catalog on ${NETWORK}`, { tags: TAG.regression }, () => { }) }) }) + + describe('Messages', () => { + it('Verify error message when insufficient balance', () => { + LimitOder.getBalanceIn((text) => { + LimitOder.setAmountIn(String(Number(text) + 1)) + LimitOder.getInsufficientErrorMessage().should('be.visible') + }) + }) + }) }) \ No newline at end of file diff --git a/cypress/e2e/specs/swap-page.e2e.cy.ts b/cypress/e2e/specs/swap-page.e2e.cy.ts index a35d65057c..a7b8136cb5 100644 --- a/cypress/e2e/specs/swap-page.e2e.cy.ts +++ b/cypress/e2e/specs/swap-page.e2e.cy.ts @@ -40,6 +40,7 @@ describe(`Token Catalog on ${NETWORK}`, { tags: TAG.regression }, () => { it('Should be removed tokenIn from favorite tokens list', () => { SwapPage.selectTokenIn().getFavoriteTokens((arr) => { tokenCatalog.removeFavoriteToken(arr[1]) + cy.wait(2000) tokenCatalog.getFavoriteTokens((list) => { expect(list).not.to.include.members([arr[1]]) }) @@ -56,6 +57,7 @@ describe(`Token Catalog on ${NETWORK}`, { tags: TAG.regression }, () => { it('Should be removed tokenOut from favorite tokens list', () => { SwapPage.selectTokenOut().getFavoriteTokens((arr) => { tokenCatalog.removeFavoriteToken(arr[2]) + cy.wait(2000) tokenCatalog.getFavoriteTokens((list) => { expect(list).not.to.include.members([arr[2]]) }) diff --git a/src/components/CurrencyInputPanel/index.tsx b/src/components/CurrencyInputPanel/index.tsx index c77b4d8be7..5fe958ce7c 100644 --- a/src/components/CurrencyInputPanel/index.tsx +++ b/src/components/CurrencyInputPanel/index.tsx @@ -307,7 +307,7 @@ export default function CurrencyInputPanel({ )} - + {customBalanceText || selectedCurrencyBalance?.toSignificant(10) || balanceRef.current || 0} @@ -319,6 +319,7 @@ export default function CurrencyInputPanel({ { onMouseEnter?: React.MouseEventHandler onMouseLeave?: React.MouseEventHandler children?: React.ReactNode + dataTestId?: string } export default function Tooltip({ @@ -45,6 +46,7 @@ export default function Tooltip({ onMouseEnter, onMouseLeave, show, + dataTestId, ...rest }: TooltipProps) { return ( @@ -57,6 +59,7 @@ export default function Tooltip({ size={size} onMouseEnter={onMouseEnter} onMouseLeave={onMouseLeave} + data-testid={dataTestId} > {text} diff --git a/src/components/swapv2/LimitOrder/LimitOrderForm.tsx b/src/components/swapv2/LimitOrder/LimitOrderForm.tsx index 35d7888231..c54c7426e5 100644 --- a/src/components/swapv2/LimitOrder/LimitOrderForm.tsx +++ b/src/components/swapv2/LimitOrder/LimitOrderForm.tsx @@ -661,7 +661,14 @@ const LimitOrderForm = forwardRef(function LimitOrd return ( <> - +