trails/e2e/journal.test.ts
Ullrich Schäfer f0ef989ac3 Rebuild the Journal home around a public feed and flagship marketing
The old home was an h1, subtitle, and two auth buttons — visitors
arriving at trails.cool had no idea what it was, and self-hosted
instances had nothing interesting to land on.

The new home is one layout that serves both audiences:

- Hero: a product-describing h1 ("Federated outdoor journal") +
  tagline. The site name already lives in the top banner and nav brand,
  so the h1 carries the pitch instead of triplicating "trails.cool".
- Auth CTAs: Register (blue) + Sign In (outlined) get primary weight.
  Planner demotes to a small "Or try the Planner without an account →"
  link below them — it's a nice escape hatch but not the goal.
- Marketing cards: on the flagship only, a 2x2 grid of emoji-icon cards
  for Planner / Journal / Federation / Ownership, matching the Planner
  home's visual weight. `IS_FLAGSHIP=true` toggles it. Self-hosters get
  a "Powered by trails.cool — about the project" link back to the
  flagship instead, so they don't have to write their own marketing.
- Public feed: reverse-chronological list of the 20 most recent public
  activities on the instance, with owner + distance + date. Empty state
  for fresh installs.

Plumbing:
- `listRecentPublicActivities(limit)` in activities.server.ts joins
  users so the feed can render "by <displayName>" in one query.
- `IS_FLAGSHIP` env wired through docker-compose.yml; cd-apps and
  cd-infra both write `IS_FLAGSHIP=true` alongside `DOMAIN=trails.cool`,
  so self-hosters (who deploy without these workflows) default to off.

Specs:
- `activity-feed`: new "Instance-wide public activity feed" requirement
  so the visibility contract is pinned (public in feed, unlisted +
  private are not).
- `journal-landing`: new small spec capturing the hero / marketing /
  feed layout contract and the `IS_FLAGSHIP` toggle, so future
  instance-branding or empty-state changes have a stable anchor.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-24 20:00:23 +02:00

55 lines
2.3 KiB
TypeScript

import { test, expect } from "./fixtures/test";
test.describe("Journal", () => {
test("loads the home page", async ({ page }) => {
await page.goto("/");
await expect(page).toHaveTitle("trails.cool");
await expect(
page.getByRole("heading", { name: "Federated outdoor journal" }),
).toBeVisible();
});
test("shows register and sign in when logged out", async ({ page }) => {
await page.goto("/");
// Nav bar has Register and Sign In links
await expect(page.getByRole("navigation").getByRole("link", { name: "Register" })).toBeVisible();
await expect(page.getByRole("navigation").getByRole("link", { name: "Sign In" })).toBeVisible();
});
test("registration page renders correctly", async ({ page }) => {
await page.goto("/auth/register");
await expect(page.getByRole("heading", { name: "Register" })).toBeVisible();
await expect(page.getByLabel("Email")).toBeVisible();
await expect(page.getByLabel("Username")).toBeVisible();
await expect(page.getByRole("button", { name: /Register with Passkey/ })).toBeVisible();
// No password field
await expect(page.locator('input[type="password"]')).not.toBeVisible();
});
test("login page has passkey and magic link options", async ({ page }) => {
await page.goto("/auth/login");
await expect(page.getByRole("button", { name: /Sign in with Passkey/ })).toBeVisible();
await expect(page.getByText(/magic link/i)).toBeVisible();
});
test("nav bar shows on all pages", async ({ page }) => {
await page.goto("/");
const nav = page.getByRole("navigation");
await expect(nav).toBeVisible();
// Logo/title links home
await expect(nav.getByRole("link", { name: "trails.cool" })).toBeVisible();
// Logged-out nav does not show Routes or Activities
await expect(nav.getByRole("link", { name: "Routes" })).not.toBeVisible();
await expect(nav.getByRole("link", { name: "Activities" })).not.toBeVisible();
});
test("routes page redirects to login when not authenticated", async ({ page }) => {
await page.goto("/routes");
await expect(page).toHaveURL(/auth\/login/);
});
test("activities page redirects to login when not authenticated", async ({ page }) => {
await page.goto("/activities");
await expect(page).toHaveURL(/auth\/login/);
});
});