Skip to content

Commit 7f050cd

Browse files
nelitowLuizAsFight
andauthored
feat(e2e-connector-test): CI FE-499 (#399)
Co-authored-by: Luiz Gomes <[email protected]> Co-authored-by: LuizAsFight <[email protected]>
1 parent 5e02231 commit 7f050cd

File tree

17 files changed

+503
-93
lines changed

17 files changed

+503
-93
lines changed

.github/workflows/pr-tests.yml

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ on:
77
push:
88
branches:
99
- release
10+
- main
1011

1112
concurrency:
1213
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
@@ -40,7 +41,6 @@ jobs:
4041
name: my-toolchain
4142
components: forc@${{ env.FORC_VERSION }}, fuel-core@${{ env.CORE_VERSION }}
4243

43-
# Unit tests running with Vitest
4444
- name: Find PR number
4545
uses: jwalton/gh-find-current-pr@v1
4646
if: ${{ github.event_name == 'pull_request' }}
@@ -76,3 +76,56 @@ jobs:
7676
working-directory: ./packages/fuelet-wallet
7777
json-summary-path: ./coverage/coverage-summary.json
7878
json-final-path: ./coverage/coverage-final.json
79+
80+
tests-e2e-connectors:
81+
runs-on: buildjet-8vcpu-ubuntu-2204
82+
steps:
83+
- name: Check out the code
84+
uses: actions/checkout@v3
85+
86+
- name: Setup Node
87+
uses: FuelLabs/github-actions/setups/node@master
88+
with:
89+
node-version: 20.11.0
90+
pnpm-version: 9.5.0
91+
92+
- uses: FuelLabs/github-actions/setups/docker@master
93+
with:
94+
username: ${{ github.repository_owner }}
95+
password: ${{ secrets.GITHUB_TOKEN }}
96+
97+
- name: Start Test Node
98+
run: pnpm node:up
99+
100+
- name: Run PNPM install
101+
id: pnpm-cache
102+
run: pnpm install --frozen-lockfile
103+
104+
- name: Run build:connectors
105+
run: pnpm build:connectors
106+
107+
# E2E tests running with Playwright
108+
- name: Install Playwright Browsers
109+
run: pnpm exec playwright install --with-deps chromium
110+
working-directory: e2e-tests
111+
112+
- name: Run Playwright tests on Testnet
113+
if: ${{ github.ref == 'refs/heads/main' }}
114+
run: xvfb-run --auto-servernum -- pnpm --filter e2e-tests test:e2e
115+
env:
116+
VITE_FUEL_PROVIDER_URL: "https://testnet.fuel.network/v1/graphql"
117+
VITE_MASTER_WALLET_MNEMONIC: ${{ secrets.VITE_MASTER_WALLET_MNEMONIC }}
118+
VITE_APP_WC_PROJECT_ID: e01471314fc69cc4efba6dce12dfd710
119+
VITE_CHAIN_ID_NAME: testnet
120+
PORT: 5173
121+
122+
- name: Run Playwright tests locally for Preview
123+
if: ${{ github.event_name == 'pull_request' }}
124+
run: xvfb-run --auto-servernum -- pnpm --filter e2e-tests test:e2e
125+
env:
126+
VITE_FUEL_PROVIDER_URL: "http://localhost:4000/v1/graphql"
127+
VITE_WALLET_SECRET: "0xa449b1ffee0e2205fa924c6740cc48b3b473aa28587df6dab12abc245d1f5298"
128+
VITE_MASTER_WALLET_MNEMONIC: ${{ secrets.VITE_MASTER_WALLET_MNEMONIC }}
129+
VITE_APP_WC_PROJECT_ID: e01471314fc69cc4efba6dce12dfd710
130+
VITE_CHAIN_ID_NAME: local
131+
PORT: 5173

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,6 @@ yarn-error.log*
3030
/playwright/.cache/
3131
/e2e-tests/playwright-report
3232
.env
33+
!docker/.env
3334
/e2e-tests/test-results
3435
**/*.tgz

docker/.env

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
PROJECT=fuels-wallet
2+
MIN_GAS_PRICE=1
3+
WALLET_SECRET=0xa449b1ffee0e2205fa924c6740cc48b3b473aa28587df6dab12abc245d1f5298
4+
DISPENSE_AMOUNT=2000000
5+
FUEL_CORE_PORT=4000
6+
FUEL_FAUCET_PORT=4040
7+
FUEL_IP=0.0.0.0

docker/Makefile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
up:
2+
docker compose -p dev --env-file .env up -d --build
3+
4+
down:
5+
docker compose -p dev stop
6+
7+
clean:
8+
docker compose -p dev down --rmi local -v --remove-orphans

docker/docker-compose.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
version: '3'
2+
3+
services:
4+
fuel-core:
5+
platform: linux/amd64
6+
container_name: '${PROJECT:-fuel-node}_fuel-core'
7+
environment:
8+
FUEL_IP: ${FUEL_IP}
9+
FUEL_CORE_PORT: ${FUEL_CORE_PORT}
10+
NETWORK_NAME: '${PROJECT} local'
11+
MIN_GAS_PRICE: ${MIN_GAS_PRICE}
12+
# This is the private key of the consensus.PoA.signing_key in the chainConfig.json
13+
# this key is responsible for validating the transactions
14+
CONSENSUS_KEY_SECRET: ${WALLET_SECRET}
15+
build: ./fuel-core
16+
ports:
17+
- '${FUEL_CORE_PORT:-4000}:4000'
18+
volumes:
19+
- fuel-core-db:/mnt/db
20+
healthcheck:
21+
test: curl --fail http://localhost:4000/v1/health || exit 1
22+
interval: 1s
23+
timeout: 5s
24+
retries: 20
25+
26+
faucet:
27+
platform: linux/amd64
28+
container_name: '${PROJECT:-fuel-node}_faucet'
29+
environment:
30+
# Other configurations can be found at;
31+
# https://github.com/FuelLabs/faucet#configuration
32+
MIN_GAS_PRICE: ${MIN_GAS_PRICE}
33+
WALLET_SECRET_KEY: ${WALLET_SECRET}
34+
DISPENSE_AMOUNT: ${DISPENSE_AMOUNT}
35+
FUEL_NODE_URL: http://${PROJECT:-fuel-node}_fuel-core:4000/v1/graphql
36+
image: ghcr.io/fuellabs/faucet:4f7bec0
37+
ports:
38+
- '${FUEL_FAUCET_PORT:-4040}:3000'
39+
links:
40+
- fuel-core
41+
depends_on:
42+
fuel-core:
43+
condition: service_healthy
44+
45+
volumes:
46+
fuel-core-db:
47+
name: '${PROJECT:-fuel-node}_fuel-core-db'

docker/fuel-core/Dockerfile

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# IMPORTANT!
2+
# Make sure to check:
3+
# https://github.com/FuelLabs/chain-configuration/tree/master/upgradelog/ignition-devnet
4+
# and apply the latest state_transition_function and consensus_parameter
5+
# when upgrading fuel-core
6+
7+
# We should be supporting always the same fuel-core version as the fuels (ts-sdk)
8+
# https://github.com/FuelLabs/fuels-ts/blob/master/internal/fuel-core/VERSION
9+
FROM ghcr.io/fuellabs/fuel-core:v0.40.0
10+
11+
# dependencies
12+
ENV DEBIAN_FRONTEND=noninteractive
13+
RUN apt update && apt install -y git curl jq && rm -rf /var/lib/apt/lists/*
14+
15+
# copy chain config
16+
WORKDIR /fuel
17+
18+
COPY ./genesis_coins.json .
19+
20+
RUN git clone \
21+
https://github.com/FuelLabs/chain-configuration.git \
22+
/chain-configuration && \
23+
cd /chain-configuration && \
24+
git checkout 0dc0960f14da7b6650b5438dc1e99d7ff7acec73
25+
26+
# Copy the base local configuration
27+
RUN cp -R /chain-configuration/local/* ./
28+
29+
# Copy the testnet consensus parameters and state transition bytecode
30+
RUN cp /chain-configuration/upgradelog/ignition-devnet/consensus_parameters/13.json \
31+
./latest_consensus_parameters.json
32+
RUN cp /chain-configuration/upgradelog/ignition-devnet/state_transition_function/15.wasm \
33+
./state_transition_bytecode.wasm
34+
35+
# update local state_config with custom genesis coins config
36+
RUN jq '.coins = input' \
37+
state_config.json genesis_coins.json > tmp.json \
38+
&& mv tmp.json state_config.json
39+
40+
# update local state_config with testnet consensus parameters
41+
RUN jq '.consensus_parameters = input' \
42+
state_config.json latest_consensus_parameters.json > tmp.json \
43+
&& mv tmp.json state_config.json
44+
45+
# expose fuel node port
46+
EXPOSE ${FUEL_CORE_PORT}
47+
48+
# copy over script and run
49+
COPY ./fuel_core.sh .
50+
CMD ["sh", "./fuel_core.sh"]

docker/fuel-core/fuel_core.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash
2+
3+
# TODO change to --poa-interval-period 1sec \
4+
5+
# Start the Fuel Core node
6+
/root/fuel-core run \
7+
--ip $FUEL_IP \
8+
--port $FUEL_CORE_PORT \
9+
--db-path ./mnt/db/ \
10+
--utxo-validation \
11+
--vm-backtrace \
12+
--poa-interval-period 1sec \
13+
--debug \
14+
--min-gas-price ${MIN_GAS_PRICE} \
15+
--snapshot ./ \
16+
--consensus-key ${CONSENSUS_KEY_SECRET}
17+

docker/fuel-core/genesis_coins.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
[
2+
{
3+
"owner": "0x94ffcc53b892684acefaebc8a3d4a595e528a8cf664eeb3ef36f1020b0809d0d",
4+
"amount": 1000000000000,
5+
"asset_id": "0xf8f8b6283d7fa5b672b530cbb84fcccb4ff8dc40f8176ef4544ddb1f1952ad07",
6+
"tx_id": "0x0000000000000000000000000000000000000000000000000000000000000032",
7+
"output_index": 0,
8+
"tx_pointer_block_height": 0,
9+
"tx_pointer_tx_idx": 0
10+
},
11+
{
12+
"owner": "0x94ffcc53b892684acefaebc8a3d4a595e528a8cf664eeb3ef36f1020b0809d0d",
13+
"amount": 1000000000000,
14+
"asset_id": "0x0000000000000000000000000000000000000000000000000000000000000001",
15+
"tx_id": "0x0000000000000000000000000000000000000000000000000000000000000033",
16+
"output_index": 0,
17+
"tx_pointer_block_height": 0,
18+
"tx_pointer_tx_idx": 0
19+
}
20+
]

e2e-tests/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@
77
"homepage": "https://github.com/FuelLabs/fuel-connectors",
88
"type": "module",
99
"scripts": {
10-
"test:e2e": "playwright test"
10+
"test:e2e": "playwright test",
11+
"test:e2e:ui": "playwright test --ui --debug"
1112
},
1213
"devDependencies": {
1314
"@fuels/connectors": "workspace:*",
14-
"@fuels/playwright-utils": "0.23.0",
15+
"@fuels/playwright-utils": "0.40.1",
1516
"@playwright/test": "1.48.1",
1617
"dotenv": "16.4.5",
1718
"fuels": "0.96.1"

e2e-tests/react-app/connectors/BurnerWalletConnector/BurnerWalletConnector.test.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@ const connectBurner = async (page: Page, walletName = 'Burner Wallet') => {
66
const connectButton = getButtonByText(page, 'Connect');
77
await connectButton.click();
88
await getByAriaLabel(page, `Connect to ${walletName}`, true).click();
9+
10+
await skipBridgeFunds(page);
11+
};
12+
13+
const skipBridgeFunds = async (page: Page) => {
14+
if (await page.isVisible('text=Bridge Funds')) {
15+
await page.click('text=Continue to application');
16+
}
917
};
1018

1119
test.describe('BurnerWalletConnector', async () => {
@@ -14,7 +22,7 @@ test.describe('BurnerWalletConnector', async () => {
1422
await page.bringToFront();
1523
});
1624

17-
test('should connect and show fuel address', async ({ page }) => {
25+
test('BurnerWallet Tests', async ({ page }) => {
1826
await connectBurner(page);
1927

2028
expect(await page.waitForSelector('text=/Your Fuel Address/')).toBeTruthy();
@@ -31,10 +39,12 @@ test.describe('BurnerWalletConnector', async () => {
3139

3240
await test.step('should connect, refresh and stay connected', async () => {
3341
await page.reload();
42+
await skipBridgeFunds(page);
3443
await page.waitForSelector('text=/Your Fuel Address/');
3544
});
3645

3746
await test.step('should connect, disconnect, refresh and stay disconnected', async () => {
47+
await skipBridgeFunds(page);
3848
await page.click('text=Disconnect');
3949
await page.waitForSelector('text=/Connect Wallet/');
4050

0 commit comments

Comments
 (0)