mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-22 21:11:14 +00:00
fix(studio): CI on the templated auto layout
The rhythm test holds the picker to what it does now: it gives the rhythm up only where no template of the book's styles frames every photo and keeps it. A design applied over a stored book keeps that book's theme, as the merge has always done, so the end to end test checks the pages instead. The MCP test builds its request through the shared schema, a travel mark's frame is read with its sides spelled out for the client's looser types, and the client's react-hooks/refs baseline drops to the 555 it holds now.
This commit is contained in:
@@ -93,14 +93,29 @@ describe('the template picker', () => {
|
||||
expect(mapped.every((t) => t !== undefined)).toBe(true);
|
||||
});
|
||||
|
||||
it('AUTOTPL-004: never the same template twice running, never loud after loud or lively', () => {
|
||||
it('AUTOTPL-004: never the same template twice running, never loud after busy, unless only that keeps every photo framed in the style', () => {
|
||||
const busy = (t: BookDecoratedTemplate) => ['loud', 'lively'].includes(templateEnergy(t));
|
||||
for (const archetype of BOOK_COVER_ARCHETYPES) {
|
||||
const picks = book(varied, { archetype, theme: null });
|
||||
expect(picks.length, archetype).toBe(varied.length);
|
||||
picks.forEach((t, i) => {
|
||||
const before = picks[i - 1];
|
||||
if (!before) return;
|
||||
expect(t.id, `${archetype} at ${i}`).not.toBe(before.id);
|
||||
if (templateEnergy(t) === 'loud') expect(['loud', 'lively']).not.toContain(templateEnergy(before));
|
||||
const page = varied[i];
|
||||
if (!before || !page) return;
|
||||
const keeps = (x: BookDecoratedTemplate) =>
|
||||
x.id !== before.id && !(templateEnergy(x) === 'loud' && busy(before));
|
||||
if (keeps(t)) return;
|
||||
// The rhythm gives way only where no template of the book's styles frames every photo and keeps it.
|
||||
const fits = (x: BookDecoratedTemplate) =>
|
||||
templatePhotoSlots(x) === page.photos.length &&
|
||||
(!page.story || roles(x).includes('body')) &&
|
||||
(!roles(x).includes('map') || page.mappable);
|
||||
expect(
|
||||
innerPool(archetype)
|
||||
.filter((x) => fits(x) && keeps(x))
|
||||
.map((x) => x.id),
|
||||
`${archetype} at ${i}`,
|
||||
).toEqual([]);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@@ -336,7 +336,8 @@ export function composeWordsPage(c: ComposeCtx, entry: AutoEntry, story: BookEle
|
||||
let x = right.x;
|
||||
for (const mark of marks) {
|
||||
if (!mark) continue;
|
||||
const frame = fitIn(mark.frame, frameOf(x, right.y + right.h * 0.7, right.w / 2 - scaled(c, 4), right.h * 0.3));
|
||||
const { w = 0, h = 0 } = mark.frame;
|
||||
const frame = fitIn({ w, h }, frameOf(x, right.y + right.h * 0.7, right.w / 2 - scaled(c, 4), right.h * 0.3));
|
||||
els.push({ ...mark, frame: frameOf(x, frame.y, frame.w, frame.h) });
|
||||
x += frame.w + scaled(c, 8);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user