Implements the profile-stats change (specs/profile-stats):
- getActivityStats(ownerId, { publicOnly }) in activities.server.ts: one indexed
aggregate over stored columns (count, sum distance/ascent/elapsed duration) +
a rolling last-4-weeks count. No cache table, no schema change, no GPX parsing
(design §D1).
- Profile loader computes it scoped to the viewer (public-only for visitors,
full totals for the owner); ProfileStats header renders count · distance ·
ascent · time + "N in the last 4 weeks" via the shared StatRow + stats.ts
formatters; hidden when there are no visible activities.
- i18n journal.profileStats.* in en + de.
Tests: ProfileStats component (jsdom: totals, empty, last-4-weeks toggle);
e2e asserts the owner roll-up counts their activities. typecheck + lint + unit
(journal 318) green; verified in the browser.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
26 lines
1.1 KiB
TypeScript
26 lines
1.1 KiB
TypeScript
import { test, expect, gotoHydrated } from "./fixtures/test";
|
|
import { setupVirtualAuthenticator, registerUser } from "./helpers/auth";
|
|
|
|
test.describe("Profile stats", () => {
|
|
test("owner profile shows a roll-up header counting their activities", async ({ page }) => {
|
|
const cdp = await page.context().newCDPSession(page);
|
|
await setupVirtualAuthenticator(cdp);
|
|
|
|
const stamp = Date.now();
|
|
const username = `ps${stamp}`;
|
|
await registerUser(page, `ps-${stamp}@example.com`, username);
|
|
|
|
// Two activities → the owner's roll-up should count both.
|
|
for (const name of ["First outing", "Second outing"]) {
|
|
await gotoHydrated(page, "/activities/new");
|
|
await page.getByLabel("Name").fill(name);
|
|
await page.getByRole("button", { name: "Create Activity" }).click();
|
|
await expect(page).toHaveURL(/\/activities\/[0-9a-f-]+$/, { timeout: 10000 });
|
|
}
|
|
|
|
await gotoHydrated(page, `/users/${username}`);
|
|
// The roll-up header — the "N in the last 4 weeks" line is unique to it
|
|
// (the section headings below read "Activities (N)").
|
|
await expect(page.getByText("2 in the last 4 weeks")).toBeVisible();
|
|
});
|
|
});
|