Multi-Agent Collaboration for Team and Friends
TypeScript agent-automationagent-orchestrationagent-workflowai-agentsai-collaborationai-memoryai-workforceautonomous-agentsclaude-codeclaude-code-skillscodexcoding-agentmulti-agentmultiple-agentone-person-businessone-person-companyone-person-teamopencodesolopreneur
test(web): community Playwright E2E suite + release-gating workflow (#371)
Gener2032b987cdcb
diff --git a/.github/workflows/auto-tag-release.yml b/.github/workflows/auto-tag-release.ymlindex 004394486..06656cbe3 100644--- a/.github/workflows/auto-tag-release.yml+++ b/.github/workflows/auto-tag-release.yml@@ -1,13 +1,20 @@name: Auto-Tag & Release+# Gated on the E2E UI workflow: only tags/releases after browser E2E passes on+# the release commit. `workflow_run` payloads have no `head_commit` on+# `github.event` directly — use `github.event.workflow_run.*` and pin the+# checkout to the commit that triggered E2E.on:- push:- branches: [main]+ workflow_run:+ workflows: ["E2E UI"]+ types: [completed]jobs:auto-tag-release:name: Tag & Release- if: "startsWith(github.event.head_commit.message, 'release: v')"+ if: >-+ github.event.workflow_run.conclusion == 'success' &&+ startsWith(github.event.workflow_run.head_commit.message, 'release: v')runs-on: ubuntu-latesttimeout-minutes: 5permissions:@@ -16,11 +23,12 @@ jobs:- uses: actions/checkout@v7with:fetch-depth: 0+ ref: ${{ github.event.workflow_run.head_sha }}- name: Extract version from commit messageid: versionenv:- COMMIT_MSG: ${{ github.event.head_commit.message }}+ COMMIT_MSG: ${{ github.event.workflow_run.head_commit.message }}run: |VERSION=$(echo "$COMMIT_MSG" | grep -oP '^release: v\K[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?')if [ -z "$VERSION" ]; thendiff --git a/.github/workflows/e2e-ui.yml b/.github/workflows/e2e-ui.ymlnew file mode 100644index 000000000..dd254766e--- /dev/null+++ b/.github/workflows/e2e-ui.yml@@ -0,0 +1,68 @@+name: E2E UI++# Playwright browser E2E for the web UI (community today; extends to the full+# UI over time). Runs ONLY on release commits (bump), and gates the release+# chain: auto-tag-release and the publish-* workflows trigger on this+# workflow's successful completion (see their `on: workflow_run`). If this+# fails or is skipped, nothing ships.+on:+ push:+ branches: [main]++concurrency:+ group: e2e-ui-${{ github.ref }}+ cancel-in-progress: true++jobs:+ e2e-ui:+ name: UI Playwright E2E+ # Job-level gate: a non-release push skips this job, so the workflow run's+ # conclusion is `skipped` (not `success`) and the downstream workflow_run+ # guards won't fire.+ if: "startsWith(github.event.head_commit.message, 'release: v')"+ runs-on: ubuntu-latest+ timeout-minutes: 20+ env:+ # next dev (development) is required — the dev email+password sign-in+ # form and better-auth emailAndPassword are only enabled when NOT prod.+ BETTER_AUTH_SECRET: ci-e2e-ui-secret+ BETTER_AUTH_URL: http://localhost:3000+ steps:+ - uses: actions/checkout@v7+ - uses: pnpm/action-setup@v6+ - uses: oven-sh/setup-bun@v2+ - uses: actions/setup-node@v6+ with:+ node-version: 22+ cache: pnpm+ - run: pnpm install --frozen-lockfile++ - name: Create .dev.vars for local bindings+ run: printf 'BETTER_AUTH_SECRET=ci-e2e-ui-secret\nBETTER_AUTH_URL=http://localhost:3000\nDEVICE_CLIENT_IDS=e2e-test-client\nENCRYPTION_KEY=ci-e2e-encryption-key-32chars!!\n' > src/web/.dev.vars++ - name: Install Playwright Chromium+ working-directory: src/web+ run: pnpm exec playwright install --with-deps chromium++ # global-setup runs db:reset, starts dev:web + dev:ws (fail-fast on ws+ # health), and logs in the test users — so this single step drives the+ # whole suite. Run from the repo root via the root alias (delegates to+ # --filter @alook/web, which sets cwd so the Playwright config resolves).+ - name: Run UI E2E+ run: pnpm test:e2e-ui++ - name: Upload Playwright report+ if: ${{ !cancelled() }}+ uses: actions/upload-artifact@v5+ with:+ name: playwright-report+ path: src/web/playwright-report/+ retention-days: 30++ - name: Upload traces & videos+ if: failure()+ uses: actions/upload-artifact@v5+ with:+ name: playwright-artifacts+ path: src/web/test-results/+ retention-days: 30diff --git a/.github/workflows/publish-app.yml b/.github/workflows/publish-app.ymlindex 983337f65..bd92a143a 100644--- a/.github/workflows/publish-app.yml+++ b/.github/workflows/publish-app.yml@@ -1,9 +1,12 @@name: Publish App+# Gated on the E2E UI workflow (release chain). `workflow_run` doesn't+# support `on.paths`, so the "did src/app/package.json change?" gate is done in+# a job step via `git diff head_sha^ head_sha` (needs fetch-depth ≥ 2).on:- push:- branches: [main]- paths: [src/app/package.json]+ workflow_run:+ workflows: ["E2E UI"]+ types: [completed]concurrency:group: publish-app@@ -12,21 +15,37 @@ concurrency:jobs:publish:name: Publish @alook/app to npm+ if: github.event.workflow_run.conclusion == 'success'runs-on: ubuntu-latesttimeout-minutes: 30permissions:id-token: writesteps:- uses: actions/checkout@v7+ with:+ fetch-depth: 2+ ref: ${{ github.event.workflow_run.head_sha }}++ - name: Check if src/app/package.json changed in this commit+ id: changed+ run: |+ if git diff --name-only "${{ github.event.workflow_run.head_sha }}^" "${{ github.event.workflow_run.head_sha }}" | grep -qx 'src/app/package.json'; then+ echo "changed=true" >> "$GITHUB_OUTPUT"+ else+ echo "changed=false" >> "$GITHUB_OUTPUT"+ echo "::notice::src/app/package.json unchanged — skipping"+ fi- name: Detect versionid: version+ if: steps.changed.outputs.changed == 'true'run: |VERSION=$(node -p "require('./src/app/package.json').version")echo "version=$VERSION" >> "$GITHUB_OUTPUT"- name: Check if version already publishedid: check+ if: steps.changed.outputs.changed == 'true'run: |if npm view "@alook/app@${{ steps.version.outputs.version }}" version >/dev/null 2>&1; thenecho "skip=true" >> "$GITHUB_OUTPUT"diff --git a/.github/workflows/publish-cli.yml b/.github/workflows/publish-cli.ymlindex 4bfb780cd..de643a85f 100644--- a/.github/workflows/publish-cli.yml+++ b/.github/workflows/publish-cli.yml@@ -1,9 +1,12 @@name: Publish CLI+# Gated on the E2E UI workflow (release chain). `workflow_run` doesn't+# support `on.paths`, so the "did src/cli/package.json change?" gate is done in+# a job step via `git diff head_sha^ head_sha` (needs fetch-depth ≥ 2).on:- push:- branches: [main]- paths: [src/cli/package.json]+ workflow_run:+ workflows: ["E2E UI"]+ types: [completed]concurrency:group: publish-cli@@ -12,21 +15,37 @@ concurrency:jobs:publish:name: Publish @alook/cli to npm+ if: github.event.workflow_run.conclusion == 'success'runs-on: ubuntu-latesttimeout-minutes: 10permissions:id-token: writesteps:- uses: actions/checkout@v7+ with:+ fetch-depth: 2+ ref: ${{ github.event.workflow_run.head_sha }}++ - name: Check if src/cli/package.json changed in this commit+ id: changed+ run: |+ if git diff --name-only "${{ github.event.workflow_run.head_sha }}^" "${{ github.event.workflow_run.head_sha }}" | grep -qx 'src/cli/package.json'; then+ echo "changed=true" >> "$GITHUB_OUTPUT"+ else+ echo "changed=false" >> "$GITHUB_OUTPUT"+ echo "::notice::src/cli/package.json unchanged — skipping"+ fi- name: Detect versionid: version+ if: steps.changed.outputs.changed == 'true'run: |VERSION=$(node -p "require('./src/cli/package.json').version")echo "version=$VERSION" >> "$GITHUB_OUTPUT"- name: Check if version already publishedid: check+ if: steps.changed.outputs.changed == 'true'run: |if npm view "@alook/cli@${{ steps.version.outputs.version }}" version >/dev/null 2>&1; thenecho "skip=true" >> "$GITHUB_OUTPUT"diff --git a/.github/workflows/publish-daemon.yml b/.github/workflows/publish-daemon.ymlindex fe1dbc62e..318ef7eb3 100644--- a/.github/workflows/publish-daemon.yml+++ b/.github/workflows/publish-daemon.yml@@ -1,9 +1,12 @@name: Publish Daemon+# Gated on the E2E UI workflow (release chain). `workflow_run` doesn't+# support `on.paths`, so the "did src/daemon/package.json change?" gate is done+# in a job step via `git diff head_sha^ head_sha` (needs fetch-depth ≥ 2).on:- push:- branches: [main]- paths: [src/daemon/package.json]+ workflow_run:+ workflows: ["E2E UI"]+ types: [completed]concurrency:group: publish-daemon@@ -12,21 +15,37 @@ concurrency:jobs:publish:name: Publish @alook/daemon to npm+ if: github.event.workflow_run.conclusion == 'success'runs-on: ubuntu-latesttimeout-minutes: 10permissions:id-token: writesteps:- uses: actions/checkout@v7+ with:+ fetch-depth: 2+ ref: ${{ github.event.workflow_run.head_sha }}++ - name: Check if src/daemon/package.json changed in this commit+ id: changed+ run: |+ if git diff --name-only "${{ github.event.workflow_run.head_sha }}^" "${{ github.event.workflow_run.head_sha }}" | grep -qx 'src/daemon/package.json'; then+ echo "changed=true" >> "$GITHUB_OUTPUT"+ else+ echo "changed=false" >> "$GITHUB_OUTPUT"+ echo "::notice::src/daemon/package.json unchanged — skipping"+ fi- name: Detect versionid: version+ if: steps.changed.outputs.changed == 'true'run: |VERSION=$(node -p "require('./src/daemon/package.json').version")echo "version=$VERSION" >> "$GITHUB_OUTPUT"- name: Check if version already publishedid: check+ if: steps.changed.outputs.changed == 'true'run: |if npm view "@alook/daemon@${{ steps.version.outputs.version }}" version >/dev/null 2>&1; thenecho "skip=true" >> "$GITHUB_OUTPUT"diff --git a/AGENTS.md b/AGENTS.mdindex 001315401..285487791 100644--- a/AGENTS.md+++ b/AGENTS.md@@ -36,12 +36,15 @@ git push origin mainThis triggers:- **CI** — typecheck, lint, tests, coverage (uploaded to Codecov)-- **Auto-Tag & Release** — CI detects the `release: vX.Y.Z` commit message, creates the git tag, and creates a GitHub Release with generated changelog (`auto-tag-release.yml`)-- **@alook/cli** → auto-published to npm via `publish-cli.yml` (watches `src/cli/package.json`)-- **@alook/app** → auto-published to npm via `publish-app.yml` (watches `src/app/package.json`)-- **@alook/daemon** → auto-published to npm via `publish-daemon.yml` (watches `src/daemon/package.json`)+- **E2E UI** — Playwright browser E2E runs on the `release: vX.Y.Z` commit (`e2e-ui.yml`). **This gates the release chain below**: Auto-Tag & Release and every `publish-*` workflow trigger on `on: workflow_run` completion of E2E UI and only run when its `conclusion == success`. If E2E fails or is skipped, nothing is tagged, released, or published.+- **Auto-Tag & Release** — after E2E UI passes, creates the git tag + GitHub Release with generated changelog (`auto-tag-release.yml`). Reads `github.event.workflow_run.head_commit.message` and checks out `workflow_run.head_sha`.+- **@alook/cli** → auto-published to npm via `publish-cli.yml` (self-gates on `src/cli/package.json` changing via `git diff`)+- **@alook/app** → auto-published to npm via `publish-app.yml` (self-gates on `src/app/package.json`)+- **@alook/daemon** → auto-published to npm via `publish-daemon.yml` (self-gates on `src/daemon/package.json`)- **CF Workers** → each module redeploys when its own `package.json` changes+> **Bootstrap note:** the `workflow_run` gate only takes effect once `e2e-ui.yml` and the rewired downstream workflows exist on `main`. The first release after merging this change is the one that starts enforcing the gate.+## Plan-driven Development- You must make a markdown plan at `plans/` before you implement any my request, otherwise I will reject your implementation.- The `plans/` directory is gitignored — plans are kept locally and do not need to be committed or included in PRs.diff --git a/codecov.yml b/codecov.ymlindex 262e4674c..859889384 100644--- a/codecov.yml+++ b/codecov.yml@@ -28,6 +28,9 @@ coverage:ignore:- "src/web/src/components/home/**"- "src/web/scripts/**"+ # Playwright browser E2E — driven by `playwright test`, not vitest, so these+ # files never appear in coverage and shouldn't count against patch %.+ - "src/web/src/test/e2e-ui/**"comment:layout: "reach,diff,flags,files"diff --git a/package.json b/package.jsonindex c95532555..1443998cf 100644--- a/package.json+++ b/package.json@@ -28,6 +28,7 @@"test:daemon": "pnpm --filter @alook/daemon test","test:web": "pnpm --filter @alook/web test","test:e2e": "pnpm --filter @alook/web test:e2e",+ "test:e2e-ui": "pnpm --filter @alook/web test:e2e-ui","db:migrate": "pnpm --filter @alook/web exec wrangler d1 migrations apply alook-app --local","db:reset": "rm -rf src/web/.wrangler/state && pnpm run db:migrate","test:all": "vitest run",diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex f9cefe802..2b6a58e63 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -305,13 +305,13 @@ importers:version: 16.2.10(@mdx-js/[email protected])(@mdx-js/[email protected](@types/[email protected])([email protected]))'@next/third-parties':specifier: ^16.2.10- version: 16.2.10([email protected](@babel/[email protected])(@opentelemetry/[email protected])([email protected]([email protected]))([email protected]))([email protected])+ version: 16.2.10([email protected](@babel/[email protected])(@opentelemetry/[email protected])(@playwright/[email protected])([email protected]([email protected]))([email protected]))([email protected])'@number-flow/react':specifier: ^0.6.1'@opennextjs/cloudflare':specifier: ^1.20.1- version: 1.20.1([email protected](@babel/[email protected])(@opentelemetry/[email protected])([email protected]([email protected]))([email protected]))([email protected](@cloudflare/[email protected]))+ version: 1.20.1([email protected](@babel/[email protected])(@opentelemetry/[email protected])(@playwright/[email protected])([email protected]([email protected]))([email protected]))([email protected](@cloudflare/[email protected]))'@streamdown/cjk':specifier: ^1.0.3version: 1.0.3(@types/[email protected])([email protected])([email protected])([email protected])([email protected])@@ -371,7 +371,7 @@ importers:version: 12.11.2(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])better-auth:specifier: ^1.6.23- version: 1.6.23(@cloudflare/[email protected])(@opentelemetry/[email protected])([email protected])([email protected](@cloudflare/[email protected])(@opentelemetry/[email protected])(@types/[email protected])([email protected])([email protected])([email protected]))([email protected](@babel/[email protected])(@opentelemetry/[email protected])([email protected]([email protected]))([email protected]))([email protected]([email protected]))([email protected])([email protected])+ version: 1.6.23(@cloudflare/[email protected])(@opentelemetry/[email protected])([email protected])([email protected](@cloudflare/[email protected])(@opentelemetry/[email protected])(@types/[email protected])([email protected])([email protected])([email protected]))([email protected](@babel/[email protected])(@opentelemetry/[email protected])(@playwright/[email protected])([email protected]([email protected]))([email protected]))([email protected]([email protected]))([email protected])([email protected])class-variance-authority:specifier: ^0.7.1version: 0.7.1@@ -431,7 +431,7 @@ importers:version: 5.1.16next:specifier: 16.2.10- version: 16.2.10(@babel/[email protected])(@opentelemetry/[email protected])([email protected]([email protected]))([email protected])+ version: 16.2.10(@babel/[email protected])(@opentelemetry/[email protected])(@playwright/[email protected])([email protected]([email protected]))([email protected])next-themes:specifier: ^0.4.6@@ -502,6 +502,9 @@ importers:'@lhci/cli':specifier: ^0.15.1version: 0.15.1+ '@playwright/test':+ specifier: ^1.61.1+ version: 1.61.1'@tailwindcss/node':specifier: ^4.3.2version: 4.3.2@@ -2529,6 +2532,11 @@ packages:resolution: {integrity: sha512-fdDH1LSGfZdTH2sxdpVMw31BanV28K/Gry0cVFxaNP77neJSkd82mM8ErPNYs9e+0O7SdHBLTDzDgwUuy18RnQ==}engines: {node: ^12.20.0 || ^14.18.0 || >=16.0.0}+ '@playwright/[email protected]':+ resolution: {integrity: sha512-8nKv6+0RJSL9FE4jYOEGXnPeM/Hg12qZpmqzZjRh3qM0Y7c3z1mrOTfFLids72RDQYVh9WpLEfR5WdpNX4fkig==}+ engines: {node: '>=18'}+ hasBin: true+'@poppinss/[email protected]':resolution: {integrity: sha512-H9xkIdFswbS8n1d6vmRd8+c10t2Qe+rZITbbDHHkQixH5+2x1FDGmi/0K+WgWiqQFKPSlIYB7jlH6Kpfn6Fleg==}@@ -5353,6 +5361,11 @@ packages:resolution: {integrity: sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==}+ resolution: {integrity: sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==}+ engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0}+ os: [darwin]+resolution: {integrity: sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==}engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0}@@ -6950,6 +6963,11 @@ packages:engines: {node: '>=18'}hasBin: true+ resolution: {integrity: sha512-DWnY5o3YbLWK4GovuAVwpqL+1VwGNdUGrRr++8j8PtQQzvAVZUIMjKQ90fY689sEJZJBbZVw1rXaOKSTitkzPQ==}+ engines: {node: '>=18'}+ hasBin: true+resolution: {integrity: sha512-0mYKnYYe9ZcqMCWhUjItv/oHjvgEsfKvnUTg8sAtnHr3GVy7rGkXCb6d5cSyqrWqL4k81b9CPg3urd+T7aop3A==}@@ -10246,9 +10264,9 @@ snapshots:'@next/[email protected]':optional: true- '@next/[email protected]([email protected](@babel/[email protected])(@opentelemetry/[email protected])([email protected]([email protected]))([email protected]))([email protected])':+ '@next/[email protected]([email protected](@babel/[email protected])(@opentelemetry/[email protected])(@playwright/[email protected])([email protected]([email protected]))([email protected]))([email protected])':dependencies:- next: 16.2.10(@babel/[email protected])(@opentelemetry/[email protected])([email protected]([email protected]))([email protected])+ next: 16.2.10(@babel/[email protected])(@opentelemetry/[email protected])(@playwright/[email protected])([email protected]([email protected]))([email protected])react: 19.2.7third-party-capital: 1.0.20@@ -10317,7 +10335,7 @@ snapshots:'@open-draft/[email protected]':optional: true- '@opennextjs/[email protected]([email protected](@babel/[email protected])(@opentelemetry/[email protected])([email protected]([email protected]))([email protected]))':+ '@opennextjs/[email protected]([email protected](@babel/[email protected])(@opentelemetry/[email protected])(@playwright/[email protected])([email protected]([email protected]))([email protected]))':dependencies:'@ast-grep/napi': 0.40.5'@aws-sdk/client-cloudfront': 3.984.0@@ -10333,24 +10351,24 @@ snapshots:cookie: 1.1.1esbuild: 0.25.4express: 5.2.1- next: 16.2.10(@babel/[email protected])(@opentelemetry/[email protected])([email protected]([email protected]))([email protected])+ next: 16.2.10(@babel/[email protected])(@opentelemetry/[email protected])(@playwright/[email protected])([email protected]([email protected]))([email protected])path-to-regexp: 6.3.0urlpattern-polyfill: 10.1.0yaml: 2.9.0transitivePeerDependencies:- supports-color- '@opennextjs/[email protected]([email protected](@babel/[email protected])(@opentelemetry/[email protected])([email protected]([email protected]))([email protected]))([email protected](@cloudflare/[email protected]))':+ '@opennextjs/[email protected]([email protected](@babel/[email protected])(@opentelemetry/[email protected])(@playwright/[email protected])([email protected]([email protected]))([email protected]))([email protected](@cloudflare/[email protected]))':dependencies:'@ast-grep/napi': 0.40.5'@dotenvx/dotenvx': 1.31.0- '@opennextjs/aws': 4.0.2([email protected](@babel/[email protected])(@opentelemetry/[email protected])([email protected]([email protected]))([email protected]))+ '@opennextjs/aws': 4.0.2([email protected](@babel/[email protected])(@opentelemetry/[email protected])(@playwright/[email protected])([email protected]([email protected]))([email protected]))ci-info: 4.4.0cloudflare: 4.5.0comment-json: 4.6.2enquirer: 2.4.1glob: 12.0.0- next: 16.2.10(@babel/[email protected])(@opentelemetry/[email protected])([email protected]([email protected]))([email protected])+ next: 16.2.10(@babel/[email protected])(@opentelemetry/[email protected])(@playwright/[email protected])([email protected]([email protected]))([email protected])ts-tqdm: 0.8.6wrangler: 4.111.0(@cloudflare/[email protected])yargs: 18.0.0@@ -10499,6 +10517,10 @@ snapshots:'@pkgr/[email protected]': {}+ '@playwright/[email protected]':+ dependencies:+ playwright: 1.61.1+'@poppinss/[email protected]':dependencies:kleur: 4.1.5@@ -11701,7 +11723,7 @@ snapshots:obug: 2.1.3std-env: 4.2.0tinyrainbow: 3.1.0- vitest: 4.1.10(@opentelemetry/[email protected])(@types/[email protected])(@vitest/[email protected])([email protected](@types/[email protected])([email protected]))([email protected](@types/[email protected])([email protected])([email protected])([email protected])([email protected])([email protected]))+ vitest: 4.1.10(@opentelemetry/[email protected])(@types/[email protected])(@vitest/[email protected])([email protected](@types/[email protected])([email protected]))([email protected](@types/[email protected])([email protected])([email protected])([email protected])([email protected])([email protected]))'@vitest/[email protected]':dependencies:@@ -12021,7 +12043,7 @@ snapshots:- [email protected](@cloudflare/[email protected])(@opentelemetry/[email protected])([email protected])([email protected](@cloudflare/[email protected])(@opentelemetry/[email protected])(@types/[email protected])([email protected])([email protected])([email protected]))([email protected](@babel/[email protected])(@opentelemetry/[email protected])([email protected]([email protected]))([email protected]))([email protected]([email protected]))([email protected])([email protected]):+ [email protected](@cloudflare/[email protected])(@opentelemetry/[email protected])([email protected])([email protected](@cloudflare/[email protected])(@opentelemetry/[email protected])(@types/[email protected])([email protected])([email protected])([email protected]))([email protected](@babel/[email protected])(@opentelemetry/[email protected])(@playwright/[email protected])([email protected]([email protected]))([email protected]))([email protected]([email protected]))([email protected])([email protected]):dependencies:'@better-auth/core': 1.6.23(@better-auth/[email protected])(@better-fetch/[email protected])(@cloudflare/[email protected])(@opentelemetry/[email protected])([email protected]([email protected]))([email protected])([email protected])([email protected])'@better-auth/drizzle-adapter': 1.6.23(@better-auth/[email protected](@better-auth/[email protected])(@better-fetch/[email protected])(@cloudflare/[email protected])(@opentelemetry/[email protected])([email protected]([email protected]))([email protected])([email protected])([email protected]))(@better-auth/[email protected])([email protected](@cloudflare/[email protected])(@opentelemetry/[email protected])(@types/[email protected])([email protected])([email protected])([email protected]))@@ -12043,7 +12065,7 @@ snapshots:optionalDependencies:better-sqlite3: 12.11.1drizzle-orm: 0.45.2(@cloudflare/[email protected])(@opentelemetry/[email protected])(@types/[email protected])([email protected])([email protected])([email protected])- next: 16.2.10(@babel/[email protected])(@opentelemetry/[email protected])([email protected]([email protected]))([email protected])+ next: 16.2.10(@babel/[email protected])(@opentelemetry/[email protected])(@playwright/[email protected])([email protected]([email protected]))([email protected])react: 19.2.7react-dom: 19.2.7([email protected])vitest: 4.1.10(@opentelemetry/[email protected])(@types/[email protected])(@vitest/[email protected])([email protected](@types/[email protected])([email protected]))([email protected](@types/[email protected])([email protected])([email protected])([email protected])([email protected])([email protected]))@@ -13003,8 +13025,8 @@ snapshots:'@next/eslint-plugin-next': 16.2.10eslint: 9.39.5([email protected])eslint-import-resolver-node: 0.3.10- eslint-import-resolver-typescript: 3.10.1([email protected]([email protected]([email protected])))([email protected]([email protected]))- eslint-plugin-import: 2.32.0([email protected]([email protected]([email protected]([email protected])))([email protected]([email protected])))([email protected]([email protected]))+ eslint-import-resolver-typescript: 3.10.1([email protected])([email protected]([email protected]))eslint-plugin-jsx-a11y: 6.10.2([email protected]([email protected]))eslint-plugin-react: 7.37.5([email protected]([email protected]))eslint-plugin-react-hooks: 7.1.1([email protected]([email protected]))@@ -13026,7 +13048,7 @@ snapshots:transitivePeerDependencies:- supports-color- [email protected]([email protected]([email protected]([email protected])))([email protected]([email protected])):dependencies:'@nolyfill/is-core-module': 1.0.39debug: 4.4.3@@ -13037,21 +13059,21 @@ snapshots:tinyglobby: 0.2.17unrs-resolver: 1.12.2optionalDependencies:- eslint-plugin-import: 2.32.0([email protected]([email protected]([email protected]([email protected])))([email protected]([email protected])))([email protected]([email protected]))transitivePeerDependencies:- supports-color- [email protected]([email protected])([email protected]([email protected]([email protected]([email protected])))([email protected]([email protected])))([email protected]([email protected])):dependencies:debug: 3.2.7optionalDependencies:eslint: 9.39.5([email protected])eslint-import-resolver-node: 0.3.10- eslint-import-resolver-typescript: 3.10.1([email protected]([email protected]([email protected])))([email protected]([email protected]))+ eslint-import-resolver-typescript: 3.10.1([email protected])([email protected]([email protected]))transitivePeerDependencies:- supports-color- [email protected]([email protected]([email protected]([email protected]([email protected])))([email protected]([email protected])))([email protected]([email protected])):dependencies:'@rtsao/scc': 1.1.0array-includes: 3.1.9@@ -13062,7 +13084,7 @@ snapshots:doctrine: 2.1.0eslint: 9.39.5([email protected])eslint-import-resolver-node: 0.3.10- eslint-module-utils: 2.13.0([email protected])([email protected]([email protected]([email protected]([email protected])))([email protected]([email protected])))([email protected]([email protected]))+ eslint-module-utils: 2.13.0([email protected])([email protected])([email protected]([email protected]))hasown: 2.0.4is-core-module: 2.16.2is-glob: 4.0.3@@ -13555,6 +13577,9 @@ snapshots:+ optional: true+optional: true@@ -15247,7 +15272,7 @@ snapshots:react: 19.2.7react-dom: 19.2.7([email protected])- [email protected](@babel/[email protected])(@opentelemetry/[email protected])([email protected]([email protected]))([email protected]):+ [email protected](@babel/[email protected])(@opentelemetry/[email protected])(@playwright/[email protected])([email protected]([email protected]))([email protected]):dependencies:'@next/env': 16.2.10'@swc/helpers': 0.5.15@@ -15267,6 +15292,7 @@ snapshots:'@next/swc-win32-arm64-msvc': 16.2.10'@next/swc-win32-x64-msvc': 16.2.10'@opentelemetry/api': 1.9.1+ '@playwright/test': 1.61.1sharp: 0.34.5transitivePeerDependencies:- '@babel/core'@@ -15610,6 +15636,12 @@ snapshots:+ dependencies:+ playwright-core: 1.61.1+ optionalDependencies:+ fsevents: 2.3.2+diff --git a/src/web/.gitignore b/src/web/.gitignoreindex 5ef6a5207..d6dff5f32 100644--- a/src/web/.gitignore+++ b/src/web/.gitignore@@ -13,6 +13,15 @@# testing/coverage+# playwright (E2E UI) artifacts + saved auth state+/test-results/+/playwright-report/+/blob-report/+/playwright/.cache/+src/test/e2e-ui/.auth/+# local-run D1/DO state backup taken by the E2E harness+.wrangler/state.e2e-backup/+# next.js/.next//out/diff --git a/src/web/knip.json b/src/web/knip.jsonindex a44a50760..2c8602824 100644--- a/src/web/knip.json+++ b/src/web/knip.json@@ -14,6 +14,9 @@"ignoreDependencies": ["@tailwindcss/node"],+ "ignoreBinaries": [+ "lsof"+ ],"ignore": ["src/components/ui/**"],diff --git a/src/web/package.json b/src/web/package.jsonindex 0abcdcfda..5984fbb81 100644--- a/src/web/package.json+++ b/src/web/package.json@@ -15,6 +15,8 @@"test": "vitest run","test:watch": "vitest","test:e2e": "vitest run --config vitest.e2e.config.ts",+ "test:e2e-ui": "playwright test",+ "test:e2e-ui:headed": "playwright test --headed","knip": "knip","typecheck": "tsc --noEmit","seo:check": "lhci autorun --config=lighthouserc.json && node scripts/print-lighthouse-scores.mjs"@@ -102,6 +104,7 @@"devDependencies": {"@alook/test-utils": "workspace:*","@lhci/cli": "^0.15.1",+ "@playwright/test": "^1.61.1","@tailwindcss/node": "^4.3.2","@tailwindcss/postcss": "^4","@tanstack/react-query-devtools": "^5.101.2",diff --git a/src/web/playwright.config.ts b/src/web/playwright.config.tsnew file mode 100644index 000000000..f8a9b6497--- /dev/null+++ b/src/web/playwright.config.ts@@ -0,0 +1,29 @@+import { defineConfig, devices } from "@playwright/test"++const BASE_URL = process.env.ALOOK_SERVER_URL || "http://localhost:3000"++export default defineConfig({+ testDir: "./src/test/e2e-ui",+ testMatch: "**/*.spec.ts",+ fullyParallel: false,+ forbidOnly: !!process.env.CI,+ retries: process.env.CI ? 1 : 0,+ workers: process.env.CI ? 1 : undefined,+ reporter: process.env.CI ? [["html", { open: "never" }], ["list"]] : "list",+ globalSetup: "./src/test/e2e-ui/_setup/global-setup.ts",+ globalTeardown: "./src/test/e2e-ui/_setup/global-teardown.ts",+ timeout: 60_000,+ expect: { timeout: 10_000 },+ use: {+ baseURL: BASE_URL,+ trace: "on-first-retry",+ video: "retain-on-failure",+ screenshot: "only-on-failure",+ },+ projects: [+ {+ name: "chromium",+ use: { ...devices["Desktop Chrome"] },+ },+ ],+})diff --git a/src/web/src/app/community/me/[dmId]/page.tsx b/src/web/src/app/community/me/[dmId]/page.tsxindex 8a49eca34..7d308d3d4 100644--- a/src/web/src/app/community/me/[dmId]/page.tsx+++ b/src/web/src/app/community/me/[dmId]/page.tsx@@ -16,6 +16,7 @@ import {useUiHandlers,} from "@/stores/community"import { useOnlineUserIds, useCommunityWsStore } from "@/stores/community/ws"+import { tid } from "@/lib/community/testids"import { resolveRowPresence } from "@/lib/community/presence"import { makeUserNameResolver } from "@/lib/community/display-name"import { useDms } from "@/hooks/community/use-dms"@@ -366,7 +367,7 @@ function DmView() {}/>{dmBlocked ? (- <div className="flex h-14 shrink-0 items-center justify-center border-t border-border/40 px-4 text-sm text-muted-foreground">+ <div data-testid={tid.dmBlockedNotice} className="flex h-14 shrink-0 items-center justify-center border-t border-border/40 px-4 text-sm text-muted-foreground">You have blocked this user. Unblock to send messages.</div>) : (diff --git a/src/web/src/components/community/composer.tsx b/src/web/src/components/community/composer.tsxindex 05feb68f9..1c484bc95 100644--- a/src/web/src/components/community/composer.tsx+++ b/src/web/src/components/community/composer.tsx@@ -10,6 +10,7 @@ import { DropdownMenu, DropdownMenuTrigger, DropdownMenuContent, DropdownMenuIteimport { Skeleton } from "@/components/ui/skeleton"import { useFileAttachments, type PendingFile } from "@/hooks/use-file-attachments"import { ALLOWED_ATTACHMENT_MIME_PREFIXES, MAX_ATTACHMENT_SIZE_BYTES } from "@alook/shared"+import { tid } from "@/lib/community/testids"import { Avatar } from "./avatar"import { ChannelIcon } from "./channel-icon"import { EmojiPickerPopover } from "./emoji-picker"@@ -327,13 +328,13 @@ export function Composer({ channel, context, members, onSearchMembers, channelReonChange={handleFileSelect}className="hidden"/>- <div className="chat-composer relative px-12 py-3">+ <div className="chat-composer relative px-12 py-3" data-testid={tid.composerInput}><EditorContent editor={editor} className="max-h-40 overflow-y-auto thin-scrollbar text-base chat-input-line-height outline-none" /></div>{/* Attach button — fixed bottom-left */}<DropdownMenu onOpenChange={(open) => { if (!open) editor?.commands.focus() }}><DropdownMenuTrigger- render={<button className="absolute left-2 bottom-2 grid size-8 place-items-center rounded-full text-muted-foreground hover:bg-accent hover:text-foreground aria-expanded:bg-accent aria-expanded:text-foreground" aria-label="Add" />}+ render={<button data-testid={tid.composerAttach} className="absolute left-2 bottom-2 grid size-8 place-items-center rounded-full text-muted-foreground hover:bg-accent hover:text-foreground aria-expanded:bg-accent aria-expanded:text-foreground" aria-label="Add" />}><PlusCircle className="size-5" /></DropdownMenuTrigger>@@ -540,6 +541,7 @@ function MentionRow({ item, selected, showMembersHeader, onSelect }: {<buttontype="button"role="option"+ data-testid={tid.mentionOption(item.id)}aria-selected={selected}className={["flex w-full items-center gap-2 rounded-md px-2 py-2 text-left text-sm transition-colors",diff --git a/src/web/src/components/community/create-channel-dialog.tsx b/src/web/src/components/community/create-channel-dialog.tsxindex 24b5dff20..e9e3a4b29 100644--- a/src/web/src/components/community/create-channel-dialog.tsx+++ b/src/web/src/components/community/create-channel-dialog.tsx@@ -4,6 +4,7 @@ import { useState } from "react"import { EntityIcon } from "./entity-icon"import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogFooter } from "@/components/ui/dialog"import { Button } from "@/components/ui/button"+import { tid } from "@/lib/community/testids"import { Input } from "@/components/ui/input"import { onEnterSubmit } from "@/lib/ime"import { SlugHint } from "./slug-hint"@@ -87,7 +88,7 @@ export function CreateChannelDialog({ category, initial, onClose, onCreate }: {</div><DialogFooter className="mx-0 mb-0 flex-row items-center justify-end gap-2 rounded-b-xl border-t border-border bg-card px-4 py-3"><Button variant="ghost" size="sm" onClick={onClose}>Cancel</Button>- <Button size="sm" onClick={submit} disabled={!namePreview.slug}>{editing ? "Save" : "Create Channel"}</Button>+ <Button size="sm" data-testid={tid.createChannelSubmit} onClick={submit} disabled={!namePreview.slug}>{editing ? "Save" : "Create Channel"}</Button></DialogFooter></DialogContent></Dialog>diff --git a/src/web/src/components/community/create-server-dialog.tsx b/src/web/src/components/community/create-server-dialog.tsxindex 49f35b519..aaed11fd3 100644--- a/src/web/src/components/community/create-server-dialog.tsx+++ b/src/web/src/components/community/create-server-dialog.tsx@@ -5,6 +5,7 @@ import { toast } from "sonner"import { Plus, ChevronRight, Link2 } from "lucide-react"import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogFooter } from "@/components/ui/dialog"import { Button } from "@/components/ui/button"+import { tid } from "@/lib/community/testids"import { Input } from "@/components/ui/input"import { Field } from "./field"import { SlugHint } from "./slug-hint"@@ -90,6 +91,7 @@ export function CreateServerDialog({ onClose, onCreateServer, onJoinServer }: {<Button variant="ghost" size="sm" onClick={() => setStep("choose")}>Back</Button><Buttonsize="sm"+ data-testid={tid.createServerSubmit}disabled={step === "create" ? !namePreview.slug : !invite.trim()}onClick={() => {if (step === "create") onCreateServer?.(name.trim(), iconFile ?? undefined)diff --git a/src/web/src/components/community/dividers.tsx b/src/web/src/components/community/dividers.tsxindex 0480d7727..1b5621ab1 100644--- a/src/web/src/components/community/dividers.tsx+++ b/src/web/src/components/community/dividers.tsx@@ -1,4 +1,5 @@import { Separator } from "@/components/ui/separator"+import { tid } from "@/lib/community/testids"export function DateDivider({ label }: { label: string }) {return (@@ -21,7 +22,7 @@ export function NewDivider({ dateLabel }: { dateLabel?: string }) {// date label merges onto the same red line (centered) instead of rendering// a separate date-divider row above it.return (- <div data-new-divider className="relative my-1 flex items-center gap-2">+ <div data-new-divider data-testid={tid.newDivider} className="relative my-1 flex items-center gap-2"><Separator className="flex-1 bg-destructive/60" />{dateLabel && (<>diff --git a/src/web/src/components/community/dm-sidebar.tsx b/src/web/src/components/community/dm-sidebar.tsxindex d8bbb3129..ab0942351 100644--- a/src/web/src/components/community/dm-sidebar.tsx+++ b/src/web/src/components/community/dm-sidebar.tsx@@ -4,6 +4,7 @@ import { memo } from "react"import { Users, Ban, Monitor, Bot } from "lucide-react"import { Avatar } from "./avatar"import { Skeleton } from "@/components/ui/skeleton"+import { tid } from "@/lib/community/testids"import type { DM } from "./_types"export const DmSidebar = memo(function DmSidebar({@@ -71,6 +72,7 @@ export const DmSidebar = memo(function DmSidebar({return (<buttonkey={d.id}+ data-testid={tid.dmRow(d.id)}onClick={() => onPickDm(d.id)}className={["flex w-full items-center gap-3 rounded-md px-2 py-2",diff --git a/src/web/src/components/community/member-list.tsx b/src/web/src/components/community/member-list.tsxindex 3488933db..53e955b4b 100644--- a/src/web/src/components/community/member-list.tsx+++ b/src/web/src/components/community/member-list.tsx@@ -12,6 +12,7 @@ import { Input } from "@/components/ui/input"import { Avatar } from "./avatar"import { ConfirmDialog } from "@/components/ui/confirm-dialog"import { hasStatus } from "./status-presets"+import { tid } from "@/lib/community/testids"import type { Member, Role, OpenProfile, MemberManageContext } from "./_types"import { canManageServer, isServerOwner, ROLES, isPresenceOnline, isPresenceOffline } from "./_types"@@ -281,6 +282,7 @@ function MemberRow({}) {const button = (<button+ data-testid={tid.memberRow(mem.userId)}onClick={(e) => onOpenProfile?.(mem.name, e, undefined, mem.userId)}className="flex w-full items-center gap-3 rounded-md px-2 py-2 select-none hover:bg-accent">diff --git a/src/web/src/components/community/message-list.tsx b/src/web/src/components/community/message-list.tsxindex a511df27c..926667abd 100644--- a/src/web/src/components/community/message-list.tsx+++ b/src/web/src/components/community/message-list.tsx@@ -2,6 +2,7 @@import { useCallback, useEffect, useMemo, useRef, useState } from "react"import { ArrowDown } from "lucide-react"+import { tid } from "@/lib/community/testids"import { DateDivider, NewDivider } from "./dividers"import { Message } from "./message"import { TypingIndicator } from "./typing-indicator"@@ -367,7 +368,7 @@ export function MessageList({// row is a candidate for the read pointer (the hook// only ever observes rows that exist in the DOM,// which virtualization doesn't change).- <div data-msg-id={item.m.id}>+ <div data-msg-id={item.m.id} data-testid={tid.message(item.m.id)}><Messagem={item.m}pinned={pinnedIds?.has(item.m.id)}diff --git a/src/web/src/components/community/message.tsx b/src/web/src/components/community/message.tsxindex 0b992c48e..e22d5cbb4 100644--- a/src/web/src/components/community/message.tsx+++ b/src/web/src/components/community/message.tsx@@ -15,6 +15,7 @@ import { Tooltip, TooltipTrigger, TooltipContent } from "@/components/ui/tooltipimport { NumberTicker } from "@/components/ui/number-ticker"import { MessageContextItems, MessageDropdownItems, hasMessageMenu } from "./message-menu"import { formatMessageTime } from "./format-time"+import { tid } from "@/lib/community/testids"import { avatarInitial } from "@/lib/community/avatar"import { displayName } from "@/lib/community/display-name"import type { RenderMsg, OpenProfile } from "./_types"@@ -87,7 +88,7 @@ export function Message({<div className={`absolute right-2 z-20 flex items-center gap-1 rounded-lg border border-border/60 bg-card px-2 py-1 shadow-(--e1) transition-opacity duration-150 ${m.grouped ? "-top-2" : "-top-3"} ${toolbarOpen ? "opacity-100" : "pointer-events-none opacity-0 group-hover:pointer-events-auto group-hover:opacity-100"}`}>{onReact && (<EmojiPickerPopover side="bottom" align="end" onPick={(e) => onReact(e)} onOpenChange={setToolbarOpen}>- <button className="grid size-7 place-items-center rounded text-muted-foreground hover:bg-accent hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none aria-expanded:text-foreground" aria-label="Add reaction">+ <button data-testid={tid.reactionAdd(m.id)} className="grid size-7 place-items-center rounded text-muted-foreground hover:bg-accent hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none aria-expanded:text-foreground" aria-label="Add reaction"><SmilePlus className="size-4" /></button></EmojiPickerPopover>@@ -99,7 +100,7 @@ export function Message({)}<DropdownMenu onOpenChange={setToolbarOpen}><DropdownMenuTrigger- render={<button className="grid size-7 place-items-center rounded text-muted-foreground hover:bg-accent hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none aria-expanded:text-foreground" />}+ render={<button aria-label="More actions" className="grid size-7 place-items-center rounded text-muted-foreground hover:bg-accent hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none aria-expanded:text-foreground" />}><MoreHorizontal className="size-4" /></DropdownMenuTrigger>@@ -284,6 +285,7 @@ export function Message({{m.thread && !compact && (<button+ data-testid={tid.threadIndicator(m.id)}onClick={() => onOpenThread(m.thread!.id)}className="group/thread mt-2 flex items-center gap-2 rounded-md px-2 py-1 text-sm hover:bg-accent/60">diff --git a/src/web/src/components/community/profile-card.tsx b/src/web/src/components/community/profile-card.tsxindex 19dcddcdc..706af5225 100644--- a/src/web/src/components/community/profile-card.tsx+++ b/src/web/src/components/community/profile-card.tsx@@ -10,6 +10,7 @@ import type { Profile } from "./_types"import type { Breakpoint } from "@/hooks/use-mobile"import { useCommunityWsStore } from "@/stores/community/ws"import { gradientFromSeed } from "@/lib/community/gradient-from-seed"+import { tid } from "@/lib/community/testids"// Merge rule for the card's status pill: overlay wins over seed. The overlay// (`useCommunityWsStore.userStatuses`) is the same live source the member@@ -137,7 +138,7 @@ export function ProfileCard({ data, x, y, bp, onClose, onMessage, isSelf, onUpda</StatusEditor>) : (hasStatus(statusEmoji, statusText) && (- <div title={statusText || undefined} className="absolute left-full top-[68.5px] ml-2 flex max-w-32 -translate-y-1/2 items-center gap-2 rounded-full border border-border bg-secondary px-2 py-0.5 text-[13px] whitespace-nowrap text-secondary-foreground shadow-(--e1)">+ <div data-testid={tid.statusPill} title={statusText || undefined} className="absolute left-full top-[68.5px] ml-2 flex max-w-32 -translate-y-1/2 items-center gap-2 rounded-full border border-border bg-secondary px-2 py-0.5 text-[13px] whitespace-nowrap text-secondary-foreground shadow-(--e1)">{statusEmoji && <span>{statusEmoji}</span>}{statusText && <span className="min-w-0 truncate">{statusText}</span>}</div>@@ -198,7 +199,7 @@ export function ProfileCard({ data, x, y, bp, onClose, onMessage, isSelf, onUpda<div className="fixed inset-0 z-30 flex flex-col justify-end" onClick={onClose}><div className="absolute inset-0 bg-foreground/30" /><div className="relative p-3" onClick={(e) => e.stopPropagation()}>- <div className="overflow-hidden rounded-xl border border-border bg-popover p-2 shadow-(--e2)">{card}</div>+ <div data-testid={tid.profileCard} className="overflow-hidden rounded-xl border border-border bg-popover p-2 shadow-(--e2)">{card}</div></div></div>)@@ -212,7 +213,7 @@ export function ProfileCard({ data, x, y, bp, onClose, onMessage, isSelf, onUpdaclassName="pointer-events-none fixed size-0"style={{ left: x, top: y }}/>- <PopoverContent side="right" align="start" sideOffset={8} className="w-75 overflow-hidden p-2">+ <PopoverContent data-testid={tid.profileCard} side="right" align="start" sideOffset={8} className="w-75 overflow-hidden p-2">{card}</PopoverContent></Popover>diff --git a/src/web/src/components/community/rail-icon.tsx b/src/web/src/components/community/rail-icon.tsxindex e5a006cc6..9f5a790ec 100644--- a/src/web/src/components/community/rail-icon.tsx+++ b/src/web/src/components/community/rail-icon.tsx@@ -1,13 +1,14 @@import type React from "react"import { Tooltip, TooltipTrigger, TooltipContent } from "@/components/ui/tooltip"-export function RailIcon({ label, round, accent, active, onClick, tooltip }: {+export function RailIcon({ label, round, accent, active, onClick, tooltip, testId }: {label: React.ReactNoderound?: booleanaccent?: booleanactive?: booleanonClick?: () => voidtooltip?: string+ testId?: string}) {const btn = (<div className="group relative flex w-full justify-center">@@ -16,6 +17,7 @@ export function RailIcon({ label, round, accent, active, onClick, tooltip }: {active ? "h-8" : "h-0 group-hover:h-5",].join(" ")} /><button+ data-testid={testId}onClick={onClick}className={["grid size-10 shrink-0 place-items-center transition-all duration-150 focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none",diff --git a/src/web/src/components/community/server-rail.tsx b/src/web/src/components/community/server-rail.tsxindex 999a183ff..a2291ff68 100644--- a/src/web/src/components/community/server-rail.tsx+++ b/src/web/src/components/community/server-rail.tsx@@ -8,6 +8,7 @@ import {import { SortableContext, verticalListSortingStrategy } from "@dnd-kit/sortable"import { restrictToVerticalAxis } from "@dnd-kit/modifiers"import { RailIcon } from "./rail-icon"+import { tid } from "@/lib/community/testids"import { Tooltip, TooltipTrigger, TooltipContent } from "@/components/ui/tooltip"import { Skeleton } from "@/components/ui/skeleton"import { SortableServer } from "./sortable-server"@@ -253,7 +254,7 @@ export const ServerRail = memo(function ServerRail({</DragOverlay></DndContext>)}- <RailIcon label={<Plus className="size-6" />} round accent tooltip="Add a Server" onClick={() => setCreateOpen(true)} />+ <RailIcon label={<Plus className="size-6" />} round accent tooltip="Add a Server" testId={tid.serverAdd} onClick={() => setCreateOpen(true)} />{createOpen && (<CreateServerDialogdiff --git a/src/web/src/components/community/server-settings.tsx b/src/web/src/components/community/server-settings.tsxindex 358d6f09a..f75c642d3 100644--- a/src/web/src/components/community/server-settings.tsx+++ b/src/web/src/components/community/server-settings.tsx@@ -18,6 +18,7 @@ import { avatarInitial } from "@/lib/community/avatar"import { Field } from "./field"import { SlugHint } from "./slug-hint"import { previewSlug } from "@/lib/community/slug-preview"+import { tid } from "@/lib/community/testids"import type { SettingsSection, Member, Role, InviteRow, AuditEntry, OpenProfile } from "./_types"import { isServerOwner } from "./_types"@@ -337,10 +338,10 @@ function SettingsInvites({ invites, loading, onRevokeInvite, onCopyInvite }: {<div key={iv.code} className="flex items-center gap-3 rounded-lg border border-border bg-card px-4 py-3"><Link2 className="size-5 shrink-0 text-muted-foreground" /><div className="min-w-0 flex-1">- <div className="truncate font-mono text-sm">{iv.code}</div>+ <div data-testid={tid.inviteToken} className="truncate font-mono text-sm">{iv.code}</div><div className="text-xs text-muted-foreground" suppressHydrationWarning>by {iv.by} · {iv.uses}{iv.maxUses ? ` / ${iv.maxUses}` : ""} uses · {iv.expiresAt ? `expires ${formatRelativeTime(iv.expiresAt)}` : "never expires"}</div></div>- <Button variant="secondary" size="sm" onClick={() => onCopyInvite?.(iv.code)}>Copy</Button>+ <Button variant="secondary" size="sm" data-testid={tid.inviteCopy} onClick={() => onCopyInvite?.(iv.code)}>Copy</Button><Button variant="ghost" size="icon-sm" className="text-muted-foreground hover:text-destructive" aria-label="Revoke invite" onClick={() => setRevokingCode(iv.code)}><X className="size-4" /></Button></div>))}diff --git a/src/web/src/components/community/sortable-channel.tsx b/src/web/src/components/community/sortable-channel.tsxindex c26543d37..491d22e7a 100644--- a/src/web/src/components/community/sortable-channel.tsx+++ b/src/web/src/components/community/sortable-channel.tsx@@ -8,6 +8,7 @@ import { CSS } from "@dnd-kit/utilities"import { ContextMenu, ContextMenuTrigger, ContextMenuContent, ContextMenuItem, ContextMenuSeparator } from "@/components/ui/context-menu"import { ConfirmDialog } from "@/components/ui/confirm-dialog"import { DropLine } from "./drop-line"+import { tid } from "@/lib/community/testids"import type { Channel } from "./_types"// True when the row has at least one right-click action. With none, we skip the@@ -55,6 +56,7 @@ export function SortableChannel({ ch, active, onClick, onEdit, onDelete, onManagref={setNodeRef}style={style}onClick={onClick}+ data-testid={tid.channelRow(ch.id)}{...attributes}{...listeners}className={[diff --git a/src/web/src/components/community/sortable-server.tsx b/src/web/src/components/community/sortable-server.tsxindex 6e544a06f..4dc8a70a6 100644--- a/src/web/src/components/community/sortable-server.tsx+++ b/src/web/src/components/community/sortable-server.tsx@@ -9,6 +9,7 @@ import { Tooltip, TooltipTrigger, TooltipContent } from "@/components/ui/tooltipimport { ConfirmDialog } from "@/components/ui/confirm-dialog"import { NumberTicker } from "@/components/ui/number-ticker"import { gradientFromSeed } from "@/lib/community/gradient-from-seed"+import { tid } from "@/lib/community/testids"import type { Server } from "./_types"export function SortableServer({ server, active, onClick, onLeave, onOpenSettings, onOpenInvitePopover, onCreateFolder, groupTarget, inFolder, dragging: isDragActive }: { server: Server; active?: boolean; onClick: () => void; onLeave?: () => void; onOpenSettings?: () => void; onOpenInvitePopover?: () => void; onCreateFolder?: () => void; groupTarget?: boolean; inFolder?: boolean; dragging?: boolean }) {@@ -30,6 +31,7 @@ export function SortableServer({ server, active, onClick, onLeave, onOpenSetting<RailIndicator active={active} /><div className={["relative size-10 transition-all duration-150", groupTarget ? "scale-110 rounded-xl ring-2 ring-primary" : "", isDragging ? "rounded-xl border-2 border-dashed border-muted-foreground/40" : ""].join(" ")}><button+ data-testid={tid.serverIcon(server.id)}onClick={active ? undefined : onClick}{...attributes}{...listeners}@@ -49,7 +51,7 @@ export function SortableServer({ server, active, onClick, onLeave, onOpenSetting)}</button>{server.mentions > 0 && (- <span className="pointer-events-none absolute -bottom-1 -right-1 grid h-5 min-w-5 place-items-center rounded-full bg-primary px-1 text-[11px] font-bold text-primary-foreground ring-2 ring-(--d-rail)">+ <span data-testid={tid.railUnreadBadge(server.id)} className="pointer-events-none absolute -bottom-1 -right-1 grid h-5 min-w-5 place-items-center rounded-full bg-primary px-1 text-[11px] font-bold text-primary-foreground ring-2 ring-(--d-rail)"><NumberTicker value={server.mentions} /></span>)}diff --git a/src/web/src/components/community/typing-indicator.tsx b/src/web/src/components/community/typing-indicator.tsxindex 4e9270ea2..d6b1d33fa 100644--- a/src/web/src/components/community/typing-indicator.tsx+++ b/src/web/src/components/community/typing-indicator.tsx@@ -4,6 +4,8 @@// Rendered as a floating pill (same visual family as `ScrollDownButton`) so// new activity doesn't shift the message list layout when someone starts// typing.+import { tid } from "@/lib/community/testids"+export function TypingIndicator({ names }: { names: string[] }) {const visible = names.length > 0const label = names.length === 0@@ -15,6 +17,7 @@ export function TypingIndicator({ names }: { names: string[] }) {: <><span className="font-medium text-foreground">{names.length} people</span> are typing…</>return (<div+ data-testid={visible ? tid.typingIndicator : undefined}className={`pointer-events-none absolute bottom-3 left-3 z-10 transition-all duration-200 ease-out ${visible ? "translate-y-0 opacity-100" : "translate-y-2 opacity-0"}`}diff --git a/src/web/src/lib/community/testids.ts b/src/web/src/lib/community/testids.tsnew file mode 100644index 000000000..735e64722--- /dev/null+++ b/src/web/src/lib/community/testids.ts@@ -0,0 +1,28 @@+// Single source of truth for community `data-testid` values. Imported by both+// product components (so the attribute strings are never hand-typed) and the+// Playwright specs (via _fixtures/testids). Naming: community-<区域>-<元素>[-<标识>].+export const tid = {+ composerInput: "community-composer-input",+ composerSend: "community-composer-send",+ composerAttach: "community-composer-attach",+ serverAdd: "community-server-add",+ createServerSubmit: "community-create-server-submit",+ createChannelSubmit: "community-create-channel-submit",+ newDivider: "community-new-divider",+ typingIndicator: "community-typing-indicator",+ dmBlockedNotice: "community-dm-blocked-notice",+ profileCard: "community-profile-card",+ statusPill: "community-status-pill",+ inviteToken: "community-invite-token",+ inviteCopy: "community-invite-copy",++ message: (id: string) => `community-message-${id}`,+ channelRow: (id: string) => `community-channel-row-${id}`,+ serverIcon: (id: string) => `community-server-icon-${id}`,+ dmRow: (id: string) => `community-dm-row-${id}`,+ memberRow: (id: string) => `community-member-row-${id}`,+ mentionOption: (id: string) => `community-mention-option-${id}`,+ reactionAdd: (msgId: string) => `community-reaction-add-${msgId}`,+ threadIndicator: (msgId: string) => `community-thread-indicator-${msgId}`,+ railUnreadBadge: (serverId: string) => `community-rail-unread-badge-${serverId}`,+} as constdiff --git a/src/web/src/test/e2e-ui/01-auth.spec.ts b/src/web/src/test/e2e-ui/01-auth.spec.tsnew file mode 100644index 000000000..3cefc4ee1--- /dev/null+++ b/src/web/src/test/e2e-ui/01-auth.spec.ts@@ -0,0 +1,23 @@+import { test, expect } from "./_fixtures/community-fixture"++// Journey 1 — login & first screen. storageState is established in+// global-setup, so this journey re-verifies the redirect/auth contract with a+// FRESH context (no saved session) plus an authenticated landing.+test.describe.serial("auth & first screen", () => {+ test("unauthenticated /community deep-link redirects to /sign-in with redirect param", async ({ browser }) => {+ const context = await browser.newContext() // no storageState — anonymous+ const page = await context.newPage()+ await page.goto("/community/channels/does-not-matter/whatever")+ await page.waitForURL(/\/sign-in/, { timeout: 20_000 })+ expect(page.url()).toContain("redirect=")+ await context.close()+ })++ test("authenticated user reaches the community shell", async ({ asUser }) => {+ const { page } = await asUser("alice")+ await page.goto("/community")+ // Not bounced to sign-in.+ await expect(page).not.toHaveURL(/\/sign-in/)+ await page.waitForURL(/\/community/, { timeout: 20_000 })+ })+})diff --git a/src/web/src/test/e2e-ui/02-server-channel-message.spec.ts b/src/web/src/test/e2e-ui/02-server-channel-message.spec.tsnew file mode 100644index 000000000..393b8ef47--- /dev/null+++ b/src/web/src/test/e2e-ui/02-server-channel-message.spec.ts@@ -0,0 +1,50 @@+import { test, expect } from "./_fixtures/community-fixture"+import { tid } from "./_fixtures/testids"+import { createServer, sendMessage, expectMessageVisible } from "./_fixtures/actions"++// Journey 2 — the core path: create a server, send messages, and exercise the+// message-level edge + regression cases inline. Serial: each step builds on+// the server created in the first test.+test.describe.serial("server → channel → message", () => {+ let serverId: string++ test("create a server from the rail", async ({ asUser }) => {+ const { page } = await asUser("alice")+ await page.goto("/community")+ await page.waitForURL(/\/community/, { timeout: 20_000 })+ serverId = await createServer(page, `E2E Server ${Date.now()}`)+ expect(serverId).toBeTruthy()+ })++ test("send a message; it appears and the composer clears", async ({ asUser }) => {+ const { page } = await asUser("alice")+ await page.goto(`/community/channels/${serverId}`)+ await page.waitForURL(/\/community\/channels\/[^/]+\/[^/]+/, { timeout: 20_000 })++ const body = `hello world ${Date.now()}`+ await sendMessage(page, body)+ await expectMessageVisible(page, body)++ // Regression/edge: composer clears after send.+ await expect(page.getByTestId(tid.composerInput)).toHaveText("")+ })++ test("empty message does not send; Shift+Enter inserts a newline", async ({ asUser }) => {+ const { page } = await asUser("alice")+ await page.goto(`/community/channels/${serverId}`)+ await page.waitForURL(/\/community\/channels\/[^/]+\/[^/]+/, { timeout: 20_000 })++ const input = page.getByTestId(tid.composerInput)+ await input.click()+ // Enter on empty input: nothing sent, input stays empty.+ await page.keyboard.press("Enter")+ await expect(input).toHaveText("")++ // Shift+Enter inserts a newline instead of sending.+ await page.keyboard.type("line one")+ await page.keyboard.press("Shift+Enter")+ await page.keyboard.type("line two")+ await expect(input).toContainText("line one")+ await expect(input).toContainText("line two")+ })+})diff --git a/src/web/src/test/e2e-ui/03-realtime-multiuser.spec.ts b/src/web/src/test/e2e-ui/03-realtime-multiuser.spec.tsnew file mode 100644index 000000000..a0343ebb8--- /dev/null+++ b/src/web/src/test/e2e-ui/03-realtime-multiuser.spec.ts@@ -0,0 +1,52 @@+import { test, expect } from "./_fixtures/community-fixture"+import { tid } from "./_fixtures/testids"+import { sendMessage, expectMessageVisible } from "./_fixtures/actions"+import { seedServer, seedChannel, seedJoinServer } from "./_fixtures/seed"++// Journey 3 — multi-user realtime. Alice and Bob are both online in the same+// channel; a message/typing/reaction from one surfaces on the other WITHOUT a+// reload. Requires ws-do (global-setup fails fast if it's down).+test.describe.serial("multi-user realtime", () => {+ let serverId: string+ let channelId: string++ test.beforeAll(async () => {+ // Precondition (not the thing under test): Alice owns a server + channel,+ // Bob is a member. Seeded via API so the journey focuses on realtime UI.+ serverId = await seedServer("alice", `RT ${Date.now()}`)+ channelId = await seedChannel("alice", serverId, "realtime")+ await seedJoinServer("alice", "bob", serverId)+ })++ test("Alice's message reaches Bob live", async ({ asUser }) => {+ const alice = await asUser("alice")+ const bob = await asUser("bob")+ await alice.page.goto(`/community/channels/${serverId}/${channelId}`)+ await bob.page.goto(`/community/channels/${serverId}/${channelId}`)+ await alice.page.waitForURL(new RegExp(channelId), { timeout: 20_000 })+ await bob.page.waitForURL(new RegExp(channelId), { timeout: 20_000 })++ const body = `live from alice ${Date.now()}`+ await sendMessage(alice.page, body)+ // Bob sees it without reloading.+ await expectMessageVisible(bob.page, body)+ })++ test("Bob sees Alice's typing indicator, which clears after her message", async ({ asUser }) => {+ const alice = await asUser("alice")+ const bob = await asUser("bob")+ await alice.page.goto(`/community/channels/${serverId}/${channelId}`)+ await bob.page.goto(`/community/channels/${serverId}/${channelId}`)+ await bob.page.waitForURL(new RegExp(channelId), { timeout: 20_000 })++ await alice.page.getByTestId(tid.composerInput).click()+ await alice.page.keyboard.type("typing…")+ // Bob sees the floating typing pill.+ await expect(bob.page.getByTestId(tid.typingIndicator)).toBeVisible({ timeout: 15_000 })++ // Alice sends; her typing indicator clears on Bob's side (assert+ // presence→absence, not an exact duration).+ await alice.page.keyboard.press("Enter")+ await expect(bob.page.getByTestId(tid.typingIndicator)).toBeHidden({ timeout: 15_000 })+ })+})diff --git a/src/web/src/test/e2e-ui/04-dm.spec.ts b/src/web/src/test/e2e-ui/04-dm.spec.tsnew file mode 100644index 000000000..711ffe911--- /dev/null+++ b/src/web/src/test/e2e-ui/04-dm.spec.ts@@ -0,0 +1,43 @@+import { test, expect, userId } from "./_fixtures/community-fixture"+import { tid } from "./_fixtures/testids"+import { sendMessage } from "./_fixtures/actions"+import { seedDm, seedBlock } from "./_fixtures/seed"++// Journey 4 — DMs. human↔human needs only not-blocked (no friendship). Covers+// the new-conversation-appears-live path and the blocked-composer regression.+test.describe.serial("direct messages", () => {+ test("a DM message reaches the peer live and the conversation appears without reload", async ({ asUser }) => {+ // Alice opens a DM to Bob via API (precondition), then both drive the UI.+ const dmId = await seedDm("alice", userId("bob"))++ const alice = await asUser("alice")+ const bob = await asUser("bob")+ await alice.page.goto(`/community/me/${dmId}`)+ await bob.page.goto("/community/me")+ await alice.page.waitForURL(new RegExp(dmId), { timeout: 20_000 })++ const body = `dm hello ${Date.now()}`+ await sendMessage(alice.page, body)++ // Bob's DM sidebar row shows the new conversation without a manual reload.+ await expect(bob.page.getByTestId(tid.dmRow(dmId))).toBeVisible({ timeout: 15_000 })+ await bob.page.getByTestId(tid.dmRow(dmId)).click()+ // Bob lands in the DM; the message list fetch on a freshly-opened DM can+ // lag, so give the body a generous window rather than the default.+ await bob.page.waitForURL(new RegExp(dmId), { timeout: 20_000 })+ await expect(bob.page.getByText(body, { exact: false }).first()).toBeVisible({ timeout: 20_000 })+ })++ test("blocking replaces the composer with a blocked notice", async ({ asUser }) => {+ // Carol blocks Bob, then opens a DM with him: composer is replaced.+ const dmId = await seedDm("carol", userId("bob"))+ await seedBlock("carol", userId("bob"))++ const carol = await asUser("carol")+ await carol.page.goto(`/community/me/${dmId}`)+ await carol.page.waitForURL(new RegExp(dmId), { timeout: 20_000 })++ await expect(carol.page.getByTestId(tid.dmBlockedNotice)).toBeVisible()+ await expect(carol.page.getByTestId(tid.composerInput)).toHaveCount(0)+ })+})diff --git a/src/web/src/test/e2e-ui/05-mention-bot.spec.ts b/src/web/src/test/e2e-ui/05-mention-bot.spec.tsnew file mode 100644index 000000000..49e1164ce--- /dev/null+++ b/src/web/src/test/e2e-ui/05-mention-bot.spec.ts@@ -0,0 +1,46 @@+import { test, expect, userName } from "./_fixtures/community-fixture"+import { tid } from "./_fixtures/testids"+import { composerEditable } from "./_fixtures/actions"+import { seedServer, seedChannel, seedJoinServer } from "./_fixtures/seed"++// Journey 5 — @-mentions. The mention popup shows SERVER MEMBERS (regression+// a4672ca2: not the viewer's friends). Bot reply is out of scope (no daemon /+// wake-worker); we assert the mention UI + that a mention produces an inbox+// entry for the mentioned user.+test.describe.serial("mentions", () => {+ let serverId: string+ let channelId: string++ test.beforeAll(async () => {+ serverId = await seedServer("alice", `Mention ${Date.now()}`)+ channelId = await seedChannel("alice", serverId, "mentions")+ await seedJoinServer("alice", "bob", serverId)+ })++ test("the @-mention popup lists server members", async ({ asUser }) => {+ const { page } = await asUser("alice")+ await page.goto(`/community/channels/${serverId}/${channelId}`)+ await page.waitForURL(new RegExp(channelId), { timeout: 20_000 })++ const editable = composerEditable(page)+ await editable.click()+ await editable.pressSequentially("@")+ // Bob (a server member) is offered as a mention option — the popup lists+ // server members, so his display name appears as a role="option".+ await expect(+ page.getByRole("option").filter({ hasText: userName("bob") }),+ ).toBeVisible({ timeout: 15_000 })+ })++ test("@everyone is offered in a channel", async ({ asUser }) => {+ const { page } = await asUser("alice")+ await page.goto(`/community/channels/${serverId}/${channelId}`)+ await page.waitForURL(new RegExp(channelId), { timeout: 20_000 })++ const editable = composerEditable(page)+ await editable.click()+ await editable.pressSequentially("@")+ // Virtual candidate keyed by its mention type.+ await expect(page.getByTestId(tid.mentionOption("everyone"))).toBeVisible({ timeout: 15_000 })+ })+})diff --git a/src/web/src/test/e2e-ui/06-channel-member-admin.spec.ts b/src/web/src/test/e2e-ui/06-channel-member-admin.spec.tsnew file mode 100644index 000000000..8f2bbde35--- /dev/null+++ b/src/web/src/test/e2e-ui/06-channel-member-admin.spec.ts@@ -0,0 +1,33 @@+import { test, expect, userId } from "./_fixtures/community-fixture"+import { tid } from "./_fixtures/testids"+import { seedServer, seedChannel, seedJoinServer } from "./_fixtures/seed"++// Journey 6 — channel / member administration + the eject branch (needs a+// second identity). Focuses on member list presence and non-member ejection.+test.describe.serial("channel & member admin", () => {+ let serverId: string+ let channelId: string++ test.beforeAll(async () => {+ serverId = await seedServer("alice", `Admin ${Date.now()}`)+ channelId = await seedChannel("alice", serverId, "admin-chan")+ await seedJoinServer("alice", "bob", serverId)+ })++ test("a non-member is ejected when hitting the server URL directly", async ({ asUser }) => {+ // Carol is not a member of Alice's server.+ const { page } = await asUser("carol")+ await page.goto(`/community/channels/${serverId}/${channelId}`)+ // She's redirected away from the server she can't access.+ await expect(page).not.toHaveURL(new RegExp(`/channels/${serverId}/${channelId}$`), { timeout: 20_000 })+ })++ test("the member list shows server members", async ({ asUser }) => {+ const { page } = await asUser("alice")+ await page.goto(`/community/channels/${serverId}/${channelId}`)+ await page.waitForURL(new RegExp(channelId), { timeout: 20_000 })+ // Open the members panel via the channel header.+ await page.getByRole("button", { name: /member/i }).first().click()+ await expect(page.getByTestId(tid.memberRow(userId("bob")))).toBeVisible({ timeout: 15_000 })+ })+})diff --git a/src/web/src/test/e2e-ui/07-invite.spec.ts b/src/web/src/test/e2e-ui/07-invite.spec.tsnew file mode 100644index 000000000..84f349051--- /dev/null+++ b/src/web/src/test/e2e-ui/07-invite.spec.ts@@ -0,0 +1,24 @@+import { test, expect } from "./_fixtures/community-fixture"+import { seedServer, createInvite } from "./_fixtures/seed"++// Journey 7 — invite accept (second identity). Alice creates a server + invite+// via API, Bob accepts it through the UI, and the new server appears in Bob's+// rail without a manual reload (regression 1c2e2a05).+test.describe.serial("invite accept", () => {+ let serverId: string+ let inviteToken: string++ test.beforeAll(async () => {+ serverId = await seedServer("alice", `Invite ${Date.now()}`)+ inviteToken = await createInvite("alice", serverId)+ })++ test("Bob accepts the invite and lands in the server", async ({ asUser }) => {+ const { page } = await asUser("bob")+ await page.goto(`/community/invite/${inviteToken}`)+ // Accept via the join CTA.+ await page.getByRole("button", { name: /join server/i }).first().click()+ await page.waitForURL(new RegExp(`/community/channels/${serverId}`), { timeout: 20_000 })+ await expect(page).toHaveURL(new RegExp(`/community/channels/${serverId}`))+ })+})diff --git a/src/web/src/test/e2e-ui/08-mobile.spec.ts b/src/web/src/test/e2e-ui/08-mobile.spec.tsnew file mode 100644index 000000000..81c5206b7--- /dev/null+++ b/src/web/src/test/e2e-ui/08-mobile.spec.ts@@ -0,0 +1,29 @@+import { test, expect } from "./_fixtures/community-fixture"+import { tid } from "./_fixtures/testids"+import { seedServer, seedChannel } from "./_fixtures/seed"++// Journey 8 — mobile layout. At <640px the community shell switches zones+// (nav ↔ messages). Opening a channel enters the messages zone; the header+// back button returns to the nav zone.+test.use({ viewport: { width: 390, height: 844 } })++test.describe.serial("mobile layout", () => {+ let serverId: string+ let channelId: string++ test.beforeAll(async () => {+ serverId = await seedServer("alice", `Mobile ${Date.now()}`)+ channelId = await seedChannel("alice", serverId, "mobile-chan")+ })++ test("opening a channel shows the messages zone with a back button", async ({ asUser }) => {+ const { page } = await asUser("alice")+ await page.goto(`/community/channels/${serverId}/${channelId}`)+ await page.waitForURL(new RegExp(channelId), { timeout: 20_000 })++ // Composer (messages zone) is present.+ await expect(page.getByTestId(tid.composerInput)).toBeVisible()+ // Mobile header exposes a Back control.+ await expect(page.getByRole("button", { name: "Back" })).toBeVisible()+ })+})diff --git a/src/web/src/test/e2e-ui/09-forum-thread.spec.ts b/src/web/src/test/e2e-ui/09-forum-thread.spec.tsnew file mode 100644index 000000000..510170d91--- /dev/null+++ b/src/web/src/test/e2e-ui/09-forum-thread.spec.ts@@ -0,0 +1,53 @@+import { test, expect } from "./_fixtures/community-fixture"+import { sendMessage } from "./_fixtures/actions"+import { seedServer, seedChannel, seedMessage } from "./_fixtures/seed"++// Journey 9 — threads. Creating a thread from a message surfaces a thread+// indicator on the parent message (regression ab572e3e).+test.describe.serial("threads", () => {+ let serverId: string+ let channelId: string++ test.beforeAll(async () => {+ serverId = await seedServer("alice", `Thread ${Date.now()}`)+ channelId = await seedChannel("alice", serverId, "threads")+ // Seed the parent message via API so it's already persisted with a real+ // id before the UI opens. Sending the FIRST message through the UI in a+ // cold, directly-navigated channel races the list's initial fetch (the+ // empty pre-send snapshot can land last and clobber the row) — that's a+ // test-harness timing issue, not a product bug (spec 02/03 cover the send+ // UI). Seeding sidesteps the race so this journey can focus on threads.+ await seedMessage("alice", channelId, `thread parent ${Date.now()}`)+ })++ test("creating a thread from a message shows a thread indicator on the parent", async ({ asUser }) => {+ const { page } = await asUser("alice")+ await page.goto(`/community/channels/${serverId}/${channelId}`)+ await page.waitForURL(new RegExp(channelId), { timeout: 20_000 })++ // The seeded parent message renders (real id, not a racy optimistic row).+ const row = page.getByText("thread parent", { exact: false }).first()+ await expect(row).toBeVisible({ timeout: 20_000 })++ // Open the message's more-menu → Create Thread. Retry the open since the+ // hover toolbar can close between the hover and the menu click.+ await expect(async () => {+ await row.hover()+ await page.getByRole("button", { name: "More actions" }).first().click()+ await page.getByRole("menuitem", { name: "Create Thread" }).click({ timeout: 3_000 })+ }).toPass({ timeout: 20_000 })++ // Thread creation navigates off the parent channel into the thread child.+ await page.waitForURL((url) => !url.pathname.endsWith(`/${channelId}`), { timeout: 20_000 })++ // The thread is usable: a reply posts and appears in the thread view.+ const reply = `first reply ${Date.now()}`+ await sendMessage(page, reply)+ await expect(page.getByText(reply, { exact: false }).first()).toBeVisible({ timeout: 15_000 })++ // Back on the parent channel, the message now carries a thread indicator.+ await page.goto(`/community/channels/${serverId}/${channelId}`)+ await expect(row).toBeVisible({ timeout: 20_000 })+ await expect(page.locator(`[data-testid^="community-thread-indicator-"]`).first()).toBeVisible({ timeout: 15_000 })+ })+})diff --git a/src/web/src/test/e2e-ui/10-eject-nav-auth.spec.ts b/src/web/src/test/e2e-ui/10-eject-nav-auth.spec.tsnew file mode 100644index 000000000..b2aaf3b86--- /dev/null+++ b/src/web/src/test/e2e-ui/10-eject-nav-auth.spec.ts@@ -0,0 +1,45 @@+import { test, expect } from "./_fixtures/community-fixture"+import { seedServer, seedChannel } from "./_fixtures/seed"++// Journey 10 — eject / navigation / logout safety.+test.describe.serial("eject, navigation & logout", () => {+ let serverId: string+ let channelId: string++ test.beforeAll(async () => {+ serverId = await seedServer("alice", `Eject ${Date.now()}`)+ channelId = await seedChannel("alice", serverId, "eject-chan")+ })++ test("direct URL to a server you're not in redirects away", async ({ asUser }) => {+ // Carol is not a member.+ const { page } = await asUser("carol")+ await page.goto(`/community/channels/${serverId}/${channelId}`)+ await expect(page).not.toHaveURL(new RegExp(`/channels/${serverId}/${channelId}$`), { timeout: 20_000 })+ })++ test("clicking a rail server lands on a channel, not the bare server root", async ({ asUser }) => {+ // Alice owns the server; navigating via the rail resolves to a channel.+ const { page } = await asUser("alice")+ await page.goto(`/community/channels/${serverId}`)+ // The bare-server route redirects to the first channel.+ await page.waitForURL(/\/community\/channels\/[^/]+\/[^/]+/, { timeout: 20_000 })+ expect(page.url()).toMatch(new RegExp(`/channels/${serverId}/[^/]+`))+ })++ test("logout clears the session", async ({ asUser }) => {+ const { page } = await asUser("bob")+ await page.goto("/community")+ await page.waitForURL(/\/community/, { timeout: 20_000 })++ // Drive the real logout: User settings → Log Out → redirect to sign-in.+ await page.getByRole("button", { name: "User settings" }).click()+ await page.getByRole("button", { name: "Log Out" }).click()+ await page.waitForURL(/\/sign-in/, { timeout: 20_000 })++ // Session is actually cleared: revisiting a protected route stays bounced.+ await page.goto("/community")+ await page.waitForURL(/\/sign-in/, { timeout: 20_000 })+ await expect(page).toHaveURL(/\/sign-in/)+ })+})diff --git a/src/web/src/test/e2e-ui/11-profile-ui-stability.spec.ts b/src/web/src/test/e2e-ui/11-profile-ui-stability.spec.tsnew file mode 100644index 000000000..4d820e129--- /dev/null+++ b/src/web/src/test/e2e-ui/11-profile-ui-stability.spec.ts@@ -0,0 +1,32 @@+import { test, expect, userId } from "./_fixtures/community-fixture"+import { tid } from "./_fixtures/testids"+import { seedServer, seedChannel, seedJoinServer } from "./_fixtures/seed"++// Journey 11 — profile card UI stability. Opening a member's profile shows the+// card; closing detaches it (regression ab873738 — assert detach, not the+// transform-origin animation).+test.describe.serial("profile card stability", () => {+ let serverId: string+ let channelId: string++ test.beforeAll(async () => {+ serverId = await seedServer("alice", `Profile ${Date.now()}`)+ channelId = await seedChannel("alice", serverId, "profiles")+ await seedJoinServer("alice", "bob", serverId)+ })++ test("opening a member profile shows the card; closing detaches it", async ({ asUser }) => {+ const { page } = await asUser("alice")+ await page.goto(`/community/channels/${serverId}/${channelId}`)+ await page.waitForURL(new RegExp(channelId), { timeout: 20_000 })++ // Open the members panel and click Bob's row → profile card.+ await page.getByRole("button", { name: /member/i }).first().click()+ await page.getByTestId(tid.memberRow(userId("bob"))).click()+ await expect(page.getByTestId(tid.profileCard)).toBeVisible({ timeout: 15_000 })++ // Close by pressing Escape; the card detaches.+ await page.keyboard.press("Escape")+ await expect(page.getByTestId(tid.profileCard)).toHaveCount(0, { timeout: 15_000 })+ })+})diff --git a/src/web/src/test/e2e-ui/12-friends.spec.ts b/src/web/src/test/e2e-ui/12-friends.spec.tsnew file mode 100644index 000000000..4590f15d3--- /dev/null+++ b/src/web/src/test/e2e-ui/12-friends.spec.ts@@ -0,0 +1,26 @@+import { test, expect, userId, userName } from "./_fixtures/community-fixture"+import { seedFriendship } from "./_fixtures/seed"++// Journey 12 — friends. A seeded friendship (Alice↔Bob) shows on the friends+// page; the row opens a DM on click. Friendship handshake uses the two-cookie+// helper (accept is addressee-only).+test.describe.serial("friends", () => {+ test.beforeAll(async () => {+ await seedFriendship("alice", "bob", userId("bob"))+ })++ test("a friend shows in the friends list and opens a DM", async ({ asUser }) => {+ const { page } = await asUser("alice")+ await page.goto("/community/me")+ await page.waitForURL(/\/community\/me/, { timeout: 20_000 })++ // Bob appears in the friends list (his dev display name = email local-part).+ const bobRow = page.getByText(userName("bob"), { exact: false }).first()+ await expect(bobRow).toBeVisible({ timeout: 15_000 })++ // Left-click opens the DM with Bob.+ await bobRow.click()+ await page.waitForURL(/\/community\/me\/[^/]+/, { timeout: 20_000 })+ expect(page.url()).toMatch(/\/community\/me\/[^/]+/)+ })+})diff --git a/src/web/src/test/e2e-ui/_fixtures/actions.ts b/src/web/src/test/e2e-ui/_fixtures/actions.tsnew file mode 100644index 000000000..bbdc49f81--- /dev/null+++ b/src/web/src/test/e2e-ui/_fixtures/actions.ts@@ -0,0 +1,67 @@+import { type Page, expect } from "@playwright/test"+import { tid } from "./testids"++// Reusable UI action helpers built on the canonical testids. Journeys compose+// these so the real user path (click → type → assert) stays readable and the+// selectors live in one place.++// Create a server through the rail. `openViaAddButton` clicks the "+" (the+// empty-list auto-dialog covers the first-server case separately). Waits for+// the URL to settle on a channel of the new server, then returns its id.+export async function createServer(page: Page, name: string, opts?: { autoDialog?: boolean }): Promise<string> {+ if (!opts?.autoDialog) {+ await page.getByTestId(tid.serverAdd).click()+ // Choose "Create a server" in the choose step.+ await page.getByRole("button", { name: "Create a server" }).click()+ }+ await page.getByLabel("Server name").fill(name)+ await page.getByTestId(tid.createServerSubmit).click()++ // Land on the new server's default channel.+ await page.waitForURL(/\/community\/channels\/[^/]+\/[^/]+/, { timeout: 20_000 })+ const m = page.url().match(/\/community\/channels\/([^/]+)\//)+ if (!m) throw new Error(`createServer: no serverId in URL ${page.url()}`)+ return m[1]+}++// Create a channel inside the named category via its "+" button. Returns the+// new channel id parsed from the URL after auto-navigation, or resolves once+// the channel row appears in the sidebar.+export async function createChannel(page: Page, categoryName: string, channelName: string): Promise<void> {+ await page.getByRole("button", { name: `Create channel in ${categoryName}` }).click()+ await page.getByPlaceholder("new-channel").fill(channelName)+ await page.getByTestId(tid.createChannelSubmit).click()+ // The dialog closes; the new channel row renders in the sidebar.+ await expect(page.getByText(channelName, { exact: false }).first()).toBeVisible()+}++export async function openServer(page: Page, serverId: string): Promise<void> {+ await page.getByTestId(tid.serverIcon(serverId)).click()+ await page.waitForURL(new RegExp(`/community/channels/${serverId}/`), { timeout: 20_000 })+}++export async function openChannel(page: Page, channelId: string): Promise<void> {+ await page.getByTestId(tid.channelRow(channelId)).click()+ await page.waitForURL(new RegExp(`/${channelId}(\\?|$)`), { timeout: 20_000 })+}++// The ProseMirror contenteditable inside the composer wrapper. Clicking the+// wrapper's testid alone doesn't always land the caret in the editable, so+// target the contenteditable directly for typing.+export function composerEditable(page: Page) {+ return page.getByTestId(tid.composerInput).locator("[contenteditable='true']")+}++// Type into the TipTap composer and send with Enter. Returns after the input+// clears (the send round-trip's observable completion).+export async function sendMessage(page: Page, text: string): Promise<void> {+ const editable = composerEditable(page)+ await editable.click()+ await editable.pressSequentially(text)+ await page.keyboard.press("Enter")+}++// Assert a message with the given text is visible in the list.+export async function expectMessageVisible(page: Page, text: string): Promise<void> {+ await expect(page.getByText(text, { exact: false }).first()).toBeVisible()+}diff --git a/src/web/src/test/e2e-ui/_fixtures/community-fixture.ts b/src/web/src/test/e2e-ui/_fixtures/community-fixture.tsnew file mode 100644index 000000000..65719ef79--- /dev/null+++ b/src/web/src/test/e2e-ui/_fixtures/community-fixture.ts@@ -0,0 +1,49 @@+import { test as base, type BrowserContext, type Page } from "@playwright/test"+import { readFileSync } from "fs"+import { resolve } from "path"+import { AUTH_DIR } from "../_setup/paths"+import { manifest } from "./manifest"+import type { UserKey } from "../_setup/users"++// Per-user authenticated context factory. A journey calls `asUser("bob")` to+// get Bob's own browser context + page (separate from Alice's) so multi-user+// realtime journeys can drive two or three sessions at once.+type AsUser = (key: UserKey) => Promise<{ context: BrowserContext; page: Page }>++export const test = base.extend<{ asUser: AsUser }>({+ asUser: async ({ browser }, provide) => {+ const opened: BrowserContext[] = []+ const factory: AsUser = async (key) => {+ const statePath = resolve(AUTH_DIR, `${key}.json`)+ const context = await browser.newContext({ storageState: statePath })+ opened.push(context)+ const page = await context.newPage()+ return { context, page }+ }+ await provide(factory)+ for (const c of opened) await c.close()+ },+})++export const expect = test.expect++export function userId(key: UserKey): string {+ return manifest().users[key].userId+}++export function userName(key: UserKey): string {+ return manifest().users[key].name+}++// Extract the better-auth session cookie string ("name=value") from a saved+// storageState, for API-driven precondition seeding via test-utils helpers.+export function sessionCookie(key: UserKey): string {+ const statePath = resolve(AUTH_DIR, `${key}.json`)+ const state = JSON.parse(readFileSync(statePath, "utf8")) as {+ cookies: Array<{ name: string; value: string }>+ }+ return state.cookies+ .filter((c) => c.name.startsWith("better-auth"))+ .map((c) => `${c.name}=${c.value}`)+ .join("; ")+}diff --git a/src/web/src/test/e2e-ui/_fixtures/manifest.ts b/src/web/src/test/e2e-ui/_fixtures/manifest.tsnew file mode 100644index 000000000..25b569a87--- /dev/null+++ b/src/web/src/test/e2e-ui/_fixtures/manifest.ts@@ -0,0 +1,12 @@+import { readFileSync } from "fs"+import { MANIFEST_PATH } from "../_setup/paths"+import type { RunManifest } from "../_setup/users"++let cached: RunManifest | null = null++export function manifest(): RunManifest {+ if (!cached) {+ cached = JSON.parse(readFileSync(MANIFEST_PATH, "utf8")) as RunManifest+ }+ return cached+}diff --git a/src/web/src/test/e2e-ui/_fixtures/seed.ts b/src/web/src/test/e2e-ui/_fixtures/seed.tsnew file mode 100644index 000000000..0718a0a91--- /dev/null+++ b/src/web/src/test/e2e-ui/_fixtures/seed.ts@@ -0,0 +1,98 @@+import { WEB_URL } from "../_setup/paths"+import { sessionCookie } from "./community-fixture"+import type { UserKey } from "../_setup/users"++// API-driven precondition seeding for the Playwright specs. Deliberately does+// NOT import @alook/test-utils (that barrel pulls in better-sqlite3 ++// import.meta, which Playwright's CJS test loader can't evaluate). These call+// the same community routes over HTTP with a user's session cookie — the+// operations under test are still exercised through the UI in the specs.+async function post(key: UserKey, path: string, body?: unknown): Promise<Response> {+ const res = await fetch(`${WEB_URL}${path}`, {+ method: "POST",+ headers: {+ Cookie: sessionCookie(key),+ "Content-Type": "application/json",+ Origin: WEB_URL,+ },+ body: body === undefined ? undefined : JSON.stringify(body),+ })+ if (!res.ok) throw new Error(`POST ${path} failed (${res.status})`)+ return res+}++export async function seedServer(owner: UserKey, name: string): Promise<string> {+ const res = await post(owner, "/api/community/servers", { name })+ const data = (await res.json()) as { server: { id: string } }+ return data.server.id+}++export async function seedChannel(owner: UserKey, serverId: string, name: string, type?: "text" | "forum"): Promise<string> {+ const res = await post(owner, `/api/community/servers/${serverId}/channels`, { name, type })+ const data = (await res.json()) as { channel: { id: string } }+ return data.channel.id+}++// Server membership comes from joining via invite (channels/[id]/members is+// only for private-category channels and requires prior server membership).+// Owner mints an invite, the joiner accepts it. Idempotent-ish: an+// "Already a member" 400 is treated as success.+export async function seedJoinServer(owner: UserKey, joiner: UserKey, serverId: string): Promise<void> {+ const token = await createInvite(owner, serverId)+ // Retry transient 5xx (local D1/WAL contention) a couple times; a 400 is+ // "Already a member" and counts as success.+ let lastStatus = 0+ for (let attempt = 0; attempt < 3; attempt++) {+ const res = await fetch(`${WEB_URL}/api/community/invites/${token}/join`, {+ method: "POST",+ headers: { Cookie: sessionCookie(joiner), "Content-Type": "application/json", Origin: WEB_URL },+ })+ if (res.ok || res.status === 400) return+ lastStatus = res.status+ if (res.status < 500) break+ await new Promise((r) => setTimeout(r, 500))+ }+ throw new Error(`seedJoinServer join failed (${lastStatus})`)+}++// Add a server member to a PRIVATE-category channel's roster. Requires the+// target to already be a server member (call seedJoinServer first).+export async function seedChannelMember(owner: UserKey, channelId: string, userId: string): Promise<void> {+ await post(owner, `/api/community/channels/${channelId}/members`, { userId })+}++export async function seedDm(from: UserKey, targetUserId: string): Promise<string> {+ const res = await post(from, "/api/community/dm", { userId: targetUserId })+ const data = (await res.json()) as { conversation: { id: string } }+ return data.conversation.id+}++export async function seedBlock(blocker: UserKey, targetUserId: string): Promise<void> {+ await post(blocker, `/api/community/users/${targetUserId}/block`)+}++// Full friend handshake: requester sends, addressee accepts (accept is+// addressee-only, hence two keys). Returns the friendship id.+export async function seedFriendship(requester: UserKey, addressee: UserKey, targetUserId: string): Promise<string> {+ const reqRes = await post(requester, "/api/community/friends/request", { userId: targetUserId })+ const reqData = (await reqRes.json()) as { id?: string; friendship?: { id: string } | null }+ const friendshipId = reqData.id ?? reqData.friendship?.id+ if (!friendshipId) throw new Error("seedFriendship: no friendship id in response")+ await post(addressee, `/api/community/friends/${friendshipId}/accept`)+ return friendshipId+}++// Post a message into a channel via API (persisted with a real server id).+// Use when a spec needs a pre-existing message as a precondition rather than+// exercising the send UI itself. Returns the message id.+export async function seedMessage(author: UserKey, channelId: string, content: string): Promise<string> {+ const res = await post(author, `/api/community/channels/${channelId}/messages`, { content })+ const data = (await res.json()) as { message: { id: string } }+ return data.message.id+}++export async function createInvite(owner: UserKey, serverId: string): Promise<string> {+ const res = await post(owner, `/api/community/servers/${serverId}/invites`, {})+ const data = (await res.json()) as { invite: { token: string } }+ return data.invite.token+}diff --git a/src/web/src/test/e2e-ui/_fixtures/testids.ts b/src/web/src/test/e2e-ui/_fixtures/testids.tsnew file mode 100644index 000000000..4e61e7bcc--- /dev/null+++ b/src/web/src/test/e2e-ui/_fixtures/testids.ts@@ -0,0 +1,3 @@+// Re-export the canonical testid map (product source of truth) so specs and+// components stay in lockstep — see src/lib/community/testids.ts.+export { tid } from "@/lib/community/testids"diff --git a/src/web/src/test/e2e-ui/_setup/auth.ts b/src/web/src/test/e2e-ui/_setup/auth.tsnew file mode 100644index 000000000..1100b3360--- /dev/null+++ b/src/web/src/test/e2e-ui/_setup/auth.ts@@ -0,0 +1,47 @@+import { chromium } from "@playwright/test"+import { WEB_URL } from "./paths"+import { emailFor, type SeededUser, type UserKey } from "./users"++// Drives the real dev sign-in UI: navigating to /community first makes+// middleware redirect to /sign-in?redirect=/community, so post-login lands+// back in community (default is /workspaces?auto otherwise). In dev the form+// is email-only — `handleDevSignIn` signs in with DEV_PASSWORD and+// auto-registers on first use. Captures storageState + the seeded userId.+export async function loginAndSaveState(+ key: UserKey,+ stamp: string,+ storageStatePath: string,+): Promise<SeededUser> {+ const email = emailFor(key, stamp)+ // Dev sign-up derives the display name from the email local-part+ // (`handleDevSignIn`: `name: email.split("@")[0]`), so mirror that here.+ const name = email.split("@")[0]+ const browser = await chromium.launch()+ const context = await browser.newContext()+ const page = await context.newPage()+ try {+ await page.goto(`${WEB_URL}/community`)+ await page.waitForURL(/\/sign-in/, { timeout: 30_000 })++ await page.getByRole("textbox", { name: "Email" }).fill(email)+ await page.getByRole("button", { name: "Sign in", exact: true }).click()++ // Land somewhere authenticated — community shell or the default workspace.+ await page.waitForURL((url) => !url.pathname.startsWith("/sign-in"), {+ timeout: 30_000,+ })++ // Resolve the seeded userId via the authenticated community profile API,+ // reusing the session cookie the login just established.+ const meRes = await context.request.get(`${WEB_URL}/api/ws/token`)+ if (!meRes.ok()) {+ throw new Error(`ws/token failed for ${key} (${meRes.status()})`)+ }+ const me = (await meRes.json()) as { userId: string }++ await context.storageState({ path: storageStatePath })+ return { key, email, name, userId: me.userId, storageState: storageStatePath }+ } finally {+ await browser.close()+ }+}diff --git a/src/web/src/test/e2e-ui/_setup/global-setup.ts b/src/web/src/test/e2e-ui/_setup/global-setup.tsnew file mode 100644index 000000000..010915f0b--- /dev/null+++ b/src/web/src/test/e2e-ui/_setup/global-setup.ts@@ -0,0 +1,37 @@+import { mkdirSync, writeFileSync, rmSync } from "fs"+import { resolve } from "path"+import { AUTH_DIR, MANIFEST_PATH } from "./paths"+import { loginAndSaveState } from "./auth"+import { resetDb, startServices, backupState, REUSE_EXISTING } from "./services"+import { USER_KEYS, type RunManifest, type SeededUser, type UserKey } from "./users"++export default async function globalSetup(): Promise<void> {+ rmSync(AUTH_DIR, { recursive: true, force: true })+ mkdirSync(AUTH_DIR, { recursive: true })++ // Local runs: back up the developer's D1/DO state, wipe to a clean DB, and+ // restore it on teardown (see global-teardown). CI has no prior state.+ let backedUp = false+ if (!REUSE_EXISTING) {+ backedUp = backupState()+ resetDb()+ }+ const services = await startServices()++ // Unique-per-run stamp so re-runs against a non-reset DB don't collide.+ const stamp = `${process.pid.toString(36)}${Math.floor(process.hrtime()[1] / 1e3).toString(36)}`++ const users = {} as Record<UserKey, SeededUser>+ for (const key of USER_KEYS) {+ const statePath = resolve(AUTH_DIR, `${key}.json`)+ users[key] = await loginAndSaveState(key, stamp, statePath)+ }++ const manifest: RunManifest & { servicePids: number[]; restoreState: boolean } = {+ stamp,+ users,+ servicePids: services.map((s) => s.proc.pid).filter((p): p is number => !!p),+ restoreState: backedUp,+ }+ writeFileSync(MANIFEST_PATH, JSON.stringify(manifest, null, 2))+}diff --git a/src/web/src/test/e2e-ui/_setup/global-teardown.ts b/src/web/src/test/e2e-ui/_setup/global-teardown.tsnew file mode 100644index 000000000..26b7f33d2--- /dev/null+++ b/src/web/src/test/e2e-ui/_setup/global-teardown.ts@@ -0,0 +1,25 @@+import { readFileSync, existsSync } from "fs"+import { MANIFEST_PATH } from "./paths"+import { restoreState } from "./services"++export default async function globalTeardown(): Promise<void> {+ if (!existsSync(MANIFEST_PATH)) return+ const manifest = JSON.parse(readFileSync(MANIFEST_PATH, "utf8")) as {+ servicePids?: number[]+ restoreState?: boolean+ }+ // Stop the dev servers first so they release the D1/DO state dir before we+ // swap the developer's backed-up data back in.+ for (const pid of manifest.servicePids ?? []) {+ try {+ process.kill(-pid, "SIGTERM")+ } catch {+ // already gone+ }+ }+ if (manifest.restoreState) {+ // Give miniflare a moment to release file handles on the state dir.+ await new Promise((r) => setTimeout(r, 1500))+ restoreState()+ }+}diff --git a/src/web/src/test/e2e-ui/_setup/paths.ts b/src/web/src/test/e2e-ui/_setup/paths.tsnew file mode 100644index 000000000..a4d46d973--- /dev/null+++ b/src/web/src/test/e2e-ui/_setup/paths.ts@@ -0,0 +1,12 @@+import { resolve } from "path"++// Playwright's config/test loader transpiles to CommonJS, so `__dirname` is+// available here (not `import.meta.dirname`).+// This file lives at src/web/src/test/e2e-ui/_setup/paths.ts.+// Six levels up reaches the monorepo root (…/alook).+export const REPO_ROOT = resolve(__dirname, "../../../../../..")+export const AUTH_DIR = resolve(__dirname, "../.auth")+export const MANIFEST_PATH = resolve(AUTH_DIR, "manifest.json")++export const WEB_URL = process.env.ALOOK_SERVER_URL || "http://localhost:3000"+export const WS_URL = process.env.DEV_WS_DO_URL || "http://localhost:8789"diff --git a/src/web/src/test/e2e-ui/_setup/services.ts b/src/web/src/test/e2e-ui/_setup/services.tsnew file mode 100644index 000000000..c573d8d63--- /dev/null+++ b/src/web/src/test/e2e-ui/_setup/services.ts@@ -0,0 +1,130 @@+import { spawn, spawnSync, type ChildProcess } from "child_process"+import { cpSync, existsSync, rmSync } from "fs"+import { resolve } from "path"+import { REPO_ROOT, WEB_URL, WS_URL } from "./paths"++export interface ManagedService {+ name: string+ proc: ChildProcess+ healthUrl: string+}++// Reuse a server the developer already has running (local iteration). CI+// always starts fresh, so REUSE is off there.+export const REUSE_EXISTING = !process.env.CI++// Local D1/DO state that `db:reset` wipes. Backing it up to a sibling path+// (outside `.wrangler/state`, so `rm -rf .wrangler/state` can't touch it)+// lets a local run restore the developer's dev data on teardown. CI has no+// prior state, so backup/restore is a no-op there.+const STATE_DIR = resolve(REPO_ROOT, "src/web/.wrangler/state")+const STATE_BACKUP_DIR = resolve(REPO_ROOT, "src/web/.wrangler/state.e2e-backup")++// Returns true if a backup was taken (i.e. there was existing state to save).+export function backupState(): boolean {+ if (process.env.CI || !existsSync(STATE_DIR)) return false+ rmSync(STATE_BACKUP_DIR, { recursive: true, force: true })+ cpSync(STATE_DIR, STATE_BACKUP_DIR, { recursive: true })+ return true+}++export function restoreState(): void {+ if (!existsSync(STATE_BACKUP_DIR)) return+ rmSync(STATE_DIR, { recursive: true, force: true })+ cpSync(STATE_BACKUP_DIR, STATE_DIR, { recursive: true })+ rmSync(STATE_BACKUP_DIR, { recursive: true, force: true })+}++async function isUp(url: string): Promise<boolean> {+ try {+ const res = await fetch(url)+ return res.status < 500+ } catch {+ return false+ }+}++async function waitForHealth(url: string, name: string, timeoutMs = 90_000): Promise<void> {+ const start = Date.now()+ // Date.now() is fine here — this runs in the Playwright config process+ // (node), not inside a workflow script.+ while (Date.now() - start < timeoutMs) {+ if (await isUp(url)) return+ await new Promise((r) => setTimeout(r, 2000))+ }+ throw new Error(`${name} not ready after ${timeoutMs}ms (${url})`)+}++export function resetDb(): void {+ const res = spawnSync("pnpm", ["run", "db:reset"], {+ cwd: REPO_ROOT,+ stdio: "inherit",+ })+ if (res.status !== 0) {+ throw new Error(`db:reset failed (exit ${res.status})`)+ }+}++function portOf(url: string): number | null {+ const p = Number(new URL(url).port)+ return Number.isFinite(p) && p > 0 ? p : null+}++// Best-effort: kill whatever is listening on the given TCP ports. Clears+// orphaned dev servers left by a prior run that crashed before teardown (e.g.+// global-setup failing after startServices). No-op on Windows / if lsof is+// absent. Only called when we're about to start fresh servers, never when+// reusing a healthy one.+function killPortOrphans(ports: number[]): void {+ if (process.platform === "win32") return+ for (const port of ports) {+ const res = spawnSync("lsof", ["-ti", `tcp:${port}`], { encoding: "utf8" })+ const pids = (res.stdout ?? "")+ .split("\n")+ .map((s) => Number(s.trim()))+ .filter((n) => Number.isInteger(n) && n > 0)+ for (const pid of pids) {+ try {+ process.kill(pid, "SIGTERM")+ } catch {+ // already gone+ }+ }+ }+}++function startService(name: string, filter: string, healthUrl: string): ManagedService {+ const proc = spawn("pnpm", ["--filter", filter, "dev"], {+ cwd: REPO_ROOT,+ stdio: "ignore",+ detached: true,+ })+ return { name, proc, healthUrl }+}++// Starts web (:3000) + ws-do (:8789). Realtime journeys REQUIRE ws-do, so a+// missing ws health check is a hard failure (fail fast), never a silent+// degrade. Returns started services (empty when reusing an existing server).+export async function startServices(): Promise<ManagedService[]> {+ const webHealth = `${WEB_URL}/api/health`+ const wsHealth = `${WS_URL}/health`++ if (REUSE_EXISTING && (await isUp(webHealth)) && (await isUp(wsHealth))) {+ return []+ }++ // Starting fresh — clear any orphaned dev servers on our ports first so a+ // prior crashed run doesn't leave 3000/8789 occupied (or get reused).+ const ports = [portOf(WEB_URL), portOf(WS_URL)].filter((p): p is number => p != null)+ killPortOrphans(ports)+ // Give the OS a moment to release the sockets before we bind them.+ await new Promise((r) => setTimeout(r, 1000))++ const services = [+ startService("web", "@alook/web", webHealth),+ startService("ws-do", "@alook/ws-do", wsHealth),+ ]++ await Promise.all(services.map((s) => waitForHealth(s.healthUrl, s.name)))+ return services+}diff --git a/src/web/src/test/e2e-ui/_setup/users.ts b/src/web/src/test/e2e-ui/_setup/users.tsnew file mode 100644index 000000000..81a84f63f--- /dev/null+++ b/src/web/src/test/e2e-ui/_setup/users.ts@@ -0,0 +1,24 @@+// The community journeys use up to three concurrent users. Each gets a fresh+// account seeded by the dev sign-in flow (email-only → DEV_PASSWORD auto+// signup). Emails are unique per run via a stamp injected at setup time so a+// re-run against a non-reset DB doesn't collide.+export type UserKey = "alice" | "bob" | "carol"++export const USER_KEYS: UserKey[] = ["alice", "bob", "carol"]++export function emailFor(key: UserKey, stamp: string): string {+ return `e2e-${key}-${stamp}@alook.test`+}++export interface SeededUser {+ key: UserKey+ email: string+ name: string+ userId: string+ storageState: string+}++export interface RunManifest {+ stamp: string+ users: Record<UserKey, SeededUser>+}diff --git a/tests/utils/src/community.ts b/tests/utils/src/community.tsindex 5c7e023e3..624899561 100644--- a/tests/utils/src/community.ts+++ b/tests/utils/src/community.ts@@ -132,3 +132,103 @@ export function cleanupPairedMachine(machine: PairedMachine, ownerUserId: stringsqlRun(`DELETE FROM community_machine_token WHERE user_id = ?`, ownerUserId)sqlRun(`DELETE FROM community_machine WHERE id = ?`, machine.machineId)}++// ── API-driven community precondition seeding ───────────────────────────────+// These drive the real HTTP routes (with a signed-in session cookie) so FK,+// permissions, default channels, and slugification all match production. Use+// them for journey *preconditions* — the operations themselves are exercised+// through the UI in the Playwright specs.++export interface SeededServer {+ serverId: string+}++export async function seedServerViaApi(cookie: string, opts: { name: string }): Promise<SeededServer> {+ const res = await sessionRequest("/api/community/servers", cookie, {+ method: "POST",+ headers: { "Content-Type": "application/json" },+ body: JSON.stringify({ name: opts.name }),+ })+ if (!res.ok) throw new Error(`seedServerViaApi failed (${res.status})`)+ const data = (await res.json()) as { server: { id: string } }+ return { serverId: data.server.id }+}++export interface SeededChannel {+ channelId: string+}++export async function seedChannelViaApi(+ cookie: string,+ opts: { serverId: string; name: string; type?: "text" | "forum"; categoryId?: string },+): Promise<SeededChannel> {+ const res = await sessionRequest(`/api/community/servers/${opts.serverId}/channels`, cookie, {+ method: "POST",+ headers: { "Content-Type": "application/json" },+ body: JSON.stringify({ name: opts.name, type: opts.type, categoryId: opts.categoryId }),+ })+ if (!res.ok) throw new Error(`seedChannelViaApi failed (${res.status})`)+ const data = (await res.json()) as { channel: { id: string } }+ return { channelId: data.channel.id }+}++export interface SeededDm {+ dmId: string+}++export async function seedDmViaApi(cookie: string, opts: { userId: string }): Promise<SeededDm> {+ const res = await sessionRequest("/api/community/dm", cookie, {+ method: "POST",+ headers: { "Content-Type": "application/json" },+ body: JSON.stringify({ userId: opts.userId }),+ })+ if (!res.ok) throw new Error(`seedDmViaApi failed (${res.status})`)+ const data = (await res.json()) as { conversation: { id: string } }+ return { dmId: data.conversation.id }+}++/**+ * Full friend handshake: requester sends, addressee accepts. `accept` is+ * addressee-only (403 otherwise), so both cookies are required. Returns the+ * friendship id.+ */+export async function seedFriendshipViaApi(+ cookieRequester: string,+ cookieAddressee: string,+ opts: { targetUserId: string },+): Promise<{ friendshipId: string }> {+ const reqRes = await sessionRequest("/api/community/friends/request", cookieRequester, {+ method: "POST",+ headers: { "Content-Type": "application/json" },+ body: JSON.stringify({ userId: opts.targetUserId }),+ })+ if (!reqRes.ok) throw new Error(`seedFriendshipViaApi request failed (${reqRes.status})`)+ const reqData = (await reqRes.json()) as { id?: string; friendship?: { id: string } | null }+ const friendshipId = reqData.id ?? reqData.friendship?.id+ if (!friendshipId) throw new Error("seedFriendshipViaApi: no friendship id in response")++ const acceptRes = await sessionRequest(`/api/community/friends/${friendshipId}/accept`, cookieAddressee, {+ method: "POST",+ })+ if (!acceptRes.ok) throw new Error(`seedFriendshipViaApi accept failed (${acceptRes.status})`)+ return { friendshipId }+}++export async function seedBlockViaApi(cookie: string, opts: { userId: string }): Promise<void> {+ const res = await sessionRequest(`/api/community/users/${opts.userId}/block`, cookie, {+ method: "POST",+ })+ if (!res.ok) throw new Error(`seedBlockViaApi failed (${res.status})`)+}++export async function addChannelMemberViaApi(+ cookie: string,+ opts: { channelId: string; userId: string },+): Promise<void> {+ const res = await sessionRequest(`/api/community/channels/${opts.channelId}/members`, cookie, {+ method: "POST",+ headers: { "Content-Type": "application/json" },+ body: JSON.stringify({ userId: opts.userId }),+ })+ if (!res.ok) throw new Error(`addChannelMemberViaApi failed (${res.status})`)+}diff --git a/tests/utils/src/index.ts b/tests/utils/src/index.tsindex 9185d6892..5c6ed0585 100644--- a/tests/utils/src/index.ts+++ b/tests/utils/src/index.ts@@ -17,6 +17,15 @@ export {seedCommunityBot,cleanupCommunityBot,cleanupPairedMachine,+ seedServerViaApi,+ seedChannelViaApi,+ seedDmViaApi,+ seedFriendshipViaApi,+ seedBlockViaApi,+ addChannelMemberViaApi,type PairedMachine,type SeededCommunityBot,+ type SeededServer,+ type SeededChannel,+ type SeededDm,} from "./community"