Skip to content

Commit 7fe8142

Browse files
authored
feat!: modernize project (#394)
* feat: begin modernization * build: migrate mui * style: adjust theme * chore: react type fix * build: update dependencies to get rid of vulnerabilities * chore: cleanup * test: add ui test suite
1 parent cbd33dc commit 7fe8142

70 files changed

Lines changed: 6073 additions & 31961 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.env.example

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# URL of the Bee node used for e2e tests.
2+
# Copy this file to .env and fill in the value before running tests.
3+
BEE_NODE_URL=

.eslintrc

Lines changed: 0 additions & 96 deletions
This file was deleted.

.github/workflows/check.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
runs-on: ubuntu-latest
1414

1515
env:
16-
REACT_APP_BEE_HOSTS: 'https://gateway-proxy-bee-0-0.gateway.ethswarm.org/,https://gateway-proxy-bee-1-0.gateway.ethswarm.org/,https://gateway-proxy-bee-2-0.gateway.ethswarm.org/,https://gateway-proxy-bee-3-0.gateway.ethswarm.org/,https://gateway-proxy-bee-4-0.gateway.ethswarm.org/,https://gateway-proxy-bee-5-0.gateway.ethswarm.org/,https://gateway-proxy-bee-6-0.gateway.ethswarm.org/,https://gateway-proxy-bee-7-0.gateway.ethswarm.org/,https://gateway-proxy-bee-8-0.gateway.ethswarm.org/,https://gateway-proxy-bee-9-0.gateway.ethswarm.org/'
16+
VITE_BEE_HOSTS: 'https://gateway-proxy-bee-0-0.gateway.ethswarm.org/,https://gateway-proxy-bee-1-0.gateway.ethswarm.org/,https://gateway-proxy-bee-2-0.gateway.ethswarm.org/,https://gateway-proxy-bee-3-0.gateway.ethswarm.org/,https://gateway-proxy-bee-4-0.gateway.ethswarm.org/,https://gateway-proxy-bee-5-0.gateway.ethswarm.org/,https://gateway-proxy-bee-6-0.gateway.ethswarm.org/,https://gateway-proxy-bee-7-0.gateway.ethswarm.org/,https://gateway-proxy-bee-8-0.gateway.ethswarm.org/,https://gateway-proxy-bee-9-0.gateway.ethswarm.org/'
1717

1818
strategy:
1919
matrix:
@@ -39,7 +39,6 @@ jobs:
3939
${{ runner.OS }}-node-${{ matrix.node-version }}-
4040
4141
- name: Install npm deps
42-
if: steps.cache-npm.outputs.cache-hit != 'true'
4342
run: npm ci
4443

4544
- name: Commit linting

.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
# misc
1515
.DS_Store
16+
.env
1617
.env.local
1718
.env.development.local
1819
.env.test.local
@@ -21,3 +22,11 @@
2122
npm-debug.log*
2223
yarn-debug.log*
2324
yarn-error.log*
25+
26+
dist
27+
28+
# playwright
29+
/playwright-report
30+
/test-results
31+
e2e/.test-hash*
32+
/test-results-video

e2e/.test-hash-folder

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
88ff2b383d7d2cda715af8a07d0a1c6ed3bf9ed6473284ba125db993e885b981

e2e/.test-hash-image

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ff666655ee45285357cf88db22b18783e6eb1535b95202584394b1cfd30f1cf7

e2e/.test-hash-txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ddb5e2bb965923861fc30d89a4ff19186f7cbac428a2115c31a1e6cc1021b5fb

e2e/.test-hash-video

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
8531bfa189483b74e83a8a367a2782edb817ab70736a13a19ee236611f5ed188

e2e/.test-hash-website

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3734316181a08d457e7a895f6b884fd009b70ad3328d30055597c50435e2476e

e2e/README.md

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# E2E Test Setup
2+
3+
## Commands
4+
5+
| Command | Purpose |
6+
|---|---|
7+
| `npm test` | Run all tests headlessly (fast, CI-friendly) |
8+
| `npm run test:ui` | Playwright UI mode — step through tests interactively |
9+
| `npm run test:video` | Run all tests with video recording + 600 ms slowMo per action |
10+
11+
Videos are saved to `test-results-video/<test-name>/video.webm` after `test:video` finishes.
12+
13+
## How it works
14+
15+
**Bee node:** Tests run against a proxied Bee node whose URL is stored in `BEE_NODE_URL`. Copy `.env.example` to `.env` and set the value before running tests. The all-zeros postage stamp (default) is accepted by that node — no other configuration needed.
16+
17+
**CORS workaround:** The browser can't call the Bee node directly because the proxy doesn't allow the `swarm-collection` header. `vite.config.ts` proxies `/bzz`, `/bytes`, `/chunks` through the Vite dev server when `BEE_PROXY_TARGET` is set. The Playwright config sets `BEE_PROXY_TARGET=$BEE_NODE_URL` and `VITE_BEE_HOSTS=http://localhost:3030` so the app sends same-origin requests that Vite then forwards to the real node.
18+
19+
**Global setup (`e2e/global-setup.ts`):** Runs once before any tests. Uploads five files through the UI and writes each resulting hash to a `.test-hash-<name>` file. Tests that need a known-good hash read from those files.
20+
21+
| File written | Content uploaded |
22+
|---|---|
23+
| `.test-hash` | Plain text (used by basic upload/access tests) |
24+
| `.test-hash-image` | `test-data/image.png` |
25+
| `.test-hash-video` | `test-data/video.webm` |
26+
| `.test-hash-website` | `test-data/website/` directory |
27+
| `.test-hash-folder` | `test-data/folder/` directory |
28+
29+
## Test files
30+
31+
| File | What it covers |
32+
|---|---|
33+
| `navigation.spec.ts` | Landing page buttons; navigation to /share and /access |
34+
| `upload.spec.ts` | Terms popup, file selection, upload flow, hash display, copy button |
35+
| `access.spec.ts` | Hash input, find button, invalid hash tooltip, not-found page |
36+
| `upload-types.spec.ts` | AssetPreview on the upload preview screen for image, video, website, folder |
37+
| `access-types.spec.ts` | AssetPreview on the access/download page for the same four types |
38+
39+
## Test data (`e2e/test-data/`)
40+
41+
| File | MIME type | Notes |
42+
|---|---|---|
43+
| `image.png` | `image/png` | 1×1 pixel PNG generated by Python |
44+
| `video.webm` | `video/webm; codecs=vp8` | Minimal 41-byte EBML/WebM header. **Must use the full codec string** — plain `video/webm` returns `'maybe'` from `canPlayType` in Chromium headless shell, which `isSupportedVideoType()` treats as unsupported. VP8 returns `'probably'`. |
45+
| `website/index.html` + `website/style.css` | `text/html` / `text/css` | Two files under a common `website/` prefix; `detectIndexHtml` finds `index.html` and sets `isWebsite = true` |
46+
| `folder/document.txt` + `folder/readme.txt` | `text/plain` | Two files under `folder/`; no `index.html` so `type = 'folder'`, `count = 2` |
47+
48+
Website and folder uploads use the `folder-input` (the "add a folder or website" button), which has the `webkitdirectory` attribute. Playwright requires a real directory path for such inputs — file-object arrays are rejected.
49+
50+
## `data-testid` selectors added to the app
51+
52+
| testid | Component | Element |
53+
|---|---|---|
54+
| `share-button` | `LandingPage` | Share navigation button |
55+
| `access-button` | `LandingPage` | Access navigation button |
56+
| `agree-button` | `TermsAndConditionsPopup` | "I agree" button |
57+
| `file-input` | `AddFile` | Hidden `<input type="file">` for single/multiple files |
58+
| `folder-input` | `AddFile` | Hidden `<input type="file" webkitdirectory>` for directories |
59+
| `upload-button` | `Upload` (preview step) | Upload submit button |
60+
| `swarm-hash` | `Share` (result step) | Typography containing the Swarm hash string |
61+
| `copy-button` | `Share` (result step) | Copy-to-clipboard button |
62+
| `hash-input` | `Access` | Hash search text input |
63+
| `find-button` | `Access` | Find/navigate button |
64+
| `download-button` | `AccessHash` | Download button (both metadata and chunk-only paths) |

0 commit comments

Comments
 (0)