-
Notifications
You must be signed in to change notification settings - Fork 190
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #50 from QuickSwap/test/tcs
Test/tcs
- Loading branch information
Showing
27 changed files
with
1,326 additions
and
1,339 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
name: Unit Tests | ||
on: | ||
push: | ||
branches: | ||
- master | ||
pull_request: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
unit-tests: | ||
name: Unit tests | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up node | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: 16 | ||
registry-url: https://registry.npmjs.org | ||
|
||
- name: Get yarn cache directory path | ||
id: yarn-cache-dir-path | ||
run: echo "::set-output name=dir::$(yarn cache dir)" | ||
|
||
- uses: actions/cache@v2 | ||
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`) | ||
with: | ||
path: ${{ steps.yarn-cache-dir-path.outputs.dir }} | ||
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} | ||
restore-keys: | | ||
${{ runner.os }}-yarn- | ||
- name: Install dependencies | ||
run: yarn install --frozen-lockfile | ||
|
||
- name: Run unit tests | ||
run: yarn test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,3 +21,7 @@ | |
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
|
||
cypress/videos | ||
cypress/screenshots | ||
cypress/fixtures/example.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
describe('Add Liquidity', () => { | ||
it('loads the two correct tokens', () => { | ||
cy.visit('/pools?currency0=0x1BFD67037B42Cf73acF2047067bd4F2C47D9BfD6¤cy1=0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619') | ||
cy.get('#add-liquidity-input-tokena .token-symbol-container').should('contain.text', 'WBTC') | ||
cy.get('#add-liquidity-input-tokenb .token-symbol-container').should('contain.text', 'ETH') | ||
}) | ||
|
||
it('does not crash if ETH is duplicated', () => { | ||
cy.visit('/pools?currency0=0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619¤cy1=0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619') | ||
cy.get('#add-liquidity-input-tokena .token-symbol-container').should('not.contain.text', 'ETH') | ||
cy.get('#add-liquidity-input-tokenb .token-symbol-container').should('contain.text', 'ETH') | ||
}) | ||
|
||
it('token not in storage is loaded', () => { | ||
cy.visit('/pools?currency0=0x64aFDF9e28946419E325d801Fb3053d8B8FFdC23¤cy1=0x60bB3D364B765C497C8cE50AE0Ae3f0882c5bD05') | ||
cy.get('#add-liquidity-input-tokena .token-symbol-container').should('contain.text', 'MEEB') | ||
cy.get('#add-liquidity-input-tokenb .token-symbol-container').should('contain.text', 'IMX') | ||
}) | ||
|
||
it('single token can be selected', () => { | ||
cy.visit('/pools?currency0=0x1BFD67037B42Cf73acF2047067bd4F2C47D9BfD6') | ||
cy.get('#add-liquidity-input-tokena .token-symbol-container').should('contain.text', 'WBTC') | ||
cy.visit('/pools?currency0=0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619') | ||
cy.get('#add-liquidity-input-tokena .token-symbol-container').should('contain.text', 'ETH') | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { TEST_ADDRESS_NEVER_USE_SHORTENED } from '../support/commands' | ||
|
||
describe('Landing Page', () => { | ||
beforeEach(() => cy.visit('/')) | ||
it('loads landing page', () => { | ||
cy.get('#landing-page') | ||
}) | ||
|
||
|
||
it('allows navigation to pool', () => { | ||
cy.get('#pools-page-link').click() | ||
cy.url().should('include', '/pools') | ||
}) | ||
|
||
it('allows navigation to swap', () => { | ||
cy.get('#swap-page-link').click() | ||
cy.url().should('include', '/swap') | ||
}) | ||
|
||
it('allows navigation to farm', () => { | ||
cy.get('#farm-page-link').click() | ||
cy.url().should('include', '/farm') | ||
}) | ||
|
||
it('allows navigation to dragons lair', () => { | ||
cy.get('#dragons-page-link').click() | ||
cy.url().should('include', '/dragons') | ||
}) | ||
|
||
it('allows navigation to analytics', () => { | ||
cy.get('#analytics-page-link').click() | ||
cy.url().should('include', '/analytics') | ||
}) | ||
|
||
/**it('is connected', () => { | ||
cy.get('#web3-status-connected').click() | ||
cy.get('#web3-account-identifier-row').contains(TEST_ADDRESS_NEVER_USE_SHORTENED) | ||
})*/ | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
describe('Lists', () => { | ||
beforeEach(() => { | ||
cy.visit('/swap') | ||
}) | ||
|
||
it('defaults to uniswap list', () => { | ||
cy.get('#swap-currency-output .open-currency-select-button').click() | ||
cy.get('#currency-search-selected-list-name').should('contain', 'Uniswap') | ||
}) | ||
|
||
it('change list', () => { | ||
cy.get('#swap-currency-output .open-currency-select-button').click() | ||
cy.get('#currency-search-change-list-button').click() | ||
cy.get('#list-row-tokens-1inch-eth .select-button').click() | ||
cy.get('#currency-search-selected-list-name').should('contain', '1inch') | ||
cy.get('#currency-search-change-list-button').click() | ||
cy.get('#list-row-tokens-uniswap-eth .select-button').click() | ||
cy.get('#currency-search-selected-list-name').should('contain', 'Uniswap') | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
describe('Migrate V1 Liquidity', () => { | ||
describe('Remove V1 liquidity', () => { | ||
it('renders the correct page', () => { | ||
cy.visit('/remove/v1/0x93bB63aFe1E0180d0eF100D774B473034fd60C36') | ||
cy.get('#remove-v1-exchange').should('contain', 'MKR/ETH') | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
describe('Pool', () => { | ||
beforeEach(() => cy.visit('/pool')) | ||
it('add liquidity links to /add/ETH', () => { | ||
cy.get('#join-pool-button').click() | ||
cy.url().should('contain', '/add/ETH') | ||
}) | ||
|
||
it('import pool links to /import', () => { | ||
cy.get('#import-pool-link').click() | ||
cy.url().should('contain', '/find') | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
describe('Remove Liquidity', () => { | ||
it('redirects', () => { | ||
cy.visit('/remove/0xc778417E063141139Fce010982780140Aa0cD5Ab-0xF9bA5210F91D0474bd1e1DcDAeC4C58E359AaD85') | ||
cy.url().should( | ||
'contain', | ||
'/remove/0xc778417E063141139Fce010982780140Aa0cD5Ab/0xF9bA5210F91D0474bd1e1DcDAeC4C58E359AaD85' | ||
) | ||
}) | ||
|
||
it('eth remove', () => { | ||
cy.visit('/remove/ETH/0xF9bA5210F91D0474bd1e1DcDAeC4C58E359AaD85') | ||
cy.get('#remove-liquidity-tokena-symbol').should('contain.text', 'ETH') | ||
cy.get('#remove-liquidity-tokenb-symbol').should('contain.text', 'MKR') | ||
}) | ||
|
||
it('eth remove swap order', () => { | ||
cy.visit('/remove/0xF9bA5210F91D0474bd1e1DcDAeC4C58E359AaD85/ETH') | ||
cy.get('#remove-liquidity-tokena-symbol').should('contain.text', 'MKR') | ||
cy.get('#remove-liquidity-tokenb-symbol').should('contain.text', 'ETH') | ||
}) | ||
|
||
it('loads the two correct tokens', () => { | ||
cy.visit('/remove/0xc778417E063141139Fce010982780140Aa0cD5Ab-0xF9bA5210F91D0474bd1e1DcDAeC4C58E359AaD85') | ||
cy.get('#remove-liquidity-tokena-symbol').should('contain.text', 'WETH') | ||
cy.get('#remove-liquidity-tokenb-symbol').should('contain.text', 'MKR') | ||
}) | ||
|
||
it('does not crash if ETH is duplicated', () => { | ||
cy.visit('/remove/0xc778417E063141139Fce010982780140Aa0cD5Ab-0xc778417E063141139Fce010982780140Aa0cD5Ab') | ||
cy.get('#remove-liquidity-tokena-symbol').should('contain.text', 'WETH') | ||
cy.get('#remove-liquidity-tokenb-symbol').should('contain.text', 'WETH') | ||
}) | ||
|
||
it('token not in storage is loaded', () => { | ||
cy.visit('/remove/0xb290b2f9f8f108d03ff2af3ac5c8de6de31cdf6d-0xF9bA5210F91D0474bd1e1DcDAeC4C58E359AaD85') | ||
cy.get('#remove-liquidity-tokena-symbol').should('contain.text', 'SKL') | ||
cy.get('#remove-liquidity-tokenb-symbol').should('contain.text', 'MKR') | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
describe('Send', () => { | ||
it('should redirect', () => { | ||
cy.visit('/send') | ||
cy.url().should('include', '/swap') | ||
}) | ||
|
||
it('should redirect with url params', () => { | ||
cy.visit('/send?outputCurrency=ETH&recipient=bob.argent.xyz') | ||
cy.url().should('contain', '/swap?outputCurrency=ETH&recipient=bob.argent.xyz') | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
describe('Swap', () => { | ||
beforeEach(() => { | ||
cy.visit('/swap') | ||
}) | ||
it('can enter an amount into input', () => { | ||
cy.get('#swap-currency-input .token-amount-input') | ||
.type('0.001', { delay: 200 }) | ||
.should('have.value', '0.001') | ||
}) | ||
|
||
it('zero swap amount', () => { | ||
cy.get('#swap-currency-input .token-amount-input') | ||
.type('0.0', { delay: 200 }) | ||
.should('have.value', '0.0') | ||
}) | ||
|
||
it('invalid swap amount', () => { | ||
cy.get('#swap-currency-input .token-amount-input') | ||
.type('\\', { delay: 200 }) | ||
.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') | ||
}) | ||
|
||
it('zero output amount', () => { | ||
cy.get('#swap-currency-output .token-amount-input') | ||
.type('0.0', { delay: 200 }) | ||
.should('have.value', '0.0') | ||
}) | ||
|
||
it('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 }) | ||
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('#swap-currency-output .token-amount-input').should('not.equal', '') | ||
cy.get('#swap-button').click() | ||
cy.get('#confirm-swap-or-send').should('contain', 'Confirm Swap') | ||
}) | ||
|
||
it('add a recipient does not exist unless in expert mode', () => { | ||
cy.get('#add-recipient-button').should('not.exist') | ||
}) | ||
|
||
describe('expert mode', () => { | ||
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('add a recipient is visible', () => { | ||
cy.get('#add-recipient-button').should('be.visible') | ||
}) | ||
|
||
it('add a recipient', () => { | ||
cy.get('#add-recipient-button').click() | ||
cy.get('#recipient').should('exist') | ||
}) | ||
|
||
it('remove recipient', () => { | ||
cy.get('#add-recipient-button').click() | ||
cy.get('#remove-recipient-button').click() | ||
cy.get('#recipient').should('not.exist') | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
describe('Warning', () => { | ||
beforeEach(() => { | ||
cy.visit('/swap?outputCurrency=0x0a40f26d74274b7f22b28556a27b35d97ce08e0a') | ||
}) | ||
|
||
it('Check that warning is displayed', () => { | ||
cy.get('.token-warning-container').should('be.visible') | ||
}) | ||
|
||
it('Check that warning hides after button dismissal', () => { | ||
cy.get('.token-dismiss-button').should('be.disabled') | ||
cy.get('.understand-checkbox').click() | ||
cy.get('.token-dismiss-button').should('not.be.disabled') | ||
cy.get('.token-dismiss-button').click() | ||
cy.get('.token-warning-container').should('not.be.visible') | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
export const TEST_ADDRESS_NEVER_USE: string | ||
|
||
export const TEST_ADDRESS_NEVER_USE_SHORTENED: string | ||
|
||
// declare namespace Cypress { | ||
// // eslint-disable-next-line @typescript-eslint/class-name-casing | ||
// interface cy { | ||
// additionalCommands(): void | ||
// } | ||
// } |
Oops, something went wrong.