-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed cypress tests dapps.cy.ts and transfer.cy.ts
- Loading branch information
1 parent
fbdc8b4
commit 7d24341
Showing
5 changed files
with
148 additions
and
132 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,72 +1,73 @@ | ||
import { defineConfig } from "cypress" | ||
import { ImapFlow } from 'imapflow' | ||
import { defineConfig } from "cypress"; | ||
import { ImapFlow } from 'imapflow'; | ||
|
||
// Cypress doesn't work very well with cross-origin testing (different domains). | ||
// In order to test dApp connection, we need to get WalletConnect uri from the dApp page and pass it to the Wallet. | ||
// Because of that - we have this variable here, and we set/get its value through setWcUrl/getWcUrl tasks in the tests. | ||
let wcUrl | ||
let wcUrl; | ||
|
||
export default defineConfig({ | ||
e2e: { | ||
baseUrl: 'http://localhost:3000/#', | ||
baseUrl: 'http://localhost:3000/', | ||
experimentalSessionAndOrigin: true, | ||
includeShadowDom: true, | ||
// macbook 13 | ||
viewportWidth: 1280, | ||
viewportHeight: 800, | ||
setupNodeEvents(on, config) { | ||
on("task", { | ||
"get-confirm-code": async () => { | ||
const [{ email }] = config.env.ACCOUNTS | ||
const [{ email }] = config.env.ACCOUNTS; | ||
|
||
const client = new ImapFlow({ | ||
host: 'mail.devlabs.bg', | ||
port: 993, | ||
secure: true, | ||
auth: { | ||
user: email, | ||
pass: config.env.EMAIL_PASSWORD | ||
pass: config.env.EMAIL_PASSWORD, | ||
}, | ||
logger: false | ||
}) | ||
logger: false, | ||
}); | ||
|
||
return new Promise( async resolve => { | ||
return new Promise(async resolve => { | ||
// Wait until client connects and authorizes | ||
await client.connect() | ||
await client.connect(); | ||
|
||
await client.mailboxOpen('INBOX') | ||
await client.mailboxOpen('INBOX'); | ||
|
||
// It returns all the emails' sequences (email index) matching the search criteria | ||
const confirmEmails = await client.search({ | ||
from: '[email protected]', | ||
subject: 'Transaction confirmation code', | ||
}) | ||
}); | ||
|
||
// Most recent email is the email having the highest sequence | ||
const mostRecentConfEmail = Math.max(...confirmEmails) | ||
const mostRecentConfEmail = Math.max(...confirmEmails); | ||
|
||
// Get most recent email content | ||
const { content } = await client.download(mostRecentConfEmail) | ||
const { content } = await client.download(mostRecentConfEmail); | ||
|
||
content.on('data', chunk => { | ||
const body = chunk.toString() | ||
const body = chunk.toString(); | ||
// Extract the code from the following msg 'Please copy this confirmation code to sign it: {code}.' | ||
const code = body.match(/Please copy this confirmation code to sign it: (.*)\./)[1] | ||
const code = body.match(/Please copy this confirmation code to sign it: (.*)\./)[1]; | ||
|
||
resolve(code) | ||
}) | ||
resolve(code); | ||
}); | ||
|
||
// Log out and close connection | ||
await client.logout() | ||
}) | ||
await client.logout(); | ||
}); | ||
}, | ||
setWcUrl: url => { | ||
return (wcUrl = url) | ||
return (wcUrl = url); | ||
}, | ||
|
||
getWcUrl: () => { | ||
return wcUrl; | ||
} | ||
}, | ||
}); | ||
}, | ||
}, | ||
}); | ||
}); |
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
Oops, something went wrong.