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

e2e:test: Add Zap In simulation #2375

Merged
merged 25 commits into from
Nov 13, 2023
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
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
4 changes: 2 additions & 2 deletions .github/workflows/cypress.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: 'Cypress Test'
name: 'E2E Smoke'

# concurrency:
# group: pr-workflow-${{ github.ref }}
Expand Down Expand Up @@ -116,7 +116,7 @@ jobs:
run: |+
#!/bin/bash
yarn preview &
yarn test-e2e -c baseUrl='http://127.0.0.1:4173/' -e grepTags=smoke,NETWORK=Ethereum
yarn test:e2e -c baseUrl='http://127.0.0.1:4173/' -e grepTags=smoke,NETWORK=Ethereum
env:
DISPLAY: :0.0

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/schedule.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: 'E2E Testing Schedule'
name: 'E2E Regression'

on:
schedule:
Expand Down Expand Up @@ -54,7 +54,7 @@ jobs:
- name: Run Cypress Test
run: |+
#!/bin/bash
yarn test-schedule -c baseUrl='https://kyberswap.com/' -e grepTags=regression,NETWORK=${{ matrix.network }}
yarn test:e2e -c baseUrl='https://kyberswap.com/' -e grepTags=regression,NETWORK=${{ matrix.network }}
env:
DISPLAY: :0.0

Expand Down
228 changes: 120 additions & 108 deletions cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,135 +13,147 @@ export default defineConfig({
},
userAgent: 'synpress',
chromeWebSecurity: true,
// video: false,
// videoCompression: false,
viewportWidth: 1920,
viewportHeight: 1080,
env: {
grepFilterSpecs: true,
grepOmitFiltered: true,
},
e2e: {
testIsolation: false,
setupNodeEvents(on, config) {
// eslint-disable-next-line @typescript-eslint/no-var-requires
require('@cypress/grep/src/plugin')(config)
synpressPlugins(on, config)
on('after:run', async results => {
if (results) {
const register = new client.Registry()
const prefix = 'e2e_cypress'
const suite = new client.Counter({
name: `${prefix}_suite`,
help: `${prefix}_suite`,
labelNames: ['buildId', 'result', 'baseName', 'duration', 'chain'] as const,
})
suite.reset()
const { totalPassed, totalFailed, totalTests, totalDuration, runs } = results
runs.forEach(run => {
const { stats, spec } = run
const { tests, passes, pending, failures, duration } = stats
const { baseName } = spec
suite
.labels({
buildId: `${process.env.GITHUB_RUN_ID}`,
result: 'failed',
baseName: baseName,
duration: duration,
chain: config.env.NETWORK,
})
.inc(failures)
const options = {
printLogsToFile: 'always',
outputRoot: config.projectRoot + '/target/',
specRoot: 'cypress/e2e/specs',
outputTarget: {
'cypress-logs|json': 'json',
},
}
require('cypress-terminal-report/src/installLogsPrinter')(on, options)
// on('after:run', async results => {
// if (results) {
// const register = new client.Registry()
// const prefix = 'e2e_cypress'
// const suite = new client.Counter({
// name: `${prefix}_suite`,
// help: `${prefix}_suite`,
// labelNames: ['buildId', 'result', 'baseName', 'duration', 'chain'] as const,
// })
// suite.reset()
// const { totalPassed, totalFailed, totalTests, totalDuration, runs } = results
// runs.forEach(run => {
// const { stats, spec } = run
// const { tests, passes, pending, failures, duration } = stats
// const { baseName } = spec
// suite
// .labels({
// buildId: `${process.env.GITHUB_RUN_ID}`,
// result: 'failed',
// baseName: baseName,
// duration: duration,
// chain: config.env.NETWORK,
// })
// .inc(failures)

suite
.labels({
buildId: `${process.env.GITHUB_RUN_ID}`,
result: 'passed',
baseName: baseName,
duration: duration,
chain: config.env.NETWORK,
})
.inc(passes)
// suite
// .labels({
// buildId: `${process.env.GITHUB_RUN_ID}`,
// result: 'passed',
// baseName: baseName,
// duration: duration,
// chain: config.env.NETWORK,
// })
// .inc(passes)

suite
.labels({
buildId: `${process.env.GITHUB_RUN_ID}`,
result: 'pending',
baseName: baseName,
duration: duration,
chain: config.env.NETWORK,
})
.inc(pending)
suite
.labels({
buildId: `${process.env.GITHUB_RUN_ID}`,
result: 'tests',
baseName: baseName,
duration: duration,
chain: config.env.NETWORK,
})
.inc(tests)
})
// suite
// .labels({
// buildId: `${process.env.GITHUB_RUN_ID}`,
// result: 'pending',
// baseName: baseName,
// duration: duration,
// chain: config.env.NETWORK,
// })
// .inc(pending)
// suite
// .labels({
// buildId: `${process.env.GITHUB_RUN_ID}`,
// result: 'tests',
// baseName: baseName,
// duration: duration,
// chain: config.env.NETWORK,
// })
// .inc(tests)
// })

suite
.labels({
buildId: `${process.env.GITHUB_RUN_ID}`,
result: 'passed',
baseName: 'All Specs',
duration: totalDuration,
chain: config.env.NETWORK,
})
.inc(totalPassed)
// suite
// .labels({
// buildId: `${process.env.GITHUB_RUN_ID}`,
// result: 'passed',
// baseName: 'All Specs',
// duration: totalDuration,
// chain: config.env.NETWORK,
// })
// .inc(totalPassed)

suite
.labels({
buildId: `${process.env.GITHUB_RUN_ID}`,
result: 'failed',
baseName: 'All Specs',
duration: totalDuration,
chain: config.env.NETWORK,
})
.inc(totalFailed)
suite
.labels({
buildId: `${process.env.GITHUB_RUN_ID}`,
result: 'total',
baseName: 'All Specs',
duration: totalDuration,
chain: config.env.NETWORK,
})
.inc(totalTests)
// suite
// .labels({
// buildId: `${process.env.GITHUB_RUN_ID}`,
// result: 'failed',
// baseName: 'All Specs',
// duration: totalDuration,
// chain: config.env.NETWORK,
// })
// .inc(totalFailed)
// suite
// .labels({
// buildId: `${process.env.GITHUB_RUN_ID}`,
// result: 'total',
// baseName: 'All Specs',
// duration: totalDuration,
// chain: config.env.NETWORK,
// })
// .inc(totalTests)

const testPass = new client.Counter({
name: `${prefix}_test_passed`,
help: `${prefix}_pass`,
labelNames: ['buildId', 'chain'] as const,
})
// const testPass = new client.Counter({
// name: `${prefix}_test_passed`,
// help: `${prefix}_pass`,
// labelNames: ['buildId', 'chain'] as const,
// })

const testFail = new client.Counter({
name: `${prefix}_test_failed`,
help: `${prefix}_fail`,
labelNames: ['buildId', 'chain'] as const,
})
// const testFail = new client.Counter({
// name: `${prefix}_test_failed`,
// help: `${prefix}_fail`,
// labelNames: ['buildId', 'chain'] as const,
// })

testPass.reset()
testFail.reset()
// testPass.reset()
// testFail.reset()

testFail.labels({ buildId: `${process.env.GITHUB_RUN_ID}`, chain: config.env.NETWORK }).inc(totalFailed)
testPass.labels({ buildId: `${process.env.GITHUB_RUN_ID}`, chain: config.env.NETWORK }).inc(totalPassed)
// testFail.labels({ buildId: `${process.env.GITHUB_RUN_ID}`, chain: config.env.NETWORK }).inc(totalFailed)
// testPass.labels({ buildId: `${process.env.GITHUB_RUN_ID}`, chain: config.env.NETWORK }).inc(totalPassed)

register.registerMetric(testPass)
register.registerMetric(testFail)
register.registerMetric(suite)
// register.registerMetric(testPass)
// register.registerMetric(testFail)
// register.registerMetric(suite)

const gateway = new client.Pushgateway(`${process.env.CORE_PUSH_GATEWAY_URL}`, [], register)
await gateway
.push({ jobName: 'ui-automation' })
.then(({ resp, body }) => {
console.log(`Body: ${body}`)
console.log(`Response status: ${resp}`)
})
.catch((err: any) => {
console.log('err: ', err)
})
}
})
// const gateway = new client.Pushgateway(`${process.env.CORE_PUSH_GATEWAY_URL}`, [], register)
// await gateway
// .push({ jobName: 'ui-automation' })
// .then(({ resp, body }) => {
// console.log(`Body: ${body}`)
// console.log(`Response status: ${resp}`)
// })
// .catch((err: any) => {
// console.log('err: ', err)
// })
// }
// })
},
specPattern: 'cypress/e2e/specs/*.e2e.cy.ts',
},
Expand Down
23 changes: 23 additions & 0 deletions cypress/e2e/pages/header.po.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import {
CrossChainLocators,
HeaderLocators,
LimitOrderLocators,
NetworkLocators,
SwapPageLocators,
TokenCatalogLocators,
WalletLocators,
} from '../selectors/selectors.cy'

export interface myCallbackType<T> {
(myArgument: T): void
}
export const Header = {
connectWallet() {
cy.get(WalletLocators.btnConnectWallet).should('be.visible').click()
cy.connectWallet()
},

getStatusConnectedWallet() {
cy.get(WalletLocators.statusConnected, { timeout: 10000 }).should('be.visible')
},
}
51 changes: 51 additions & 0 deletions cypress/e2e/pages/pools-page.po.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import { PoolLocators } from '../selectors/selectors.cy'

export enum CustomRange {
FullRange = 'Full Range',
Safe = 'Safe',
Common = 'Common',
Expert = 'Expert',
}
export type FarmingRange = {
minPrice: string
maxPrice: string
}
export const PoolsPage = {
open(chain: string) {
cy.visit('/pools/' + chain)
},
searchByPoolAddress(poolAddress: string) {
cy.get(PoolLocators.txtSearchPool).clear().type(poolAddress)
cy.wait(2000)
},
selectCustomRange(range: CustomRange) {
cy.get('button').contains(range).click()
},
selectFarmingRange(farmingRange: FarmingRange) {
cy.get('[role=button]').contains('Farming Ranges').click()
cy.get(PoolLocators.txtPriceValue).eq(0).clear().type(farmingRange.minPrice)
cy.get(PoolLocators.txtPriceValue).eq(1).clear().type(farmingRange.maxPrice)
},
getCurrentPrice() {
return cy
.get(PoolLocators.lblCurrentPrice)
.invoke('text')
.then(currenPriceValue => {
return currenPriceValue
})
},
addLiquidity(poolAddress: string, amountIn: string, customRange?: CustomRange, farmingRange?: FarmingRange) {
PoolsPage.searchByPoolAddress(poolAddress)
cy.get('button').contains('Add Liquidity').click()
cy.get(PoolLocators.btnZapIn).click()
if (typeof customRange != 'undefined') {
PoolsPage.selectCustomRange(customRange)
}
if (typeof farmingRange != 'undefined') {
PoolsPage.selectFarmingRange(farmingRange)
}
cy.get(PoolLocators.txtAmountIn).type(amountIn)
cy.wait(20000)
cy.go('back')
},
}
Loading
Loading