Skip to content

Commit

Permalink
Tests for rewards campaign creation + some improvments (#933)
Browse files Browse the repository at this point in the history
* Added tests for switching networks and more swapping (#896)

* Added tests for swapping

* Added tests for swapping

* Transaction Settings Smoke Test

* Small fix for improving stability of the tests

* Small fix for improving stability of the tests

* Added tests for swaping

* Small fix for improving stability of the tests

* Added tests for wallet connection

* Added test for switching networks

* Added test for switching networks

* Added test for switching networks

* Added test for switching networks

* Added test for switching networks

* Added test for switching networks

* Added test for switching networks

* Added test for switching networks

* Added test for switching networks

Co-authored-by: MilanVojnovic95 <mv.coversproduction@gmail.com>

* Tests for creating a campaign (#929)

* Added tests for swapping

* Added tests for swapping

* Transaction Settings Smoke Test

* Small fix for improving stability of the tests

* Small fix for improving stability of the tests

* Added tests for swaping

* Fix showing avatar without an image

* Small fix for improving stability of the tests

* Added tests for wallet connection

* Added test for switching networks

* Added test for switching networks

* Added test for switching networks

* Added test for switching networks

* Added test for switching networks

* Added test for switching networks

* fix: hide unsupported net popup

* fix: remove whitespace

* Added test for switching networks

* Added test for switching networks

* Added test for switching networks

* Added test for switching networks

* Added tests for switching networks and more swapping (#896) (#902)

* Added tests for swapping

* Added tests for swapping

* Transaction Settings Smoke Test

* Small fix for improving stability of the tests

* Small fix for improving stability of the tests

* Added tests for swaping

* Small fix for improving stability of the tests

* Added tests for wallet connection

* Added test for switching networks

* Added test for switching networks

* Added test for switching networks

* Added test for switching networks

* Added test for switching networks

* Added test for switching networks

* Added test for switching networks

* Added test for switching networks

* Added test for switching networks

Co-authored-by: MilanVojnovic95 <mv.coversproduction@gmail.com>

Co-authored-by: MilanVojnovic95 <mv.coversproduction@gmail.com>

* Added test for liquidity campaign creation

* Added test for liquidity campaign creation

* Added test for liquidity campaign creation

* Added test for liquidity campaign creation

* Added test for liquidity campaign creation

* Added test for liquidity campaign creation

* Added test for liquidity campaign creation

* Added test for liquidity campaign creation

* Added test for liquidity campaign creation

* Added test for liquidity campaign creation

* Added test for liquidity campaign creation

Co-authored-by: MilanVojnovic95 <mv.coversproduction@gmail.com>
Co-authored-by: Diogo <diogo.mart.ferreira@gmail.com>
Co-authored-by: Oskar Karcz <oskar.karcz@rumblefish.pl>
Co-authored-by: Adam Azad <adam@adamazad.com>
Co-authored-by: karczuRF <88723742+karczuRF@users.noreply.github.com>

* Small fixes along with name changes, added possibility to add cypress plugins to synpress

* Fix for opening reward card

* Fix for opening reward card

* Fixes from cr

* Fixes from cr

* Fixes from cr

* Fixes from cr

* Fixes from cr

* Fixes from cr

* Fixes from cr

* Fixes from cr

* Fixes from cr

Co-authored-by: MilanVojnovic95 <mv.coversproduction@gmail.com>
Co-authored-by: Diogo <diogo.mart.ferreira@gmail.com>
Co-authored-by: Oskar Karcz <oskar.karcz@rumblefish.pl>
Co-authored-by: Adam Azad <adam@adamazad.com>
Co-authored-by: karczuRF <88723742+karczuRF@users.noreply.github.com>
  • Loading branch information
6 people committed May 10, 2022
1 parent 91f9042 commit d1ce4fc
Show file tree
Hide file tree
Showing 34 changed files with 514 additions and 153 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
"cross-env": "^7.0.2",
"cypress": "^9.5.3",
"cypress-localstorage-commands": "^1.7.0",
"date-fns": "^2.28.0",
"decimal.js-light": "^2.5.1",
"eslint": "^7.32.0",
"eslint-config-prettier": "^8.5.0",
Expand Down Expand Up @@ -138,7 +139,7 @@
"check-errors": "yarn lint --fix && tsc --noEmit",
"cypress:run": "cross-env MOCHAWESOME_HTML='false' MOCHAWESOME_OVERWRITE='false' cypress run -r mochawesome -s 'tests/cypress/integration/smoke/*'",
"cypress:ct": "cross-env start-server-and-test 'yarn start' http-get://localhost:3000 'yarn cypress:run'",
"synpress:run": "cross-env MOCHAWESOME_HTML='false' MOCHAWESOME_OVERWRITE='false' NETWORK_NAME='rinkeby' CYPRESS_SKIP_RESOURCES_WAIT='true' FAIL_ON_ERROR='0' PRIVATE_KEY='367f6baeb27b33408c85040e13d1ba3e2a173a9112eb3b103f79df0729ddda72' ETHERSCAN_KEY='25VF97IQZ8EFIYSYFI72UCTJJII3HSZU7Z' synpress run --configFile tests/synpress/synpress.json -r mochawesome --reporterOptions 'overwrite=false, html=false, json=true'",
"synpress:run": "cross-env MOCHAWESOME_HTML='false' MOCHAWESOME_OVERWRITE='false' NETWORK_NAME='rinkeby' CYPRESS_SKIP_RESOURCES_WAIT='true' FAIL_ON_ERROR='0' PRIVATE_KEY='367f6baeb27b33408c85040e13d1ba3e2a173a9112eb3b103f79df0729ddda72' ETHERSCAN_KEY='25VF97IQZ8EFIYSYFI72UCTJJII3HSZU7Z' synpress run --configFile tests/synpress/synpress.json --config supportFile='tests/support/index.js',pluginsFile='tests/plugins/index.js' -r mochawesome --reporterOptions 'overwrite=false, html=false, json=true'",
"synpress:open": "cross-env MOCHAWESOME_HTML='false' MOCHAWESOME_OVERWRITE='false' NETWORK_NAME='rinkeby' CYPRESS_SKIP_RESOURCES_WAIT='true' FAIL_ON_ERROR='0' PRIVATE_KEY='367f6baeb27b33408c85040e13d1ba3e2a173a9112eb3b103f79df0729ddda72' ETHERSCAN_KEY='25VF97IQZ8EFIYSYFI72UCTJJII3HSZU7Z' synpress open --configFile tests/synpress/synpress.json",
"synpress:ct": "cross-env start-server-and-test 'yarn start' http-get://localhost:3000 'yarn synpress:run'",
"report:merge": "mochawesome-merge mochawesome-report/*.json > index.json",
Expand Down
2 changes: 1 addition & 1 deletion src/components/CurrencyInputPanel/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ export default function CurrencyInputPanel({
onUserInput(val)
}}
disabled={disabled}
data-testid={'transaction-value-input'}
data-testid="transaction-value-input"
/>
)}
<CurrencySelect
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ export default function StakingRewardsDistributionCreationModalFooter({
</RowBetween>

<AutoRow>
<ButtonError onClick={onConfirm} style={{ margin: '10px 0 0 0' }}>
<ButtonError onClick={onConfirm} style={{ margin: '10px 0 0 0' }} data-testid="modal-confirm-button">
<Text fontSize={13} fontWeight={600}>
Confirm
</Text>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,11 @@ export default function AssetSelector({ title, currency0, currency1, onClick }:
<AssetLogo currency0={currency0} currency1={currency1} />
</Box>
<Box>
<TYPE.body lineHeight="20px" color="white">
<TYPE.body
lineHeight="20px"
color="white"
data-testid={title.toLocaleLowerCase().replace(' ', '-') + '-select'}
>
{assetTitle || 'Click to select'}
</TYPE.body>
</Box>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ export default function PreviewAndCreate({
<ButtonPrimary
disabled={areButtonsDisabled || approvalState !== ApprovalState.APPROVED}
onClick={onCreate}
data-testid="confirm-button"
>
{getConfirmButtonMessage()}
</ButtonPrimary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ export default function RewardAmount({
</Box>
<Box>
<RelativeContainer>
<StyledNumericalInput value={amount} onUserInput={handleLocalUserInput} />
<StyledNumericalInput value={amount} onUserInput={handleLocalUserInput} data-testid="reward-input" />
<RewardInputLogo size="16px" currency={reward?.token} />
</RelativeContainer>
</Box>
Expand Down
4 changes: 2 additions & 2 deletions src/components/LiquidityMining/Create/Steps/Time/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export default function Time({
return (
<Card>
<FlexContainer justifyContent="stretch" width="100%">
<Box flex="1">
<Box flex="1" data-testid="start-time-selector-box">
<TimeSelector
title="START DATE AND TIME"
placeholder="Start date & time"
Expand All @@ -56,7 +56,7 @@ export default function Time({
<Box mx="18px">
<Divider />
</Box>
<ResponsiveBoxContainer flex="1">
<ResponsiveBoxContainer flex="1" data-testid="end-time-selector-box">
<TimeSelector
title="END DATE AND TIME"
placeholder="End date & time"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ function Information({
<CurrencyLogo currency={targetedPair} loading={!targetedPair} />
)}
</Box>
<Box>
<Box data-testid="campaign-tokens">
<Text fontSize="18px" fontWeight="600" lineHeight="20px">
{!targetedPair ? (
<Skeleton width="60px" height="18px" />
Expand Down Expand Up @@ -256,7 +256,7 @@ function Information({
<Skeleton width="40px" height="14px" />
) : (
<BadgeRoot expired={expired} upcoming={upcoming}>
<BadgeText expired={expired} upcoming={upcoming}>
<BadgeText expired={expired} upcoming={upcoming} data-testid="campaign-status">
{expired ? 'EXPIRED' : upcoming ? 'UPCOMING' : 'ACTIVE'}
</BadgeText>
</BadgeRoot>
Expand Down Expand Up @@ -307,7 +307,7 @@ function Information({
/>
</MaxPollSizeSection>
<RewardsSection alignItems="flex-start">
<Box mr="24px">
<Box mr="24px" data-testid="rewards-box">
<DataDisplayer
title="REWARDS"
data={
Expand Down Expand Up @@ -383,7 +383,7 @@ function Information({
/>
</PoolTypeSection>
<DatesSection>
<Box mr="24px">
<Box mr="24px" data-testid="start-date">
<DataDisplayer
title="START"
data={
Expand All @@ -396,7 +396,7 @@ function Information({
dataTextSize={10.5}
/>
</Box>
<Box>
<Box data-testid="end-date">
<DataDisplayer
title="END"
data={
Expand Down
2 changes: 1 addition & 1 deletion src/components/Pool/LiquidityMiningCampaignView/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ function LiquidityMiningCampaignView({ campaign, containsKpiToken, isSingleSided
setShowUSDValue(!showUSDValue)
}, [showUSDValue])
return (
<AutoColumn gap="18px">
<AutoColumn gap="18px" data-testid="reward-campaign-information-card">
<RowBetween>
<GoBackContainer onClick={history.goBack}>
<StyledChevronLeft />
Expand Down
10 changes: 7 additions & 3 deletions src/components/Pool/PairsList/CampaignCard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,12 @@ export function CampaignCard({
}, [campaign.ended, campaign.startsAt])

return (
<SizedCard cardColor={status !== undefined ? STATUS[status].cardColor : 'transperent'} {...rest}>
<Flex flexDirection="column" height={'100%'}>
<SizedCard
cardColor={status !== undefined ? STATUS[status].cardColor : 'transperent'}
{...rest}
data-testid="reward-card"
>
<Flex flexDirection="column" height={'100%'} data-testid={'reward-starting-at-' + campaign.startsAt}>
<Flex justifyContent="space-between" flexGrow={1}>
<Flex flexDirection="column">
{isSingleSidedStakingCampaign ? (
Expand Down Expand Up @@ -165,7 +169,7 @@ export function CampaignCard({
</EllipsizedText>
</Flex>
<RightSection>
<Flex width="max-content" alignItems="center" data-testid="ended-campaign">
<Flex width="max-content" alignItems="center">
<ClockSvg width={'10px'} height={'10px'} />
<TYPE.body marginLeft="4px" fontSize="10px" fontFamily="Fira Code" fontWeight="500">
<Countdown
Expand Down
2 changes: 1 addition & 1 deletion src/components/Pool/PairsList/Pair/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export default function Pair({
const isMobile = width ? width < MEDIA_WIDTHS.upToExtraSmall : false

return (
<SizedCard selectable {...rest}>
<SizedCard selectable {...rest} data-testid="pair-card">
<Flex height="100%" justifyContent="space-between">
<Flex flexDirection={isMobile ? 'column' : 'row'} alignItems={!isMobile ? 'center' : ''}>
{isSingleSidedStakingCampaign ? (
Expand Down
4 changes: 2 additions & 2 deletions src/components/TransactionConfirmationModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import styled, { ThemeContext } from 'styled-components'
import Modal from '../Modal'
import { ExternalLink, TYPE } from '../../theme'
import { Text } from 'rebass'
import { CloseIcon, CustomLightSpinner } from '../../theme/components'
import { CloseIcon, CustomLightSpinner } from '../../theme'
import { RowBetween } from '../Row'
import { AlertTriangle, ArrowUpCircle } from 'react-feather'
import { ButtonPrimary } from '../Button'
Expand Down Expand Up @@ -94,7 +94,7 @@ function TransactionSubmittedContent({
</Text>
</ExternalLink>
)}
<ButtonPrimary onClick={onDismiss} style={{ margin: '20px 0 0 0' }}>
<ButtonPrimary onClick={onDismiss} style={{ margin: '20px 0 0 0' }} data-testid="close-modal-button">
<Text fontWeight={600} fontSize="13px">
Close
</Text>
Expand Down
10 changes: 5 additions & 5 deletions tests/cypress/integration/smoke/RewardsPageTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ describe('Rewards Page Smoke Test', () => {
NetworkSwitcher.gnosis().click()
RewardsPage.getExpiredCampaignsButton().should('be.visible')
RewardsPage.getExpiredCampaignsButton().click()
RewardsPage.getRewardCard()
RewardsPage.getRewardCards()
.first()
.should('be.visible')
RewardsPage.getActiveCampaignsButton().should('be.visible')
RewardsPage.getActiveCampaignsButton().click()
RewardsPage.getRewardCard()
RewardsPage.getRewardCards()
.first()
.should('be.visible')
})
Expand All @@ -37,12 +37,12 @@ describe('Rewards Page Smoke Test', () => {
NetworkSwitcher.arbitrum().click()
RewardsPage.getExpiredCampaignsButton().should('be.visible')
RewardsPage.getExpiredCampaignsButton().click()
RewardsPage.getRewardCard()
RewardsPage.getRewardCards()
.first()
.should('be.visible')
RewardsPage.getActiveCampaignsButton().should('be.visible')
RewardsPage.getActiveCampaignsButton().click()
RewardsPage.getRewardCard()
RewardsPage.getRewardCards()
.first()
.should('be.visible')
})
Expand All @@ -52,7 +52,7 @@ describe('Rewards Page Smoke Test', () => {
NetworkSwitcher.ethereum().click()
RewardsPage.getExpiredCampaignsButton().should('be.visible')
RewardsPage.getExpiredCampaignsButton().click()
RewardsPage.getRewardCard()
RewardsPage.getRewardCards()
.first()
.should('be.visible')
//TODO: When Active Reward cards exist then uncomment functions down below
Expand Down
31 changes: 31 additions & 0 deletions tests/pages/CampaignPage.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
export class CampaignPage {
static getCampaignTokensText() {
return cy.get('[data-testid=campaign-tokens]')
}
static getCampaignStatusText(specifiedTimout = 30000) {
return cy.get('[data-testid=campaign-status]', { timeout: specifiedTimout })
}
static getCampaignStartDateText() {
return cy.get('[data-testid=start-date]')
}
static getCampaignEndDateText() {
return cy.get('[data-testid=end-date]')
}
static getCampaignRewardsBox() {
return cy.get('[data-testid=rewards-box]')
}
static checkCampaignData(
tokenPair: string,
rewardsInput: number,
campaignStatus: string,
startsAt: string,
endsAt: string
) {
CampaignPage.getCampaignTokensText().should('contain.text', tokenPair)
CampaignPage.getCampaignRewardsBox().should('contain.text', rewardsInput)
CampaignPage.getCampaignStatusText(90000).should('contain.text', campaignStatus)
CampaignPage.getCampaignStartDateText().should('contain.text', startsAt)
CampaignPage.getCampaignEndDateText().should('contain.text', endsAt)
return cy.get('[data-testid=rewards-box]')
}
}
28 changes: 28 additions & 0 deletions tests/pages/CreatePoolPage.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
export class CreatePoolPage {
static getLiquidityPairMenuButton() {
return cy.get('[data-testid=liquidity-pair-select]')
}
static getRewardTokenMenuButton() {
return cy.get('[data-testid=reward-token-select]')
}
static getTotalRewardInput() {
return cy.get('[data-testid=reward-input]')
}
static getConfirmButton() {
return cy.get('[data-testid=confirm-button]')
}
static setStartTime(time: string) {
return cy.get('[data-testid=start-time-selector-box]').within(() => {
cy.get('.react-datepicker__input-container').type(time)
})
}
static setEndTime(time: string) {
return cy.get('[data-testid=end-time-selector-box]').within(() => {
cy.get('.react-datepicker__input-container').type(time)
})
}
static confirmPoolCreation() {
this.getConfirmButton().click()
cy.get('[data-testid=modal-confirm-button]').click()
}
}
14 changes: 14 additions & 0 deletions tests/pages/LiquidityPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,18 @@ export class LiquidityPage {
static getTokenSearchField() {
return cy.get('[id=token-search-input]')
}
static getPairCards() {
return cy.get('[data-testid=pair-card]')
}
static getRewardsCampaignButton() {
return cy.get('#rewards-campaign-for-pair')
}
static switchCampaignsToogle() {
LiquidityPage.getCampaignsAndMyPairsToggleSwitch().within(() => {
return cy
.get('label')
.first()
.click()
})
}
}
2 changes: 1 addition & 1 deletion tests/pages/MenuBar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export class MenuBar {
cy.get('.Toastify__close-button').click({ multiple: true, force: true })
}
static checkToastMessage(message: string) {
cy.get('.Toastify__toast', { timeout: 100000 }).should('contain', message)
cy.get('.Toastify__toast', { timeout: 300000 }).should('contain', message)
this.closeToastAlerts()
}
static getSwap() {
Expand Down
8 changes: 8 additions & 0 deletions tests/pages/PairMenu.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export class PairMenu {
static getSearchPairInput() {
return cy.get('[data-testid=search-pair]')
}
static choosePair(pairName: string) {
return this.getSearchPairInput().type(pairName + '{enter}{enter}', { delay: 100 })
}
}
36 changes: 34 additions & 2 deletions tests/pages/RewardsPage.ts
Original file line number Diff line number Diff line change
@@ -1,32 +1,64 @@
import { getUnixTime } from 'date-fns'
import { PairMenu } from './PairMenu'

export class RewardsPage {
static visitRewardsPage() {
cy.visit('/#/rewards')
}

static getActiveCampaignsButton() {
return cy.get('[data-testid=active-campaigns]')
}

static getExpiredCampaignsButton() {
return cy.get('[data-testid=expired-campaigns]')
}

static getCreateCampaignButton() {
return cy.get('[data-testid=create-campaign]')
}

static getAllPairsButton() {
return cy.get('[data-testid=all-pairs]')
}

static getSearchAPairModalWindow() {
return cy.get('[data-testid=select-a-pair]')
}

static getSearchAPairField() {
return cy.get('[data-testid=search-pair]')
}

static getCloseSearchAPairModalWindowButton() {
return cy.get('[data-testid=close-search-pair]')
}

static getMyPairsToggleSwitch() {
return cy.get('.react-switch-button')
}
static getRewardCard() {
return cy.get('[data-testid=ended-campaign]')

static getRewardCards() {
return cy.get('[data-testid=reward-card]')
}

static getRewardCardByStartingAt(startingAt: string) {
return cy.get('[data-testid=reward-starting-at-' + startingAt + ']', { timeout: 60000 })
}

static clickOnRewardCardUntilCampaignOpen(startingAt: Date, chosenPair = '') {
cy.waitUntil(() => {
if (Cypress.$('[data-testid=reward-card]').length) {
//TODO After opening campaign for first time it instead of opening reward card opens all rewards page
if (chosenPair != '') {
RewardsPage.getAllPairsButton().click()
PairMenu.choosePair(chosenPair)
}
return RewardsPage.getRewardCardByStartingAt(getUnixTime(startingAt).toString())
.click()
.then(() => false)
}
return true
})
}
}
1 change: 0 additions & 1 deletion tests/pages/TokenMenu.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { SwapPage } from './SwapPage'
export class TokenMenu {
static chooseToken(token: string) {
cy.scrollTo('top')
this.getSingleTokenManagerInput()
.should('be.visible')
.type(token)
Expand Down

0 comments on commit d1ce4fc

Please sign in to comment.