Files
SlabUploader/frontend/src/review/copy.test.ts
T
Ty 49c22c9385 feat(greenfield): rebuild SlabUploader M1-M3 on clean foundation, all gates green
Clean re-implementation of the full product (not a port of the old M3 tree):
- P0 foundation: 13-table schema + per-call sqlite factory (thread-safe),
  FastAPI app (health, JSON logging + secret redaction, CORS, startup guard).
- P1 M1 Capture: mask/sheetKeep, geometry/rect (min-area rect), measure,
  png crop/inventory/overlay, EXIF decodeOrientedBitmap.
- P2 M2 Photos: stateful capture session (batch, pick-cal, apply mask/crop
  to batch) + photos-ready lineup.
- P3 M3 Create: real backend (crypto, woo client, taxonomy sync, pricing,
  inference Call1/Call2, review, publish, settings, slabs, photos) + real FE
  review/publish/settings screens consuming the API (no hardcoded Woo ids).
- P4 gate exit: check_requirements + check_coverage both exit 0
  (137/155 IDs, 0 gaps); backend 130/130, frontend 150/150, build green.

Cite: docs/REQUIREMENTS.md (155 rows), docs/MILESTONES.md M1-M3.
2026-09-25 06:57:29 -07:00

74 lines
2.7 KiB
TypeScript

import assert from 'node:assert/strict';
import { test } from 'node:test';
import { buildShortDescription, buildTitle, type CopyFacts } from './copy';
const FACTS: CopyFacts = { lengthIn: 48, widthAvgIn: 18, thicknessIn: 2, bdft: 12 };
test('copy: live-edge leaf title, no dims, figure drops when absent', () => {
assert.equal(
buildTitle(FACTS, 'Cathedral', 'Black Walnut', { slug: 'live-edge-wood', name: 'Live edge wood' }),
'Cathedral Black Walnut Live Edge Slab',
);
assert.equal(
buildTitle(FACTS, null, 'Black Walnut', { slug: 'live-edge-wood', name: 'Live edge wood' }),
'Black Walnut Live Edge Slab',
);
});
test('copy: dimensional leaf gains "Live Edge" only from the synced edge term (METADATA-5)', () => {
assert.equal(
buildTitle({ ...FACTS, edgeName: 'Live' }, null, 'Red Oak', { slug: 'dimensional-wood', name: 'Dimensional wood' }),
'Red Oak Live Edge Dimensional',
);
assert.equal(
buildTitle({ ...FACTS, edgeName: 'Straight' }, null, 'Red Oak', { slug: 'dimensional-wood', name: 'Dimensional wood' }),
'Red Oak Dimensional',
);
});
test('copy: knife-blank leaf carries dims', () => {
assert.equal(
buildTitle(FACTS, null, 'Cherry', { slug: 'knife-blanks', name: 'Knife blanks' }),
'Cherry Knife Blank (48 x 18 x 2 in)',
);
});
test('copy: unknown leaf slug falls back to "Slab"', () => {
assert.equal(
buildTitle(FACTS, 'Spalted', 'Olive', { slug: 'mystery-leaf', name: 'Mystery' }),
'Spalted Olive Slab',
);
});
test('copy: title collapses double spaces', () => {
assert.equal(
buildTitle(FACTS, ' ', 'Black Walnut', { slug: 'live-edge-wood', name: 'Live edge wood' }),
'Black Walnut Live Edge Slab',
);
});
test('copy: short description = title + ft/in split + dims + rounded bdft', () => {
assert.equal(
buildShortDescription(FACTS, null, 'Black Walnut', { slug: 'live-edge-wood', name: 'Live edge wood' }),
'Black Walnut Live Edge Slab, 4ft 0in x 18in x 2in, 12 bdft',
);
});
test('copy: short description keeps fractional bdft to 1 dp', () => {
assert.equal(
buildShortDescription({ ...FACTS, bdft: 11.46 }, null, 'Black Walnut', { slug: 'live-edge-wood', name: 'Live edge wood' }),
'Black Walnut Live Edge Slab, 4ft 0in x 18in x 2in, 11.5 bdft',
);
});
test('copy: non-whole feet split into ft + rem inches', () => {
assert.equal(
buildShortDescription({ ...FACTS, lengthIn: 60 }, null, 'Cherry', { slug: 'live-edge-wood', name: 'Live edge wood' }),
'Cherry Live Edge Slab, 5ft 0in x 18in x 2in, 12 bdft',
);
assert.equal(
buildShortDescription({ ...FACTS, lengthIn: 41.5 }, null, 'Cherry', { slug: 'live-edge-wood', name: 'Live edge wood' }),
'Cherry Live Edge Slab, 3ft 5.5in x 18in x 2in, 12 bdft',
);
});