-
Notifications
You must be signed in to change notification settings - Fork 5
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
Getting Wallet Address #17
Changes from all commits
6009faa
5590696
9567506
682e71d
9ab2db4
9ff28d3
1638199
7c1c89e
8715041
157131c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,13 +4,17 @@ const { onboardingElements } = require('../pages/keplr/first-time-flow-page'); | |
const { | ||
notificationPageElements, | ||
} = require('../pages/keplr/notification-page'); | ||
const clipboardy = require('clipboardy'); | ||
|
||
|
||
let extensionId; | ||
let extensionVersion; | ||
let registrationUrl; | ||
let permissionsUrl; | ||
let popupUrl; | ||
let walletsPageUrl; | ||
let switchBackToCypressWindow; | ||
let walletAddress; | ||
|
||
const keplr = { | ||
async resetState() { | ||
|
@@ -19,15 +23,22 @@ const keplr = { | |
extensionVersion = undefined; | ||
registrationUrl = undefined; | ||
permissionsUrl = undefined; | ||
popupUrl = undefined; | ||
walletAddress = undefined; | ||
walletsPageUrl = undefined; | ||
}, | ||
walletAddress: () => { | ||
return walletAddress; | ||
|
||
}, | ||
extensionId: () => { | ||
return extensionId; | ||
}, | ||
extensionUrls: () => { | ||
return { | ||
registrationUrl, | ||
permissionsUrl, | ||
popupUrl, | ||
}; | ||
}, | ||
async goTo(url) { | ||
|
@@ -43,6 +54,9 @@ const keplr = { | |
async goToPermissions() { | ||
await module.exports.goTo(permissionsUrl); | ||
}, | ||
async goToHome() { | ||
await module.exports.goTo(popupUrl); | ||
}, | ||
async goToWalletsPage() { | ||
await module.exports.goTo(walletsPageUrl); | ||
}, | ||
|
@@ -60,13 +74,15 @@ const keplr = { | |
extensionVersion = keplrExtensionData.version; | ||
registrationUrl = `chrome-extension://${extensionId}/register.html`; | ||
permissionsUrl = `chrome-extension://${extensionId}/popup.html#/setting/security/permission`; | ||
popupUrl = `chrome-extension://${extensionId}/popup.html`; | ||
walletsPageUrl = `chrome-extension://${extensionId}/popup.html#/wallet/select`; | ||
|
||
return { | ||
extensionId, | ||
extensionVersion, | ||
registrationUrl, | ||
permissionsUrl, | ||
popupUrl, | ||
walletsPageUrl, | ||
}; | ||
}, | ||
|
@@ -153,7 +169,6 @@ const keplr = { | |
await playwright.keplrWindow(), | ||
); | ||
|
||
await playwright.switchToCypressWindow(); | ||
return true; | ||
}, | ||
async importWalletWithPhrase(secretWords) { | ||
|
@@ -224,6 +239,17 @@ const keplr = { | |
return true; | ||
}, | ||
|
||
async getWalletAddress() { | ||
await playwright.switchToKeplrWindow(); | ||
await module.exports.goToHome(); | ||
const page = playwright.keplrWindow(); | ||
await playwright.waitAndClickByText(notificationPageElements.copyAddress); | ||
await page.click(notificationPageElements.copyWalletAddressSelector); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a temp. I'll update it according to the appropriate helper method after adding implementation for selecting chain in our import wallet flow. Btw, you tried it with |
||
walletAddress = clipboardy.readSync(); | ||
await playwright.switchToCypressWindow(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've initially tried to get value from the clipboard by executing a script through
I tried a few more things which mainly involved executing a script through |
||
return walletAddress; | ||
}, | ||
|
||
async initialSetup( | ||
playwrightInstance, | ||
{ secretWordsOrPrivateKey, password, newAccount, walletName }, | ||
|
@@ -235,17 +261,15 @@ const keplr = { | |
} | ||
|
||
await playwright.assignWindows(); | ||
if (!playwright.isKeplrWindowActive()) { | ||
await playwright.switchToKeplrWindow(); | ||
} | ||
playwright.assignActiveTabName('keplr'); | ||
await playwright.switchToKeplrWindow(); | ||
await module.exports.getExtensionDetails(); | ||
await module.exports.importWallet( | ||
secretWordsOrPrivateKey, | ||
password, | ||
newAccount, | ||
walletName, | ||
); | ||
await playwright.switchToCypressWindow(); | ||
}, | ||
|
||
async switchWallet({ walletName }) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,6 +44,9 @@ module.exports = { | |
isCypressWindowActive() { | ||
return activeTabName === 'cypress'; | ||
}, | ||
activeTabName() { | ||
return activeTabName; | ||
}, | ||
async switchToKeplrWindow() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not being used but I feel it's still handy and can be used in the future. It was helpful when I was debugging an issue in |
||
await keplrWindow.bringToFront(); | ||
module.exports.assignActiveTabName('keplr'); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
const approveButton = `button`; | ||
const copyAddress = 'Copy Address'; | ||
const copyWalletAddressSelector = 'div.sc-dkzDqf div.sc-hKMtZM.sc-kDDrLX.cyoEAq.dkJSBQ' | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. At the moment, using a selector to copy cosmos address. This is temporary as I have to add an implementation for selecting agoric chain in our |
||
module.exports.notificationPageElements = { | ||
approveButton, | ||
copyAddress, | ||
copyWalletAddressSelector | ||
}; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
/* eslint-disable ui-testing/no-disabled-tests */ | ||
|
||
describe('Keplr', () => { | ||
context('Test commands', () => { | ||
it(`should complete Keplr setup by importing an existing wallet using 24 word phrase`, () => { | ||
|
@@ -85,5 +86,11 @@ describe('Keplr', () => { | |
expect(taskCompleted).to.be.true; | ||
}); | ||
}); | ||
|
||
it(`should get wallet address`, () => { | ||
cy.getWalletAddress().then(walletAddress => { | ||
expect(walletAddress.length).to.be.equal(45); | ||
}); | ||
}); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. At the moment, validating it based on the length. Because cosmos address seems to change in subsequent iterations of running tests. But once I add select chain implementation in our There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why not get the agoriclocal address instead? that is always constant There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, that chain still has to be selected for its address to be visible when collecting wallet addresses. For the implementation I'm referring to, I am planning to select agoric as well as agoric-local in it. |
||
}); | ||
}); |
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.
rename to 'dashbaordUrl' or 'homeUrl'. it more closely resemble the intended purpose of the page
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.
You're right. These names are more intention revealing. But I'm noticing that
popup.html
has dynamic content. For example, it's the same URL when we encounter a notification. I feel we should stick withpopupUrl
as a generic