Skip to content

Commit

Permalink
Merge pull request #7 from argentlabs/tests/e2e-POC
Browse files Browse the repository at this point in the history
Tests/e2e-POC
  • Loading branch information
bluecco authored Dec 5, 2024
2 parents f1d816b + 3f52234 commit 1f72402
Show file tree
Hide file tree
Showing 57 changed files with 5,615 additions and 123 deletions.
194 changes: 193 additions & 1 deletion .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,26 @@ on:
- develop
- main
pull_request:
env:
PNPM_VERSION: 9.1.4
NODE_VERSION: 20.x

jobs:
build:
runs-on: ubuntu-latest
container:
image: mcr.microsoft.com/playwright:v1.48.2-jammy
env:
ARGENT_X_ENVIRONMENT: "hydrogen"
E2E_REPO: ${{ secrets.E2E_REPO }}
E2E_REPO_TOKEN: ${{ secrets.E2E_REPO_TOKEN }}
E2E_REPO_OWNER: ${{ secrets.E2E_REPO_OWNER }}
E2E_REPO_RELEASE_NAME: ${{ secrets.E2E_REPO_RELEASE_NAME }}

WW_EMAIL: ${{ secrets.WW_EMAIL }}
WW_LOGIN_PASSWORD: ${{ secrets.WW_LOGIN_PASSWORD }}
EMAIL_PASSWORD: ${{ secrets.EMAIL_PASSWORD }}

steps:
- name: Checkout code
uses: actions/checkout@v4
Expand All @@ -18,8 +34,13 @@ jobs:
- uses: pnpm/action-setup@v4
name: Install pnpm
with:
# version: 9
run_install: false
version: ${{ env.PNPM_VERSION }}

- uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: "pnpm"

- name: Get pnpm store directory
shell: bash
Expand All @@ -36,5 +57,176 @@ jobs:
- name: Install dependencies
run: pnpm install

- name: Build demo-dapp-starknet
run: pnpm run build

- name: Use Cache
uses: actions/cache@v4
with:
path: ./*
key: ${{ github.sha }}


test-webwallet:
runs-on: ubuntu-latest
container:
image: mcr.microsoft.com/playwright:v1.48.2-jammy
needs: [build]
env:
ARGENT_X_ENVIRONMENT: "hydrogen"

WW_EMAIL: ${{ secrets.WW_EMAIL }}
WW_LOGIN_PASSWORD: ${{ secrets.WW_LOGIN_PASSWORD }}
EMAIL_PASSWORD: ${{ secrets.EMAIL_PASSWORD }}

steps:
- uses: actions/checkout@v4

- uses: pnpm/action-setup@v4
name: Install pnpm
id: pnpm-install
with:
version: ${{ env.PNPM_VERSION }}
run_install: false

- uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: "pnpm"

- name: Restore pnpm cache
uses: actions/cache/restore@v4
with:
path: ~/.pnpm-store
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Restore cached build
uses: actions/cache/restore@v4
with:
path: ./*
key: ${{ github.sha }}

- name: Run e2e tests
run: |
pnpm run start & # Start the server in background
echo "Waiting for server to be ready..."
for i in {1..30}; do
if curl -s http://localhost:3000 > /dev/null; then
echo "Server is ready!"
break
fi
echo "Attempt $i: Server not ready yet..."
if [ $i -eq 30 ]; then
echo "Server failed to start"
exit 1
fi
sleep 1
done
xvfb-run --auto-servernum pnpm test:webwallet
- name: Upload artifacts
uses: actions/upload-artifact@v4
if: always()
with:
name: test-artifacts
path: |
e2e/artifacts/playwright/
!e2e/artifacts/playwright/*.webm
retention-days: 5

test-argentX:
runs-on: ubuntu-latest
container:
image: mcr.microsoft.com/playwright:v1.48.2-jammy
needs: [build]
env:
ARGENT_X_ENVIRONMENT: "hydrogen"
E2E_REPO: ${{ secrets.E2E_REPO }}
E2E_REPO_TOKEN: ${{ secrets.E2E_REPO_TOKEN }}
E2E_REPO_OWNER: ${{ secrets.E2E_REPO_OWNER }}
E2E_REPO_RELEASE_NAME: ${{ secrets.E2E_REPO_RELEASE_NAME }}

steps:
- uses: actions/checkout@v4

- uses: pnpm/action-setup@v4
name: Install pnpm
id: pnpm-install
with:
version: ${{ env.PNPM_VERSION }}
run_install: false

- uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: "pnpm"

- name: Restore pnpm cache
uses: actions/cache/restore@v4
with:
path: ~/.pnpm-store
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Restore cached build
uses: actions/cache/restore@v4
with:
path: ./*
key: ${{ github.sha }}

- name: Install libarchive-tools
shell: bash
run: |
try_apt() {
rm -f /var/lib/apt/lists/lock
rm -f /var/cache/apt/archives/lock
rm -f /var/lib/dpkg/lock*
dpkg --configure -a
apt-get update && apt-get install -y libarchive-tools
}
for i in {1..3}; do
echo "Attempt $i to install libarchive-tools"
if try_apt; then
echo "Successfully installed libarchive-tools"
exit 0
fi
echo "Attempt $i failed, waiting 10 seconds..."
sleep 10
done

echo "Failed to install libarchive-tools after 3 attempts"
exit 1

- name: Run e2e tests
run: |
pnpm run start & # Start the server in background
echo "Waiting for server to be ready..."
for i in {1..30}; do
if curl -s http://localhost:3000 > /dev/null; then
echo "Server is ready!"
break
fi
echo "Attempt $i: Server not ready yet..."
if [ $i -eq 30 ]; then
echo "Server failed to start"
exit 1
fi
sleep 1
done
xvfb-run --auto-servernum pnpm test:argentx
- name: Upload artifacts
uses: actions/upload-artifact@v4
if: always()
with:
name: test-artifacts
path: |
e2e/artifacts/playwright/
!e2e/artifacts/playwright/*.webm
retention-days: 5

6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,8 @@ next-env.d.ts
.playwright-*
playwright-report*

.eslintcache
.eslintcache
artifacts
argent-x-dist

/e2e/node_modules/
86 changes: 86 additions & 0 deletions e2e/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
import path from "path"
import dotenv from "dotenv"
import fs from "fs"

const envPath = path.resolve(__dirname || "", ".env")
if (fs.existsSync(envPath)) {
dotenv.config({ path: envPath })
}
const commonConfig = {
isProdTesting: process.env.ARGENT_X_ENVIRONMENT === "prod" ? true : false || "",
password: "MyP@ss3!",
//accounts used for setup
senderAddrs: process.env.E2E_SENDER_ADDRESSES?.split(",") || "",
senderKeys: process.env.E2E_SENDER_PRIVATEKEYS?.split(",") || "",
destinationAddress: process.env.E2E_SENDER_ADDRESSES?.split(",")[0] ||"", //used as transfers destination
// urls
rpcUrl: process.env.ARGENT_SEPOLIA_RPC_URL || "",
beAPIUrl:
process.env.ARGENT_X_ENVIRONMENT === "prod"
? ""
: process.env.ARGENT_API_BASE_URL || "",
viewportSize: { width: 360, height: 800 },
artifactsDir: path.resolve(__dirname, "./artifacts/playwright"),
isCI: Boolean(process.env.CI),
migDir: path.join(__dirname, "../../e2e/argent-x-dist/"),
distDir: path.join(__dirname, "../../extension/dist/"),
migVersionDir: path.join(__dirname || "", "../../e2e/argent-x-dist/dist"),
migRepo: process.env.E2E_REPO || "",
migRepoToken: process.env.E2E_REPO_TOKEN || "",
migRepoOwner: process.env.E2E_REPO_OWNER || "",
migReleaseName: process.env.E2E_REPO_RELEASE_NAME || "",
}

const extensionHydrogenConfig = {
...commonConfig || "",
testSeed1: process.env.E2E_TESTNET_SEED1 || "", //wallet with 33 regular deployed accounts and 1 multisig deployed account
testSeed3: process.env.E2E_TESTNET_SEED3 || "", //wallet with 1 deployed account|| "", and multisig with removed user
testSeed4: process.env.E2E_TESTNET_SEED4 || "", //wallet with non deployed account but with funds
senderSeed: process.env.E2E_SENDER_SEED || "",
account1Seed2: process.env.E2E_ACCOUNT_1_SEED2 || "",
spokCampaignName: process.env.E2E_SPOK_CAMPAIGN_NAME || "",
spokCampaignUrl: process.env.E2E_SPOK_CAMPAIGN_URL || "",
guardianEmail: process.env.E2E_GUARDIAN_EMAIL || "",
useStrkAsFeeToken: process.env.E2E_USE_STRK_AS_FEE_TOKEN || "",
skipTXTests: process.env.E2E_SKIP_TX_TESTS || "",
accountsToImport: process.env.E2E_ACCOUNTS_TO_IMPORT || "",
accountToImportAndTx: process.env.E2E_ACCOUNT_TO_IMPORT_AND_TX?.split(",") || "",
qaUtilsURL: process.env.E2E_QA_UTILS_URL || "",
qaUtilsAuthToken: process.env.E2E_QA_UTILS_AUTH_TOKEN || "",
initialBalanceMultiplier: process.env.INITIAL_BALANCE_MULTIPLIER || 1 || "",
migAccountAddress: process.env.E2E_MIG_ACCOUNT_ADDRESS || "",
}

const extensionProdConfig = {
...commonConfig,
testSeed1: process.env.E2E_MAINNET_SEED1 || "",
testSeed3: "",
testSeed4: "",
senderSeed: process.env.E2E_SENDER_SEED || "",
account1Seed2:"",
account1Seed3:"",
spokCampaignName:"",
spokCampaignUrl:"",
guardianEmail:"",
useStrkAsFeeToken: "false",
skipTXTests: "true",
accountsToImport:"",
accountToImportAndTx:"",
qaUtilsURL:"",
qaUtilsAuthToken:"",
initialBalanceMultiplier: 1,
migAccountAddress:"",
migVersions:"",
}

const config = commonConfig.isProdTesting
? extensionProdConfig
: extensionHydrogenConfig
// check that no value of config is undefined|| "", otherwise throw error
Object.entries(config).forEach(([key, value]) => {
if (value === undefined) {
throw new Error(`Missing ${key} config variable; check .env file`)
}
})

export default config
41 changes: 41 additions & 0 deletions e2e/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"name": "@demo-dapp-starket/e2e",
"private": true,
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"peerDependencies": {
"@scure/base": "^1.1.1",
"@scure/bip39": "^1.2.1",
"axios": "^1.7.7",
"fs-extra": "^11.2.0",
"lodash-es": "^4.17.21",
"object-hash": "^3.0.0",
"react": "^18.0.0",
"react-dom": "^18.0.0",
"swr": "^1.3.0",
"zod": "^3.23.8"
},
"devDependencies": {
"@playwright/test": "^1.48.1",
"@types/axios": "^0.14.0",
"@types/fs-extra": "^11.0.4",
"@types/imap-simple": "^4.2.9",
"@types/mailparser": "^3.4.5",
"@types/node": "^22.0.0",
"@types/nodemailer": "^6.4.17",
"@types/uuid": "^10.0.0",
"dotenv": "^16.3.1",
"starknet": "6.11.0",
"uuid": "^11.0.0"
},
"scripts": {
"test:argentx": "pnpm playwright test --project=ArgentX",
"test:webwallet": "pnpm playwright test --project=WebWallet"
},
"dependencies": {
"imap-simple": "^5.1.0",
"mailparser": "^3.7.1",
"nodemailer": "^6.9.16"
}
}
Loading

0 comments on commit 1f72402

Please sign in to comment.