-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(e2e): Fullset Solana tests FE-446 (#436)
- Loading branch information
Showing
21 changed files
with
208 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
NEXT_PUBLIC_WC_PROJECT_ID= | ||
NEXT_PUBLIC_PROVIDER_URL=https://testnet.fuel.network/v1/graphql | ||
NEXT_PUBLIC_WC_PROJECT_ID=e01471314fc69cc4efba6dce12dfd710 | ||
NEXT_PUBLIC_PROVIDER_URL=http://localhost:4000/v1/graphql |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
# Running E2E Tests Locally | ||
|
||
## Prerequisites | ||
- Node.js v20.11.0 | ||
- PNPM v9.5.0 | ||
- Rust toolchain with `forc` and `fuel-core` | ||
|
||
## Environment Setup | ||
1. Copy `e2e-tests/runner/.env.example` to `e2e-tests/runner/.env`. They will have the required environment variables for local testing providing you have a local Fuel node running. | ||
2. Copy `examples/react-app/.env.example` to `examples/react-app/.env`. | ||
3. Copy `examples/react-next/.env.example` to `examples/react-next/.env`. | ||
|
||
## Steps to Run Tests | ||
|
||
1. **Start the Local Node** | ||
```bash | ||
pnpm node:up | ||
``` | ||
|
||
2. **Install Dependencies** | ||
```bash | ||
pnpm install --frozen-lockfile | ||
``` | ||
|
||
3. **Build Connectors** | ||
```bash | ||
pnpm build:connectors | ||
``` | ||
|
||
4. **Build and Deploy Contracts** | ||
```bash | ||
cd e2e-tests/runner/scripts | ||
pnpm deploy:contracts | ||
``` | ||
|
||
5. **Build and Deploy EVM Predicates** | ||
Copy `packages/evm-predicates/.env.example` to `packages/evm-predicates/.env`. | ||
From the root directory: | ||
```bash | ||
cd packages/evm-predicates | ||
pnpm fuels build && pnpm fuels deploy | ||
``` | ||
|
||
6. **Build and Deploy Solana Predicates** | ||
Copy `packages/solana-connector/.env.example` to `packages/solana-connector/.env`. | ||
```bash | ||
cd packages/solana-connector | ||
pnpm fuels build && pnpm fuels deploy | ||
``` | ||
|
||
7. **Install Playwright Browser** | ||
```bash | ||
cd e2e-tests/runner | ||
pnpm exec playwright install --with-deps chromium | ||
``` | ||
|
||
8. **Setup Synpress** | ||
```bash | ||
cd e2e-tests/runner | ||
pnpm synpress wallet-setup | ||
``` | ||
|
||
9. **Run the Tests** | ||
```bash | ||
cd e2e-tests/runner | ||
pnpm test:e2e | ||
``` | ||
Or to run the Playwright UI and start the servers: | ||
```bash | ||
cd e2e-tests/runner | ||
pnpm test:e2e:dev | ||
``` | ||
|
||
## Environment Variables | ||
- `VITE_FUEL_PROVIDER_URL`: URL for the local Fuel node (default: http://localhost:4000/v1/graphql) | ||
- `NEXT_PUBLIC_WC_PROJECT_ID`: Your WalletConnect project ID | ||
- `VITE_WALLET_SECRET`: Your wallet secret key | ||
- `VITE_MASTER_WALLET_MNEMONIC`: Your wallet mnemonic phrase | ||
|
||
## Notes | ||
- The tests require a local Fuel node to be running | ||
- All commands should be run from the project root unless specified otherwise | ||
- Make sure you have the correct Rust toolchain version installed with `forc` and `fuel-core` |
82 changes: 56 additions & 26 deletions
82
e2e-tests/runner/examples/connectors/SolanaConnector/SolanaConnector.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,77 @@ | ||
import { | ||
expect, | ||
getButtonByText, | ||
getByAriaLabel, | ||
} from '@fuels/playwright-utils'; | ||
import { getButtonByText, getByAriaLabel } from '@fuels/playwright-utils'; | ||
import type { Page } from '@playwright/test'; | ||
import phantom from '../../../node_modules/@phantom/synpress/commands/phantom'; | ||
import { | ||
incrementTests, | ||
sessionTests, | ||
skipBridgeFunds, | ||
transferTests, | ||
} from '../../../common/common'; | ||
import type { | ||
ApproveTransferFunction, | ||
ConnectFunction, | ||
} from '../../../common/types'; | ||
import { fundWallet } from '../setup'; | ||
import phantomExtended from './phantom/phantom'; | ||
import { test } from './setup'; | ||
|
||
phantom.confirmTransaction = async () => { | ||
const notificationPage = | ||
await phantom.playwright.switchToNotification('phantom'); | ||
await phantom.playwright.waitAndClick( | ||
'phantom', | ||
phantom.transactionPageElements.buttons.confirmTransaction, // Ensure this locator exists or define it | ||
notificationPage, | ||
{ waitForEvent: 'close' }, | ||
); | ||
return true; | ||
}; | ||
|
||
test.describe('SolanaConnector', () => { | ||
test.slow(); | ||
|
||
const connect = async (page: Page) => { | ||
await page.goto('/'); | ||
const connect: ConnectFunction = async (page: Page) => { | ||
const connectButton = getButtonByText(page, 'Connect Wallet', true); | ||
await connectButton.click(); | ||
await getByAriaLabel(page, 'Connect to Solana Wallets', true).click(); | ||
await page.getByText('Proceed anyway').click(); | ||
await getButtonByText(page, 'Phantom').click(); | ||
await phantom.acceptAccess(); | ||
await page.waitForTimeout(3000); | ||
try { | ||
await phantomExtended.acceptAccess(); | ||
} catch (error) { | ||
// Phantom might not need to accept access if it already connected before | ||
console.log('Error: ', error); | ||
} | ||
}; | ||
|
||
test('Fuel tests', async ({ page }) => { | ||
const approveTransfer: ApproveTransferFunction = async () => { | ||
await phantomExtended.confirmSignatureRequest(); | ||
}; | ||
|
||
test.beforeEach(async ({ page }) => { | ||
await page.goto('/'); | ||
}); | ||
|
||
test('Solana tests', async ({ page }) => { | ||
await test.step('Session tests', async () => { | ||
await sessionTests(page, { connect, approveTransfer }); | ||
}); | ||
|
||
await connect(page); | ||
await skipBridgeFunds(page); | ||
|
||
const addressElement = await page.locator('#address'); | ||
let address = null; | ||
let address: string | null = null; | ||
if (addressElement) { | ||
address = await addressElement.getAttribute('data-address'); | ||
} | ||
test.step('Check if address is not null', () => { | ||
expect(address).not.toBeNull(); | ||
|
||
if (address) { | ||
await fundWallet({ publicKey: address }); | ||
} else { | ||
throw new Error('Address is null'); | ||
} | ||
await test.step('Transfer tests', async () => { | ||
await transferTests(page, { | ||
connect, | ||
approveTransfer, | ||
keepSession: true, | ||
}); | ||
}); | ||
|
||
await test.step('Increment tests', async () => { | ||
await incrementTests(page, { | ||
connect, | ||
approveTransfer, | ||
keepSession: true, | ||
}); | ||
}); | ||
}); | ||
}); |
7 changes: 7 additions & 0 deletions
7
e2e-tests/runner/examples/connectors/SolanaConnector/phantom/phantom.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import phantomCommands from '../../../../node_modules/@phantom/synpress/commands/phantom'; | ||
|
||
export const phantomExtended = { | ||
...phantomCommands, | ||
}; | ||
|
||
export default phantomExtended; |
4 changes: 2 additions & 2 deletions
4
e2e-tests/runner/examples/connectors/SolanaConnector/phantom/setup.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,3 @@ | ||
VITE_APP_WC_PROJECT_ID= | ||
VITE_CHAIN_ID_NAME=testnet | ||
VITE_FUEL_PROVIDER_URL=https://testnet.fuel.network/v1/graphql | ||
VITE_WALLET_SECRET="0xa449b1ffee0e2205fa924c6740cc48b3b473aa28587df6dab12abc245d1f5298" | ||
VITE_MASTER_WALLET_MNEMONIC="shuffle become fold deputy sick shove wolf olympic breeze antique ball broom" | ||
PORT=5173 | ||
VITE_APP_WC_PROJECT_ID=e01471314fc69cc4efba6dce12dfd710 | ||
VITE_CHAIN_ID_NAME=local | ||
VITE_FUEL_PROVIDER_URL=http://localhost:4000/v1/graphql |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
NEXT_PUBLIC_WC_PROJECT_ID= | ||
NEXT_PUBLIC_WC_PROJECT_ID=e01471314fc69cc4efba6dce12dfd710 | ||
NEXT_PUBLIC_CHAIN_ID_NAME=testnet | ||
NEXT_PUBLIC_PROVIDER_URL=http://localhost:4000/v1/graphql |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
PRIVATE_KEY=0xa449b1ffee0e2205fa924c6740cc48b3b473aa28587df6dab12abc245d1f5298 | ||
PROVIDER_URL=http://localhost:4000/v1/graphql |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,16 @@ | ||
import dotenv from 'dotenv'; | ||
import { createConfig } from 'fuels'; | ||
|
||
dotenv.config({ | ||
path: ['.env'], | ||
}); | ||
|
||
export default createConfig({ | ||
providerUrl: 'http://localhost:4000/v1/graphql', | ||
providerUrl: process.env.PROVIDER_URL || 'http://localhost:4000/v1/graphql', | ||
predicates: ['./predicate'], | ||
output: './src/generated/tmp', | ||
forcBuildFlags: ['--release'], | ||
// needs the private key to deploy the predicate | ||
privateKey: | ||
'0xa449b1ffee0e2205fa924c6740cc48b3b473aa28587df6dab12abc245d1f5298', // genesis private key | ||
'0xa449b1ffee0e2205fa924c6740cc48b3b473aa28587df6dab12abc245d1f5298', | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
PRIVATE_KEY=0xa449b1ffee0e2205fa924c6740cc48b3b473aa28587df6dab12abc245d1f5298 | ||
PROVIDER_URL=http://localhost:4000/v1/graphql |
Oops, something went wrong.