This UI repo is now a Node project and ships Playwright tests that mock MetaMask.
- Node.js
- Playwright browser binaries:
npx playwright install
The e2e harness now auto-provisions token-lock-contract when no matching local checkout is present.
It uses this priority:
CONTRACT_REPOif you set it../token-lock-contractif it already exists and already matches the selected contract ref- a managed clone in
./.e2e/token-lock-contract
The selected contract ref is resolved in this order:
CONTRACT_REPO_REF, treated as an explicit git ref such as a branch, tag, or full commit SHAGITHUB_HEAD_REFGITHUB_REF_NAME- the current local git branch, if that branch exists in
Liberdus/token-lock-contract main
If the sibling checkout is present but is on a different ref, the harness leaves it alone and uses the managed clone instead.
You can still create the sibling checkout manually if you prefer:
git clone https://github.com/Liberdus/token-lock-contract ../token-lock-contractFrom token-lock-ui:
npm install
npx playwright install
npm run test:e2eFrom token-lock-ui:
npm run test:e2e -- --headed --project=chromiumOptional slow motion:
npm run test:e2e -- --headed --project=chromium --slow-mo=250What this does:
- Ensures
token-lock-contractis available on the selected ref - Installs contract repo dependencies when needed
- Starts a local Hardhat node in
token-lock-contract - Compiles and deploys TokenLock to the local node
- Starts a local static server that proxies JSON-RPC
- Runs Playwright tests with a mocked
window.ethereum
Use a fresh Hardhat node so the deterministic deployment addresses match js/config.js.
Terminal 1:
cd ../token-lock-contract
npx hardhat node --hostname 127.0.0.1 --port 8545Terminal 2:
node scripts/deploy-local.jsThen open the UI through VS Code Live Server with:
?env=hardhat
MetaMask must use chain ID 31337 (0x7a69) for http://127.0.0.1:8545.
If MetaMask already has that RPC saved as chain ID 1337, edit or remove that network first; MetaMask will not add a second network with the same RPC URL and a different chain ID.
Use the deployed mockToken address from node scripts/deploy-local.js as the token address in the lock form.
- The mock provider exposes one account:
0xf39f...2266(Hardhat default #0). - The static server serves a test
js/config.jsthat targets the local chain. - No real MetaMask is required for tests.