Skip to content

Commit

Permalink
Resolve #1594 [Test] Reduce number of infura calls
Browse files Browse the repository at this point in the history
  • Loading branch information
timothywangdev committed May 13, 2020
1 parent 3d7da14 commit 514a938
Show file tree
Hide file tree
Showing 21 changed files with 714 additions and 49 deletions.
2 changes: 1 addition & 1 deletion jest-puppeteer.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module.exports = {
It takes the max resolution then.
*/
defaultViewport: null,
args: ['--no-sandbox', '--disable-web-security', '--disable-gpu', '--disable-setuid-sandbox']
args: ['--no-sandbox', '--disable-web-security', '--disable-gpu', '--disable-setuid-sandbox', '--unlimited-storage', '--disable-dev-shm-usage']
},
browser: 'chromium',
server: process.env.E2E_TEST_START_SERVER === 'true' && {
Expand Down
2 changes: 2 additions & 0 deletions src/components/MicroComponents/Disconnect.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ const Disconnect = (props) => {
return true
}
return false
}, {
interval: 10000 // 10 seconds
})
setAllowanceTxHash(txHash)
}
Expand Down
12 changes: 12 additions & 0 deletions src/tests/e2e/accountManagement.test.e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ const reduxTracker = new ReduxTracker()
describe('Account Management page tests', () => {
beforeAll(async () => {
await resetUserDefault()

// setup interceptor
await requestInterceptor.setRequestInterception(true)
requestInterceptor.byPass({
platform: 'chainsfrApi',
method: 'GET_CRYPTO_ACCOUNTS'
})

await page.goto(process.env.E2E_TEST_URL)
// login to app
const loginPage = new LoginPage()
Expand All @@ -19,6 +27,10 @@ describe('Account Management page tests', () => {
)
}, timeout)

afterAll(async () => {
requestInterceptor.showStats()
})

beforeEach(async () => {
await Promise.all([
reduxTracker.waitFor(
Expand Down
39 changes: 39 additions & 0 deletions src/tests/e2e/cancelTransfer.test.e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ describe('Cancel transfer tests', () => {

beforeAll(async () => {
await resetUserDefault()

// setup interceptor
await requestInterceptor.setRequestInterception(true)

await page.goto(`${process.env.E2E_TEST_URL}`)
// login to app
const loginPage = new LoginPage()
Expand All @@ -52,6 +56,7 @@ describe('Cancel transfer tests', () => {
}, timeout)

afterAll(async () => {
requestInterceptor.showStats()
await jestPuppeteer.resetBrowser()
})

Expand Down Expand Up @@ -125,6 +130,11 @@ describe('Cancel transfer tests', () => {

const { transferId, idx } = pendingReceive[`${walletType}_${cryptoType}`]
log.info(`Transfer Id: ${transferId}`)
requestInterceptor.byPass({
platform: 'chainsfrApi',
method: 'GET_TRANSFER'
})

while (true) {
await page.waitFor(15000) // 15 seconds
var transferData = await getTransfer({ transferId: transferId })
Expand All @@ -138,6 +148,10 @@ describe('Cancel transfer tests', () => {
log.info('Send tx confirmed', sendTxState)

// back to home page
requestInterceptor.byPass({
platform: 'chainsfrApi',
method: 'BATCH_GET'
})
await page.goto(process.env.E2E_TEST_URL, {
waitUntil: 'networkidle0'
})
Expand All @@ -146,6 +160,11 @@ describe('Cancel transfer tests', () => {
const itemIdx = numPendingReceive - idx - 1
await landingPage.expandTxHistoryItem(itemIdx)

requestInterceptor.byPass({
platform: 'chainsfrApi',
method: 'GET_TRANSFER'
})

const cancelPageTab = await getNewPopupPage(browser, async () => {
await landingPage.cancelTx(itemIdx)
})
Expand Down Expand Up @@ -186,6 +205,15 @@ describe('Cancel transfer tests', () => {
it(
'Send DAI from metamask',
async () => {
requestInterceptor.byPass({
platform: 'ethereum',
method: 'eth_call',
funcSig: 'allowance',
addresses: [
'0xd3ced3b16c8977ed0e345d162d982b899e978588',
'0xdccf3b5910e936b7bfda447f10530713c2420c5d'
]
})
const platformType = 'ethereum'

// reset metamask dai allowance
Expand All @@ -205,6 +233,7 @@ describe('Cancel transfer tests', () => {
})

await sendTx('metamask', 'dai')
requestInterceptor.byPass(null)
},
timeout
)
Expand Down Expand Up @@ -246,6 +275,15 @@ describe('Cancel transfer tests', () => {
it(
'Send DAI from drive wallet',
async () => {
requestInterceptor.byPass({
platform: 'ethereum',
method: 'eth_call',
funcSig: 'allowance',
addresses: [
'0x259ec51efaa03c33787752e5a99becbf7f8526c4',
'0xdccf3b5910e936b7bfda447f10530713c2420c5d'
]
})
const platformType = 'ethereum'

// reset drive dai allowance
Expand All @@ -265,6 +303,7 @@ describe('Cancel transfer tests', () => {
})

await sendTx('drive', 'dai')
requestInterceptor.byPass(null)
},
timeout
)
Expand Down
5 changes: 5 additions & 0 deletions src/tests/e2e/directTransferForm.test.e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ const timeout = 180000
describe('Direct transfer form tests', () => {
beforeAll(async () => {
await resetUserDefault()

// setup interceptor
await requestInterceptor.setRequestInterception(true)

await page.goto(process.env.E2E_TEST_URL)
// login to app
const loginPage = new LoginPage()
Expand All @@ -19,6 +23,7 @@ describe('Direct transfer form tests', () => {
}, timeout)

afterAll(async () => {
requestInterceptor.showStats()
await jestPuppeteer.resetBrowser()
})

Expand Down
5 changes: 5 additions & 0 deletions src/tests/e2e/directTransferReview.test.e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ function aboutEqual (valueA, valueB, tolerance = 0.05) {
describe('Direct transfer review tests', () => {
beforeAll(async () => {
await resetUserDefault()

// setup interceptor
await requestInterceptor.setRequestInterception(true)

await page.goto(process.env.E2E_TEST_URL)
// login to app
const loginPage = new LoginPage()
Expand All @@ -25,6 +29,7 @@ describe('Direct transfer review tests', () => {
}, timeout)

afterAll(async () => {
requestInterceptor.showStats()
await jestPuppeteer.resetBrowser()
})

Expand Down
33 changes: 33 additions & 0 deletions src/tests/e2e/directTransferWalletAuth.test.e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ describe('Direct Transfer Auth Tests', () => {

beforeAll(async () => {
await resetUserDefault()

await requestInterceptor.setRequestInterception(true)

await page.goto(`${process.env.E2E_TEST_URL}`)
// login to app
const loginPage = new LoginPage()
Expand All @@ -55,6 +58,14 @@ describe('Direct Transfer Auth Tests', () => {
}, timeout)

beforeEach(async () => {
if (['Send BTC from drive wallet to ledger wallet'].includes(jasmine['currentTest'].description)) {
requestInterceptor.byPass({
platform: 'bitcoin',
method: 'txs',
})
} else {
requestInterceptor.byPass(null)
}
await page.goto(`${process.env.E2E_TEST_URL}/directTransfer`)
})

Expand Down Expand Up @@ -84,6 +95,7 @@ describe('Direct Transfer Auth Tests', () => {
}
)

requestInterceptor.showStats()
await jestPuppeteer.resetBrowser()
})

Expand Down Expand Up @@ -157,6 +169,16 @@ describe('Direct Transfer Auth Tests', () => {
test(
'Send DAI from drive wallet to metamask wallet',
async () => {
requestInterceptor.byPass({
platform: 'ethereum',
method: 'eth_call',
funcSig: 'allowance',
addresses: [
'0x259EC51eFaA03c33787752E5a99BeCBF7F8526c4',
'0xdccf3b5910e936b7bfda447f10530713c2420c5d'
]
})

const CRYPTO_AMOUNT = '1'
await dtPage.fillForm({
...FORM_BASE,
Expand Down Expand Up @@ -219,6 +241,7 @@ describe('Direct Transfer Auth Tests', () => {
test(
'Send BTC from drive wallet to ledger wallet',
async () => {

const CRYPTO_AMOUNT = '0.001'
await dtPage.fillForm({
...FORM_BASE,
Expand Down Expand Up @@ -339,6 +362,16 @@ describe('Direct Transfer Auth Tests', () => {
test(
'Send DAI from metamask wallet to drive wallet',
async () => {
requestInterceptor.byPass({
platform: 'ethereum',
method: 'eth_call',
funcSig: 'allowance',
addresses: [
'0xd3ced3b16c8977ed0e345d162d982b899e978588',
'0xdccf3b5910e936b7bfda447f10530713c2420c5d'
]
})

const CRYPTO_AMOUNT = '1'

await dtPage.dispatchFormActions('transferIn')
Expand Down
14 changes: 8 additions & 6 deletions src/tests/e2e/emailTransferForm.test.e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ async function fillForm (formInfo) {
describe('Email transfer form tests', () => {
beforeAll(async () => {
await resetUserDefault()

// setup interceptor
await requestInterceptor.setRequestInterception(true)

await page.goto(`${process.env.E2E_TEST_URL}`)
// login to app
const loginPage = new LoginPage()
Expand All @@ -80,15 +84,13 @@ describe('Email transfer form tests', () => {
}, timeout)

beforeEach(async () => {
await Promise.all([
page.waitForNavigation({
waitUntil: 'networkidle0'
}),
page.goto(`${process.env.E2E_TEST_URL}/send`)
])
await page.goto(`${process.env.E2E_TEST_URL}/send`, {
waitUntil: 'networkidle0'
})
})

afterAll(async () => {
requestInterceptor.showStats()
await jestPuppeteer.resetBrowser()
})

Expand Down
17 changes: 6 additions & 11 deletions src/tests/e2e/emailTransferFormEntryPoint.test.e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ const timeout = 180000
describe('Email transfer form entry point tests', () => {
beforeAll(async () => {
await resetUserDefault()

// setup interceptor
await requestInterceptor.setRequestInterception(true)

await page.goto(process.env.E2E_TEST_URL)
// login to app
const loginPage = new LoginPage()
Expand All @@ -23,13 +27,10 @@ describe('Email transfer form entry point tests', () => {
}, timeout)

afterAll(async () => {
requestInterceptor.showStats()
await jestPuppeteer.resetBrowser()
})

afterEach(async () => {
await page.goto(process.env.E2E_TEST_URL)
})

it(
'Landing page entry',
async () => {
Expand All @@ -46,13 +47,7 @@ describe('Email transfer form entry point tests', () => {
it(
'Recipients page entry',
async () => {
await Promise.all([
page.waitForNavigation({
waitUntil: 'networkidle0'
}),
page.goto(`${process.env.E2E_TEST_URL}/contacts`)
])
// await page.waitFor(1000)
await page.goto(`${process.env.E2E_TEST_URL}/contacts`, { waitUntil: 'networkidle0' })
const recipientPage = new RecipientPage()
const recipients = await recipientPage.getRecipientList()
let recipient = {}
Expand Down
17 changes: 11 additions & 6 deletions src/tests/e2e/emailTransferReview.test.e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ async function goToReview (formInfo) {
describe('Email transfer review tests', () => {
beforeAll(async () => {
await resetUserDefault()

// setup interceptor
await requestInterceptor.setRequestInterception(true)

await page.goto(process.env.E2E_TEST_URL)
// login to app
const loginPage = new LoginPage()
Expand All @@ -72,13 +76,14 @@ describe('Email transfer review tests', () => {
)
}, timeout)

afterAll(async () => {
requestInterceptor.showStats()
})

beforeEach(async () => {
await Promise.all([
page.waitForNavigation({
waitUntil: 'networkidle0'
}),
page.goto(`${process.env.E2E_TEST_URL}/send`)
])
await page.goto(`${process.env.E2E_TEST_URL}/send`, {
waitUntil: 'networkidle0'
})
})

it(
Expand Down

0 comments on commit 514a938

Please sign in to comment.