Skip to content

Commit

Permalink
🫠 test(cypress): /liquidity (#299)
Browse files Browse the repository at this point in the history
Add Cypress test for `/liquidity` page
  • Loading branch information
aahna-ashina authored Aug 22, 2024
1 parent 0ca342b commit 43ac1c4
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 0 deletions.
1 change: 1 addition & 0 deletions ui/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,6 @@ yarn-error.log*
.vercel

# cypress
cypress/downloads
cypress/screenshots
cypress/videos
55 changes: 55 additions & 0 deletions ui/cypress/e2e/liquidity.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
describe('Liquidity', () => {

it('stake: type a deposit amount', () => {
cy.visit('/liquidity')

// Expect default value to be '0'
cy.get('#depositValue')
.invoke('val')
.then(val => {
expect(val).to.equal('0')
})

// Clear the default '0' value before typing a number
cy.get('#depositValue').clear()

// Type a number
cy.get('#depositValue').type('3.3333')

// Expect the value to no longer be '0'
cy.get('#depositValue')
.invoke('val')
.then(val => {
expect(val).to.equal('3.3333')
})
})

it('unstake: type a withdrawal amount', () => {
cy.visit('/liquidity')

// Click the "Unstake" tab
cy.get("#unstakeTab").click()

// Expect default value to be '0'
cy.get('#withdrawalValue')
.invoke('val')
.then(val => {
expect(val).to.equal('0')
})

// Clear the default '0' value before typing a number
cy.get('#withdrawalValue').clear()

// Type a number
cy.get('#withdrawalValue').type('0.3333')

// Expect the value to no longer be '0'
cy.get('#withdrawalValue')
.invoke('val')
.then(val => {
expect(val).to.equal('0.3333')
})
})
})

export {}
4 changes: 4 additions & 0 deletions ui/pages/liquidity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -239,13 +239,15 @@ export default function Liquidity() {
<a
className={`tab grow ${activeTab === 0 ? 'tab-active dark:font-semibold' : ''}`}
onClick={() => setActiveTab(0)}
id="stakeTab"
>
Stake
</a>

<a
className={`tab grow ${activeTab === 1 ? 'tab-active dark:font-semibold' : ''}`}
onClick={() => setActiveTab(1)}
id="unstakeTab"
>
Unstake
</a>
Expand All @@ -268,6 +270,7 @@ export default function Liquidity() {
type="number"
placeholder="Amount"
className="input input-bordered w-full dark:bg-slate-200"
id="depositValue"
value={depositValue}
onChange={setDepositValue}
/>
Expand Down Expand Up @@ -310,6 +313,7 @@ export default function Liquidity() {
type="number"
placeholder="Amount"
className="input input-bordered w-full dark:bg-slate-200"
id="withdrawalValue"
value={withdrawalValue}
onChange={(value: any) => {
setWithdrawalValue(value)
Expand Down

0 comments on commit 43ac1c4

Please sign in to comment.