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

chore(deps): Bump yaml from 2.2.1 to 2.2.2 #4

Open
wants to merge 16 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
380 changes: 271 additions & 109 deletions commands/metamask.js

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

400 changes: 309 additions & 91 deletions commands/playwright.js

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion commands/synthetix.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
const { SynthetixJs } = require('synthetix-js');
const { synthetix } = require('@synthetixio/js');
const { getNetwork } = require('../helpers');
const metamask = require('./metamask');
const metamask =
process.env.PROVIDER === 'phantom'
? require('./phantom')
: require('./metamask');
const bytes32 = require('bytes32');
const sleep = require('util').promisify(setTimeout);

Expand Down
113 changes: 98 additions & 15 deletions helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ module.exports = {
},
getSynpressPath() {
if (process.env.SYNPRESS_LOCAL_TEST) {
return '.';
return './node_modules/@phantom/synpress';
} else {
return path.dirname(require.resolve(packageJson.name));
}
Expand Down Expand Up @@ -150,7 +150,62 @@ module.exports = {
);
}
},
async download(url, destination) {
getPhantomReleases: async version => {
log(`Trying to find phantom version ${version} in GitHub releases..`);
let filename;
let downloadUrl;
let tagName;
let response;

try {
if (version === 'latest' || !version) {
if (process.env.GH_USERNAME && process.env.GH_PAT) {
response = await axios.get(
'https://api.github.com/repos/phantom-labs/phantom-wallet/releases',
{
auth: {
username: process.env.GH_USERNAME,
password: process.env.GH_PAT,
},
},
);
} else {
response = await axios.get(
'https://api.github.com/repos/phantom-labs/phantom-wallet/releases',
);
}
filename = response.data[0].assets[0].name;
downloadUrl = response.data[0].assets[0].url;
tagName = 'phantom-chrome-latest';
log(
`Phantom version found! Filename: ${filename}; Download url: ${downloadUrl}; Tag name: ${tagName}`,
);
} else if (version) {
filename = `chrome-dist.zip`;
downloadUrl = `https://github.com/phantom-labs/phantom-wallet/releases/download/v${version}/chrome-dist.zip`;
tagName = `phantom-chrome-${version}`;
log(
`Phantom version found! Filename: ${filename}; Download url: ${downloadUrl}; Tag name: ${tagName}`,
);
}
return {
filename,
downloadUrl,
tagName,
};
} catch (e) {
if (e.response && e.response.status === 403) {
throw new Error(
`[getPhantomReleases] Unable to fetch phantom releases from GitHub because you've been rate limited! Please set GH_USERNAME and GH_PAT environment variables to avoid this issue or retry again.`,
);
} else {
throw new Error(
`[getPhantomReleases] Unable to fetch phantom releases from GitHub with following error:\n${e}`,
);
}
}
},
download: async (provider, url, destination) => {
try {
log(
`Trying to download and extract file from: ${url} to following path: ${destination}`,
Expand All @@ -159,39 +214,67 @@ module.exports = {
await download(url, destination, {
extract: true,
auth: `${process.env.GH_USERNAME}:${process.env.GH_PAT}`,
headers: {
Accept: 'application/octet-stream',
},
});

/**
* Some extensions will zip their dist folder
*/
if (provider === 'phantom') {
await moveFiles(`${destination}/dist`, destination);
}
} else {
await download(url, destination, {
extract: true,
});
}
} 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);
const 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 providerDirectory = path.join(downloadsDirectory, release.tagName);
const providerkDirectoryExists = await module.exports.checkDirOrFileExist(
providerDirectory,
);
const metamaskManifestFilePath = path.join(
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;
},
};

async function moveFiles(srcDir, destDir) {
const files = await fs.readdir(srcDir);

return Promise.all(
files.map(function (file) {
var destFile = path.join(destDir, file);
return fs.rename(path.join(srcDir, file), destFile);
}),
);
}
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@synthetixio/synpress",
"version": "3.5.0",
"name": "@phantom/synpress",
"version": "4.0.0-alpha.8",
"description": "Synpress is e2e testing framework based around Cypress.io & playwright with included MetaMask support. Test your dapps with ease.",
"keywords": [
"Synpress",
Expand Down Expand Up @@ -114,6 +114,9 @@
"**/ansi-regex": "5.0.1",
"**/@testing-library/dom": "8.20.0"
},
"overrides": {
"lodash@<4.17.20": "4.17.20"
},
"engines": {
"node": ">=14"
},
Expand Down
1 change: 1 addition & 0 deletions pages/metamask/main-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ 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 = {
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,
};
85 changes: 85 additions & 0 deletions pages/phantom/first-time-flow-page.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
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 continueOnShortcutConfirm =
'[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,
continueOnShortcutConfirm,
};

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