From 6b7428319f82ff24333544a02f23e7a794d7af84 Mon Sep 17 00:00:00 2001 From: Keyrxng <106303466+Keyrxng@users.noreply.github.com> Date: Mon, 29 Apr 2024 15:36:55 +0100 Subject: [PATCH] feat: anvil cypress CI action --- .github/workflows/cypress-testing.yml | 66 ++++++++++++++++++++++++++ cypress/e2e/claim-portal-success.cy.ts | 6 ++- package.json | 5 +- 3 files changed, 74 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/cypress-testing.yml diff --git a/.github/workflows/cypress-testing.yml b/.github/workflows/cypress-testing.yml new file mode 100644 index 00000000..b338e0a1 --- /dev/null +++ b/.github/workflows/cypress-testing.yml @@ -0,0 +1,66 @@ +name: test + +on: + push: + branches: + - main + - development + pull_request: + branches: + - main + - development + +env: + FOUNDRY_PROFILE: ci + +jobs: + tests: + name: Cypress tests + runs-on: ubuntu-latest + steps: + - uses: actions/setup-node@v4 + with: + node-version: 20.10.0 + - uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Install Foundry + uses: foundry-rs/foundry-toolchain@v1 + with: + version: nightly + + - name: Install dependencies + run: yarn install + + - name: Start Anvil + run: yarn test:anvil & + + - name: Cypress run + uses: cypress-io/github-action@v6 + with: + build: yarn run build + start: yarn test:fund, yarn start + + env: + SUPABASE_URL: "https://wfzpewmlyiozupulbuur.supabase.co" + SUPABASE_ANON_KEY: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6IndmenBld21seWlvenVwdWxidXVyIiwicm9sZSI6ImFub24iLCJpYXQiOjE2OTU2NzQzMzksImV4cCI6MjAxMTI1MDMzOX0.SKIL3Q0NOBaMehH0ekFspwgcu3afp3Dl9EDzPqs1nKs" + AMOUNT_IN_ETH: "0.1" + BENEFICIARY_ADDRESS: "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266" + CHAIN_ID: "31337" + FRONTEND_URL: "http://localhost:8080" + PAYMENT_TOKEN_ADDRESS: "0xe91D153E0b41518A2Ce8Dd3D7944Fa863463a97d" + RPC_PROVIDER_URL: "http://localhost:8545" + UBIQUIBOT_PRIVATE_KEY: "0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d" + - uses: actions/upload-artifact@v4 + if: failure() + with: + name: cypress-screenshots + path: cypress/screenshots + if-no-files-found: ignore + - uses: actions/upload-artifact@v4 + if: failure() + with: + name: cypress-videos + path: cypress/videos + if-no-files-found: ignore diff --git a/cypress/e2e/claim-portal-success.cy.ts b/cypress/e2e/claim-portal-success.cy.ts index 4c09f1b9..fb4275e0 100644 --- a/cypress/e2e/claim-portal-success.cy.ts +++ b/cypress/e2e/claim-portal-success.cy.ts @@ -27,7 +27,11 @@ describe("Claims Portal Success", () => { cy.get("#invalidator").should("not.be.visible"); - cy.get("#claim-loader").should("be.visible"); + cy.get("#claim-loader").should("be.visible").as("loader"); + + cy.wait(5000); // required for the action to complete + + cy.get("@loader").should("not.be.visible"); cy.get("#view-claim").should("be.visible").and("include.text", "View Claim"); diff --git a/package.json b/package.json index 1940c85b..e5a65b64 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,8 @@ "test:anvil": "tsx cypress/scripts/anvil.ts", "test:start": "yarn start", "test:run": "cypress run", - "test:open": "cypress open" + "test:open": "cypress open", + "test:fund": "cast rpc --rpc-url http://127.0.0.1:8545 anvil_impersonateAccount 0xba12222222228d8ba445958a75a0704d566bf2c8 & cast send --rpc-url http://127.0.0.1:8545 0xe91D153E0b41518A2Ce8Dd3D7944Fa863463a97d --unlocked --from 0xba12222222228d8ba445958a75a0704d566bf2c8 'transfer(address,uint256)(bool)' 0x70997970C51812dc3A010C7d01b50e0d17dc79C8 337888400000000000000000 & cast send --rpc-url http://127.0.0.1:8545 0xe91D153E0b41518A2Ce8Dd3D7944Fa863463a97d --unlocked --from 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 'approve(address,uint256)(bool)' 0x000000000022D473030F116dDEE9F6B43aC78BA3 9999999999999991111111119999999999999999 & cast send --rpc-url http://127.0.0.1:8545 0xe91D153E0b41518A2Ce8Dd3D7944Fa863463a97d --unlocked --from 0x70997970C51812dc3A010C7d01b50e0d17dc79C8 'approve(address,uint256)(bool)' 0x000000000022D473030F116dDEE9F6B43aC78BA3 999999999999999111119999999999999999" }, "keywords": [ "typescript", @@ -85,4 +86,4 @@ "@commitlint/config-conventional" ] } -} +} \ No newline at end of file