Files
zeekayandGitHub 4b7a524989 Type pages (mcp to x-tender) under strict (#9)
* Type model, templates, reviews and sms pages under strict

Props, state, refs and handlers typed; null guards where the types showed a possible null. creativeData exports Slug.

Claude-Session: https://claude.ai/code/session_015XYKLix9PSyn6Jw2HWKprk

* Type Kai/Mori/Koe/Uta, research, philosophy, press and risk pages under strict

Props, state, refs and handlers typed; ref callbacks no longer return the element.

Claude-Session: https://claude.ai/code/session_015XYKLix9PSyn6Jw2HWKprk

* Type x-tender, solutions, story, tag, startups, support, newsletter and mcp pages under strict

Captured-page trees and docs get shared types. Null-safe reads where a figure has no source or a page has no siblings.

Claude-Session: https://claude.ai/code/session_015XYKLix9PSyn6Jw2HWKprk

* Type open source, platform, products, operative, trust, sdks and o11y pages under strict

Captured-page trees, product docs and org data get shared types. Null guards on refs and canvas contexts; product() throws a clear error for a captured page with no API section.

Claude-Session: https://claude.ai/code/session_015XYKLix9PSyn6Jw2HWKprk

* Type post, pricing, team, slack, skills, security, tabs and proof pages under strict

Live pricing uses the lib Rung/Group/Row types. Null guards on refs and canvas contexts.

Claude-Session: https://claude.ai/code/session_015XYKLix9PSyn6Jw2HWKprk

* Type models, studio, university, science, referral, operator, network and module pages under strict

Model and university data tables get explicit row types; the Opener shape is shared by ModelsPage and Studio.

Claude-Session: https://claude.ai/code/session_015XYKLix9PSyn6Jw2HWKprk

* Narrow the review entry in its test

entry() returns Review | null under strict; the test asserts it is set before use.

Claude-Session: https://claude.ai/code/session_015XYKLix9PSyn6Jw2HWKprk

* Type the Newsletter send button ref as a button

Claude-Session: https://claude.ai/code/session_015XYKLix9PSyn6Jw2HWKprk

* Fit the callers of the typed pages to their types

Product, solutions and tabs-tree callers use the page types; the open-source snapshot reads lib/oss's own Summary and Activity; the O11y card ref is a list item ref.

Claude-Session: https://claude.ai/code/session_015XYKLix9PSyn6Jw2HWKprk
2026-11-14 01:44:08 -08:00

54 lines
2.9 KiB
TypeScript

// node --test components/pages/Reviews.test.mjs: the reviews are hanzo.ai's nine, a visitor's own is made and kept the way
// hanzo.ai makes it, and a category shows what it says.
import test from 'node:test';
import assert from 'node:assert/strict';
import { API, CATEGORIES, PRODUCTS, REVIEWS, entry, kept, lead, response, visible } from './Reviews.data.ts';
const answers = { name: ' Ada Lovelace ', role: '', company: ' ', product: 'Hanzo Cloud', rating: 4, title: ' Fast ', body: ' It works. ' };
test('nine reviews, five products, and every review is of one of them', () => {
assert.equal(REVIEWS.length, 9);
assert.deepEqual(CATEGORIES, ['All', ...PRODUCTS]);
assert.ok(REVIEWS.every((r) => PRODUCTS.includes(r.product) && r.rating === 5 && r.verified));
assert.equal(new Set(REVIEWS.map((r) => r.id)).size, 9);
});
test('a category shows its own, a visitor\'s review leads, and All shows every one', () => {
assert.deepEqual(PRODUCTS.map((p) => visible([], p).length), [2, 2, 2, 2, 1]);
assert.equal(visible([], 'All').length, 9);
const mine = entry(answers, 7);
assert.ok(mine);
assert.equal(visible([mine], 'All')[0], mine);
assert.equal(visible([mine], 'Hanzo Cloud')[0], mine);
assert.equal(visible([mine], 'Enterprise').length, 1);
});
test('a visitor\'s review: trimmed, a role and company defaulted as hanzo.ai defaults them, and refused without a name, headline or review', () => {
assert.deepEqual(entry(answers, 7), { id: 'user-7', author: 'Ada Lovelace', role: 'Builder', company: 'Community', product: 'Hanzo Cloud', rating: 4, title: 'Fast', body: 'It works.', date: 'Just now', verified: true });
assert.equal(entry({ ...answers, name: ' ' }), null);
assert.equal(entry({ ...answers, title: '' }), null);
assert.equal(entry({ ...answers, body: ' \n ' }), null);
});
test('what localStorage holds comes back only if it is a list', () => {
assert.deepEqual(kept(null), []);
assert.deepEqual(kept('{not json'), []);
assert.deepEqual(kept('{"a":1}'), []);
assert.deepEqual(kept(JSON.stringify([entry(answers, 7)])), [entry(answers, 7)]);
});
test('a review is sent as hanzo.ai sends it: a lead and a form response, on the gateway', () => {
const e = entry(answers, 7);
assert.ok(e);
assert.equal(API, 'https://api.hanzo.ai');
assert.deepEqual(lead(e), { program: 'hanzo_review', name: 'Ada Lovelace', role: 'Builder', company: 'Community', product: 'Hanzo Cloud', rating: 4, title: 'Fast', review: 'It works.', source: 'hanzo.reviews' });
assert.deepEqual(response(e, 7), {
token: 'rv_7',
answers: [
{ field: 'name', text: 'Ada Lovelace' }, { field: 'role', text: 'Builder' }, { field: 'company', text: 'Community' }, { field: 'product', text: 'Hanzo Cloud' },
{ field: 'rating', number: 4 }, { field: 'title', text: 'Fast' }, { field: 'review', text: 'It works.' },
],
hidden: { source: 'hanzo.reviews' },
});
});