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

Support Phantom wallet #698

Open
wants to merge 88 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 43 commits
Commits
Show all changes
88 commits
Select commit Hold shift + click to select a range
e3371b5
feat: Make sure onboarding a wallet works
maximgeerinck Feb 8, 2023
25b3b4c
chore: Add phantom selectors
maximgeerinck Feb 9, 2023
cdde119
chore: Adjust timings
maximgeerinck Feb 9, 2023
0d11954
chore: Phantom download
maximgeerinck Feb 14, 2023
1e43761
chore: Support phantom 3.6.0
maximgeerinck Mar 21, 2023
f7d1900
feat: Add multi provider support
maximgeerinck Mar 23, 2023
0878ca1
v4.0.0-alpha.1
maximgeerinck Mar 23, 2023
0523b94
chore: provider leftovers
maximgeerinck Mar 28, 2023
8798a22
chore: Add new phantom welcome screen
maximgeerinck Apr 3, 2023
8fea081
Add disconnectWalletFromDapp method and selectors
jenniferyen Apr 12, 2023
f796d90
wip
maximgeerinck Apr 19, 2023
be1b371
chore: Add more selectors + remove PAT
maximgeerinck Apr 26, 2023
cf7e85e
fix: wrong window names
maximgeerinck May 2, 2023
b70022e
chore: Add phantom crx downloader
maximgeerinck May 8, 2023
d690912
chore: update lockfile
maximgeerinck Jun 8, 2023
3fdd8e8
chore: align initialSetup with metamask
maximgeerinck Jun 9, 2023
37569e9
udpate
piotrjanosz Jun 20, 2023
17b2bf2
fix
piotrjanosz Jun 20, 2023
37a5fb8
Merge pull request #7 from phantom/piotr/dimiss-rebrand-modal
alecmarcus Jun 20, 2023
c469637
Revert "fix: update button / dismiss welcome flow"
alecmarcus Jun 20, 2023
3e881db
Merge pull request #8 from phantom/revert-7-piotr/dimiss-rebrand-modal
alecmarcus Jun 20, 2023
7f3ca61
chore: Add new connected sites
maximgeerinck Jun 21, 2023
d552f0e
chore: add announcement check
maximgeerinck Jun 21, 2023
aab09f8
chore: missing provider
maximgeerinck Jun 27, 2023
2ab3daf
chore: use correct task
maximgeerinck Jun 27, 2023
e315768
rejectTransaction;
laamia Jul 3, 2023
307292f
update button selectors
laamia Jul 3, 2023
d977457
update button selectors
laamia Jul 3, 2023
a95e06a
Merge pull request #9 from phantom/laamia/reject
laamia Jul 3, 2023
cd72388
release(4.0.0-alpha.26)
maximgeerinck Jul 10, 2023
9b373aa
Add selector for developerSettingsRow
laamia Jul 11, 2023
7039e10
typo
laamia Jul 11, 2023
5321d0c
Merge pull request #10 from phantom/laamia/dev-settings
laamia Jul 13, 2023
3034c95
updated importing wallet to match shorter onboarding changes
piotrjanosz Jul 24, 2023
4eead39
change
piotrjanosz Jul 27, 2023
8cf097e
Merge pull request #11 from phantom/piotr/update-onboarding
piotrjanosz Jul 27, 2023
e9b9b06
chore: bump version
maximgeerinck Jul 28, 2023
249c8c4
fix
piotrjanosz Aug 2, 2023
bd21569
Merge pull request #12 from phantom/piotr/remove-rebrand-announcement
piotrjanosz Aug 7, 2023
affae02
Merge remote-tracking branch 'upstream/dev' into dev
maximgeerinck Sep 19, 2023
a08518f
wip
maximgeerinck Sep 19, 2023
f30bbfd
chore: rebase fixes
maximgeerinck Sep 20, 2023
26bd100
chore: Update metamask v11
maximgeerinck Sep 20, 2023
13836fe
feat: Add switch account
rafinskipg Jan 25, 2024
555ffbd
Use selectors
rafinskipg Jan 25, 2024
8ed316f
Merge pull request #13 from phantom/feat/switch-accounts
rafinskipg Jan 25, 2024
fc05644
release: alpha.30
maximgeerinck Jan 26, 2024
3f469d1
Fix preferences
rafinskipg Jan 26, 2024
d8c4490
Merge pull request #14 from phantom/fix/preferences
maximgeerinck Jan 26, 2024
2927df1
release: alpha-31
maximgeerinck Jan 26, 2024
c2b7e67
fix: Flaky continue button
maximgeerinck Mar 1, 2024
9875fbb
fix: unlock
maximgeerinck Mar 30, 2024
05237d7
fix: interstitial login
maximgeerinck Apr 2, 2024
6ba9812
fix: remove pause
maximgeerinck May 24, 2024
0a0428a
Merge branch 'dev' of github.com:Synthetixio/synpress into Synthetixi…
maximgeerinck Jul 19, 2024
72931f9
Merge pull request #16 from phantom/Synthetixio-dev
maximgeerinck Jul 19, 2024
ae8e4d0
chore: update release
maximgeerinck Jul 19, 2024
4f15507
feat: Add go to experimental settings
maximgeerinck Aug 1, 2024
9e81d3d
fix: remove export from phantom-js
0xproflupin Aug 5, 2024
057065b
add export for backToMainFromSettings
0xproflupin Aug 5, 2024
249501e
Merge pull request #17 from phantom/anvit/fix-phantom-export-syntax
0xproflupin Aug 5, 2024
3f7e10b
chore: release alpha 39
maximgeerinck Aug 5, 2024
c29a491
fix: element changes
maximgeerinck Sep 3, 2024
ccefc15
release: alpha 40
maximgeerinck Sep 3, 2024
f0ed79e
v4.0.0-alpha.41
maximgeerinck Sep 3, 2024
d91ff3d
add a wait for get started button
jkadamczyk Sep 5, 2024
54de943
Merge pull request #18 from phantom/kuba/add-wait-for-get-started
maximgeerinck Sep 5, 2024
c1b5d70
v4.0.0-alpha.42
maximgeerinck Sep 5, 2024
b4577ff
fix: get started screen gets pushed twice
jkadamczyk Sep 6, 2024
a45ccfe
v4.0.0-alpha.43
maximgeerinck Sep 6, 2024
b5c3a72
increase timeout by 2s
jkadamczyk Sep 6, 2024
ebd2089
v4.0.0-alpha.44
maximgeerinck Sep 6, 2024
b7130e2
fix: wait for text to appear befoire waiting to click
jkadamczyk Sep 6, 2024
ecff4cd
v4.0.0-alpha.45
maximgeerinck Sep 6, 2024
e7e112f
fix: increase timeout before pressing get started to 2s
jkadamczyk Sep 6, 2024
2198d0c
fix: missing testIds in new onboarding start page
jkadamczyk Sep 16, 2024
a56b751
v4.0.0-alpha.46
maximgeerinck Sep 16, 2024
f0b86c6
fix: another missing testID
jkadamczyk Sep 16, 2024
48aaac2
v4.0.0-alpha.47
maximgeerinck Sep 16, 2024
14b1b11
chore: Use Yarn
maximgeerinck Sep 18, 2024
0d1d314
chore: bump version
jkadamczyk Sep 18, 2024
6eb637e
make sure we use correct .gitignore
jkadamczyk Sep 20, 2024
7b12abf
remove install state
jkadamczyk Sep 20, 2024
09006d2
bump version and add logs
jkadamczyk Sep 20, 2024
598a982
test new changes
jkadamczyk Oct 3, 2024
c72df9a
bump version
jkadamczyk Oct 3, 2024
7a9f346
revert logs
jkadamczyk Oct 3, 2024
387bbd3
bump version
jkadamczyk Oct 3, 2024
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
455 changes: 339 additions & 116 deletions commands/metamask.js

Large diffs are not rendered by default.

565 changes: 565 additions & 0 deletions commands/phantom.js

Large diffs are not rendered by default.

439 changes: 300 additions & 139 deletions commands/playwright.js

Large diffs are not rendered by default.

62 changes: 46 additions & 16 deletions helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const packageJson = require('./package.json');
const chains = require('viem/chains');
const appRoot = require('app-root-path');
const os = require('os');
const unzipCrx = require('unzip-crx-3');

let currentNetwork = chains.mainnet;
// list of added networks to metamask
Expand Down Expand Up @@ -193,15 +194,38 @@ module.exports = {
);
}
},
async download(url, destination) {
getPhantomReleases: async () => {
const PHANTOM_URL = 'https://crx-backup.phantom.dev/latest.crx';

return {
filename: 'phantom-chrome-latest',
downloadUrl: PHANTOM_URL,
tagName: 'phantom-chrome-latest',
};
},
download: async (provider, url, destination) => {
try {
log(
`Trying to download and extract file from: ${url} to following path: ${destination}`,
);

if (provider === 'phantom') {
await download(url, destination, {
headers: {
Accept: 'application/octet-stream',
},
});
await unzipCrx(`${destination}/latest.crx`, destination);
return;
}

if (process.env.GH_USERNAME && process.env.GH_PAT) {
await download(url, destination, {
extract: true,
auth: `${process.env.GH_USERNAME}:${process.env.GH_PAT}`,
headers: {
Accept: 'application/octet-stream',
},
});
} else {
await download(url, destination, {
Expand All @@ -210,37 +234,43 @@ module.exports = {
}
} catch (e) {
throw new Error(
`[download] Unable to download metamask release from: ${url} to: ${destination} with following error:\n${e}`,
`[download] Unable to download provider release from: ${url} to: ${destination} with following error:\n${e}`,
);
}
},
async prepareMetamask(version) {
const release = await module.exports.getMetamaskReleases(version);

prepareProvider: async (provider, version) => {
const release =
provider === 'phantom'
? await module.exports.getPhantomReleases(version)
: await module.exports.getMetamaskReleases(version);
let downloadsDirectory;
if (os.platform() === 'win32') {
downloadsDirectory = appRoot.resolve('/node_modules');
} else {
downloadsDirectory = path.resolve(__dirname, 'downloads');
}

await module.exports.createDirIfNotExist(downloadsDirectory);
const metamaskDirectory = path.join(downloadsDirectory, release.tagName);
const metamaskDirectoryExists =
await module.exports.checkDirOrFileExist(metamaskDirectory);
const metamaskManifestFilePath = path.join(
const providerDirectory = path.join(downloadsDirectory, release.tagName);
const providerkDirectoryExists = await module.exports.checkDirOrFileExist(
providerDirectory,
);
const providerManifestFilePath = path.join(
downloadsDirectory,
release.tagName,
'manifest.json',
);
const metamaskManifestFileExists = await module.exports.checkDirOrFileExist(
metamaskManifestFilePath,
const providerManifestFileExists = await module.exports.checkDirOrFileExist(
providerManifestFilePath,
);
if (!metamaskDirectoryExists && !metamaskManifestFileExists) {
await module.exports.download(release.downloadUrl, metamaskDirectory);
if (!providerkDirectoryExists && !providerManifestFileExists) {
await module.exports.download(
provider,
release.downloadUrl,
providerDirectory,
);
} else {
log('Metamask is already downloaded');
log('provider is already downloaded');
}
return metamaskDirectory;
return providerDirectory;
},
};
8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@synthetixio/synpress",
"version": "3.7.2-beta.6",
"name": "@phantom/synpress",
maximgeerinck marked this conversation as resolved.
Show resolved Hide resolved
"version": "4.0.0-alpha.28",
"packageManager": "[email protected]",
"description": "Synpress is e2e testing framework based around Cypress.io & playwright with included MetaMask support. Test your dapps with ease.",
"keywords": [
Expand Down Expand Up @@ -81,6 +81,7 @@
"get-port": "^7.0.0",
"node-fetch": "^2.6.1",
"underscore": "^1.13.6",
"unzip-crx-3": "^0.2.0",
"viem": "^1.6.0",
"wait-on": "^7.0.1"
},
Expand Down Expand Up @@ -114,6 +115,9 @@
"ansi-regex": "5.0.1",
"@testing-library/dom": "8.20.0"
},
"overrides": {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we override lodash here?

Copy link
Author

@maximgeerinck maximgeerinck Sep 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there were some instances were an insecure version of lodash is used in dependencies, this overrides it

"lodash@<4.17.20": "4.17.20"
},
"engines": {
"node": ">=14"
},
Expand Down
5 changes: 5 additions & 0 deletions pages/metamask/first-time-flow-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,16 @@ const app = '#app-content .app';
const onboardingWelcomePage = `${onboardingFlow} [data-testid="onboarding-welcome"]`;
const importWalletButton = `${onboardingWelcomePage} [data-testid="onboarding-import-wallet"]`;
const createWalletButton = `${onboardingWelcomePage} [data-testid="onboarding-create-wallet"]`;
const acceptTermsCheckbox = `[data-testid="onboarding-terms-checkbox"]`;
const agreeMetricsButton = `[data-testid="metametrics-i-agree"]`;

module.exports.onboardingWelcomePageElements = {
app,
onboardingWelcomePage,
importWalletButton,
createWalletButton,
acceptTermsCheckbox,
agreeMetricsButton,
};

const firstTimeFlowImportPage = `${onboardingFlow} [data-testid="import-srp"]`;
Expand Down
3 changes: 3 additions & 0 deletions pages/metamask/main-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,13 @@ const accountMenu = {
createAccountButton: '.account-menu__item--clickable:nth-child(6)',
importAccountButton: '.account-menu__item--clickable:nth-child(7)',
settingsButton: '.account-menu__item--clickable:nth-child(11)',
lockButton: '.account_menu__lock-button',
};

const optionsMenu = {
button: '[data-testid=account-options-menu-button]',
accountDetailsButton: '[data-testid="account-options-menu__account-details"]',
accountDetailsButtonV11: '[data-testid="account-list-menu-details"]',
connectedSitesButton: '[data-testid="account-options-menu__connected-sites"]',
};

Expand All @@ -90,6 +92,7 @@ const connectedSites = {
const accountModalSelector = '.account-modal';
const accountModal = {
walletAddressInput: `${accountModalSelector} .qr-code__address`,
walletAddressInputV11: `[data-testid="address-copy-button-text"]`,
closeButton: '.account-modal__close',
};

Expand Down
12 changes: 12 additions & 0 deletions pages/phantom/confirmation-page.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const confirmationPage = '.confirmation-page';
const confirmationPageFooter = `${confirmationPage} .confirmation-footer`;
const footer = {
footer: confirmationPageFooter,
cancelButton: `${confirmationPageFooter} .btn-secondary`,
approveButton: `${confirmationPageFooter} .btn-primary`,
};

module.exports.confirmationPageElements = {
confirmationPage,
footer,
};
84 changes: 84 additions & 0 deletions pages/phantom/first-time-flow-page.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
const app = '#root';
const welcomePage = '#root';
const confirmButton = `${welcomePage} .first-time-flow__button`;
module.exports.welcomePageElements = {
app,
welcomePage,
confirmButton,
};

const metametricsPage = '.metametrics-opt-in';
const optOutAnalyticsButton = `${metametricsPage} [data-testid="page-container-footer-cancel"]`;
module.exports.metametricsPageElements = {
metametricsPage,
optOutAnalyticsButton,
};

const firstTimeFlowPage = '.first-time-flow';
const importWalletButton = `[data-testid="import-recovery-phrase-button"]`;
const createWalletButton = `${firstTimeFlowPage} [data-testid="create-wallet-button"]`;
module.exports.firstTimeFlowPageElements = {
firstTimeFlowPage,
importWalletButton,
createWalletButton,
};

const firstTimeFlowImportPage = '.first-time-flow__import';
const newVaultForm = `${firstTimeFlowImportPage} .create-new-vault__form`;
const secretWordsInput = number =>
`[data-testid="secret-recovery-phrase-word-input-${number}"]`;
const confirmWordsButton = `[data-testid="onboarding-form-submit-button"]`;
const passwordInput = `[data-testid="onboarding-form-password-input"]`;
const confirmPasswordInput = `[data-testid="onboarding-form-confirm-password-input"]`;
const termsCheckbox = `[data-testid="onboarding-form-terms-of-service-checkbox"]`;
const continueAfterPasswordButton =
'[data-testid="onboarding-form-submit-button"]';
const getStartedButton = '[data-testid="onboarding-form-submit-button"]';
const importButton = `${newVaultForm} .create-new-vault__submit-button`;

module.exports.firstTimeFlowImportPageElements = {
firstTimeFlowImportPage,
newVaultForm,
secretWordsInput,
passwordInput,
confirmPasswordInput,
termsCheckbox,
importButton,
confirmWordsButton,
continueAfterPasswordButton,
getStartedButton,
};

const firstTimeFlowCreatePage = '.first-time-flow';
const newPasswordInput = `${firstTimeFlowCreatePage} [data-testid="create-password"]`;
const confirmNewPasswordInput = `${firstTimeFlowCreatePage} [data-testid="confirm-password"]`;
const newSignupCheckbox = `${firstTimeFlowCreatePage} .first-time-flow__checkbox`;
const createButton = `${firstTimeFlowCreatePage} .first-time-flow__button`;
module.exports.firstTimeFlowCreatePagePageElements = {
firstTimeFlowCreatePage,
newPasswordInput,
confirmNewPasswordInput,
newSignupCheckbox,
createButton,
};

const secureYourWalletPage = '[data-testid="seed-phrase-intro"]';
const nextButton = `${secureYourWalletPage} button`;
module.exports.secureYourWalletPageElements = {
secureYourWalletPage,
nextButton,
};

const revealSeedPage = '[data-testid="reveal-seed-phrase"]';
const remindLaterButton = `${revealSeedPage} .first-time-flow__button`;
module.exports.revealSeedPageElements = {
revealSeedPage,
remindLaterButton,
};

const endOfFlowPage = '[data-testid="end-of-flow"]';
const allDoneButton = `${endOfFlowPage} [data-testid="EOF-complete-button"]`;
module.exports.endOfFlowPageElements = {
endOfFlowPage,
allDoneButton,
};
Loading