-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Code refactoring and new test scripts automated
- Loading branch information
1 parent
b81f7f6
commit 844c9f0
Showing
7 changed files
with
212 additions
and
27 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
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,48 @@ | ||
import selectors from '../fixtures/selectors.json' | ||
let { tokenSearch, selectTokens, toEstimated, amountInTokensSwap, confirmSwap, toTokenChain, swappingMsg } = selectors.swap | ||
let { createPairToken1, createPairToken2, createAddTokenValues, createAddConfirmBtn, createAddMaxBtn, createAddOutputMsg, createAddBtn, createAddAmountField, createAddSupplyBtn, createAddTokenNamesValues } = selectors.pools | ||
function selectTokensPoolftn(token1, token2, pairBtn ) { | ||
cy.get(createPairToken1).eq(0).click() | ||
cy.get(tokenSearch).eq(0).should('have.attr', 'placeholder', 'Search').type(token1); | ||
cy.get(selectTokens).contains(token1).click() | ||
cy.get(createPairToken2).contains("Select a Token").click() | ||
cy.get(tokenSearch).eq(1).should('have.attr', 'placeholder', 'Search').type(token2); | ||
cy.get(selectTokens).contains(token2).click() | ||
cy.get(createAddBtn, { timeout: 30000 }).should('contain', pairBtn).click() | ||
|
||
} | ||
|
||
function pairDetailsCardftn() { | ||
for (var i = 0; i <= 1; i++) { | ||
cy.get(toEstimated).eq(i).should('be.visible'); | ||
cy.get(createAddTokenValues).eq(i).invoke('text').should('match', /^\d+(\.\d+)?$/); | ||
cy.get(amountInTokensSwap).eq(i).invoke('text').should('match', /^(-|0%$)/); | ||
cy.get(createAddConfirmBtn).contains("Enter an amount").should('be.visible') | ||
cy.get(createAddMaxBtn).eq(0).should('be.visible').click() | ||
cy.get(amountInTokensSwap).eq(i).invoke('text').should('match', /\d+/); | ||
cy.get(createAddAmountField).eq(i).invoke('val').should('match', /\d+/); | ||
} | ||
} | ||
|
||
function createEnterValuesftn(cardName, supplyBtn, token1, token2) { | ||
for (var i = 0; i <= 1; i++) { | ||
// Entering values | ||
cy.get(createAddAmountField).eq(i).type("99999"); | ||
cy.get(createAddConfirmBtn).contains(/Insufficient \w+ balance/i).should('be.visible'); | ||
cy.get(createAddAmountField).eq(i).clear(); | ||
cy.get(createAddAmountField).eq(i).type("0.001"); | ||
} | ||
|
||
cy.get(createAddSupplyBtn).eq(0).should('contain', 'Supply').click(); | ||
|
||
// You will receive card | ||
cy.get(confirmSwap).contains(cardName).should('be.visible'); | ||
cy.get(createAddTokenNamesValues).eq(0).contains(new RegExp(`^\\d+\\.\\d+ ${token1}$`)).should('be.visible'); | ||
cy.get(createAddTokenNamesValues).eq(1).contains(new RegExp(`^\\d+\\.\\d+ ${token2}$`)).should('be.visible'); | ||
cy.get(toTokenChain).contains("PGL").should('be.visible'); | ||
cy.get(toTokenChain).contains("Share of Pool").should('be.visible'); | ||
cy.get(createAddOutputMsg).contains("Output is estimated. If the price changes by more than 0.5% your transaction will revert.").should('be.visible'); | ||
cy.get(createAddSupplyBtn).eq(1).should('contain', supplyBtn).click(); | ||
cy.get(swappingMsg).contains(new RegExp(`^Supplying \\d+\\.\\d+ ${token1} and \\d+\\.\\d+ ${token2}$`)).should('be.visible'); | ||
} | ||
export{selectTokensPoolftn, pairDetailsCardftn, createEnterValuesftn} |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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,112 @@ | ||
import selectors from '../../../cypress/fixtures/selectors.json' | ||
import { connectWalletftn } from '../../../cypress/src/dashboard' | ||
import { nativeDetails } from '../../../cypress/src/dashboard' | ||
import { notificationftn } from '../../../cypress/src/swap' | ||
import { selectTokensPoolftn } from '../../../cypress/src/pool' | ||
import { pairDetailsCardftn } from '../../../cypress/src/pool' | ||
import { createEnterValuesftn } from '../../../cypress/src/pool' | ||
|
||
let { connectToWallet, connectToMetamask, connectWallet, connected } = selectors.dashboard | ||
let { poolsSideMenu, standardSideMenu, createPair, createAddTitle } = selectors.pools | ||
|
||
//To run each file | ||
//npx env-cmd -f .env npx synpress run --spec 'tests/e2e/specs/pool.spec.js' -cf synpress.json | ||
describe('pool standard', () => { | ||
it('Connects with Metamask', () => { | ||
//Connect to MetaMask from pool page | ||
cy.visit('/dashboard') | ||
cy.get(poolsSideMenu).click() | ||
cy.get(standardSideMenu).click() | ||
//MetaMask connection | ||
cy.get(connectToWallet).click(); | ||
cy.get(connectToMetamask).contains("Metamask").click(); | ||
cy.get(connectWallet).click() | ||
cy.switchToMetamaskWindow(); | ||
cy.acceptMetamaskAccess().should("be.true"); | ||
cy.switchToCypressWindow(); | ||
cy.get(connected).should("not.be.empty"); | ||
//After connecting, the Network name (Avalanche), native token (PNG) and the gas token (AVAX) in the menu will change to the chain specific ones | ||
nativeDetails(0) | ||
}) | ||
|
||
it('Details on Create a pair card', () => { | ||
//Connect to MetaMask from pool page | ||
cy.visit('/dashboard') | ||
cy.get(poolsSideMenu).click() | ||
cy.get(standardSideMenu).click() | ||
//MetaMask connection | ||
connectWalletftn() | ||
//Create a pair | ||
cy.get(createPair).contains("Create a pair").click() | ||
//selecting tokens | ||
selectTokensPoolftn("GRELF","USDt","Create a pair") | ||
//create a pair card | ||
cy.get(createAddTitle).contains("Create a pair").should('be.visible') | ||
pairDetailsCardftn() | ||
}) | ||
|
||
it('You are creating a pool card', () => { | ||
//Connect to MetaMask from pool page | ||
cy.visit('/dashboard') | ||
cy.get(poolsSideMenu).click() | ||
cy.get(standardSideMenu).click() | ||
//MetaMask connection | ||
connectWalletftn() | ||
//Creating the pair | ||
cy.get(createPair).contains("Create a pair").click() | ||
//selecting tokens | ||
selectTokensPoolftn("GRELF","USDt","Create a pair") | ||
//entering values | ||
//You are creating a pool card | ||
createEnterValuesftn("You are creating a pool", "Create Pool & Supply", "GRELF", "USDt") | ||
//Approve transaction | ||
cy.confirmMetamaskTransaction() | ||
cy.wait(10000); | ||
//Notification | ||
notificationftn("Added") | ||
// //Successful card | ||
// successfulCardftn(confirmSwapBtn, limitSuccessfulTransactionLink) | ||
|
||
}) | ||
|
||
it('Details on Add liquidity card', () => { | ||
//Connect to MetaMask from pool page | ||
cy.visit('/dashboard') | ||
cy.get(poolsSideMenu).click() | ||
cy.get(standardSideMenu).click() | ||
//MetaMask connection | ||
connectWalletftn() | ||
//Add Liquidity | ||
cy.get(createPair).contains("Create a pair").click() | ||
//selecting tokens | ||
selectTokensPoolftn("PNG","USDt","Add Liquidity") | ||
//Add liquidity card | ||
cy.get(createAddTitle).contains("Add liquidity").should('be.visible') | ||
pairDetailsCardftn() | ||
}) | ||
|
||
it('You will receive card', () => { | ||
//Connect to MetaMask from pool page | ||
cy.visit('/dashboard') | ||
cy.get(poolsSideMenu).click() | ||
cy.get(standardSideMenu).click() | ||
//MetaMask connection | ||
connectWalletftn() | ||
//Adding Liquidity | ||
cy.get(createPair).contains("Create a pair").click() | ||
//selecting tokens | ||
selectTokensPoolftn("PNG","USDt","Add Liquidity") | ||
//Add liquidity card | ||
cy.get(createAddTitle).contains("Add liquidity").should('be.visible') | ||
//entering values | ||
//You will receive card | ||
createEnterValuesftn("You will receive", "Confirm Supply", "PNG", "USDt") | ||
//Approve transaction | ||
cy.confirmMetamaskTransaction() | ||
cy.wait(10000); | ||
//Notification | ||
notificationftn("Added") | ||
// //Successful card | ||
//successfulCardftn(confirmSwapBtn, limitSuccessfulTransactionLink) | ||
}) | ||
}) |
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
844c9f0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test run results for pool
Reference: