diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 35ae9828..2de7e81d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -70,13 +70,53 @@ jobs: test-results if-no-files-found: ignore - - name: Run unit tests - run: npm run test:unit - - name: Fail if visual regressions detected if: steps.visual.outcome == 'failure' run: exit 1 + unit-tests: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + node-version: [20] + shard: [1, 2, 3] + + steps: + - name: Check out repository + uses: actions/checkout@v4 + + - name: Set up Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node-version }} + + - name: Cache npm directory + uses: actions/cache@v4 + with: + path: ~/.npm + key: ${{ runner.os }}-node-${{ matrix.node-version }}-npm-${{ hashFiles('package-lock.json') }} + restore-keys: | + ${{ runner.os }}-node-${{ matrix.node-version }}-npm- + + - name: Cache node_modules + id: node-modules-cache + uses: actions/cache@v4 + with: + path: node_modules + key: ${{ runner.os }}-node-${{ matrix.node-version }}-modules-${{ hashFiles('package-lock.json') }} + restore-keys: | + ${{ runner.os }}-node-${{ matrix.node-version }}-modules- + + - name: Install dependencies + if: steps.node-modules-cache.outputs.cache-hit != 'true' + run: npm ci + + - name: Run unit tests (shard ${{ matrix.shard }}/3) + env: + UNIT_TEST_TIMEOUT_MS: 300000 + run: npm run test:unit:shard${{ matrix.shard }} + dm-unit-tests: runs-on: ubuntu-latest strategy: diff --git a/.gitignore b/.gitignore index 9ba12610..2f2cee23 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ playwright-report/ test-results/ tests/visual/__snapshots__/ artifacts/ +css/tailwind.generated.css diff --git a/AGENTS.md b/AGENTS.md index 031e5aa6..c55a1d28 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -2,6 +2,8 @@ This guide tells AI agents how to keep bitvid aligned with the current product direction. Follow it whenever you touch code, content, or documentation inside this repository. +**Important:** Before starting any development or debugging, please review `KNOWN_ISSUES.md`. This file documents pre-existing test failures, environmental quirks, and architectural limitations that you should be aware of to avoid unnecessary investigation. + For any nostr related work, please review the nip documentation located in /docs/nips before begining work. **Comment publishing guardrail:** Session actors are limited to passive telemetry (e.g., view counters). Always require the logged-in Nostr signer when sending video comments through [`js/nostr/commentEvents.js`](js/nostr/commentEvents.js). See the reminder in [`docs/nostr-event-schemas.md`](docs/nostr-event-schemas.md#event-catalogue) for context. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 9cc7cc55..a233dbc2 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -30,6 +30,7 @@ If we later introduce **dual-licensing** options (e.g., commercial licenses for * Add tests where reasonable; keep UI accessible. * Follow existing formatting/lint rules. * Update docs and user-facing text when behavior changes. +* Do not commit `css/tailwind.generated.css`; it is generated at build time. ## Agent PR Conventions diff --git a/KNOWN_ISSUES.md b/KNOWN_ISSUES.md new file mode 100644 index 00000000..0bc7354c --- /dev/null +++ b/KNOWN_ISSUES.md @@ -0,0 +1,33 @@ +# Known Issues + +## Tests + +### Unit Tests +- `npm run test:unit` consistently times out in the CI environment due to resource constraints. Targeted testing (`test:dm:unit`, `test:dm:integration`) is recommended. + +### Visual Regression Tests (`test:visual`) +- **Moderation UI (`tests/visual/moderation.spec.ts`)**: The "Show anyway" button and related moderation badges fail to render in the test environment, causing `toBeVisible()` assertions to fail. The logic for creating the button appears correct (`allowOverride` is true), but the button element is not found in the DOM during the test execution. This might be due to a race condition in the test fixture's state initialization or an environment-specific rendering issue. +- **Sidebar Layout (`tests/visual/overlay-layers.spec.ts`)**: The `mobile sidebar shares desktop rail behavior` test fails. The expected margin for the app container does not match the computed margin in the test environment (diff of ~45px). Attempts to fix this by adjusting CSS margin calculations were incomplete and reverted to avoid instability. +- **Kitchen Sink (`tests/visual/kitchen-sink.spec.ts`)**: Minor pixel mismatch (width 1292 vs expected 1280) in snapshot comparison. + +### E2E Tests (`test:e2e`) +- **Modals (`tests/e2e/ui-modals.spec.ts`)**: + - `application-form` and `profile-modal` fail with 404 errors for requested resources (likely related to how `http-server` serves relative paths or nested components in the test runner). + - Several modals (`upload-modal`, `edit-video-modal`, etc.) timeout waiting for close actions or visibility checks. This might be due to the `reducedMotion` application interacting poorly with visibility checks or genuine performance issues in the test runner. + - `login-modal` fails to find the `[data-nsec-error]` element (it expects it to be visible but it remains hidden). +- **Popover (`tests/e2e/popover.spec.ts`)**: Fails with `ReferenceError: getPanelWithTriggerMetrics is not defined`. This helper function seems to be missing or not imported correctly in the test file. + +## CSS / Design System +- The global CSS (`css/tailwind.source.css`) was updated to fix a linter error by using `calc(theme("screens.md") - var(--breakpoint-edge-offset))` instead of raw pixels. + +## Retrospective & Future Improvements + +### Challenges +- **Generated Artifacts**: The build process modifies `css/tailwind.generated.css`, which creates noise in diffs and potential merge conflicts. It is recommended to ignore this file in version control or enforce a check that it matches the build output without committing it manually in every PR. +- **Test Environment Isolation**: Debugging visual test failures (like the Sidebar Layout and Moderation UI) was difficult without access to the live browser UI or artifacts. The reproduction script failed due to environment restrictions on launching browsers. +- **Test Flakiness**: E2E tests for modals are prone to timeouts, likely due to animation/transition handling or resource loading delays in the CI environment. Using `applyReducedMotion` consistently helps but doesn't solve all timing issues. + +### Suggestions +- **Commit Hooks**: Implement a pre-commit hook that runs the linter and potentially the build to ensure generated files are in sync, or configure CI to fail if they are not. +- **Dockerized Testing**: Running tests in a consistent Docker container with Xvfb properly configured would help reproduce environment-specific failures locally. +- **Visual Testing improvements**: Ensure that test fixtures (like `moderation/fixtures/index.html`) correctly force UI updates after state injection to avoid race conditions. diff --git a/README.md b/README.md index 9ca262ff..bdab848c 100644 --- a/README.md +++ b/README.md @@ -112,6 +112,7 @@ To run **bitvid** locally: ```bash npm run build ``` + (This generates `css/tailwind.generated.css`, which is gitignored and required for styling.) 4. Start a local server: - Using Python: @@ -387,7 +388,7 @@ placeholder at “—” and development builds log a warning—so mixed deploym 4. **Make Changes**: - Ensure your code follows best practices and is well-documented. 5. **Test**: - - Run unit tests: `npm run test:unit` + - Run unit tests: `npm run test:unit` (or a shard like `npm run test:unit:shard1`) - Validate the site functionality locally before submitting. 6. **Submit a Pull Request**: - Explain your changes and reference any related issues. @@ -405,8 +406,12 @@ placeholder at “—” and development builds log a warning—so mixed deploym Continuous integration runs CSS linting/builds, the DM unit/integration suites, the Playwright kitchen-sink snapshots, headless E2E flows, and the Node-based unit tests on every push. Before pushing, run `npm run build` locally so the Tailwind bundle regenerates. -Pair that with `npm run test:unit` for application logic changes and -`npm run test:visual` for presentation updates to mirror the CI surface area. +Pair that with `npm run test:unit` for application logic changes, or a shard +(`npm run test:unit:shard1`, `test:unit:shard2`, `test:unit:shard3`) when you want to +split the suite. You can also set `UNIT_TEST_SHARD=1/3` or pass `--shard=1/3` +to `scripts/run-unit-tests.mjs` for custom shard splits, and use +`UNIT_TEST_TIMEOUT_MS=120000` to abort a single stalled test file without +blocking the entire run. `npm run test:visual` covers presentation updates to mirror the CI surface area. For DM-specific changes, also run `npm run test:dm:unit` and `npm run test:dm:integration` to cover the direct message flows. Use `npm run test:e2e` to execute the headless Playwright journeys in `tests/e2e`. diff --git a/artifacts/load-report-20260122.json b/artifacts/load-report-20260122.json new file mode 100644 index 00000000..64d1f39d --- /dev/null +++ b/artifacts/load-report-20260122.json @@ -0,0 +1,70 @@ +{ + "summary": { + "date": "2026-01-22T19:39:07.362Z", + "duration_sec": 14.367, + "clients": 50, + "events_published": 380, + "events_confirmed": 380, + "events_failed": 0 + }, + "metrics": { + "throughput": { + "avg_events_per_sec": 26.44950233173244 + }, + "latency_ms": { + "build": { + "avg": 0.09473684210526316, + "p95": 1 + }, + "sign": { + "avg": 6.257894736842105, + "p95": 10 + }, + "rtt": { + "avg": 30.563157894736843, + "p95": 50 + } + }, + "resources": { + "cpu_samples": [ + { + "timestamp": 9.227, + "user": 1834418, + "system": 114421 + }, + { + "timestamp": 14.266, + "user": 3170422, + "system": 155074 + } + ], + "memory_samples": [ + { + "timestamp": 9.227, + "rss": 94273536, + "heapUsed": 11273392 + }, + { + "timestamp": 14.266, + "rss": 94453760, + "heapUsed": 11443640 + } + ] + }, + "errors": [] + }, + "hot_functions": [ + { + "name": "buildEvent", + "avg_ms": 0.09473684210526316 + }, + { + "name": "signEvent", + "avg_ms": 6.257894736842105 + } + ], + "recommendations": [ + "If signEvent latency > 5ms, consider offloading signing to Web Workers or using Wasm optimization.", + "If RTT is high but build/sign is low, network or relay processing is the bottleneck." + ] +} \ No newline at end of file diff --git a/components/application-form.html b/components/application-form.html index 23569aa2..a0ca5090 100644 --- a/components/application-form.html +++ b/components/application-form.html @@ -46,7 +46,7 @@