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

Add synpress config #292

Closed
wants to merge 2 commits into from
Closed
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
1 change: 1 addition & 0 deletions cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { defineConfig } from 'cypress';
import getCompareSnapshotsPlugin from 'cypress-image-diff-js/dist/plugin';

export default defineConfig({
video: false,
env: {
browserPermissions: {
clipboard: 'allow',
Expand Down
33 changes: 33 additions & 0 deletions cypress/e2e/login.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
describe('Bridge | Connect | MestaMask | Connect', () => {
afterEach(() => {
cy.disconnectMetamaskWalletFromDapp();
});
it('it should connect with MM and switch the network automatically', () => {
cy.visit('http://localhost:8080');

cy.get('[data-testid="connect-wallet-button"]').click();

cy.get('[ data-testid="connect-metamask-button"]').click();

cy.get('div').contains('MetaMask').click();

cy.acceptMetamaskAccess({ switchNetwork: true }).should('be.true');
cy.get('[data-testid="tag"]').contains('Connected');
});

it('should change to sepolia network and connect', () => {
cy.visit('http://localhost:8080');
cy.changeMetamaskNetwork('sepolia');

cy.get('[data-testid="connect-wallet-button"]')
.contains('Connect wallets')
.click();

cy.get('[ data-testid="connect-metamask-button"]').click();

cy.get('div').contains('MetaMask').click();

cy.acceptMetamaskAccess().should('be.true');
cy.get('[data-testid="tag"]').contains('Connected');
});
});
11 changes: 11 additions & 0 deletions cypress/plugins/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/* eslint-disable import/no-extraneous-dependencies */
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
import synpressPlugins from '@synthetixio/synpress/plugins';
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
const pluginsConfig = (on, config) => {
synpressPlugins(on, config);
};

export default pluginsConfig;
1 change: 1 addition & 0 deletions cypress/support/e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

// Import commands.js using ES2015 syntax:
import './commands';
import '@synthetixio/synpress/support';

// Alternatively you can use CommonJS syntax:
// require('./commands')
7,749 changes: 6,770 additions & 979 deletions package-lock.json

Large diffs are not rendered by default.

7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,25 +22,30 @@
"postcy:e2e-ci": "mv -n cypress-visual-report/cypress-visual-report.html cypress-visual-report/cypress-visual-report-e2e.html",
"cy:component": "cypress run --component --browser chrome",
"cy:component-ci": "export VITE_CI_TEST=true && cypress run --component --browser chrome",
"postcy:component-ci": "mv -n cypress-visual-report/cypress-visual-report.html cypress-visual-report/cypress-visual-report-component.html"
"postcy:component-ci": "mv -n cypress-visual-report/cypress-visual-report.html cypress-visual-report/cypress-visual-report-component.html",
"synpress:run": "env-cmd -f .env npx synpress run --browser chrome -cf synpress.config.ts supportFile='cypress/support/e2e.ts'",
"synpress:e2e": "start-server-and-test dev http://localhost:8080 'synpress:run'"
},
"dependencies": {
"@massalabs/massa-web3": "^1.24.3-dev",
"@massalabs/react-ui-kit": "^0.0.4-dev",
"@massalabs/wallet-provider": "^1.4.1",
"@rainbow-me/rainbowkit": "^1.0.7",
"@synthetixio/synpress": "^3.7.2-beta.9",
"@tanstack/react-query": "^4.29.5",
"axios": "^1.4.0",
"big.js": "^6.2.1",
"currency.js": "^2.0.4",
"delay": "^6.0.0",
"dot-object": "^2.1.4",
"env-cmd": "^10.1.0",
"esbuild": "0.17.19",
"localforage": "^1.10.0",
"lottie-react": "^2.4.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-router-dom": "^6.10.0",
"start-server-and-test": "^2.0.2",
"viem": "^1.3.0",
"wagmi": "^1.3.9",
"zustand": "^4.3.8"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export function CustomConnectButton(): JSX.Element {
if (!connected) {
return (
<Button
data-testid="connect-metamask-button"
variant="secondary"
customClass="h-14 pt-4"
onClick={openConnectModal}
Expand Down
2 changes: 2 additions & 0 deletions src/layouts/LayoutBridge/LayoutBridge.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export function LayoutBridge({ ...props }) {
variant="secondary"
customClass="h-[54px]"
onClick={() => setOpen(true)}
data-testid="connect-wallet-button"
>
{Intl.t('connect-wallet.connected')}
</Button>
Expand All @@ -74,6 +75,7 @@ export function LayoutBridge({ ...props }) {
disabled={isFetching}
customClass="h-[54px] relative"
onClick={() => setOpen(true)}
data-testid="connect-wallet-button"
>
{Intl.t('connect-wallet.title')}
{showPingAnimation && <PingAnimation />}
Expand Down
28 changes: 28 additions & 0 deletions synpress.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
import { defineConfig } from 'cypress';

import setupNodeEvents from './cypress/plugins';

export default defineConfig({
video: false,
userAgent: 'synpress',
retries: {
openMode: 0,
runMode: 0,
},
fixturesFolder: './cypress/fixtures',
screenshotsFolder: './cypress/screenshots',
chromeWebSecurity: true,
viewportWidth: 1920,
viewportHeight: 1080,
defaultCommandTimeout: 30000,
pageLoadTimeout: 30000,
requestTimeout: 30000,
projectId: 'massaBridge',
e2e: {
setupNodeEvents,
supportFile: './cypress/support/e2e.ts',
specPattern: './cypress/e2e/**/*.spec.ts',
},
});
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
"@/*": ["./src/*"]
}
},
"include": ["src", "cypress"],
"include": ["src", "cypress", "synpress"],
"references": [{ "path": "./tsconfig.node.json" }]
}