diff --git a/cypress.config.ts b/cypress.config.ts index 18b4866a..c86dfa17 100644 --- a/cypress.config.ts +++ b/cypress.config.ts @@ -10,6 +10,12 @@ export default defineConfig({ e2e: { baseUrl: 'http://localhost:3000', specPattern: 'cypress/{e2e,staging}/**/*.test.{ts,tsx}', + defaultCommandTimeout: 10000, // Sets the timeout for commands like cy.get() to 10 seconds + pageLoadTimeout: 60000, // Sets the timeout for cy.visit() to 60 seconds + retries: { + runMode: 4, // Retries failing tests 2 times in CI mode + openMode: 0 // No retries in interactive mode + }, }, component: { devServer: { diff --git a/cypress/e2e/flows.test.ts b/cypress/e2e/flows.test.ts index 9fa52637..05834980 100644 --- a/cypress/e2e/flows.test.ts +++ b/cypress/e2e/flows.test.ts @@ -112,12 +112,12 @@ describe('Select tokens & input amount', () => { cy.contains('Price Impact') cy.contains('Expected output') cy.contains('Path') - + cy.get('[data-testid="swap__details__priceImpact"]').as('priceImpact') cy.get('[data-testid="swap__details__expectedOutput"]').as('expectedOutput') cy.get('[data-testid="swap__details__path"]').as('path') cy.get('[data-testid="swap__details__platform"]').as('platform') - + cy.get('@priceImpact').should('exist') cy.get('@expectedOutput').should('exist') cy.get('@path').should('exist') @@ -153,41 +153,41 @@ describe('Input & output amount validation', () => { //Validate type in cy.get('@inputAmount').should('eq', '1'); - + cy.get('[data-testid="swap-output-input-panel"]').invoke('val') - .then((outputAmount: any) => { - //reselect input asset - cy.get('[data-testid="swap__input__panel"]').within(() => { - cy.get('[data-testid="swap__token__select"]').click(); - }); - cy.get('[data-testid="token-search-input"]').type('usdc'); - cy.get('[data-testid="currency__list__USDC"]').click(); - //Input amount - cy.get('[data-testid="swap__output__panel"]').within(() => { - cy.get('.token-amount-input').type('{backspace}'); - cy.get('.token-amount-input').type('{backspace}'); - cy.get('.token-amount-input').type('1'); - }); - cy.wait(2500); - cy.get('[data-testid="swap-input-input-panel"]').invoke('val').then((inputAmount: any)=>{ - const belowOutput = Math.floor(parseFloat(outputAmount) * 0.5); - const aboveOutput = Math.ceil(parseFloat(outputAmount) * 1.5); - expect(parseFloat(inputAmount)).within(belowOutput, aboveOutput) + .then((outputAmount: any) => { + //reselect input asset + cy.get('[data-testid="swap__input__panel"]').within(() => { + cy.get('[data-testid="swap__token__select"]').click(); + }); + cy.get('[data-testid="token-search-input"]').type('usdc'); + cy.get('[data-testid="currency__list__USDC"]').click(); + //Input amount + cy.get('[data-testid="swap__output__panel"]').within(() => { + cy.get('.token-amount-input').type('{backspace}'); + cy.get('.token-amount-input').type('{backspace}'); + cy.get('.token-amount-input').type('1'); + }); + cy.wait(2500); + cy.get('[data-testid="swap-input-input-panel"]').invoke('val').then((inputAmount: any) => { + const belowOutput = Math.floor(parseFloat(outputAmount) * 0.5); + const aboveOutput = Math.ceil(parseFloat(outputAmount) * 1.5); + expect(parseFloat(inputAmount)).within(belowOutput, aboveOutput) + }) }) - }) }) }); -describe('Slippage tolerance config', ()=>{ - it('should change slippage tolerance', ()=>{ +describe('Slippage tolerance config', () => { + it('should change slippage tolerance', () => { cy.visit('/swap'); cy.get('[data-testid="open-settings-dialog-button"]').click(); cy.get('[data-testid="max-slippage-settings"]').click(); cy.get('[data-testid="slippage-input"]').type('1.05'); cy.get('[data-testid="max-slippage-settings"]').contains('1.05%'); }) - it('Show display an alert if slippage is too high', ()=>{ + it('Show display an alert if slippage is too high', () => { cy.visit('/swap'); cy.get('[data-testid="open-settings-dialog-button"]').click(); cy.get('[data-testid="max-slippage-settings"]').click(); @@ -196,7 +196,7 @@ describe('Slippage tolerance config', ()=>{ cy.get('[data-testid="slippage-alert"]').should('exist'); cy.get('[data-testid="slippage-alert-too-high"]').should('exist'); }) - it('Show display an alert if slippage is too low', ()=>{ + it('Show display an alert if slippage is too low', () => { cy.visit('/swap'); cy.get('[data-testid="open-settings-dialog-button"]').click(); cy.get('[data-testid="max-slippage-settings"]').click(); @@ -205,7 +205,7 @@ describe('Slippage tolerance config', ()=>{ cy.get('[data-testid="slippage-alert"]').should('exist'); cy.get('[data-testid="slippage-alert-too-low"]').should('exist'); }) - it('should keep the slippage tolerance after closing the settings', ()=>{ + it('should keep the slippage tolerance after closing the settings', () => { cy.visit('/swap'); cy.get('[data-testid="open-settings-dialog-button"]').click(); cy.get('[data-testid="max-slippage-settings"]').click(); @@ -216,7 +216,7 @@ describe('Slippage tolerance config', ()=>{ cy.get('[data-testid="max-slippage-settings"]').should('exist') cy.get('[data-testid="max-slippage-settings"]').contains('1.05%'); }) - it('Should set the slippage tolerance to auto when pressing "auto" button', ()=>{ + it('Should set the slippage tolerance to auto when pressing "auto" button', () => { cy.visit('/swap'); cy.get('[data-testid="open-settings-dialog-button"]').click(); cy.get('[data-testid="max-slippage-settings"]').click(); @@ -236,41 +236,41 @@ describe('Navigation flow', () => { it('should navigate to balances', () => { cy.visit('/'); cy.get('[data-testid="navbar__container"]').click(); - cy.wait(1500); + // cy.wait(1500); cy.contains('Balance').click(); - cy.wait(3000); + // cy.wait(3000); cy.contains("Your token's balance:"); }); it('should navigate to swap', () => { cy.visit('/bridge'); cy.get('[data-testid="navbar__container"]').click(); - cy.wait(1500); + // cy.wait(1500); cy.contains('Swap').click(); - cy.wait(3000); + // cy.wait(3000); cy.contains('You sell'); }); it('should navigate to liquidity', () => { cy.visit('/'); cy.get('[data-testid="navbar__container"]').click(); - cy.wait(1500); + // cy.wait(1500); cy.contains('Liquidity').click(); - cy.wait(3000); + // cy.wait(3000); cy.contains('List of your liquidity positions'); }); it('should navigate to bridge', () => { cy.visit('/'); cy.get('[data-testid="navbar__container"]').click(); - cy.wait(1500); + // cy.wait(1500); cy.contains('Bridge').click(); - cy.wait(3000); + // cy.wait(3000); cy.contains('Disclaimer'); }); it('should navigate to info', () => { cy.visit('/'); cy.get('[data-testid="navbar__container"]').click(); - cy.wait(1500); + // cy.wait(1500); cy.contains('Info').click(); - cy.wait(3000); + // cy.wait(3000); cy.url().should('match', /https:\/\/info\.soroswap\.finance\//); }); });