Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add liquidity test #1516

Draft
wants to merge 94 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
94 commits
Select commit Hold shift + click to select a range
6fec6b1
Updated synpress version
niemam29 Sep 12, 2022
99cf22c
Updated synpress version
niemam29 Sep 12, 2022
68098e8
Updated synpress version
niemam29 Sep 14, 2022
e1a7b78
Merge branch 'develop' into synpress-update
niemam29 Sep 14, 2022
0f0de60
Updated synpress version
niemam29 Sep 14, 2022
c36c75d
Merge remote-tracking branch 'origin/synpress-update' into synpress-u…
niemam29 Sep 14, 2022
e255958
Updated synpress version
niemam29 Sep 14, 2022
74f7cf8
Updated synpress version
niemam29 Sep 14, 2022
c4070eb
Updated synpress version
niemam29 Sep 14, 2022
cca89a2
Updated synpress version
niemam29 Sep 14, 2022
2992035
Updated synpress version
niemam29 Sep 14, 2022
5f67860
Updated synpress version
niemam29 Sep 14, 2022
5383e7f
Refactored a way of switching
niemam29 Sep 14, 2022
877b223
Refactored a way of switching
niemam29 Sep 15, 2022
676260e
add-liquidity-WIP
MilanVojnovic95 Sep 15, 2022
9936c35
add-liquidity-WIP
MilanVojnovic95 Sep 15, 2022
9463845
add-liquidity-WIP
MilanVojnovic95 Sep 15, 2022
24dca47
Refactored a way of switching
niemam29 Sep 15, 2022
8911399
Fixes for smoke tests
niemam29 Sep 16, 2022
a2d0215
Fixes for smoke tests
niemam29 Sep 16, 2022
ee501e2
Fixes for smoke tests
niemam29 Sep 16, 2022
493143e
Fixes for smoke tests
niemam29 Sep 16, 2022
eb85ecc
Fixes for smoke tests
niemam29 Sep 16, 2022
65e6b7d
Fixes for smoke tests
niemam29 Sep 16, 2022
4ec1427
Fixes for smoke tests
niemam29 Sep 16, 2022
bede8ef
Fixes for smoke tests
niemam29 Sep 16, 2022
7fd779d
Fixes for smoke tests
niemam29 Sep 16, 2022
be1f72a
Fixes for smoke tests
niemam29 Sep 16, 2022
170b594
Fixes for smoke tests
niemam29 Sep 16, 2022
731ffcb
Fixes for smoke tests
niemam29 Sep 16, 2022
a9373bb
Fixes for smoke tests
niemam29 Sep 16, 2022
3a84f1e
Fixes for smoke tests
niemam29 Sep 16, 2022
734edf5
Fixes for smoke tests
niemam29 Sep 16, 2022
efacf86
Fixes for smoke tests
niemam29 Sep 16, 2022
0048baa
Fixes for smoke tests
niemam29 Sep 16, 2022
be6f206
Fixes for smoke tests
niemam29 Sep 16, 2022
aea4622
Fixes for smoke tests
niemam29 Sep 16, 2022
af0d776
Fixes for smoke tests
niemam29 Sep 16, 2022
062dd2d
Fixes for smoke tests
niemam29 Sep 16, 2022
fa4f222
Fixes for smoke tests
niemam29 Sep 16, 2022
4b41f59
Fixes for smoke tests
niemam29 Sep 16, 2022
c8f74ee
Fixes for smoke tests
niemam29 Sep 16, 2022
48c3932
Fixes for smoke tests
niemam29 Sep 16, 2022
7867416
Fixes for smoke tests
niemam29 Sep 16, 2022
2f31405
Fixes for smoke tests
niemam29 Sep 16, 2022
b61c6c2
fixes
niemam29 Sep 16, 2022
54c4edd
Fixes for smoke tests
niemam29 Sep 16, 2022
eed1c16
Fixes for smoke tests
niemam29 Sep 19, 2022
8a34cbb
Fixes for smoke tests
niemam29 Sep 19, 2022
309ab7c
Fixes for smoke tests
niemam29 Sep 19, 2022
d1e9c4b
Merge remote-tracking branch 'origin/develop' into synpress-update
niemam29 Sep 19, 2022
b79df5d
Fixes for smoke tests
niemam29 Sep 19, 2022
18e2312
Fixes for smoke tests
niemam29 Sep 19, 2022
f11c7dc
Fixes for smoke tests
niemam29 Sep 19, 2022
2afc3c1
Fixes for smoke tests
niemam29 Sep 19, 2022
dacce68
Fixes for smoke tests
niemam29 Sep 19, 2022
bde48e0
Fixes for smoke tests
niemam29 Sep 19, 2022
796e18e
Fixes for smoke tests
niemam29 Sep 19, 2022
77ee59d
Fixes for smoke tests
niemam29 Sep 19, 2022
f1cc9cd
Fixes for smoke tests
niemam29 Sep 19, 2022
9046c16
Fixes for smoke tests
niemam29 Sep 19, 2022
d3756f2
Fixes for smoke tests
niemam29 Sep 19, 2022
b4ff879
Fixes for smoke tests
niemam29 Sep 19, 2022
975eadd
Fixes for smoke tests
niemam29 Sep 19, 2022
fe53d10
Fixes for smoke tests
niemam29 Sep 19, 2022
5fe49da
Fixes for smoke tests
niemam29 Sep 19, 2022
bf0aa4b
Fixes for smoke tests
niemam29 Sep 20, 2022
1bc874d
Merge remote-tracking branch 'origin/develop' into synpress-update
niemam29 Sep 20, 2022
f8b5dfc
Fixes for smoke tests
niemam29 Sep 20, 2022
b5e83ea
Fixes for smoke tests
niemam29 Sep 20, 2022
36c81c7
Fixes for smoke tests
niemam29 Sep 20, 2022
caee938
Fixes for smoke tests
niemam29 Sep 20, 2022
88465cf
Fixes for smoke tests
niemam29 Sep 20, 2022
40992fe
Fixes for smoke tests
niemam29 Sep 20, 2022
fcb79fa
Fixes for smoke tests
niemam29 Sep 20, 2022
bf4b9d9
Fixes for smoke tests
niemam29 Sep 20, 2022
23f464f
add-liquidity-WIP
MilanVojnovic95 Sep 21, 2022
617515b
Fixes for smoke tests
niemam29 Sep 21, 2022
64628a1
Fixes for smoke tests
niemam29 Sep 21, 2022
63f8d37
Fixes for smoke tests
niemam29 Sep 21, 2022
6bd35ab
Fixes for smoke tests
niemam29 Sep 21, 2022
c0cc18d
Fixes for smoke tests
niemam29 Sep 21, 2022
ed2b197
Fixes for smoke tests
niemam29 Sep 22, 2022
0660ec9
Fixes for smoke tests
niemam29 Sep 22, 2022
59ee3b9
Merge remote-tracking branch 'origin/develop' into synpress-update
niemam29 Sep 22, 2022
a2e70e5
Fixes for smoke tests
niemam29 Sep 22, 2022
7e8ac49
Fixes for smoke tests
niemam29 Sep 22, 2022
a29c2f2
Fixes for smoke tests
niemam29 Sep 22, 2022
9f5f49d
Fixes for smoke tests
niemam29 Sep 22, 2022
98a31c9
Fixes for smoke tests
niemam29 Sep 23, 2022
8d3a727
Merge branch 'develop' into synpress-update
niemam29 Sep 23, 2022
d86c900
Merge remote-tracking branch 'origin/synpress-update' into add-liquid…
niemam29 Sep 23, 2022
9b70ba1
add-liquidity-WIP
MilanVojnovic95 Sep 29, 2022
2b5c325
merge with develop
MilanVojnovic95 Oct 7, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added docker/videos-ci/CI-full-video.mp4
Binary file not shown.
8 changes: 4 additions & 4 deletions src/components/Pool/PairView/UserLiquidity/UserLiquidity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export function UserLiquidity({ pair }: UserLiquidityProps) {
<Box mr="6px">
<CurrencyLogo size="14px" currency={currency0} />
</Box>
<TextWithColor fontSize={['13px', '15px']}>
<TextWithColor fontSize={['13px', '15px']} data-testid="token-balance">
{token0Deposited ? token0Deposited.toSignificant(6) : '0'}
</TextWithColor>
</Flex>
Expand All @@ -91,23 +91,23 @@ export function UserLiquidity({ pair }: UserLiquidityProps) {
<Box mr="6px">
<CurrencyLogo size="14px" currency={currency1} />
</Box>
<TextWithColor fontSize={['13px', '15px']}>
<TextWithColor fontSize={['13px', '15px']} data-testid="token-balance">
{token1Deposited ? token1Deposited.toSignificant(6) : '0'}
</TextWithColor>
</Flex>
</ValueWithLabel>
</InfoGrid>
</Box>
<Flex flexDirection={['column', 'row']} alignItems="center">
<Box marginBottom={[3, 0]} width="100%">
<Box marginBottom={[3, 0]} width="100%" data-testid="add-liquidity-button">
<ButtonPurpleDim
as={Link}
to={currency0 && currency1 ? `/pools/add/${currencyId(currency0)}/${currencyId(currency1)}` : ''}
>
{t('addLiquidity')}
</ButtonPurpleDim>
</Box>
<Box marginLeft={[0, 3]} width="100%">
<Box marginLeft={[0, 3]} width="100%" data-testid="remove-liquidity-button">
<ButtonPurpleDim
disabled={token0Deposited?.equalTo('0')}
as={token0Deposited?.equalTo('0') ? ButtonPurpleDim : Link}
Expand Down
5 changes: 3 additions & 2 deletions tests/pages/LiquidityPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,12 @@ export class LiquidityPage {
return cy.get('[data-testid=user-pool-balance]')
}
static getFirstTokenBalance() {
return cy.get('[data-testid=first-token-balance]')
return cy.get('[data-testid=token-balance]').eq(0)
}
static getSecondTokenBalance() {
return cy.get('[data-testid=second-token-balance]')
return cy.get('[data-testid=token-balance]').eq(1)
}

static getUsersPoolShare() {
return cy.get('[data-testid=pool-share]')
}
Expand Down
116 changes: 116 additions & 0 deletions tests/synpress/specs/02transactionfull/liquidity/AddLiquidityTests.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
import { MenuBar } from '../../../../pages/MenuBar'
import { SwapPage } from '../../../../pages/SwapPage'
import { LiquidityPage } from '../../../../pages/LiquidityPage'
import { MetamaskNetworkHandler } from '../../../../utils/MetamaskNetworkHandler'

describe('Add liquidity', () => {
const TRANSACTION_VALUE: number = 0.000001
let firstTokenBefore: number
let secondTokenBefore: number
let firstTokenAfter: number
let secondTokenAfter: number
let firstTokenAddedAmount: number = TRANSACTION_VALUE
let secondTokenAddedAmount: number
let firstTokenBalance: number = 0
let secondTokenBalance: number = 0

before(() => {
MetamaskNetworkHandler.switchToNetworkIfNotConnected()
})
beforeEach(() => {
LiquidityPage.visitLiquidityPage()
MenuBar.connectWallet()
})
afterEach(() => {
cy.disconnectMetamaskWalletFromAllDapps()
cy.clearCookies()
cy.clearLocalStorage()
})
after(() => {
cy.disconnectMetamaskWalletFromAllDapps()
cy.resetMetamaskAccount()
cy.wait(500)
})

it('Should get balance of tokens from liquidity pool [TC-59]', () => {
MenuBar.getLiquidity().click()
LiquidityPage.getPairCards().contains('DXD').contains('WEENUS').click()
LiquidityPage.getFirstTokenBalance()
.invoke('text')
.should(res => {
expect(parseFloat(res)).be.greaterThan(0)
console.log('FIRST TOKEN BALANCE: ', res)
firstTokenBefore = parseFloat(res)
})
cy.wrap(null).then(() => {
console.log('FIRST TOKEN BALANCE: ', firstTokenBefore)
})
LiquidityPage.getSecondTokenBalance()
.invoke('text')
.should(res => {
expect(parseFloat(res)).be.greaterThan(0)
console.log('SECOND TOKEN BALANCE: ', res)
secondTokenBefore = parseFloat(res)
})
cy.wrap(null).then(() => {
console.log('SECOND TOKEN BALANCE: ', secondTokenBefore)
})
})
it('Should add tokens to liquidity pool [TC-59]', () => {
LiquidityPage.getAddLiquidityButton().click()
LiquidityPage.typeValueToFirstToken(TRANSACTION_VALUE.toFixed(9).toString())
console.log('FIST TOKEN ADDED AMOUNT', firstTokenAddedAmount)
LiquidityPage.getSecondTokenField()
.invoke('val')
.should(res => {
expect(parseFloat(res as string)).be.greaterThan(0)
console.log('SECOND TOKEN ADDED AMOUNT', res)
secondTokenAddedAmount = parseFloat(res as string)
firstTokenBalance = firstTokenBefore + firstTokenAddedAmount
console.log('FINAL FIRST TOKEN BALANCE', firstTokenBalance)
secondTokenBalance = secondTokenBefore + secondTokenAddedAmount
console.log('FINAL SECOND TOKEN BALANCE', secondTokenBalance)
})
LiquidityPage.getSupplyButton().click()
LiquidityPage.getConfirmSupplyButton().click()
cy.confirmMetamaskTransaction({})
LiquidityPage.getCloseTransactionSubmittedWindowButton().click()
MenuBar.checkToastMessage('Add')
})
it('Should check if tokens are added to liquidity pool [TC-59]', () => {
MenuBar.getLiquidity().click()
LiquidityPage.getPairCards().contains('DXD').contains('WEENUS').click()
LiquidityPage.getFirstTokenBalance()
.invoke('text')
.should(res => {
expect(parseFloat(res)).be.greaterThan(0)
console.log('FIRST TOKEN BALANCE AFTER: ', res)
firstTokenAfter = parseFloat(res)
})
cy.wrap(null).then(() => {
console.log('FIRST TOKEN BALANCE AFTER: ', firstTokenAfter)
})
LiquidityPage.getSecondTokenBalance()
.invoke('text')
.should(res => {
expect(parseFloat(res)).be.greaterThan(0)
console.log('SECOND TOKEN BALANCE AFTER: ', res)
secondTokenAfter = parseFloat(res)
})
cy.wrap(null).then(() => {
console.log('SECOND TOKEN BALANCE AFTER: ', secondTokenAfter)
if (firstTokenBalance.toFixed(3) === firstTokenAfter.toFixed(3)) {
console.log('SUM OF THE FIRST TOKEN BALANCE IS OK')
} else {
console.log('NOT GOOD SUM OF THE FIRST TOKEN BALANCE')
}
if (secondTokenBalance.toFixed(3) === secondTokenAfter.toFixed(3)) {
console.log('SUM OF THE SECOND TOKEN BALANCE IS OK')
} else {
console.log('NOT GOOD SUM OF THE SECOND TOKEN BALANCE')
}
expect(firstTokenBalance.toFixed(3)).to.be.eq(firstTokenAfter.toFixed(3))
expect(secondTokenBalance.toFixed(3)).to.be.eq(secondTokenAfter.toFixed(3))
})
})
})