Files
Waters ChurchandClaude Fable 5.1 78cd0cc550 Plan Your Visit landing page for visit.waterschurch.org
Next.js 16 static export + PHP 8 API for cPanel/Apache hosting.

- Location-aware campus finder (IP estimate, optional precise location, ZIP search)
- Three-step Plan Your Visit form with separate email/SMS consent
- PHP API: validation, anti-spam, rate limiting, SQLite lead store,
  Mailchimp and Sinch Engage adapters, idempotent retries via cron
- Attribution capture (utm_*, gclid/gbraid/wbraid, fbclid, ttclid, twclid) and
  consent-aware analytics hooks
- Vitest and PHP test suites, cPanel deployment script and docs

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-22 13:22:26 -04:00

39 lines
1.7 KiB
TypeScript

import { describe, expect, it } from "vitest";
import { campuses, centralCampus, formatAddress, formatTimes, openCampuses, serviceOptions } from "@/config/campuses";
describe("campus configuration", () => {
it("loads and validates every campus", () => {
expect(campuses.length).toBeGreaterThanOrEqual(5);
for (const c of campuses) {
expect(c.id).toMatch(/^[a-z0-9-]+$/);
expect(c.coordinates.lat).not.toBe(0);
expect(c.phone).toMatch(/^\+1\d{10}$/);
expect(c.directionsUrl).toMatch(/^https:\/\//);
}
});
it("only open campuses are selectable and every open campus can be texted", () => {
for (const c of openCampuses) {
expect(c.status).toBe("open");
expect(c.smsNumber).toMatch(/^\+1\d{10}$/);
expect(c.sinchAccountId).toMatch(/^WatersChurch_OLA_\d{4}$/);
}
});
it("has exactly one central campus", () => {
expect(campuses.filter((c) => c.isCentral)).toHaveLength(1);
expect(centralCampus.id).toBe("north-attleboro");
});
it("formats addresses and times", () => {
const na = openCampuses.find((c) => c.id === "north-attleboro")!;
expect(formatAddress(na)).toBe("57 John L Dietsch Square, North Attleboro, MA 02763");
expect(formatTimes(["7:30 AM", "9:30 AM", "11:30 AM"])).toBe("7:30, 9:30 & 11:30 AM");
expect(formatTimes(["10:30 AM"])).toBe("10:30 AM");
expect(formatTimes(["9:30 AM", "7:00 PM"])).toBe("9:30 AM & 7:00 PM");
});
it("builds service options per campus", () => {
const nw = openCampuses.find((c) => c.id === "norwood")!;
const opts = serviceOptions(nw);
expect(opts.map((o) => o.value)).toContain("Sunday 9:30 AM");
expect(opts.some((o) => o.value.startsWith("First Wednesday"))).toBe(true);
});
});