From 83a97681efdece41eca0a506bd527eacfc10584e Mon Sep 17 00:00:00 2001 From: wsdt Date: Mon, 26 Aug 2024 21:08:00 +0200 Subject: [PATCH 01/25] test: run e2e --- .circleci/config.yml | 18 +++++++++--------- snap-account-abstraction-keyring | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 5bdc902..1e38ee9 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -63,14 +63,14 @@ jobs: - run: name: Install pnpm command: | - curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash - - sudo apt-get install -y nodejs - npm i -g yarn pnpm - echo "NPM version: $(npm --version)" - echo "Yarn version: $(yarn --version)" - echo "PNPM version: $(pnpm --version)" - pnpm config set store-dir .pnpm-store - + curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash - + sudo apt-get install -y nodejs + npm i -g yarn pnpm + echo "NPM version: $(npm --version)" + echo "Yarn version: $(yarn --version)" + echo "PNPM version: $(pnpm --version)" + pnpm config set store-dir .pnpm-store + - save_cache: name: Save pnpm Package Cache key: pnpm-packages-{{ checksum "pnpm-lock.yaml" }} @@ -99,7 +99,7 @@ jobs: name: Run Hardhat tests command: | cd ./contracts - npx hardhat test + npx playwright test ./test/e2e/send-user-op.e2e.test.ts --timeout=600000 environment: TOKEN_PRICE_CONTRACT: ${TOKEN_PRICE_CONTRACT} RPC_URL: ${RPC_URL} diff --git a/snap-account-abstraction-keyring b/snap-account-abstraction-keyring index 3c57571..cfdd3a5 160000 --- a/snap-account-abstraction-keyring +++ b/snap-account-abstraction-keyring @@ -1 +1 @@ -Subproject commit 3c575712536bb245a8e69d45faf0944d59dfdf75 +Subproject commit cfdd3a50ccd50271565126df6b25195f77c1021c From f8e260fc7748e4ca3f7a3d04b4b1864d6c7555a7 Mon Sep 17 00:00:00 2001 From: wsdt Date: Tue, 27 Aug 2024 10:17:51 +0200 Subject: [PATCH 02/25] fix: playwright first run --- .circleci/config.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index 1e38ee9..1802592 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -13,6 +13,7 @@ jobs: image: ubuntu-2204:current resource_class: large parallelism: 10 + executor: steps: - checkout - docker/install-docker @@ -87,6 +88,9 @@ jobs: command: | cd ./contracts pnpm install + - run: + name: Install Playwright (E2E) + command: pnpm playwright install - run: name: Start local environment command: | From ba769d59f1835218b82adcecb620ae0998010bd1 Mon Sep 17 00:00:00 2001 From: wsdt Date: Tue, 27 Aug 2024 11:48:51 +0200 Subject: [PATCH 03/25] fix: playwright exec --- .circleci/config.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 1802592..cf1d86a 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -89,8 +89,11 @@ jobs: cd ./contracts pnpm install - run: - name: Install Playwright (E2E) - command: pnpm playwright install + name: Install Playwright as Dev Dependency + command: pnpm add playwright --save-dev + - run: + name: Install Playwright Browser Binaries + command: pnpm exec playwright install - run: name: Start local environment command: | From ddaf2cd46d9584c5c5adb5331261d053b9bd27e4 Mon Sep 17 00:00:00 2001 From: wsdt Date: Tue, 27 Aug 2024 11:52:48 +0200 Subject: [PATCH 04/25] fix: wksp --- .circleci/config.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index cf1d86a..6837774 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -85,9 +85,7 @@ jobs: command: pnpm install - run: name: Install dependencies (contracts) - command: | - cd ./contracts - pnpm install + command: pnpm install - run: name: Install Playwright as Dev Dependency command: pnpm add playwright --save-dev From 4df38acd843ecb869d12766d95d448ab1207e6ba Mon Sep 17 00:00:00 2001 From: wsdt Date: Tue, 27 Aug 2024 11:55:29 +0200 Subject: [PATCH 05/25] fix: wksp --- .circleci/config.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 6837774..131048f 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -83,12 +83,6 @@ jobs: - run: name: Install dependencies (root) command: pnpm install - - run: - name: Install dependencies (contracts) - command: pnpm install - - run: - name: Install Playwright as Dev Dependency - command: pnpm add playwright --save-dev - run: name: Install Playwright Browser Binaries command: pnpm exec playwright install From 1ebe1e04cb4e85f573790b01c393b9790bdf4ac7 Mon Sep 17 00:00:00 2001 From: wsdt Date: Tue, 27 Aug 2024 13:04:22 +0200 Subject: [PATCH 06/25] fix: pw --- contracts/package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/contracts/package.json b/contracts/package.json index 6a05d67..c3da3ab 100644 --- a/contracts/package.json +++ b/contracts/package.json @@ -41,7 +41,8 @@ "ts-jest": "^29.2.3", "ts-node": "^10.9.2", "typechain": "^8.3.2", - "typescript": "^5.5.3" + "typescript": "^5.5.3", + "@playwright/test": "^1.42.0" }, "dependencies": { "@openzeppelin/contracts": "^4.0.2", From 0060a4cfc16ca21f07799a2ca2f644bb6dd64d58 Mon Sep 17 00:00:00 2001 From: wsdt Date: Tue, 27 Aug 2024 13:13:06 +0200 Subject: [PATCH 07/25] test: test --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 131048f..60c7442 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -98,7 +98,7 @@ jobs: name: Run Hardhat tests command: | cd ./contracts - npx playwright test ./test/e2e/send-user-op.e2e.test.ts --timeout=600000 + pnpm exec playwright test ./test/e2e/send-user-op.e2e.test.ts --timeout=600000 environment: TOKEN_PRICE_CONTRACT: ${TOKEN_PRICE_CONTRACT} RPC_URL: ${RPC_URL} From 107251168f2005bc90b90b076e045d5f5d6de9f2 Mon Sep 17 00:00:00 2001 From: wsdt Date: Tue, 27 Aug 2024 13:20:55 +0200 Subject: [PATCH 08/25] test: test --- .circleci/config.yml | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 60c7442..9b02558 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -9,19 +9,17 @@ orbs: jobs: integration-tests: - machine: - image: ubuntu-2204:current + docker: + - image: mcr.microsoft.com/playwright:v1.23.1-focal resource_class: large parallelism: 10 - executor: steps: - checkout - - docker/install-docker - run: name: Install essential tools command: | - sudo apt-get update - sudo apt-get install -y curl git software-properties-common python3 python3-pip + apt-get update + apt-get install -y curl git software-properties-common python3 python3-pip - go/install: version: 1.22.5 - node/install @@ -64,14 +62,13 @@ jobs: - run: name: Install pnpm command: | - curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash - - sudo apt-get install -y nodejs + curl -fsSL https://deb.nodesource.com/setup_18.x | bash - + apt-get install -y nodejs npm i -g yarn pnpm echo "NPM version: $(npm --version)" echo "Yarn version: $(yarn --version)" echo "PNPM version: $(pnpm --version)" pnpm config set store-dir .pnpm-store - - save_cache: name: Save pnpm Package Cache key: pnpm-packages-{{ checksum "pnpm-lock.yaml" }} @@ -79,13 +76,10 @@ jobs: - .pnpm-store - run: name: Install Make - command: sudo apt-get install -y make + command: apt-get install -y make - run: name: Install dependencies (root) command: pnpm install - - run: - name: Install Playwright Browser Binaries - command: pnpm exec playwright install - run: name: Start local environment command: | From 76b8ffd39143796f0f06dd745f3d174ca00a2d3e Mon Sep 17 00:00:00 2001 From: wsdt Date: Tue, 27 Aug 2024 13:28:45 +0200 Subject: [PATCH 09/25] test: test --- .circleci/config.yml | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 9b02558..e598840 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -9,17 +9,18 @@ orbs: jobs: integration-tests: - docker: - - image: mcr.microsoft.com/playwright:v1.23.1-focal + machine: + image: ubuntu-2204:current resource_class: large parallelism: 10 steps: - checkout + - docker/install-docker - run: name: Install essential tools command: | - apt-get update - apt-get install -y curl git software-properties-common python3 python3-pip + sudo apt-get update + sudo apt-get install -y curl git software-properties-common python3 python3-pip - go/install: version: 1.22.5 - node/install @@ -62,8 +63,8 @@ jobs: - run: name: Install pnpm command: | - curl -fsSL https://deb.nodesource.com/setup_18.x | bash - - apt-get install -y nodejs + curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash - + sudo apt-get install -y nodejs npm i -g yarn pnpm echo "NPM version: $(npm --version)" echo "Yarn version: $(yarn --version)" @@ -76,10 +77,15 @@ jobs: - .pnpm-store - run: name: Install Make - command: apt-get install -y make + command: sudo apt-get install -y make - run: name: Install dependencies (root) command: pnpm install + - run: + name: Install Playwright and browsers + command: | + sudo apt-get install -y libgbm-dev + PLAYWRIGHT_BROWSERS_PATH=/home/circleci/playwright-browsers pnpm exec playwright install --with-deps chromium - run: name: Start local environment command: | @@ -92,7 +98,7 @@ jobs: name: Run Hardhat tests command: | cd ./contracts - pnpm exec playwright test ./test/e2e/send-user-op.e2e.test.ts --timeout=600000 + PLAYWRIGHT_BROWSERS_PATH=/home/circleci/playwright-browsers pnpm exec playwright test ./test/e2e/send-user-op.e2e.test.ts --timeout=600000 environment: TOKEN_PRICE_CONTRACT: ${TOKEN_PRICE_CONTRACT} RPC_URL: ${RPC_URL} From 2de2b7ca7bfdd42bb52e853f5c976ae5a305e0d4 Mon Sep 17 00:00:00 2001 From: wsdt Date: Tue, 27 Aug 2024 13:45:28 +0200 Subject: [PATCH 10/25] test: test --- .circleci/config.yml | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index e598840..105f53c 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -13,6 +13,7 @@ jobs: image: ubuntu-2204:current resource_class: large parallelism: 10 + executor: steps: - checkout - docker/install-docker @@ -82,10 +83,8 @@ jobs: name: Install dependencies (root) command: pnpm install - run: - name: Install Playwright and browsers - command: | - sudo apt-get install -y libgbm-dev - PLAYWRIGHT_BROWSERS_PATH=/home/circleci/playwright-browsers pnpm exec playwright install --with-deps chromium + name: Install Playwright Browser Binaries + command: pnpm exec playwright install - run: name: Start local environment command: | @@ -93,12 +92,12 @@ jobs: no_output_timeout: 60m environment: PRIVATE_KEY: ${PRIVATE_KEY} - CONRANKING_API_KEY: ${CONRANKING_API_KEY} + COINRANKING_API_KEY: ${COINRANKING_API_KEY} - run: - name: Run Hardhat tests + name: Run E2E tests command: | cd ./contracts - PLAYWRIGHT_BROWSERS_PATH=/home/circleci/playwright-browsers pnpm exec playwright test ./test/e2e/send-user-op.e2e.test.ts --timeout=600000 + pnpm exec playwright test ./test/e2e/send-user-op.e2e.test.ts --timeout=600000 environment: TOKEN_PRICE_CONTRACT: ${TOKEN_PRICE_CONTRACT} RPC_URL: ${RPC_URL} From aacbf5ae238f0d47a9e61a21c46f7170c87d95e9 Mon Sep 17 00:00:00 2001 From: wsdt Date: Tue, 27 Aug 2024 13:53:02 +0200 Subject: [PATCH 11/25] test: test --- .circleci/config.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 105f53c..4883350 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -84,7 +84,7 @@ jobs: command: pnpm install - run: name: Install Playwright Browser Binaries - command: pnpm exec playwright install + command: npx playwright install --with-deps - run: name: Start local environment command: | @@ -97,7 +97,7 @@ jobs: name: Run E2E tests command: | cd ./contracts - pnpm exec playwright test ./test/e2e/send-user-op.e2e.test.ts --timeout=600000 + npx playwright test ./test/e2e/send-user-op.e2e.test.ts --timeout=600000 environment: TOKEN_PRICE_CONTRACT: ${TOKEN_PRICE_CONTRACT} RPC_URL: ${RPC_URL} From d5cf703532088c9d5a2f7bcfb8106d31012e47ca Mon Sep 17 00:00:00 2001 From: wsdt Date: Tue, 27 Aug 2024 14:00:10 +0200 Subject: [PATCH 12/25] test: test --- .circleci/config.yml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 4883350..9fed8c8 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -82,9 +82,16 @@ jobs: - run: name: Install dependencies (root) command: pnpm install + - run: + name: Install dependencies (contracts) + command: | + cd ./contracts + pnpm install - run: name: Install Playwright Browser Binaries - command: npx playwright install --with-deps + command: | + cd ./contracts + npx playwright install --with-deps - run: name: Start local environment command: | From 39cddccca462a37e95efb048bcf1fe34db02613a Mon Sep 17 00:00:00 2001 From: wsdt Date: Tue, 27 Aug 2024 14:14:22 +0200 Subject: [PATCH 13/25] test: test --- .circleci/config.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 9fed8c8..8947780 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -13,7 +13,6 @@ jobs: image: ubuntu-2204:current resource_class: large parallelism: 10 - executor: steps: - checkout - docker/install-docker From bbe9f870fe054a70b59a3280c6bbf33536fd9c4f Mon Sep 17 00:00:00 2001 From: wsdt Date: Tue, 27 Aug 2024 14:36:02 +0200 Subject: [PATCH 14/25] test: test --- .circleci/config.yml | 2 +- contracts/script/deploy-local.ts | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 8947780..e4be0b1 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -90,7 +90,7 @@ jobs: name: Install Playwright Browser Binaries command: | cd ./contracts - npx playwright install --with-deps + npx playwright install-deps chromium - run: name: Start local environment command: | diff --git a/contracts/script/deploy-local.ts b/contracts/script/deploy-local.ts index ba270de..cee58ab 100644 --- a/contracts/script/deploy-local.ts +++ b/contracts/script/deploy-local.ts @@ -31,7 +31,6 @@ const backendEnvPath = path.resolve(__dirname, "../../backend/.env"); const contractsEnvPath = path.resolve(__dirname, "../.env"); let aaConfigFile = fs.readFileSync('../snap-account-abstraction-keyring/packages/snap/src/constants/aa-config.ts', 'utf8'); - // TODO: fix .env file loading. Currently .env needs to be in /script directory async function main() { try { From 719e4a9e77cfd9997ac0fc0be0f3efc39f063f10 Mon Sep 17 00:00:00 2001 From: wsdt Date: Tue, 27 Aug 2024 14:40:57 +0200 Subject: [PATCH 15/25] test: test --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index e4be0b1..5bb0c9a 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -90,7 +90,7 @@ jobs: name: Install Playwright Browser Binaries command: | cd ./contracts - npx playwright install-deps chromium + npx playwright install - run: name: Start local environment command: | From 4772918b573b3b02ed262d4bfb0f13e8eae89d5a Mon Sep 17 00:00:00 2001 From: wsdt Date: Tue, 27 Aug 2024 15:05:21 +0200 Subject: [PATCH 16/25] test: accept --- contracts/test/e2e/send-user-op.e2e.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/test/e2e/send-user-op.e2e.test.ts b/contracts/test/e2e/send-user-op.e2e.test.ts index 1d44bde..29be757 100644 --- a/contracts/test/e2e/send-user-op.e2e.test.ts +++ b/contracts/test/e2e/send-user-op.e2e.test.ts @@ -59,7 +59,7 @@ test('Scramble : Recover existing wallet!', async ({ context, extensionId }) => await clickTestIdAndWait(extensionPopup, 'confirmation-submit-button'); await clickTestIdAndWait(extensionPopup, 'confirmation-submit-button'); await clickTestIdAndWait(extensionPopup, 'snap-privacy-warning-scroll'); - await clickButtonWithText(extensionPopup, "Akzeptieren"); + await clickButtonWithText(extensionPopup, "Accept"); await clickTestIdAndWait(extensionPopup, 'page-container-footer-next'); await clickTestIdAndWait(extensionPopup, 'page-container-footer-next'); await clickTestIdAndWait(extensionPopup, 'page-container-footer-next'); From 36adc4de939265c5992c985f1de558deb6575d75 Mon Sep 17 00:00:00 2001 From: wsdt Date: Tue, 27 Aug 2024 15:51:31 +0200 Subject: [PATCH 17/25] test: click --- contracts/test/e2e/send-user-op.e2e.test.ts | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/contracts/test/e2e/send-user-op.e2e.test.ts b/contracts/test/e2e/send-user-op.e2e.test.ts index 29be757..f61cc33 100644 --- a/contracts/test/e2e/send-user-op.e2e.test.ts +++ b/contracts/test/e2e/send-user-op.e2e.test.ts @@ -59,7 +59,9 @@ test('Scramble : Recover existing wallet!', async ({ context, extensionId }) => await clickTestIdAndWait(extensionPopup, 'confirmation-submit-button'); await clickTestIdAndWait(extensionPopup, 'confirmation-submit-button'); await clickTestIdAndWait(extensionPopup, 'snap-privacy-warning-scroll'); - await clickButtonWithText(extensionPopup, "Accept"); + await sleep(500); + await clickButtonWithClass(extensionPopup, "mm-button-primary"); + await sleep(500); await clickTestIdAndWait(extensionPopup, 'page-container-footer-next'); await clickTestIdAndWait(extensionPopup, 'page-container-footer-next'); await clickTestIdAndWait(extensionPopup, 'page-container-footer-next'); @@ -139,6 +141,21 @@ export const clickTestIdAndWait = async (page: any, id: string) => { await sleep(500); } +export const clickButtonWithClass = async (page: any, buttonClass: string) => { + console.log(`Finding and clicking