Skip to content

Commit

Permalink
Merge pull request #284 from reflexer-labs/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
mstfash authored Dec 7, 2021
2 parents 7458b7d + 41334cc commit bd7f77d
Show file tree
Hide file tree
Showing 94 changed files with 4,546 additions and 1,927 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ To have the app default to a different network when a wallet is not connected:
### Cypress integration test

```bash
yarn cypress-test
yarn test:e2e
```

### Jest test
Expand Down
21 changes: 7 additions & 14 deletions cypress/integration/landing-no-proxy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,7 @@ describe('App Page - No Proxy', () => {
cy.get('[data-test-id="topup-manage"]').click()
cy.wait(15000)
cy.url().should('include', TEST_ADDRESS_NEVER_USE)
cy.contains('accounts')
cy.get('.safeBlock').first().contains('Manage Safe').click()
cy.get('.safeBlock').first().click()
cy.url().should('include', 'safes/')
})

Expand All @@ -117,8 +116,7 @@ describe('App Page - No Proxy', () => {
cy.get('[data-test-id="topup-manage"]').click()
cy.wait(15000)
cy.url().should('include', TEST_ADDRESS_NEVER_USE)
cy.contains('accounts')
cy.get('.safeBlock').first().contains('Manage Safe').click()
cy.get('.safeBlock').first().click()
cy.url().should('include', 'safes/')
cy.contains('CAUTION')
})
Expand All @@ -130,17 +128,15 @@ describe('App Page - No Proxy', () => {
cy.get('[data-test-id="topup-manage"]').click()
cy.wait(15000)
cy.url().should('include', TEST_ADDRESS_NEVER_USE)
cy.contains('accounts')
cy.get('.safeBlock').first().contains('Manage Safe').click()
cy.get('.safeBlock').first().click()
cy.url().should('include', 'safes/')
cy.contains('CAUTION')
cy.get('#deposit_borrow').click()
cy.get('#safe-header').contains('Safe Deposit & Borrow')
cy.wait(5000)
cy.get('[data-test-id="deposit_borrow_right"]').should('be.disabled')
cy.get('[data-test-id="deposit_borrow_left"]').type('0.001')
cy.contains('Cancel').click()
cy.contains('Back').click()
cy.get('#repay_withdraw').click()
cy.get('#safe-header').contains('Safe Repay & Withdraw')
cy.get('[data-test-id="repay_withdraw_left"]').should('be.disabled')
cy.get('[data-test-id="repay_withdraw_right"]').type('0.001')
})
Expand All @@ -152,15 +148,12 @@ describe('App Page - No Proxy', () => {
cy.get('[data-test-id="topup-manage"]').click()
cy.wait(15000)
cy.url().should('include', TEST_ADDRESS_NEVER_USE)
cy.contains('accounts')
cy.get('.safeBlock').first().contains('Manage Safe').click()
cy.get('.safeBlock').first().click()
cy.url().should('include', 'safes/')
cy.contains('CAUTION')
cy.get('#repay_withdraw').click()
cy.get('#safe-header').contains('Safe Repay & Withdraw')
cy.get('[data-test-id="repay_withdraw_left"]').should('be.disabled')
cy.get('[data-test-id="repay_withdraw_right"]').type('0.001')
cy.contains('Review Transaction').click()
cy.contains('You do not have a proxy address')
cy.contains('Create a Reflexer Account to continue')
})
})
20 changes: 8 additions & 12 deletions cypress/integration/landing-no-safes.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,18 @@ describe('App Page - No Safes', () => {
cy.get('#step2 > div').contains('Create a Safe')
cy.get('[data-test-id="steps-btn"]').contains('Create a Safe').click()
cy.wait(2000)
cy.get('#safe-header').contains('Create a Safe')
cy.url().should('include', 'create')
})

it('creates a new safe', () => {
cy.contains('✓ Accept').click()
cy.get('[data-test-id="steps-btn"]').contains('Create a Safe').click()
cy.wait(2000)
cy.get('#safe-header').contains('Create a Safe')
cy.get('[data-test-id="deposit_borrow_left"]').type('4')
cy.get('[data-test-id="deposit_borrow_right"]').type('1000')
cy.url().should('include', 'create')
cy.get('[data-test-id="deposit_borrow"]').type('4')
cy.get('[data-test-id="repay_withdraw"]').type('1000')
cy.contains('Review Transaction').click()
cy.contains('Confirm Transaction Details')
cy.get('#confirm_tx').click()
cy.get('#create_confirm').click()
cy.contains('Transaction Failed')
})

Expand All @@ -64,18 +63,15 @@ describe('App Page - No Safes', () => {
cy.get('#topup_input').type(TEST_ADDRESS_NEVER_USE)
cy.get('[data-test-id="topup-manage"]').click()
cy.url().should('include', TEST_ADDRESS_NEVER_USE)
cy.contains('accounts')
cy.wait(10000)
cy.get('.safeBlock').first().contains('Manage Safe').click()
cy.get('.safeBlock').first().click()
cy.url().should('include', 'safes/')
cy.contains('CAUTION')
cy.get('#repay_withdraw').click()
cy.get('#safe-header').contains('Safe Repay & Withdraw')
cy.url().should('include', 'withdraw')
cy.get('[data-test-id="repay_withdraw_left"]').should('be.disabled')
cy.get('[data-test-id="repay_withdraw_right"]').type('0.001')
cy.wait(10000)
cy.contains('Review Transaction').click()
cy.contains('RAI Allowance')
cy.contains('Unlock')
cy.contains('Unlock RAI')
})
})
1 change: 0 additions & 1 deletion cypress/integration/landing-safes.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ describe('App Page - Has Safes', () => {
cy.get($el).contains('RAI Borrowed')
cy.get($el).contains('Collateralization Ratio')
cy.get($el).contains('Liquidation Price')
cy.get($el).contains('Manage Safe')
})
})
})
112 changes: 5 additions & 107 deletions cypress/integration/safe-details.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ describe('App Page - Safe Details', () => {
}
})
cy.contains('✓ Accept').click()
cy.get('.safeBlock').first().contains('Manage Safe').click()
cy.get('.safeBlock').first().click()
cy.wait(2000)
cy.get('body').then((body) => {
if (body.find('[data-test-id="waiting-modal"]').length > 0) {
Expand All @@ -46,97 +46,6 @@ describe('App Page - Safe Details', () => {
cy.get('#web3-account-identifier-row').contains(shortenedAddress)
})

it('should show equal values between details and deposit & borrow modal', () => {
cy.get('#deposit_borrow').click()
cy.get('[data-test-id="details_col_ratio"]')
.invoke('text')
.then((tx) => {
expect(cy.get('[data-test-id="modal_col_ratio"]').contains(tx))
})
cy.get('[data-test-id="details_liq_price"]')
.invoke('text')
.then((tx) => {
expect(cy.get('[data-test-id="modal_liq_price"]').contains(tx))
})
cy.get('[data-test-id="details_liq_penalty"]')
.invoke('text')
.then((tx) => {
expect(
cy.get('[data-test-id="modal_liq_penalty"]').contains(tx)
)
})
cy.get('[data-test-id="details_eth_price"]')
.invoke('text')
.then((tx) => {
expect(cy.get('[data-test-id="modal_eth_price"]').contains(tx))
})
cy.get('[data-test-id="details_red_price"]')
.invoke('text')
.then((tx) => {
expect(cy.get('[data-test-id="modal_red_price"]').contains(tx))
})

cy.get('[data-test-id="details_collateral"]')
.invoke('text')
.then((tx) => {
const val = tx.split(' ')[0]
expect(
cy.get('[data-test-id="modal_collateral"]').contains(val)
)
})
cy.get('[data-test-id="details_debt"]')
.invoke('text')
.then((tx) => {
const val = tx.split(' ')[0]
expect(cy.get('[data-test-id="modal_debt"]').contains(val))
})
})

it('should show equal values between details and repay & withdraw modal', () => {
cy.get('#repay_withdraw').click()
cy.get('[data-test-id="details_col_ratio"]')
.invoke('text')
.then((tx) => {
expect(cy.get('[data-test-id="modal_col_ratio"]').contains(tx))
})
cy.get('[data-test-id="details_liq_price"]')
.invoke('text')
.then((tx) => {
expect(cy.get('[data-test-id="modal_liq_price"]').contains(tx))
})
cy.get('[data-test-id="details_liq_penalty"]')
.invoke('text')
.then((tx) => {
expect(
cy.get('[data-test-id="modal_liq_penalty"]').contains(tx)
)
})
cy.get('[data-test-id="details_eth_price"]')
.invoke('text')
.then((tx) => {
expect(cy.get('[data-test-id="modal_eth_price"]').contains(tx))
})
cy.get('[data-test-id="details_red_price"]')
.invoke('text')
.then((tx) => {
expect(cy.get('[data-test-id="modal_red_price"]').contains(tx))
})
cy.get('[data-test-id="details_collateral"]')
.invoke('text')
.then((tx) => {
const val = tx.split(' ')[0]
expect(
cy.get('[data-test-id="modal_collateral"]').contains(val)
)
})
cy.get('[data-test-id="details_debt"]')
.invoke('text')
.then((tx) => {
const val = tx.split(' ')[0]
expect(cy.get('[data-test-id="modal_debt"]').contains(val))
})
})

it('tries max borrow, and checks on CRatio and LiquidationPrice', () => {
cy.get('#deposit_borrow').click()
cy.get('[data-test-id="deposit_borrow_left_label"]')
Expand All @@ -153,67 +62,59 @@ describe('App Page - Safe Details', () => {
getValue(tx)
)
cy.wait(2000)
cy.get('[data-test-id="modal_col_ratio"]').contains('140.00%')
cy.contains('140.00%')
})
})

it('should show error if no amount to deposit or borrow', () => {
cy.get('#deposit_borrow').click()
cy.get('[data-test-id="deposit_borrow_left"]').type('0')
cy.get('[data-test-id="deposit_borrow_right"]').type('0')
cy.contains('Review Transaction').click()
cy.contains('Please enter the amount')
})

it('should show error if not enough Eth to deposit', () => {
cy.get('#deposit_borrow').click()
cy.get('[data-test-id="deposit_borrow_left"]').type('50')
cy.contains('Review Transaction').click()
cy.contains('Insufficient balance')
})

it('should show error if RAI exceeds available amount to borrow', () => {
cy.get('#deposit_borrow').click()
cy.get('[data-test-id="deposit_borrow_right"]').type('3000')
cy.contains('Review Transaction').click()
cy.contains('RAI borrowed cannot exceed available amount')
})

it('should show error if no amount to repay or withdraw', () => {
cy.get('#repay_withdraw').click()
cy.get('[data-test-id="repay_withdraw_left"]').type('0')
cy.get('[data-test-id="repay_withdraw_right"]').type('0')
cy.contains('Review Transaction').click()
cy.contains(
'Please enter the amount of ETH to free or the amount of RAI to be repay'
'Please enter the amount of ETH to free or the amount of RAI to repay'
)
})

it('should show error if amount to withdraw exeeds available amount', () => {
cy.get('#repay_withdraw').click()
cy.get('[data-test-id="repay_withdraw_left"]').type('1000')
cy.contains('Review Transaction').click()
cy.contains('ETH to unlock cannot exceed available amount')
})

it('should show error if amount to repay exeeds owed amount', () => {
cy.get('#repay_withdraw').click()
cy.get('[data-test-id="repay_withdraw_right"]').type('1000')
cy.contains('Review Transaction').click()
cy.contains('RAI to repay cannot exceed owed amount')
})

it('should show error if too much debt', () => {
cy.get('#repay_withdraw').click()
cy.get('[data-test-id="repay_withdraw_left"]').type('1.5')
cy.contains('Review Transaction').click()
cy.contains('Too much debt')
})

it('should show error if debt is greater than debt floor', () => {
cy.get('#repay_withdraw').click()
cy.get('[data-test-id="repay_withdraw_right"]').type('530')
cy.contains('Review Transaction').click()
cy.contains(`The resulting debt should be at least`)
})

Expand All @@ -222,15 +123,14 @@ describe('App Page - Safe Details', () => {
cy.get('[data-test-id="deposit_borrow_left"]').type('0.001')
cy.get('[data-test-id="deposit_borrow_right"]').type('0.001')
cy.contains('Review Transaction').click()
cy.contains('Confirm Transaction Details')
cy.get('#confirm_tx').click()
cy.get('[data-test-id="waiting-modal-title"]')
.should('be.visible')
.then((e) =>
cy.waitUntil(
() => Cypress.$(e).text() === 'Transaction Submitted',
{
timeout: 100000,
timeout: 1000000,
interval: 2000,
}
)
Expand All @@ -246,16 +146,14 @@ describe('App Page - Safe Details', () => {
cy.get('[data-test-id="repay_withdraw_left"]').type('0.001')
cy.get('[data-test-id="repay_withdraw_right"]').type('0.001')
cy.contains('Review Transaction').click()
cy.contains('Confirm Transaction Details')
cy.get('#confirm_tx').click()

cy.get('[data-test-id="waiting-modal-title"]')
.should('be.visible')
.then((e) =>
cy.waitUntil(
() => Cypress.$(e).text() === 'Transaction Submitted',
{
timeout: 100000,
timeout: 1000000,
interval: 2000,
}
)
Expand Down
2 changes: 2 additions & 0 deletions cypress/support/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@ const returnWallet = (type: string) => {
}

Cypress.Commands.overwrite('visit', (original, url, options) => {
console.log(options)

const { privateKey, walletAddress, allowTx } = returnWallet(
options && options.qs ? options.qs.type : ''
)
Expand Down
8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"dayjs": "^1.9.4",
"easy-peasy": "^3.3.1",
"ethers": "^5.0.14",
"geb.js": "^1.1.20",
"geb.js": "^1.1.26",
"i18next": "^19.7.0",
"jazzicon": "^1.5.0",
"jdenticon": "^3.0.1",
Expand All @@ -43,6 +43,7 @@
"react-feather": "^2.0.9",
"react-helmet-async": "^1.0.7",
"react-i18next": "^11.7.2",
"react-lottie-player": "^1.4.1",
"react-paginate": "^6.5.0",
"react-router-dom": "^5.2.0",
"react-scripts": "3.4.3",
Expand All @@ -58,7 +59,7 @@
"build": "react-scripts build",
"prettier": "prettier --write \"{,**/*.{ts,tsx,json,js,md}}\"",
"test": "react-scripts test",
"cypress-test": "start-server-and-test start http://localhost:3000 'cypress run'",
"test:e2e": "start-server-and-test 'serve build -l 3000' http://localhost:3000 'cypress run'",
"eject": "react-scripts eject"
},
"eslintConfig": {
Expand Down Expand Up @@ -95,7 +96,8 @@
"husky": "^5.0.9",
"lint-staged": "^10.5.4",
"prettier": "^2.2.1",
"start-server-and-test": "^1.12.0"
"serve": "^11.3.2",
"start-server-and-test": "^1.11.0"
},
"husky": {
"hooks": {
Expand Down
Loading

0 comments on commit bd7f77d

Please sign in to comment.