Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.
JavaScript 3d-generationai-agentsanimationavatardigital-humangenerative-aiglbgltfimage-to-3dllmmcpmcp-servermodel-context-protocolsolanatext-to-3dthreejsweb-componentswebglwebxrx402
test(event): cover the event-config guard and wire it into the gate
nirholas8439ae299669
diff --git a/package.json b/package.jsonindex b3160b36d..a6df3850f 100644--- a/package.json+++ b/package.json@@ -187,7 +187,7 @@"audit:route-shadowing": "node scripts/audit-route-shadowing.mjs","audit:handlers": "node scripts/audit-empty-handlers.mjs","audit:x402-catalog": "node scripts/audit-x402-catalog.mjs",- "gate": "npm run check:conflicts && npm run check:claude && npm run check:cron-syntax && npm run check:studio-openapi && npm run test:gate && npm run test:gate-3d && npm run audit:mcp && npm run audit:mcp-golden && npm run audit:mcp-safety && npm run audit:mcp-catalog && npm run audit:routes && npm run audit:handlers && npm run audit:pages && npm run audit:docs && npm run check:tutorials && npm run audit:hidden-guard && npm run audit:inline-handlers && npm run audit:x402-catalog && npm run audit:tokens && npm run audit:guards && npm run audit:tour-atlas",+ "gate": "npm run check:conflicts && npm run check:claude && npm run check:event && npm run check:cron-syntax && npm run check:studio-openapi && npm run test:gate && npm run test:gate-3d && npm run audit:mcp && npm run audit:mcp-golden && npm run audit:mcp-safety && npm run audit:mcp-catalog && npm run audit:routes && npm run audit:handlers && npm run audit:pages && npm run audit:docs && npm run check:tutorials && npm run audit:hidden-guard && npm run audit:inline-handlers && npm run audit:x402-catalog && npm run audit:tokens && npm run audit:guards && npm run audit:tour-atlas","test:gate-3d": "vitest run tests/glb-canonicalize.test.js tests/animation-retarget.test.js tests/animation-retarget-rest-pollution.test.js tests/viewer-framing.test.js","audit:mcp-golden": "node scripts/audit-mcp-golden.mjs","audit:mcp-safety": "node scripts/audit-mcp-safety.mjs",@@ -314,6 +314,9 @@"check:evm-rpc": "node --env-file=.env scripts/probe-evm-rpc.mjs --chain 1 --ens","awal:pin": "node scripts/update-awal-version.mjs","smoke:prod": "node scripts/check-pages.mjs --base https://three.ws",+ "event:watch": "node scripts/event-watch.mjs",+ "event:capacity": "node scripts/play-capacity-smoke.mjs",+ "event:failover": "node --env-file=.env scripts/event-dependency-failover.mjs","deploy": "npm run build:all && npm run check:dist && vercel --local-config vercel.json --prod","build:info": "node scripts/write-build-info.mjs","build:info:snapshot": "node scripts/write-build-info.mjs --snapshot",diff --git a/scripts/check-event-window.mjs b/scripts/check-event-window.mjsindex 58a468781..631118cad 100644--- a/scripts/check-event-window.mjs+++ b/scripts/check-event-window.mjs@@ -56,9 +56,19 @@ const ZONES = [/** The instant as an ISO string without the noise of trailing milliseconds. */export const isoOf = (ms) => new Date(ms).toISOString().replace('.000', '');-/** The instant as a human reads it in `tz`, which is what announcement copy quotes. */+/**+ * The instant as a human reads it in `tz`, which is what announcement copy quotes.+ *+ * Modern ICU separates the time from AM/PM with a NARROW NO-BREAK SPACE (U+202F)+ * rather than a plain one. These strings exist to be pasted into posts and blog+ * copy, so that invisible character would travel into published announcements and+ * into any search for the time that assumes a normal space. Normalised to ASCII+ * spaces for exactly that reason.+ */export const clockIn = (ms, tz) =>- new Intl.DateTimeFormat('en-US', { timeZone: tz, dateStyle: 'medium', timeStyle: 'short' }).format(new Date(ms));+ new Intl.DateTimeFormat('en-US', { timeZone: tz, dateStyle: 'medium', timeStyle: 'short' })+ .format(new Date(ms))+ .replace(/[\u202f\u00a0]/g, ' ');/** One line per announcement timezone, in the order the marketing copy lists them. */export function zoneLines(ms) {diff --git a/tests/check-event-window.test.js b/tests/check-event-window.test.jsnew file mode 100644index 000000000..3bf5657f9--- /dev/null+++ b/tests/check-event-window.test.js@@ -0,0 +1,138 @@+import { describe, it, expect } from 'vitest';+import { readFileSync } from 'node:fs';+import { validateEventConfig, CONFIG_PATH, isoOf, zoneLines } from '../scripts/check-event-window.mjs';++// The shape of public/event.json, minus the fields the validator ignores. Kept+// close to the real file so a rule that only passes on a toy config fails here.+const BASE = {+ id: 'three-first-meetup',+ name: '$THREE First Holders Meetup',+ startsAt: '2026-08-09T17:00:00Z',+ endsAt: '2026-08-09T19:30:00Z',+ link: '/play?coin=FeMbDoX7R1Psc4GEcvJdsbNbZA3bfztcyDCatJVJpump&name=three.ws&symbol=three',+ souvenir: { cosmeticId: 'laurel-meetup' },+ agenda: [+ { atMin: 0, title: 'Doors open in the plaza', icon: '👋' },+ { atMin: 105, title: 'Fireworks finale', icon: '🎆' },+ ],+};++const BEFORE = Date.parse('2026-08-09T12:00:00Z');+const DURING = Date.parse('2026-08-09T18:00:00Z');+const AFTER = Date.parse('2026-08-10T00:00:00Z');++const cfg = (over = {}) => ({ ...BASE, ...over });+const reasons = (doc, now) => validateEventConfig(doc, now).failures.join(' | ');++describe('validateEventConfig', () => {+ it('accepts a coherent upcoming event', () => {+ const { failures, state } = validateEventConfig(cfg(), BEFORE);+ expect(failures).toEqual([]);+ expect(state).toBe('upcoming');+ });++ it('accepts the event while it is running', () => {+ const { failures, state } = validateEventConfig(cfg(), DURING);+ expect(failures).toEqual([]);+ expect(state).toBe('live');+ });++ // The bug this check exists for: a rehearsal window left in the file. Every+ // surface reads it as "no event" and mounts nothing, silently.+ it('rejects a window that has already ended', () => {+ const { failures, state } = validateEventConfig(cfg(), AFTER);+ expect(state).toBe('over');+ expect(failures).toHaveLength(1);+ expect(failures[0]).toMatch(/ENDED/);+ });++ it('rejects a config with no usable start time', () => {+ expect(reasons(cfg({ startsAt: 'tomorrow-ish' }), BEFORE)).toMatch(/startsAt/);+ expect(reasons(cfg({ startsAt: undefined }), BEFORE)).toMatch(/startsAt/);+ });++ // An end that loses to the start is dropped by the parser for a silent+ // six-hour default, which is never what whoever typed it meant.+ it('rejects an end that does not beat the start', () => {+ expect(reasons(cfg({ endsAt: '2026-08-09T16:00:00Z' }), BEFORE)).toMatch(/not after startsAt/);+ expect(reasons(cfg({ endsAt: 'never' }), BEFORE)).toMatch(/unparseable/);+ });++ it('rejects a window long enough to be a typo', () => {+ expect(reasons(cfg({ endsAt: '2026-08-19T17:00:00Z' }), BEFORE)).toMatch(/reads like a typo/);+ });++ describe('souvenir', () => {+ it('rejects a cosmetic that is not in the catalog', () => {+ expect(reasons(cfg({ souvenir: { cosmeticId: 'laurel-imaginary' } }), BEFORE)).toMatch(/not in multiplayer/);+ });++ // The server only grants tier 'event', so any other tier grants nothing.+ it('rejects a cosmetic the server would refuse to grant', () => {+ expect(reasons(cfg({ souvenir: { cosmeticId: 'hat-cowboy' } }), BEFORE)).toMatch(/only grants tier 'event'/);+ });++ it('rejects a souvenir with no cosmeticId', () => {+ expect(reasons(cfg({ souvenir: {} }), BEFORE)).toMatch(/names no cosmeticId/);+ });++ // The grant is scoped to the coin world the CTA points at.+ it('rejects a souvenir whose link names no world', () => {+ expect(reasons(cfg({ link: '/play' }), BEFORE)).toMatch(/no \?coin=/);+ expect(reasons(cfg({ link: '' }), BEFORE)).toMatch(/no \?coin=/);+ });++ it('allows an event that grants nothing', () => {+ expect(validateEventConfig(cfg({ souvenir: undefined, link: '/play' }), BEFORE).failures).toEqual([]);+ });+ });++ describe('agenda', () => {+ it('rejects a beat scheduled past the end of the window', () => {+ const late = cfg({ agenda: [{ atMin: 0, title: 'Doors' }, { atMin: 999, title: 'Fireworks finale' }] });+ expect(reasons(late, BEFORE)).toMatch(/never fires/);+ });++ it('rejects beats that run backwards', () => {+ const jumbled = cfg({ agenda: [{ atMin: 45, title: 'Wheel' }, { atMin: 20, title: 'Totem' }] });+ expect(reasons(jumbled, BEFORE)).toMatch(/must be in order/);+ });++ it('rejects a beat with no usable minute offset', () => {+ expect(reasons(cfg({ agenda: [{ atMin: -5, title: 'Doors' }] }), BEFORE)).toMatch(/non-negative/);+ expect(reasons(cfg({ agenda: [{ atMin: 'soon', title: 'Doors' }] }), BEFORE)).toMatch(/non-negative/);+ });+ });++ // The formatters feed the announcement copy, and copy that disagrees with the+ // config is the other way this event has gone wrong.+ describe('clock rendering', () => {+ it('renders the window in the zones the announcements quote', () => {+ const lines = zoneLines(Date.parse('2026-08-09T17:00:00Z'));+ expect(lines).toHaveLength(4);+ expect(lines[0]).toBe('Aug 9, 2026, 10:00 AM Pacific');+ expect(lines[1]).toBe('Aug 9, 2026, 1:00 PM Eastern');+ expect(lines[2]).toBe('Aug 9, 2026, 6:00 PM London');+ expect(lines[3]).toBe('Aug 9, 2026, 7:00 PM Berlin');+ });++ it('writes instants back in the config\'s own format', () => {+ expect(isoOf(Date.parse('2026-08-09T17:00:00Z'))).toBe('2026-08-09T17:00:00Z');+ });+ });+});++// The config that ships is the one that matters; a green suite over fixtures+// while the real file is broken would be the same silent failure in a new place.+describe('the configured event that ships', () => {+ const doc = JSON.parse(readFileSync(CONFIG_PATH, 'utf8'));++ it('is coherent when judged at its own start', () => {+ const { failures } = validateEventConfig(doc, Date.parse(doc.startsAt));+ expect(failures).toEqual([]);+ });++ it('has not already ended', () => {+ expect(Date.parse(doc.endsAt)).toBeGreaterThan(Date.now());+ });+});