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

WIP Swap/Bridge negative test (reject transaction) #1076

Closed
wants to merge 48 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
ee6c419
Added tests for switching networks and more swapping (#896)
niemam29 Apr 20, 2022
88cb2e6
Tests for creating a campaign (#929)
niemam29 Apr 28, 2022
2980e83
Merge branch 'develop' into automation-tests
niemam29 Apr 28, 2022
aaca50b
Small fixes along with name changes, added possibility to add cypress…
niemam29 Apr 29, 2022
80ed28e
Fix for opening reward card
niemam29 May 5, 2022
027502c
Merge branch 'develop' into automation-tests
niemam29 May 5, 2022
dc1b183
Fix for opening reward card
niemam29 May 5, 2022
b5171ea
Merge remote-tracking branch 'origin/automation-tests' into automatio…
niemam29 May 5, 2022
0348275
Fixes from cr
niemam29 May 5, 2022
51aaab5
Fixes from cr
niemam29 May 5, 2022
981d71b
Fixes from cr
niemam29 May 6, 2022
0e449a0
Fixes from cr
niemam29 May 6, 2022
d53f411
Fixes from cr
niemam29 May 9, 2022
bdf451b
Fixes from cr
niemam29 May 10, 2022
a77dd96
Fixes from cr
niemam29 May 10, 2022
61c0fdc
Merge branch 'develop' into automation-tests
niemam29 May 10, 2022
8355a76
Fixes from cr
niemam29 May 10, 2022
4d10b9f
Merge remote-tracking branch 'origin/automation-tests' into automatio…
niemam29 May 10, 2022
e46538e
Fixes from cr
niemam29 May 10, 2022
4e1387a
Add Liquidity WIP
MilanVojnovic95 May 12, 2022
97ad165
Add Liquidity WIP/small changes
MilanVojnovic95 May 12, 2022
c033b95
Add Liquidity/fix the typo
MilanVojnovic95 May 12, 2022
872c227
Merge branch 'develop' into automation-tests
MilanVojnovic95 May 12, 2022
3a1361d
Fix for failing test
niemam29 May 11, 2022
55522a0
Add Liquidity/fix for getting element
MilanVojnovic95 May 13, 2022
4184010
Add Liquidity/deleted unnecessary selector
MilanVojnovic95 May 13, 2022
0a16d5e
Add Liquidity/small fix for disconecting wallet
MilanVojnovic95 May 19, 2022
0bda2b6
Add Liquidity/adding comment
MilanVojnovic95 May 19, 2022
54757e9
Added tests for Polygon network (#991)
niemam29 May 26, 2022
7920737
Merge remote-tracking branch 'origin/develop' into automation-tests
niemam29 May 26, 2022
6567a78
Deleted TODO
niemam29 May 26, 2022
12b0e57
Fixed problem with network switching
niemam29 May 26, 2022
01945f3
Fixed problem with network switching
niemam29 May 26, 2022
015f26b
Fixed problem with network switching
niemam29 May 26, 2022
3a3d82a
Fixed problem with network switching
niemam29 May 26, 2022
b3943a9
Fixed problem with network switching
niemam29 May 26, 2022
8ffb458
Fixed problem with network switching
niemam29 May 26, 2022
9d7a43d
Fixed problem with network switching
niemam29 May 26, 2022
ae54a10
WIP swap/brigde-netagive-tc
MilanVojnovic95 Jun 12, 2022
816f022
WIP swap/brigde-netagive-tc
MilanVojnovic95 Jun 13, 2022
59e3c0b
WIP swap/brigde-negative-tc resolved conflicts
MilanVojnovic95 Jun 13, 2022
9ecf70f
WIP swap/brigde-negative-tc resolved conflicts
MilanVojnovic95 Jun 13, 2022
c3f49c6
WIP brigde-negative-tc
MilanVojnovic95 Jun 13, 2022
959e14c
Merge branch 'develop' into swap/bridge-negative-tc
MilanVojnovic95 Jun 29, 2022
9ad5cf2
WIP/changed token and some logic
MilanVojnovic95 Jun 29, 2022
4c6ded3
Merge branch 'develop' into swap/bridge-negative-tc
MilanVojnovic95 Jul 5, 2022
c5c9124
WIP develop merge and small fix
MilanVojnovic95 Jul 6, 2022
21a04fb
merge develop and solve conflicts
MilanVojnovic95 Aug 30, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 13 additions & 3 deletions src/components/TransactionConfirmationModal/index.tsx
Expand Up @@ -148,18 +148,28 @@ export function TransactionErrorContent({ message, onDismiss }: { message: strin
<Wrapper data-testid="transaction-error-modal">
<Section>
<RowBetween>
<TYPE.MediumHeader color="text4">Error</TYPE.MediumHeader>
<TYPE.mediumHeader data-testid="rejected-error-modal" color="text4">
Error
</TYPE.mediumHeader>
<CloseIcon data-testid="close-icon" onClick={onDismiss} />
</RowBetween>
<AutoColumn style={{ marginTop: 20, padding: '2rem 0' }} gap="24px" justify="center">
<AlertTriangle color={theme.red1} style={{ strokeWidth: 1.5 }} size={64} />
<Text fontWeight={500} fontSize={16} color={theme.red1} style={{ textAlign: 'center', width: '85%' }}>
<Text
data-testid="error-modal-message"
fontWeight={500}
fontSize={16}
color={theme.red1}
style={{ textAlign: 'center', width: '85%' }}
>
{message}
</Text>
</AutoColumn>
</Section>
<BottomSection gap="12px">
<ButtonPrimary onClick={onDismiss}>Dismiss</ButtonPrimary>
<ButtonPrimary data-testid="dismiss-button" onClick={onDismiss}>
Dismiss
</ButtonPrimary>
</BottomSection>
</Wrapper>
)
Expand Down
3 changes: 3 additions & 0 deletions tests/pages/NetworkSwitcher.ts
Expand Up @@ -32,4 +32,7 @@ export class NetworkSwitcher {
expect((window as any).ethereum.networkVersion).to.be.eq(networkId)
})
}
static polygon() {
return cy.get('[data-testid=polygon-network-button]')
}
}
9 changes: 9 additions & 0 deletions tests/pages/SwapPage.ts
Expand Up @@ -86,6 +86,15 @@ export class SwapPage {
static getAlternateReceiverInput() {
return cy.get('[data-testid=address-input]')
}
static getErrorModalWindowTitle() {
return cy.get('[data-testid=rejected-error-modal]')
}
static getDismissButtonOnErrorModalWindow() {
return cy.get('[data-testid=dismiss-button]')
}
static getErrorMessage() {
return cy.get('[data-testid=error-modal-message]')
}
static getTransactionConfirmedModal() {
return cy.get('[data-testid=transaction-confirmed-modal]')
}
Expand Down
32 changes: 32 additions & 0 deletions tests/synpress/specs/02transactionfull/bridge/BridgeTests.ts
@@ -1,6 +1,7 @@
import { MenuBar } from '../../../../pages/MenuBar'
import { TokenMenu } from '../../../../pages/TokenMenu'
import { BridgePage } from '../../../../pages/BridgePage'
import { SwapPage } from '../../../../pages/SwapPage'
import { NetworkSwitcher } from '../../../../pages/NetworkSwitcher'
import { AddressesEnum } from '../../../../utils/enums/AddressesEnum'
import { ScannerFacade, SCANNERS } from '../../../../utils/facades/ScannerFacade'
Expand All @@ -11,6 +12,8 @@ import { MetamaskNetworkHandler } from '../../../../utils/MetamaskNetworkHandler
describe('Bridge tests', () => {
let balanceBefore: number
const TRANSACTION_VALUE = 1
const REJECT_TRANSACTION_VALUE = 13.5
const TYPING_DELAY = 200

before(() => {
ScannerFacade.erc20TokenBalance(
Expand Down Expand Up @@ -252,4 +255,33 @@ describe('Bridge tests', () => {
expect(parseInt(res.body.result)).to.be.at.least(Number(balanceBefore) + Number(1000000))
})
})
it.only('Should get the correct error message when reject transaction', function () {
if (isNaN(balanceBefore)) {
this.skip() // Skipping test if Arbiscan is down
}
MenuBar.getNetworkSwitcher().click()
NetworkSwitcher.gnosis().click()
cy.allowMetamaskToAddAndSwitchNetwork()
MenuBar.getNetworkSwitcher().should('contain.text', 'Gnosis')
BridgePage.getNetworkFromSelector().click()
NetworkSwitcher.gnosis().click()
BridgePage.getNetworkToSelector().click()
NetworkSwitcher.ethereum().click()
BridgePage.getBridgeButton().should('contain.text', 'Enter amount')
BridgePage.getTransactionValueInput().type(String(REJECT_TRANSACTION_VALUE))
BridgePage.getSelectTokenButton().click()
TokenMenu.chooseToken('usdc')
BridgePage.getBridgeButton().should('contain.text', 'Select bridge below')
BridgePage.getBridgeSelector('omnibridge').should('be.visible')
BridgePage.getBridgedAmount().should('contain.text', String(REJECT_TRANSACTION_VALUE))
BridgePage.getBridgeSelector('omnibridge').click()
BridgePage.getBridgeButton().should('contain.text', 'Bridge to').click()
BridgePage.confirmBridging()
cy.wait(5000) //METAMASK MODAL IS OPENING WITH 5 SEC DELAY WHICH IS TOO LONG FOR SYNPRESS
cy.rejectMetamaskTransaction()
SwapPage.getErrorMessage().should('contain.text', 'Transaction rejected')
SwapPage.getErrorModalWindowTitle().should('be.visible')
SwapPage.getDismissButtonOnErrorModalWindow().should('be.visible')
SwapPage.getDismissButtonOnErrorModalWindow().click()
})
})
40 changes: 28 additions & 12 deletions tests/synpress/specs/02transactionfull/swap/SwapTests.ts
Expand Up @@ -239,19 +239,35 @@ describe('Swapping tests', () => {
)
})
})
it('Should reject transaction in expert mode [TC-54]', () => {
MenuBar.getSettings().click()
TransactionSettings.switchExpertModeOn()
SwapPage.chooseTokes('xeenus', 'weth')
SwapPage.typeValueFrom(TRANSACTION_VALUE.toFixed(9).toString())
SwapPage.swap()
it('Should get the correct error message when reject transaction while swapping DAI to ETH []', () => {
SwapPage.openTokenToSwapMenu().chooseToken('dxd').typeValueFrom(TRANSACTION_VALUE.toFixed(9).toString())

cy.rejectMetamaskTransaction()
SwapPage.getToInput()
.should('not.have.value', '')
.then((res: JQuery) => {
estimatedTransactionOutput = parseFloat(res.val() as string)
})

cy.scrollTo('top')
SwapPage.getSwapBox().should('be.visible')
SwapPage.getSwapButton().should('be.visible')
SwapPage.getToInput().should('be.visible')
SwapPage.getFromInput().should('be.visible')
SwapPage.swap().confirmSwap()
cy.rejectMetamaskTransaction()
SwapPage.getErrorMessage().should('contain.text', 'Transaction rejected.')
SwapPage.getErrorModalWindowTitle().should('be.visible')
SwapPage.getDismissButtonOnErrorModalWindow().should('be.visible')
SwapPage.getDismissButtonOnErrorModalWindow().click()
it('Should reject transaction in expert mode [TC-54]', () => {
MenuBar.getSettings().click()
TransactionSettings.switchExpertModeOn()
SwapPage.chooseTokes('xeenus', 'weth')
SwapPage.typeValueFrom(TRANSACTION_VALUE.toFixed(9).toString())
SwapPage.swap()

cy.rejectMetamaskTransaction()

cy.scrollTo('top')
SwapPage.getSwapBox().should('be.visible')
SwapPage.getSwapButton().should('be.visible')
SwapPage.getToInput().should('be.visible')
SwapPage.getFromInput().should('be.visible')
})
})
})