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

test: WalletConnect tests FE-443 #427

Draft
wants to merge 18 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
eb4b050
chore: update .gitignore to include test results and cache directories
nelitow Nov 14, 2024
e5e5676
feat: add @synthetixio/synpress and update dependencies in package.json
nelitow Nov 14, 2024
697fc03
feat(e2e-tests): integrate synpress fixtures into Playwright configur…
nelitow Nov 14, 2024
3917a83
feat(e2e-tests): add TypeScript configuration for test runner
nelitow Nov 14, 2024
e41c30e
fix(e2e-tests): add timeout to visibility check for Bridge Funds
nelitow Nov 14, 2024
5a4e77a
feat(e2e-tests): add tests for FuelWalletConnector with MetaMask inte…
nelitow Nov 14, 2024
c7e1eac
feat(e2e-tests): add Synpress cache build step in PR workflow
nelitow Nov 14, 2024
464d13a
fix(workflow): reorder Synpress cache build step in PR workflow
nelitow Nov 14, 2024
ebb40c3
fix(workflow): run Synpress wallet-setup with xvfb-run in PR workflow
nelitow Nov 14, 2024
fcc798a
refactor(e2e-tests): comment out Next.js example configuration in Pla…
nelitow Nov 14, 2024
ff4daaf
fix(e2e-tests): add wait timeout before checking visibility of Bridge…
nelitow Nov 14, 2024
cd421bc
fix(e2e-tests): rename test suite to WalletConnectConnector and updat…
nelitow Nov 14, 2024
94d379d
fix(e2e-tests): reduce wait timeout for Bridge Funds visibility check
nelitow Nov 14, 2024
1a1ac90
fix(page): improve error handling for PROVIDER_URL and standardize st…
nelitow Nov 12, 2024
80c70b3
refactor(e2e-tests): uncomment Next.js example configuration in Playw…
nelitow Nov 14, 2024
295c58c
Merge branch 'main' into nj/e2e/walletconnect-tests
nelitow Nov 14, 2024
24f1431
refactor(workflow): remove debug paths check before deployment
nelitow Nov 14, 2024
7fb7134
refactor(tests): remove unnecessary comment in WalletConnectConnector…
nelitow Nov 14, 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
11 changes: 4 additions & 7 deletions .github/workflows/pr-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,6 @@ jobs:
forc --version
fuel-core --version

# Check the directory structure before deployment
- name: Debug Paths Before Deployment
run: |
echo "Checking paths before deployment"
ls -la e2e-tests/runner/src
ls -la examples/react-app/src/types/

- name: Build & Deploy Contracts
run: pnpm deploy:contracts:ci
working-directory: e2e-tests/runner/scripts
Expand All @@ -135,6 +128,10 @@ jobs:
run: pnpm exec playwright install --with-deps chromium
working-directory: e2e-tests/runner

- name: Build Synpress cache
run: xvfb-run pnpm synpress wallet-setup
working-directory: e2e-tests/runner

- name: Run Playwright tests locally for Preview
if: ${{ github.event_name == 'pull_request' }}
run: xvfb-run --auto-servernum -- pnpm --filter @e2e-tests/runner test:e2e
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,6 @@ yarn-error.log*
e2e-tests/runner/playwright-report/
e2e-tests/runner/blob-report/
e2e-tests/runner/test-results/
e2e-tests/runner/.cache-synpress/
e2e-tests/runner/src/contracts/
e2e-tests/runner/src/contracts/contract-ids.json
3 changes: 2 additions & 1 deletion e2e-tests/runner/common/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import type { ApproveTransferFunction, ConnectorFunctions } from './types';

// biome-ignore lint/suspicious/noExportsInTest: <explanation>
export const skipBridgeFunds = async (page: Page) => {
if (await page.isVisible('text=Bridge Funds')) {
await page.waitForTimeout(1000);
if (await page.isVisible('text=Bridge Funds', { timeout: 2000 })) {
await page.click('text=Continue to application');
}
};
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import {
downloadFuel,
getButtonByText,
getByAriaLabel,
} from '@fuels/playwright-utils';
import { testWithSynpress } from '@synthetixio/synpress';
import { MetaMask, metaMaskFixtures } from '@synthetixio/synpress/playwright';
import { sessionTests, skipBridgeFunds } from '../../../common/common';
import type { ConnectorFunctions } from '../../../common/types';
import basicSetup from '../../../wallet-setup/basic.setup';

const test = testWithSynpress(metaMaskFixtures(basicSetup));

test.describe('WalletConnectConnector', () => {
let metamask: MetaMask;

test.beforeEach(async ({ context, extensionId, metamaskPage, page }) => {
metamask = new MetaMask(
context,
metamaskPage,
basicSetup.walletPassword,
extensionId,
);
await page.goto('/', { waitUntil: 'domcontentloaded' });
});

const connect: ConnectorFunctions['connect'] = async (page) => {
await page.goto('/');
const connectButton = getButtonByText(page, 'Connect Wallet', true);
await connectButton.click();
await getByAriaLabel(page, 'Connect to Ethereum Wallets', true).click();

await page.getByText('Proceed anyway').click();
await getButtonByText(page, 'MetaMask', true).click();

await metamask.connectToDapp();
// wait 3 seconds for the connection to be established
await page.waitForTimeout(3000);

await metamask.confirmSignature();
};

const approveTransfer: ConnectorFunctions['approveTransfer'] = async () => {
await metamask.confirmTransaction();
};

test('Fuel tests', async ({ page }) => {
await sessionTests(page, { connect, approveTransfer });
});
});
4 changes: 3 additions & 1 deletion e2e-tests/runner/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
"devDependencies": {
"@fuels/connectors": "workspace:*",
"@fuels/playwright-utils": "0.41.1",
"@playwright/test": "1.48.1",
"@playwright/test": "1.48.2",
"@synthetixio/synpress": "4.0.3",
"@synthetixio/synpress-cache": "0.0.4",
"dotenv": "16.4.5",
"fuels": "0.96.1"
},
Expand Down
2 changes: 2 additions & 0 deletions e2e-tests/runner/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import {
defineConfig,
devices,
} from '@playwright/test';
import { synpressFixtures } from '@synthetixio/synpress';

import dotenv from 'dotenv';
dotenv.config();

Expand Down
6 changes: 6 additions & 0 deletions e2e-tests/runner/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"compilerOptions": {
"moduleResolution": "bundler",
"strict": true
}
}
12 changes: 12 additions & 0 deletions e2e-tests/runner/wallet-setup/basic.setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { defineWalletSetup } from '@synthetixio/synpress';
import { MetaMask } from '@synthetixio/synpress/playwright';

const SEED_PHRASE =
'test test test test test test test test test test test junk';
const PASSWORD = 'SynpressIsAwesomeNow!!!';

export default defineWalletSetup(PASSWORD, async (context, walletPage) => {
const metamask = new MetaMask(context, walletPage, PASSWORD);

await metamask.importWallet(SEED_PHRASE);
});
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,8 @@
"fast-xml-parser@<4.4.1": ">=4.4.1"
}
},
"packageManager": "[email protected]"
"packageManager": "[email protected]",
"dependencies": {
"@synthetixio/synpress": "4.0.3"
}
}
Loading
Loading