Skip to content

Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.

Go

test(e2e): guest smoke spec that fails on any refused request (MUL-9876) (#11212)

Jiayuan Zhang44989876f4a8
diff --git a/.github/ci-paths.json b/.github/ci-paths.json
index 6b094df4ec..befb381848 100644
--- a/.github/ci-paths.json
+++ b/.github/ci-paths.json
@@ -182,5 +182,23 @@
".github/ci-paths.json",
"scripts/ci-scope.mjs",
"scripts/ci-scope.test.mjs"
+ ],
+ "e2e": [
+ "e2e/**",
+ "playwright.config.ts",
+ "scripts/dev-fixtures.mjs",
+ "apps/web/**",
+ "packages/**",
+ "server/**",
+ "package.json",
+ ".npmrc",
+ "pnpm-lock.yaml",
+ "pnpm-workspace.yaml",
+ "patches/**",
+ "turbo.json",
+ ".github/workflows/ci.yml",
+ ".github/ci-paths.json",
+ "scripts/ci-scope.mjs",
+ "scripts/ci-scope.test.mjs"
]
}
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index d5ddbdee23..3d3ba53e8c 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -37,6 +37,7 @@ jobs:
scripts: ${{ steps.decide.outputs.scripts }}
installer: ${{ steps.decide.outputs.installer }}
images: ${{ steps.decide.outputs.images }}
+ e2e: ${{ steps.decide.outputs.e2e }}
full: ${{ steps.decide.outputs.full }}
steps:
- name: Checkout
@@ -292,9 +293,117 @@ jobs:
- name: Test docs
run: pnpm --filter @multica/docs test
+ # Playwright against a real API and a production web build. Only the guest
+ # spec runs here so far: a guest passes an API allowlist that no member-side
+ # test exercises, so a member component reused on a guest page can fail with
+ # 403 unnoticed (MUL-9873). The rest of e2e/ runs locally through `make check`.
+ # The web app is served the way scripts/web-prod.mjs serves it: same-origin,
+ # with `next start` proxying /api and /ws to the API.
+ e2e:
+ needs: changes
+ if: ${{ needs.changes.outputs.e2e == 'true' }}
+ # Playwright 1.58 installs Chromium only up to Ubuntu 24.04; ubuntu-latest
+ # is past that.
+ runs-on: ubuntu-24.04
+ timeout-minutes: 25
+ services:
+ postgres:
+ image: pgvector/pgvector:pg17
+ env:
+ POSTGRES_DB: multica
+ POSTGRES_USER: multica
+ POSTGRES_PASSWORD: multica
+ ports:
+ - 5432:5432
+ options: >-
+ --health-cmd "pg_isready -U multica -d multica"
+ --health-interval 5s
+ --health-timeout 5s
+ --health-retries 20
+ env:
+ DATABASE_URL: postgres://multica:multica@localhost:5432/multica?sslmode=disable
+ PORT: "8080"
+ FRONTEND_PORT: "3000"
+ FRONTEND_ORIGIN: http://localhost:3000
+ MULTICA_APP_URL: http://localhost:3000
+ PLAYWRIGHT_BASE_URL: http://localhost:3000
+ NEXT_TELEMETRY_DISABLED: "1"
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v6
+
+ - name: Setup Go
+ uses: actions/setup-go@v5
+ with:
+ go-version: "~1.27.4"
+ check-latest: true
+ cache: false
+
+ # Restore only: backend-tests owns publishing this entry.
+ - name: Restore Go module cache
+ uses: actions/cache/restore@v6
+ with:
+ path: ~/go/pkg/mod
+ key: go-mod-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('server/go.sum') }}
+
+ - name: Setup pnpm
+ uses: pnpm/action-setup@v4
+
+ - name: Setup Node.js
+ uses: actions/setup-node@v6
+ with:
+ node-version: 22
+ cache: pnpm
+
+ - name: Install dependencies
+ run: pnpm install --frozen-lockfile
+
+ - name: Install Chromium
+ run: pnpm exec playwright install --with-deps chromium
+
+ - name: Build and migrate the API
+ working-directory: server
+ run: |
+ go build -o bin/server ./cmd/server
+ go run ./cmd/migrate up
+
+ # REMOTE_API_URL is a runtime setting; at build time it breaks prerendering.
+ - name: Build the web app
+ env:
+ NEXT_PUBLIC_API_URL: ""
+ NEXT_PUBLIC_WS_URL: ""
+ REMOTE_API_URL: ""
+ run: pnpm --filter @multica/web build
+
+ - name: Start the API and the web app
+ run: |
+ (cd server && nohup ./bin/server > "$RUNNER_TEMP/api.log" 2>&1 &)
+ (cd apps/web && PORT=3000 REMOTE_API_URL=http://localhost:8080 nohup node_modules/.bin/next start --port 3000 > "$RUNNER_TEMP/web.log" 2>&1 &)
+ for url in http://localhost:8080/health http://localhost:3000/; do
+ for _ in $(seq 1 60); do
+ curl -sf -o /dev/null "$url" && break
+ sleep 1
+ done
+ curl -sf -o /dev/null "$url" || { echo "$url did not answer within 60s"; exit 1; }
+ done
+
+ - name: Run the guest spec
+ run: pnpm exec playwright test e2e/guest.spec.ts
+
+ - name: Upload logs and Playwright results
+ if: ${{ failure() }}
+ uses: actions/upload-artifact@v4
+ with:
+ name: e2e-results
+ path: |
+ test-results/
+ ${{ runner.temp }}/api.log
+ ${{ runner.temp }}/web.log
+ if-no-files-found: ignore
+
# Preserve the aggregate check names while validating intentional skips.
frontend:
- needs: [changes, frontend-build, frontend-test, frontend-views-test, frontend-quality, docs-test]
+ needs: [changes, frontend-build, frontend-test, frontend-views-test, frontend-quality, docs-test, e2e]
if: ${{ !cancelled() }}
runs-on: ubuntu-latest
steps:
@@ -302,7 +411,7 @@ jobs:
- name: Check frontend job results
env:
NEEDS_JSON: ${{ toJSON(needs) }}
- JOB_SCOPES: '{"frontend-build":"frontend","frontend-test":"frontend","frontend-views-test":"frontend","frontend-quality":"quality_only","docs-test":"docs"}'
+ JOB_SCOPES: '{"frontend-build":"frontend","frontend-test":"frontend","frontend-views-test":"frontend","frontend-quality":"quality_only","docs-test":"docs","e2e":"e2e"}'
run: node scripts/ci-scope.mjs gate
# The Go caches are handled explicitly here rather than through setup-go's
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 958943caca..4b735836c9 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -779,16 +779,20 @@ it again adds new issues and notifications and reuses the agents, projects and
views.
`guest` is for checking a change as a guest. It signs `guest@localhost` in
-with the dev verification code, invites it as a guest of the Client portal
-project and accepts, so the guest sees that project and nothing else; the
-Internal planning project and its issue stay hidden from it. In Client portal,
-`dev@localhost` mentions the guest on one issue, replies to the guest's comment
-on its sub-issue and assigns it a third, which leaves three unread issues in
-the guest's Inbox. `--json` prints `guest_token` and `guest_user_id` with the
-project and issue URLs; set the token as `multica_token` to open the app as the
-guest. The token is kept in the environment's profile directory, so running it
-again signs in only when that token stopped working, keeps the membership and
-adds new issues and notifications. `all` leaves `guest` out.
+with the dev verification code, invites it as a guest of three projects and
+accepts: Client portal (visible to the workspace), Client contracts (private)
+and Client portal v1 (archived), each with an issue. The guest sees those and
+nothing else; the Internal planning project and its issue stay hidden from it.
+In Client portal, `dev@localhost` mentions the guest on one issue, replies to
+the guest's comment on its sub-issue and assigns it a third, which leaves three
+unread issues in the guest's Inbox. `--json` prints `guest_token` and
+`guest_user_id` with the project and issue URLs; set the token as
+`multica_token` to open the app as the guest. The token is kept in the
+environment's profile directory, so running it again signs in only when that
+token stopped working, keeps the membership and adds new issues and
+notifications. `--guest-email` signs in someone else as the guest, which is
+how `e2e/guest.spec.ts` gets a fresh guest on every run. `all` leaves `guest`
+out.
`task` is for UI and CLI work that needs an agent mid-run: agent status,
the issue's execution log, Working / Idle filters, task panels. It assigns a new
diff --git a/e2e/fixtures.ts b/e2e/fixtures.ts
index 326677a1e1..1c0981d651 100644
--- a/e2e/fixtures.ts
+++ b/e2e/fixtures.ts
@@ -10,7 +10,7 @@ import pg from "pg";
// `||` (not `??`) so an empty `NEXT_PUBLIC_API_URL=` in .env still falls
// back to localhost. dotenv sets unset-vs-empty both as "" — treating them
// the same matches user intent.
-const API_BASE = process.env.NEXT_PUBLIC_API_URL || `http://localhost:${process.env.PORT || "8080"}`;
+export const API_BASE = process.env.NEXT_PUBLIC_API_URL || `http://localhost:${process.env.PORT || "8080"}`;
const DATABASE_URL = process.env.DATABASE_URL ?? "postgres://multica:multica@localhost:5432/multica?sslmode=disable";
interface TestWorkspace {
diff --git a/e2e/guest.spec.ts b/e2e/guest.spec.ts
new file mode 100644
index 0000000000..63298585dc
--- /dev/null
+++ b/e2e/guest.spec.ts
@@ -0,0 +1,232 @@
+import { execFileSync } from "node:child_process";
+import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
+import { tmpdir } from "node:os";
+import { join, resolve } from "node:path";
+import { expect, test, type Page } from "@playwright/test";
+import { API_BASE, TestApiClient } from "./fixtures";
+
+// Guests are deny-by-default: the API answers a guest only on the routes
+// allowlisted in server/internal/middleware/guest.go, while guest pages reuse
+// member components. A member component that starts reading a route the list
+// lacks fails with 403 for a guest only, which no member-side test notices
+// (MUL-9873). This walks every page a guest can reach and fails on any 4xx
+// response or page error, and on member write actions showing up.
+
+const RUN = `${process.env.TEST_WORKER_INDEX ?? "0"}-${process.env.E2E_RUN_ID ?? `${Date.now().toString(36)}-${process.pid.toString(36)}`}`;
+
+type ProjectKey = "shared" | "private" | "archived" | "internal";
+type IssueKey = "review" | "form" | "export" | "contract" | "migration" | "pricing";
+
+interface GuestFixture {
+ guest_token: string;
+ projects: Record<ProjectKey, { id: string; title: string }>;
+ issues: Record<IssueKey, { id: string; identifier: string; title: string }>;
+}
+
+let fixture: GuestFixture;
+let slug: string;
+let owner: TestApiClient;
+
+// `scripts/dev-fixtures.mjs guest` builds the scenario, run against a
+// workspace of its own so the guest and its projects stay out of other specs.
+// The fixture reads an environment profile; this one holds the owner's token
+// and the guest's, signed in here so no fixed verification code is needed.
+test.beforeAll(async ({}, testInfo) => {
+ owner = new TestApiClient();
+ await owner.login(`e2e-guest-owner-${RUN}@multica.ai`, "E2E Guest Owner");
+ const workspace = await owner.ensureWorkspace(`E2E Guest ${RUN}`, `e2e-guest-${RUN}`);
+ await owner.markUserOnboarded();
+ slug = workspace.slug;
+
+ const guestEmail = `e2e-guest-${RUN}@multica.ai`;
+ const guest = new TestApiClient();
+ await guest.login(guestEmail, "E2E Guest");
+
+ const profiles = mkdtempSync(join(tmpdir(), "multica-e2e-guest-"));
+ try {
+ const profile = join(profiles, "e2e-guest");
+ mkdirSync(profile);
+ writeFileSync(
+ join(profile, "config.json"),
+ JSON.stringify({
+ token: owner.getToken(),
+ workspace_id: workspace.id,
+ server_url: API_BASE,
+ app_url: testInfo.project.use.baseURL,
+ }),
+ );
+ writeFileSync(join(profile, "guest.json"), JSON.stringify({ email: guestEmail, token: guest.getToken() }));
+ // Without PORT and FRONTEND_PORT the fixture takes both URLs from the profile.
+ const { PORT: _port, FRONTEND_PORT: _frontendPort, ...env } = process.env;
+ const output = execFileSync(
+ process.execPath,
+ [resolve("scripts/dev-fixtures.mjs"), "guest", "--json", "--guest-email", guestEmail],
+ { env: { ...env, MULTICA_DEV_PROFILES_HOME: profiles, MULTICA_DEV_PROFILE: "e2e-guest" }, encoding: "utf8" },
+ );
+ fixture = JSON.parse(output).guest;
+ } finally {
+ rmSync(profiles, { recursive: true, force: true });
+ }
+});
+
+test.afterAll(async () => {
+ await owner?.deleteWorkspace();
+});
+
+interface PageWatch {
+ problems: string[];
+ settled: () => Promise<void>;
+}
+
+/**
+ * Records every 4xx/5xx response and page error from here on. `notFound`
+ * lists URL fragments whose 404 is the expected answer.
+ */
+function watch(page: Page, { notFound = [] as string[] } = {}): PageWatch {
+ const problems: string[] = [];
+ let inFlight = 0;
+ let lastActivity = Date.now();
+ const isApi = (url: string) => url.startsWith(API_BASE) || new URL(url).pathname.startsWith("/api/");
+ page.on("request", (request) => {
+ if (!isApi(request.url())) return;
+ inFlight++;
+ lastActivity = Date.now();
+ });
+ const finished = (request: { url(): string }) => {
+ if (!isApi(request.url())) return;
+ inFlight--;
+ lastActivity = Date.now();
+ };
+ page.on("requestfinished", finished);
+ page.on("requestfailed", finished);
+ page.on("response", (response) => {
+ if (response.status() < 400) return;
+ // The server shedding load ("busy, retry shortly"); the client retries.
+ if (response.status() === 503 && response.headers()["retry-after"]) return;
+ const url = response.url();
+ if (response.status() === 404 && notFound.some((fragment) => url.includes(fragment))) return;
+ problems.push(`${response.status()} ${response.request().method()} ${url}`);
+ });
+ page.on("pageerror", (error) => problems.push(`page error: ${error.message}`));
+
+ // Done once the page has made no API request for a second: a component
+ // that mounts late still gets its requests answered before the check.
+ const settled = () =>
+ expect
+ .poll(() => inFlight <= 0 && Date.now() - lastActivity > 1000, { timeout: 20_000, intervals: [100] })
+ .toBe(true);
+ return { problems, settled };
+}
+
+async function openAsGuest(page: Page, path: string, options?: { notFound?: string[] }) {
+ await page.addInitScript((token) => {
+ localStorage.setItem("multica_token", token);
+ localStorage.setItem("multica:chat:isOpen", "false");
+ }, fixture.guest_token);
+ const seen = watch(page, options);
+ await page.goto(path, { waitUntil: "domcontentloaded" });
+ return seen;
+}
+
+async function expectClean(seen: PageWatch) {
+ await seen.settled();
+ expect(seen.problems, "requests the guest was refused, and page errors").toEqual([]);
+}
+
+const PROJECT_ACTIONS = /(rename|archive|restore|delete) project/i;
+
+/**
+ * Write actions only a member has: creating issues and managing projects,
+ * including the archived-project banner's "Restore". Run after the page has
+ * settled, since `toHaveCount(0)` passes before late content mounts.
+ */
+async function expectNoMemberActions(page: Page) {
+ await expect(page.getByRole("button", { name: /new issue|add issue|create issue/i })).toHaveCount(0);
+ await expect(page.getByRole("button", { name: /^restore$/i })).toHaveCount(0);
+ await expect(page.getByRole("button", { name: PROJECT_ACTIONS })).toHaveCount(0);
+}
+
+/** The project title menu holds the project actions; they exist only while it is open. */
+async function expectGuestProjectMenu(page: Page, seen: PageWatch, title: string) {
+ await page.getByRole("heading", { level: 1 }).getByRole("button", { name: title }).click();
+ const menu = page.getByRole("menu");
+ await expect(menu.getByRole("menuitem", { name: "Copy link", exact: true })).toBeVisible();
+ await expect(menu.getByRole("menuitem", { name: PROJECT_ACTIONS })).toHaveCount(0);
+ await page.keyboard.press("Escape");
+ await expect(menu).toHaveCount(0);
+ await expectClean(seen);
+}
+
+test.describe("as a guest", () => {
+ test("Inbox and the Work panel show only what is shared", async ({ page }) => {
+ const seen = await openAsGuest(page, `/${slug}/inbox`);
+ const shared = page.getByRole("region", { name: "Shared with you" });
+ await expect(shared).toBeVisible({ timeout: 30_000 });
+ await expect(shared.getByText(fixture.projects.shared.title, { exact: true })).toBeVisible();
+ await expect(shared.getByText(fixture.projects.private.title, { exact: true })).toBeVisible();
+ await expect(page.getByText(fixture.projects.internal.title)).toHaveCount(0);
+ const inbox = page.getByRole("region", { name: "Inbox" });
+ for (const key of ["review", "form", "export"] as const) {
+ await expect(inbox.getByText(fixture.issues[key].title, { exact: true })).toBeVisible();
+ }
+ await expect(page.getByText(fixture.issues.pricing.title)).toHaveCount(0);
+ await expectClean(seen);
+ await expectNoMemberActions(page);
+
+ await inbox.getByText(fixture.issues.review.title, { exact: true }).click();
+ await expect(page.getByText("Guests can view and comment, but cannot change issue properties.")).toBeVisible();
+ await expectClean(seen);
+ await expectNoMemberActions(page);
+
+ await page.getByRole("link", { name: "Involved", exact: true }).click();
+ await expect(page.getByText(fixture.issues.export.title).first()).toBeVisible();
+ await expectClean(seen);
+ await expectNoMemberActions(page);
+ });
+
+ for (const [key, kind] of [["shared", "workspace-visible"], ["private", "private"], ["archived", "archived"]] as const) {
+ test(`a shared ${kind} project opens on every tab`, async ({ page }) => {
+ const project = fixture.projects[key];
+ const seen = await openAsGuest(page, `/${slug}/projects/${project.id}?tab=overview`);
+ await expect(page.getByText(project.title).first()).toBeVisible({ timeout: 30_000 });
+ await expect(page.getByText("Guests can view this project, but cannot change its properties.")).toBeVisible();
+ if (key === "archived") await expect(page.getByText("This project is archived.")).toBeVisible();
+ await expectClean(seen);
+ await expectNoMemberActions(page);
+ await expectGuestProjectMenu(page, seen, project.title);
+
+ for (const tab of ["Issues", "Activity", "Overview"]) {
+ await page.getByRole("tab", { name: new RegExp(`^${tab}`) }).click();
+ await expect(page).toHaveURL(new RegExp(`tab=${tab.toLowerCase()}`));
+ await expectClean(seen);
+ await expectNoMemberActions(page);
+ await expectGuestProjectMenu(page, seen, project.title);
+ }
+ });
+ }
+
+ for (const [key, kind] of [["review", "workspace-visible"], ["contract", "private"], ["migration", "archived"]] as const) {
+ test(`an issue in the shared ${kind} project opens`, async ({ page }) => {
+ const issue = fixture.issues[key];
+ const seen = await openAsGuest(page, `/${slug}/issues/${issue.identifier}`);
+ await expect(page.getByText(issue.title).first()).toBeVisible({ timeout: 30_000 });
+ await expect(page.getByText("Guests can view and comment, but cannot change issue properties.")).toBeVisible();
+ await expectClean(seen);
+ await expectNoMemberActions(page);
+ });
+ }
+
+ test("a project that is not shared is not found", async ({ page }) => {
+ const { id } = fixture.projects.internal;
+ const seen = await openAsGuest(page, `/${slug}/projects/${id}`, { notFound: [id] });
+ await expect(page.getByText("Project not found")).toBeVisible({ timeout: 30_000 });
+ await expectClean(seen);
+ });
+
+ test("an issue that is not shared is not found", async ({ page }) => {
+ const { id, identifier } = fixture.issues.pricing;
+ const seen = await openAsGuest(page, `/${slug}/issues/${identifier}`, { notFound: [id, identifier] });
+ await expect(page.getByText("Issue not found")).toBeVisible({ timeout: 30_000 });
+ await expectClean(seen);
+ });
+});
diff --git a/scripts/ci-scope.test.mjs b/scripts/ci-scope.test.mjs
index 077de60918..d10e3a9e3b 100644
--- a/scripts/ci-scope.test.mjs
+++ b/scripts/ci-scope.test.mjs
@@ -22,22 +22,22 @@ for (const [name, files, selected] of [
["release creation", [".goreleaser.yml"], ["scripts"]],
["docs only", ["apps/docs/content/docs/guide.mdx"], ["quality", "docs"]],
["docs test", ["apps/docs/lib/unrendered-bold.test.ts"], ["quality", "docs"]],
- ["AI traffic classifier", ["packages/core/ai-traffic/index.ts"], ["frontend", "quality", "docs"]],
+ ["AI traffic classifier", ["packages/core/ai-traffic/index.ts"], ["frontend", "quality", "docs", "e2e"]],
["self-hosting guide for agents", ["SELF_HOSTING_AI.md"], ["docs"]],
- ["web changelog", ["apps/web/features/landing/i18n/en.ts"], ["frontend", "quality"]],
+ ["web changelog", ["apps/web/features/landing/i18n/en.ts"], ["frontend", "quality", "e2e"]],
["mobile UI", ["apps/mobile/app/index.tsx"], ["quality"]],
["collaboration service", ["apps/collab/src/documents.ts"], ["frontend", "quality"]],
- ["migration only", ["server/migrations/999_example.up.sql"], ["backend", "sqlc"]],
- ["agent process code", ["server/pkg/agent/cursor_background.go"], ["backend", "runtime"]],
- ["runtime env variables", ["server/internal/daemon/agents_probe.go"], ["backend", "runtime", "docs"]],
- ["built-in runtime registry", ["server/pkg/agent/builtin_runtimes.go"], ["backend", "runtime", "docs"]],
- ["daemon config", ["server/internal/daemon/config.go"], ["backend", "runtime", "docs"]],
- ["feature flag keys", ["server/internal/featureflags/keys.go"], ["backend", "runtime", "docs"]],
- ["daemon dependency", ["server/internal/skill/service.go"], ["backend", "runtime"]],
- ["process-group control", ["server/internal/daemon/processtree/controller_unix.go"], ["backend", "runtime", "processtree"]],
- ["process-group caller", ["server/internal/daemon/gc.go"], ["backend", "runtime"]],
- ["native test compilation dependency", ["server/pkg/db/generated/issues.sql.go"], ["backend", "sqlc", "runtime"]],
- ["Go dependencies", ["server/go.mod", "server/go.sum"], ["backend", "runtime"]],
+ ["migration only", ["server/migrations/999_example.up.sql"], ["backend", "sqlc", "e2e"]],
+ ["agent process code", ["server/pkg/agent/cursor_background.go"], ["backend", "runtime", "e2e"]],
+ ["runtime env variables", ["server/internal/daemon/agents_probe.go"], ["backend", "runtime", "docs", "e2e"]],
+ ["built-in runtime registry", ["server/pkg/agent/builtin_runtimes.go"], ["backend", "runtime", "docs", "e2e"]],
+ ["daemon config", ["server/internal/daemon/config.go"], ["backend", "runtime", "docs", "e2e"]],
+ ["feature flag keys", ["server/internal/featureflags/keys.go"], ["backend", "runtime", "docs", "e2e"]],
+ ["daemon dependency", ["server/internal/skill/service.go"], ["backend", "runtime", "e2e"]],
+ ["process-group control", ["server/internal/daemon/processtree/controller_unix.go"], ["backend", "runtime", "processtree", "e2e"]],
+ ["process-group caller", ["server/internal/daemon/gc.go"], ["backend", "runtime", "e2e"]],
+ ["native test compilation dependency", ["server/pkg/db/generated/issues.sql.go"], ["backend", "sqlc", "runtime", "e2e"]],
+ ["Go dependencies", ["server/go.mod", "server/go.sum"], ["backend", "runtime", "e2e"]],
["Helm only", ["deploy/helm/multica/templates/deployment.yaml"], ["scripts"]],
["container entrypoint", ["docker/entrypoint.sh"], ["scripts"]],
["selfhost config", [".env.example"], ["backend", "scripts", "installer"]],
@@ -49,28 +49,31 @@ for (const [name, files, selected] of [
["cleanup script", ["scripts/drop-database.sh"], ["scripts"]],
["check script regression tests", ["scripts/check.test.sh"], ["scripts"]],
["performance harness", ["scripts/perf-compare.test.sh"], ["scripts"]],
- ["attachment preview source", ["server/internal/handler/attachment_text_preview.json"], ["backend", "runtime", "scripts"]],
- ["attachment preview output", ["packages/views/editor/utils/text-preview-whitelist.generated.ts"], ["frontend", "quality", "scripts"]],
- ["reserved slug source", ["server/internal/handler/reserved_slugs.json"], ["backend", "runtime", "scripts"]],
- ["reserved slug output", ["packages/core/paths/reserved-slugs.ts"], ["frontend", "quality", "scripts"]],
- ["integration key gates", ["server/cmd/server/router.go"], ["backend", "runtime", "scripts"]],
- ["brand source", ["packages/ui/lib/multica-brand.ts"], ["frontend", "quality"]],
- ["CLI brand copy", ["server/cmd/multica/cmd_auth.go"], ["backend", "runtime", "quality"]],
+ ["attachment preview source", ["server/internal/handler/attachment_text_preview.json"], ["backend", "runtime", "scripts", "e2e"]],
+ ["attachment preview output", ["packages/views/editor/utils/text-preview-whitelist.generated.ts"], ["frontend", "quality", "scripts", "e2e"]],
+ ["reserved slug source", ["server/internal/handler/reserved_slugs.json"], ["backend", "runtime", "scripts", "e2e"]],
+ ["reserved slug output", ["packages/core/paths/reserved-slugs.ts"], ["frontend", "quality", "scripts", "e2e"]],
+ ["integration key gates", ["server/cmd/server/router.go"], ["backend", "runtime", "scripts", "e2e"]],
+ ["brand source", ["packages/ui/lib/multica-brand.ts"], ["frontend", "quality", "e2e"]],
+ ["CLI brand copy", ["server/cmd/multica/cmd_auth.go"], ["backend", "runtime", "quality", "e2e"]],
["mobile brand copy", ["apps/mobile/components/brand/multica-logo.tsx"], ["quality"]],
["README logo", ["docs/assets/logo-dark.svg"], ["quality"]],
["brand generator", ["scripts/brand/sync.mjs"], ["quality"]],
["PR evidence uploader", ["scripts/pr-shots"], ["quality"]],
- ["cross-module runtime contract", ["packages/core/runtimes/cli-version.ts"], ["frontend", "backend", "runtime", "quality"]],
- ["inbox type contract", ["packages/core/types/inbox.ts"], ["frontend", "backend", "quality"]],
- ["shared quick action body contract", ["server/internal/handler/testdata/quick_action_bodies.json"], ["frontend", "backend", "runtime"]],
- ["lockfile", ["pnpm-lock.yaml"], ["frontend", "quality", "docs"]],
- ["workspace catalog", ["pnpm-workspace.yaml"], ["frontend", "quality", "docs"]],
- ["workspace package patch", ["patches/example.patch"], ["frontend", "quality", "docs"]],
+ ["cross-module runtime contract", ["packages/core/runtimes/cli-version.ts"], ["frontend", "backend", "runtime", "quality", "e2e"]],
+ ["inbox type contract", ["packages/core/types/inbox.ts"], ["frontend", "backend", "quality", "e2e"]],
+ ["shared quick action body contract", ["server/internal/handler/testdata/quick_action_bodies.json"], ["frontend", "backend", "runtime", "e2e"]],
+ ["lockfile", ["pnpm-lock.yaml"], ["frontend", "quality", "docs", "e2e"]],
+ ["workspace catalog", ["pnpm-workspace.yaml"], ["frontend", "quality", "docs", "e2e"]],
+ ["workspace package patch", ["patches/example.patch"], ["frontend", "quality", "docs", "e2e"]],
["mobile package patch", ["apps/mobile/patches/example.patch"], ["quality"]],
["radius policy", ["scripts/check-ui-radius-tokens.mjs"], ["quality"]],
["shared quality action", [".github/actions/frontend-quality/action.yml"], ["frontend", "quality"]],
- ["new bitmap", ["apps/web/public/hero.png"], ["frontend", "quality", "images"]],
- ["mixed docs and migration", ["apps/docs/content/guide.mdx", "server/migrations/999_example.up.sql"], ["quality", "docs", "backend", "sqlc"]],
+ ["new bitmap", ["apps/web/public/hero.png"], ["frontend", "quality", "images", "e2e"]],
+ ["mixed docs and migration", ["apps/docs/content/guide.mdx", "server/migrations/999_example.up.sql"], ["quality", "docs", "backend", "sqlc", "e2e"]],
+ ["E2E spec", ["e2e/guest.spec.ts"], ["e2e"]],
+ ["Playwright config", ["playwright.config.ts"], ["e2e"]],
+ ["dev fixtures", ["scripts/dev-fixtures.mjs"], ["quality", "e2e"]],
["CI configuration", [".github/ci-paths.json"], Object.keys(filters)],
]) {
test(`PR and main select only affected scopes: ${name}`, () => {
diff --git a/scripts/dev-fixtures.mjs b/scripts/dev-fixtures.mjs
index 1b027c8bb8..e5809331f0 100644
--- a/scripts/dev-fixtures.mjs
+++ b/scripts/dev-fixtures.mjs
@@ -38,7 +38,7 @@ const FIXTURE_WORKER_NAME = "Fixture Worker";
const HEARTBEAT_INTERVAL_MS = 15_000;
const USAGE = `Usage: node scripts/dev-fixtures.mjs <all | chat | builder | issue | task | sidebar | guest | app-request | app-resume>...
- [--queued] [--hold] [--app SLUG] [--member] [--json]
+ [--queued] [--hold] [--app SLUG] [--member] [--guest-email EMAIL] [--json]
chat a chat session: a user message and an assistant reply with a table, code and a long log line
builder an Agent Builder session with the same kind of reply and a filled-in draft
@@ -46,8 +46,9 @@ const USAGE = `Usage: node scripts/dev-fixtures.mjs <all | chat | builder | issu
task an issue assigned to the Fixture Worker agent whose task stays running, with an execution log
sidebar a Work panel in use: 11 issues in 3 projects, read and unread notifications from 3 agents,
pinned issues and a pinned project, and 2 saved views
- guest guest@localhost as a guest of a shared project, with an issue, a sub-issue, an assigned
- issue and unread notifications; a second project stays hidden from it. Prints the guest's token
+ guest guest@localhost as a guest of three shared projects (workspace-visible, private and
+ archived), with an issue, a sub-issue, an assigned issue and unread notifications; a fourth
+ project stays hidden from it. Prints the guest's token
all chat, builder, issue and task
app-request an issue assigned to the Fixture Agent whose run asks for an app account through
apps_request_connection, then ends its turn; needs \`node scripts/fake-composio.mjs up\`
@@ -58,6 +59,8 @@ const USAGE = `Usage: node scripts/dev-fixtures.mjs <all | chat | builder | issu
--app app-request: the app slug to ask for (default googlecalendar)
--member app-request: start the run as Alice (alice@localhost), a plain member of the workspace;
--json adds her member_token for signing a browser in as her
+ --guest-email guest: the guest's email (default guest@localhost); a new one gets a fresh user,
+ clear of the per-recipient invitation limit
--json print the created ids and URLs as JSON instead of text; task adds task_id, auth_token and agent_id,
guest adds guest_token and guest_user_id
@@ -82,6 +85,7 @@ function parseCli(argv) {
let hold = false;
let app;
let member = false;
+ let guestEmail;
for (let i = 0; i < argv.length; i++) {
const arg = argv[i];
if (arg === "-h" || arg === "--help") {
@@ -94,6 +98,9 @@ function parseCli(argv) {
else if (arg === "--app") {
app = argv[++i];
if (!app) fail(`--app needs an app slug.\n\n${USAGE}`);
+ } else if (arg === "--guest-email") {
+ guestEmail = argv[++i];
+ if (!guestEmail?.includes("@")) fail(`--guest-email needs an email address.\n\n${USAGE}`);
} else if (arg === "all") ALL_KINDS.forEach((kind) => kinds.add(kind));
else if (KINDS.includes(arg)) kinds.add(arg);
else fail(`unknown argument ${arg}\n\n${USAGE}`);
@@ -101,7 +108,16 @@ function parseCli(argv) {
if (kinds.size === 0) fail(`name at least one fixture.\n\n${USAGE}`);
if ((queued || hold) && !kinds.has("task")) fail(`--queued and --hold apply to the task fixture.\n\n${USAGE}`);
if ((app || member) && !kinds.has("app-request")) fail(`--app and --member apply to the app-request fixture.\n\n${USAGE}`);
- return { kinds: KINDS.filter((kind) => kinds.has(kind)), json, queued, hold, app: app ?? "googlecalendar", member };
+ if (guestEmail && !kinds.has("guest")) fail(`--guest-email applies to the guest fixture.\n\n${USAGE}`);
+ return {
+ kinds: KINDS.filter((kind) => kinds.has(kind)),
+ json,
+ queued,
+ hold,
+ app: app ?? "googlecalendar",
+ member,
+ guestEmail: guestEmail?.toLowerCase() ?? GUEST_EMAIL,
+ };
}
function loadProfile(env) {
@@ -437,7 +453,8 @@ const SIDEBAR_SCRIPTS = [
];
// The guest fixture's cast. The guest signs in with the dev verification code
-// like dev@localhost, and is a guest of the shared project only.
+// like dev@localhost, and is a guest of the shared projects only: one visible
+// to the workspace, one private and one archived.
const GUEST_EMAIL = "guest@localhost";
const GUEST_NAME = "Gina Guest";
const GUEST_CAPABILITIES = { "X-Client-Capabilities": "workspace-guests-v1" };
@@ -445,15 +462,33 @@ const GUEST_CAPABILITIES = { "X-Client-Capabilities": "workspace-guests-v1" };
const GUEST_PROJECTS = {
shared: {
title: "Client portal",
- description: "Shared with guest@localhost by scripts/dev-fixtures.mjs.",
+ description: "Shared with the guest by scripts/dev-fixtures.mjs.",
status: "in_progress",
priority: "high",
+ sharedWithGuest: true,
+ },
+ private: {
+ title: "Client contracts",
+ description: "A private project shared with the guest by scripts/dev-fixtures.mjs.",
+ status: "in_progress",
+ priority: "medium",
+ visibility: "private",
+ sharedWithGuest: true,
+ },
+ archived: {
+ title: "Client portal v1",
+ description: "An archived project shared with the guest by scripts/dev-fixtures.mjs.",
+ status: "completed",
+ priority: "low",
+ sharedWithGuest: true,
+ archived: true,
},
internal: {
title: "Internal planning",
- description: "Not shared with guest@localhost; the guest must not see it or its issues.",
+ description: "Not shared with the guest; the guest must not see it or its issues.",
status: "planned",
priority: "medium",
+ sharedWithGuest: false,
},
};
@@ -479,6 +514,20 @@ const GUEST_ISSUES = {
status: "todo",
priority: "medium",
},
+ contract: {
+ project: "private",
+ title: "Countersign the support contract",
+ description: "The client signed the renewed support contract; it needs our countersignature.",
+ status: "in_review",
+ priority: "medium",
+ },
+ migration: {
+ project: "archived",
+ title: "Move v1 clients to the new portal",
+ description: "Every v1 client now signs in through the new portal.",
+ status: "done",
+ priority: "low",
+ },
pricing: {
project: "internal",
title: "Decide renewal pricing for the client",
@@ -921,40 +970,52 @@ function createSidebarIssue(request, spec, projects, agent) {
// send-code is rate-limited to 5 a minute, so the guest's token is kept in the
// environment's profile directory and a rerun signs in again only when that
// token no longer works. `make destroy` removes it with the profile.
-async function guestSession(profile) {
+async function guestSession(profile, email) {
const file = join(profile.dir, "guest.json");
try {
const { token } = JSON.parse(readFileSync(file, "utf8"));
const me = await client({ ...profile, token })("GET", "/api/me");
- if (me?.email === GUEST_EMAIL) return { token, user: me };
+ if (me?.email === email) return { token, user: me };
} catch {
// No saved token, or it stopped working: sign in below.
}
const anonymous = client({ ...profile, token: "" });
- await anonymous("POST", "/auth/send-code", { email: GUEST_EMAIL });
- const verified = await anonymous("POST", "/auth/verify-code", { email: GUEST_EMAIL, code: devCode() });
+ await anonymous("POST", "/auth/send-code", { email });
+ const verified = await anonymous("POST", "/auth/verify-code", { email, code: devCode() });
const created = await client({ ...profile, token: verified.token })("POST", "/api/tokens", {
name: "dev-fixtures guest",
expires_in_days: 365,
});
const asGuest = client({ ...profile, token: created.token });
const user = await asGuest("PATCH", "/api/me", { name: GUEST_NAME });
- writeFileSync(file, `${JSON.stringify({ email: GUEST_EMAIL, token: created.token }, null, 2)}\n`, { mode: 0o600 });
+ writeFileSync(file, `${JSON.stringify({ email, token: created.token }, null, 2)}\n`, { mode: 0o600 });
return { token: created.token, user };
}
-// Invites the guest to the shared project and accepts as the guest, the way
+// An archived project takes no new issues, so one an earlier run archived is
+// restored here and archived again once this run's issues are in.
+async function ensureGuestProject(request, existing, { sharedWithGuest: _shared, archived, ...project }) {
+ const found = existing.find((p) => p.title === project.title && (archived || !p.archived_at));
+ if (!found) return request("POST", "/api/projects", project);
+ if (found.archived_at) await request("POST", `/api/projects/${found.id}/restore`);
+ return found;
+}
+
+// Invites the guest to the shared projects and accepts as the guest, the way
// the web app does. On a rerun the guest is already a member and keeps its
-// other projects, but always has the shared one and never the internal one.
-async function ensureGuestMember({ request, asGuest, workspaceId, guest, shared, internal }) {
+// other projects, but always has the shared ones and never the internal one.
+async function ensureGuestMember({ request, asGuest, workspaceId, guest, email, projects }) {
+ const sharedIds = Object.keys(GUEST_PROJECTS)
+ .filter((key) => GUEST_PROJECTS[key].sharedWithGuest)
+ .map((key) => projects[key].id);
const workspaces = (await asGuest("GET", "/api/workspaces")) ?? [];
if (!workspaces.some((ws) => ws.id === workspaceId)) {
try {
await request("POST", `/api/workspaces/${workspaceId}/members`, {
- email: GUEST_EMAIL,
+ email,
role: "guest",
- project_ids: [shared.id],
+ project_ids: sharedIds,
});
} catch (error) {
// An interrupted run can leave its invitation pending; accept that one.
@@ -962,7 +1023,7 @@ async function ensureGuestMember({ request, asGuest, workspaceId, guest, shared,
}
const invitations = listOf(await asGuest("GET", "/api/invitations"), "invitations");
const invitation = invitations.find((inv) => inv.workspace_id === workspaceId);
- if (!invitation) throw new Error(`no pending invitation for ${GUEST_EMAIL} in workspace ${workspaceId}`);
+ if (!invitation) throw new Error(`no pending invitation for ${email} in workspace ${workspaceId}`);
await asGuest("POST", `/api/invitations/${invitation.id}/accept`);
}
@@ -972,27 +1033,28 @@ async function ensureGuestMember({ request, asGuest, workspaceId, guest, shared,
);
const member = members.find((m) => m.user_id === guest.id);
if (member?.role !== "guest") {
- throw new Error(`${GUEST_EMAIL} is a ${member?.role ?? "missing"} member of this workspace, not a guest`);
+ throw new Error(`${email} is a ${member?.role ?? "missing"} member of this workspace, not a guest`);
}
const current = member.project_ids ?? [];
- const wanted = [...current.filter((id) => id !== internal.id && id !== shared.id), shared.id];
- if (current.length !== wanted.length || !current.includes(shared.id)) {
+ const fixtureIds = new Set(Object.values(projects).map((project) => project.id));
+ const wanted = [...current.filter((id) => !fixtureIds.has(id)), ...sharedIds];
+ if (current.length !== wanted.length || !wanted.every((id) => current.includes(id))) {
await request("PUT", `/api/workspaces/${workspaceId}/members/${member.id}/projects`, { project_ids: wanted });
}
return member;
}
-async function seedGuest({ request, profile, appUrl, slug }) {
- const existingProjects = listOf(await request("GET", "/api/projects"), "projects");
+async function seedGuest({ request, profile, appUrl, slug, guestEmail }) {
+ const existingProjects = listOf(await request("GET", "/api/projects?include_archived=true"), "projects");
const projects = {};
for (const [key, project] of Object.entries(GUEST_PROJECTS)) {
- projects[key] = await ensureProject(request, existingProjects, project);
+ projects[key] = await ensureGuestProject(request, existingProjects, project);
}
- const session = await guestSession(profile);
+ const session = await guestSession(profile, guestEmail);
const guest = session.user;
const asGuest = client({ ...profile, token: session.token });
- await ensureGuestMember({ request, asGuest, workspaceId: profile.workspaceId, guest, ...projects });
+ await ensureGuestMember({ request, asGuest, workspaceId: profile.workspaceId, guest, email: guestEmail, projects });
const issues = {};
for (const [key, spec] of Object.entries(GUEST_ISSUES)) {
@@ -1021,11 +1083,15 @@ async function seedGuest({ request, profile, appUrl, slug }) {
});
await request("PUT", `/api/issues/${issues.export.id}`, { assignee_type: "member", assignee_id: guest.id });
+ for (const [key, spec] of Object.entries(GUEST_PROJECTS)) {
+ if (spec.archived) await request("POST", `/api/projects/${projects[key].id}/archive`);
+ }
+
const inbox = listOf(await asGuest("GET", "/api/inbox"), "items");
const issueUrl = (issue) => `${appUrl}/${slug}/issues/${issue.identifier}`;
return {
url: `${appUrl}/${slug}/inbox`,
- guest_email: GUEST_EMAIL,
+ guest_email: guestEmail,
guest_code: devCode(),
guest_user_id: guest.id,
guest_token: session.token,
@@ -1034,7 +1100,14 @@ async function seedGuest({ request, profile, appUrl, slug }) {
projects: Object.fromEntries(
Object.entries(projects).map(([key, project]) => [
key,
- { id: project.id, title: project.title, url: `${appUrl}/${slug}/projects/${project.id}` },
+ {
+ id: project.id,
+ title: project.title,
+ url: `${appUrl}/${slug}/projects/${project.id}`,
+ visibility: GUEST_PROJECTS[key].visibility ?? "workspace",
+ archived: !!GUEST_PROJECTS[key].archived,
+ visible_to_guest: GUEST_PROJECTS[key].sharedWithGuest,
+ },
]),
),
issues: Object.fromEntries(
@@ -1043,8 +1116,9 @@ async function seedGuest({ request, profile, appUrl, slug }) {
{
id: issue.id,
identifier: issue.identifier,
+ title: issue.title,
url: issueUrl(issue),
- visible_to_guest: GUEST_ISSUES[key].project === "shared",
+ visible_to_guest: GUEST_PROJECTS[GUEST_ISSUES[key].project].sharedWithGuest,
},
]),
),
@@ -1067,14 +1141,14 @@ async function holdRuntime(request, runtime) {
}
async function main() {
- const { kinds, json, queued, hold, app, member } = parseCli(process.argv.slice(2));
+ const { kinds, json, queued, hold, app, member, guestEmail } = parseCli(process.argv.slice(2));
const profile = loadProfile(process.env);
const request = client(profile);
const workspaces = (await request("GET", "/api/workspaces")) ?? [];
const workspace = workspaces.find((ws) => ws.id === profile.workspaceId);
if (!workspace) fail(`the profile's workspace ${profile.workspaceId} is not visible to its token.`);
- const context = { request, profile, appUrl: profile.appUrl, slug: workspace.slug, queued, app, member };
+ const context = { request, profile, appUrl: profile.appUrl, slug: workspace.slug, queued, app, member, guestEmail };
if (kinds.some((kind) => !RUNTIMELESS_KINDS.includes(kind))) {
context.runtime = await ensureRuntime(request, profile.workspaceId);