From 158d9b442526a9f30cbb5ae621c038ca3bd9ea0e Mon Sep 17 00:00:00 2001 From: Kai Peacock Date: Wed, 26 Jun 2024 13:57:38 -0700 Subject: [PATCH] ci: removing headless browser tests pending a rewrite (#900) --- .github/workflows/e2e-browser-tests.yml | 79 ----------------------- README.md | 2 + docs/CHANGELOG.md | 3 +- e2e/browser/.gitignore | 2 - e2e/browser/.proxyrc | 5 -- e2e/browser/cypress.config.js | 12 ---- e2e/browser/cypress/.eslintrc.json | 6 -- e2e/browser/cypress/e2e/ecdsa.cy.js | 59 ----------------- e2e/browser/cypress/fixtures/example.json | 5 -- e2e/browser/cypress/support/commands.js | 25 ------- e2e/browser/cypress/support/e2e.js | 20 ------ e2e/browser/cypress/utils/actor.js | 25 ------- e2e/browser/dfx.json | 8 --- e2e/browser/package.json | 38 ----------- e2e/browser/src/index.html | 10 --- e2e/browser/src/whoami/main.mo | 5 -- package.json | 1 - 17 files changed, 3 insertions(+), 302 deletions(-) delete mode 100644 .github/workflows/e2e-browser-tests.yml delete mode 100644 e2e/browser/.gitignore delete mode 100644 e2e/browser/.proxyrc delete mode 100644 e2e/browser/cypress.config.js delete mode 100644 e2e/browser/cypress/.eslintrc.json delete mode 100644 e2e/browser/cypress/e2e/ecdsa.cy.js delete mode 100644 e2e/browser/cypress/fixtures/example.json delete mode 100644 e2e/browser/cypress/support/commands.js delete mode 100644 e2e/browser/cypress/support/e2e.js delete mode 100644 e2e/browser/cypress/utils/actor.js delete mode 100644 e2e/browser/dfx.json delete mode 100644 e2e/browser/package.json delete mode 100644 e2e/browser/src/index.html delete mode 100644 e2e/browser/src/whoami/main.mo diff --git a/.github/workflows/e2e-browser-tests.yml b/.github/workflows/e2e-browser-tests.yml deleted file mode 100644 index 270d6fd2a..000000000 --- a/.github/workflows/e2e-browser-tests.yml +++ /dev/null @@ -1,79 +0,0 @@ -name: E2E Browser Tests - -on: - pull_request: - types: - - opened - - reopened - - edited - - synchronize - -jobs: - test: - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - os: [ubuntu-20.04] - ghc: ['8.8.4'] - spec: - - '0.16.1' - node: - - 20 - - steps: - - uses: actions/checkout@v4 - - name: Use Node.js ${{ matrix.node }} - uses: actions/setup-node@v4 - with: - node-version: ${{ matrix.node }} - - - name: Cache node modules - id: cache-npm - uses: actions/cache@v4 - env: - cache-name: cache-node-modules - with: - # npm cache files are stored in `~/.npm` on Linux/macOS - path: ~/.npm - key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} - restore-keys: | - ${{ runner.os }}-build-${{ env.cache-name }}- - ${{ runner.os }}-build- - ${{ runner.os }}- - - if: ${{ steps.cache-npm.outputs.cache-hit != 'true' }} - name: List the state of node modules - continue-on-error: true - run: npm list - - run: npm ci - - run: npm run build -ws - - # build monorepo incl. each subpackage - - run: npm run build --workspaces --if-present - - - uses: dfinity/setup-dfx@main - - - name: running dfx - id: dfx - run: | - dfx start --background - - - name: Cypress e2e tests - uses: cypress-io/github-action@v6 - with: - install: false - project: ./e2e/browser - wait-on: 'http://localhost:1234' - wait-on-timeout: 240 - build: npm run setup --workspace e2e/browser - start: npm run start --workspace e2e/browser - - aggregate: - name: e2e:required - if: ${{ always() }} - needs: [test] - runs-on: ubuntu-latest - steps: - - name: check e2e test result - if: ${{ needs.test.result != 'success' }} - run: exit 1 diff --git a/README.md b/README.md index 09b83944f..d9b94c159 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,8 @@ dfx stop We expect you to have the replica running on port `4943`. If you are using a different port, you can set an environment variable `REPLICA_PORT` to the port number. +> Note: browser tests have been temporarily removed pending a rewrite + To run the e2e browser tests, you can run ```bash diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 818bebd06..96e145aa1 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -4,8 +4,7 @@ ### Changed -- ci: breaking out browser and noded e2e tests into separate workflows -- ci: using cypress github action for e2e tests +- ci: removing headless browser tests pending a rewrite ## [1.4.0] - 2024-06-17 diff --git a/e2e/browser/.gitignore b/e2e/browser/.gitignore deleted file mode 100644 index 4be3c33d4..000000000 --- a/e2e/browser/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -.parcel-cache -src/declarations diff --git a/e2e/browser/.proxyrc b/e2e/browser/.proxyrc deleted file mode 100644 index 4e68b07fe..000000000 --- a/e2e/browser/.proxyrc +++ /dev/null @@ -1,5 +0,0 @@ -{ - "/api": { - "target": "http://127.0.0.1:4943/" - } -} diff --git a/e2e/browser/cypress.config.js b/e2e/browser/cypress.config.js deleted file mode 100644 index 03743f098..000000000 --- a/e2e/browser/cypress.config.js +++ /dev/null @@ -1,12 +0,0 @@ -/* eslint-disable no-undef */ -/* eslint-disable @typescript-eslint/no-var-requires */ -const { defineConfig } = require('cypress'); - -module.exports = defineConfig({ - video: false, - e2e: { - setupNodeEvents() { - // implement node event listeners here - }, - }, -}); diff --git a/e2e/browser/cypress/.eslintrc.json b/e2e/browser/cypress/.eslintrc.json deleted file mode 100644 index 96a5a52f1..000000000 --- a/e2e/browser/cypress/.eslintrc.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "plugins": ["cypress"], - "env": { - "cypress/globals": true - } -} diff --git a/e2e/browser/cypress/e2e/ecdsa.cy.js b/e2e/browser/cypress/e2e/ecdsa.cy.js deleted file mode 100644 index 3005ca286..000000000 --- a/e2e/browser/cypress/e2e/ecdsa.cy.js +++ /dev/null @@ -1,59 +0,0 @@ -import { ECDSAKeyIdentity } from '@dfinity/identity'; -import { get, set } from 'idb-keyval'; -import { createActor } from '../utils/actor'; -import ids from '../../.dfx/local/canister_ids.json'; -import fetchPolyfill from 'isomorphic-fetch'; -const canisterId = ids.whoami.local; - -const setup = async () => { - const identity1 = await ECDSAKeyIdentity.generate(); - const whoami1 = createActor(ids.whoami.local, { - agentOptions: { - verifyQuerySignatures: false, - identity: identity1, - fetch: fetchPolyfill, - host: 'http://localhost:4943/', - }, - }); - - const principal1 = await whoami1.whoami(); - - return { principal1, whoami1, identity1 }; -}; - -describe('ECDSAKeyIdentity tests with SubtleCrypto', () => { - it('generates a new identity', () => { - cy.visit('http://localhost:1234'); - cy.window().then(async () => { - const { principal1 } = await setup(); - const str = principal1.toString(); - expect(str).to.be.an('string'); - }); - }); - it('can persist an identity in indexeddb', () => { - cy.visit('http://localhost:1234'); - cy.window().then(async () => { - const { principal1, identity1 } = await setup(); - const str = principal1.toString(); - expect(str).to.be.an('string'); - - await set('keyPair', identity1.getKeyPair()); - const storedKeyPair = await get('keyPair'); - - const identity2 = await ECDSAKeyIdentity.fromKeyPair(storedKeyPair); - - const whoami2 = createActor(canisterId, { - agentOptions: { - verifyQuerySignatures: false, - identity: identity2, - fetchPolyfill, - host: 'http://localhost:4943/', - }, - }); - - const principal2 = await whoami2.whoami(); - - expect(principal2.toString()).to.equal(str); - }); - }); -}); diff --git a/e2e/browser/cypress/fixtures/example.json b/e2e/browser/cypress/fixtures/example.json deleted file mode 100644 index 02e425437..000000000 --- a/e2e/browser/cypress/fixtures/example.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "name": "Using fixtures to represent data", - "email": "hello@cypress.io", - "body": "Fixtures are a great way to mock data for responses to routes" -} diff --git a/e2e/browser/cypress/support/commands.js b/e2e/browser/cypress/support/commands.js deleted file mode 100644 index 119ab03f7..000000000 --- a/e2e/browser/cypress/support/commands.js +++ /dev/null @@ -1,25 +0,0 @@ -// *********************************************** -// This example commands.js shows you how to -// create various custom commands and overwrite -// existing commands. -// -// For more comprehensive examples of custom -// commands please read more here: -// https://on.cypress.io/custom-commands -// *********************************************** -// -// -// -- This is a parent command -- -// Cypress.Commands.add('login', (email, password) => { ... }) -// -// -// -- This is a child command -- -// Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... }) -// -// -// -- This is a dual command -- -// Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... }) -// -// -// -- This will overwrite an existing command -- -// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... }) diff --git a/e2e/browser/cypress/support/e2e.js b/e2e/browser/cypress/support/e2e.js deleted file mode 100644 index 5df9c0186..000000000 --- a/e2e/browser/cypress/support/e2e.js +++ /dev/null @@ -1,20 +0,0 @@ -// *********************************************************** -// This example support/e2e.js is processed and -// loaded automatically before your test files. -// -// This is a great place to put global configuration and -// behavior that modifies Cypress. -// -// You can change the location of this file or turn off -// automatically serving support files with the -// 'supportFile' configuration option. -// -// You can read more here: -// https://on.cypress.io/configuration -// *********************************************************** - -// Import commands.js using ES2015 syntax: -import './commands'; - -// Alternatively you can use CommonJS syntax: -// require('./commands') diff --git a/e2e/browser/cypress/utils/actor.js b/e2e/browser/cypress/utils/actor.js deleted file mode 100644 index 21a56a487..000000000 --- a/e2e/browser/cypress/utils/actor.js +++ /dev/null @@ -1,25 +0,0 @@ -import { Actor, HttpAgent } from '@dfinity/agent'; - -// Imports and re-exports candid interface -import { idlFactory } from '../../src/declarations/whoami/whoami.did.js'; -export { idlFactory } from '../../src/declarations/whoami/whoami.did.js'; -// CANISTER_ID is replaced by webpack based on node environment - -/** - * - * @param {string | import("@dfinity/principal").Principal} canisterId Canister ID of Agent - * @param {{agentOptions?: import("@dfinity/agent").HttpAgentOptions; actorOptions?: import("@dfinity/agent").ActorConfig}} [options] - Options for creating the actor - * @returns {import("@dfinity/agent").ActorSubclass} - Actor - */ -export const createActor = (canisterId, options) => { - const agent = new HttpAgent({ ...options?.agentOptions }); - - agent.fetchRootKey(); - - // Creates an actor with using the candid interface and the HttpAgent - return Actor.createActor(idlFactory, { - agent, - canisterId, - ...options?.actorOptions, - }); -}; diff --git a/e2e/browser/dfx.json b/e2e/browser/dfx.json deleted file mode 100644 index e679204e2..000000000 --- a/e2e/browser/dfx.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "canisters": { - "whoami": { - "type": "motoko", - "main": "src/whoami/main.mo" - } - } -} diff --git a/e2e/browser/package.json b/e2e/browser/package.json deleted file mode 100644 index df5076aaf..000000000 --- a/e2e/browser/package.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "private": true, - "name": "@do-not-publish/ic-cypress-e2e-tests", - "version": "1.4.0", - "scripts": { - "ci": "npm run e2e", - "setup": "dfx deploy; dfx generate; pm2 --name parcel start npm -- start", - "cypress": "cypress run", - "e2e": "npm run cypress", - "poste2e": "pm2 kill", - "eslint:fix": "npm run lint -- --fix", - "eslint": "eslint --ext '.js,.jsx,.ts,.tsx' cypress *.js", - "lint": "npm run eslint", - "build": "", - "lint:fix": "npm run lint -- --fix", - "test:coverage": "", - "test": "", - "start": "parcel src/index.html" - }, - "devDependencies": { - "@types/node": "^18.0.6", - "concurrently": "^8.2.2", - "cypress": "^13.7.0", - "esbuild": "^0.20.2", - "parcel": "^2.12.0", - "pm2": "^5.3.1", - "size-limit": "^8.1.0" - }, - "dependencies": { - "@dfinity/agent": "^1.4.0", - "@dfinity/identity": "^1.4.0", - "@dfinity/principal": "^1.4.0", - "idb-keyval": "^6.2.0" - }, - "optionalDependencies": { - "@rollup/rollup-linux-x64-gnu": "4.6.1" - } -} diff --git a/e2e/browser/src/index.html b/e2e/browser/src/index.html deleted file mode 100644 index 5f5781da8..000000000 --- a/e2e/browser/src/index.html +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - test - - - diff --git a/e2e/browser/src/whoami/main.mo b/e2e/browser/src/whoami/main.mo deleted file mode 100644 index 86c9b9aad..000000000 --- a/e2e/browser/src/whoami/main.mo +++ /dev/null @@ -1,5 +0,0 @@ -actor { - public shared query (msg) func whoami() : async Principal { - msg.caller - }; -}; diff --git a/package.json b/package.json index 473b9cb1e..f9b3a07e5 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,6 @@ "packages/auth-client", "packages/assets", "packages/identity-secp256k1", - "e2e/browser", "e2e/node" ] },