Skip to content

armgit / TREK

Public Imported from GitHub
0

The most complete open-source travel planner: real-time collaboration, bookings, budgets, packing lists, journals, offline PWA, SSO and an AI-ready MCP server, with planet-wide place search and routing built in.

test(studio): pin which texts count as a template's figures

Mauriceb3d30a834e71
diff --git a/shared/src/book/templates/template-words.spec.ts b/shared/src/book/templates/template-words.spec.ts
index ee3e307b4..9754d35a7 100644
--- a/shared/src/book/templates/template-words.spec.ts
+++ b/shared/src/book/templates/template-words.spec.ts
@@ -1,10 +1,10 @@
import { bookSpreadSchema, bookTextElementSchema, type BookSpread, type BookTextElement } from '../book.schema';
import type { BookTemplateTextRole } from './template-format';
-import { assignTemplateTexts, bookTemplateWords } from './template-words';
+import { assignTemplateTexts, bookTemplateWords, isTemplateFigureText } from './template-words';
import { describe, expect, it } from 'vitest';
-// TPLWORDS-001 to TPLWORDS-006
+// TPLWORDS-001 to TPLWORDS-007
/**
* Which of a page's words a template's roles take: the journal's bindings
@@ -57,6 +57,15 @@ describe('the page words in the roles', () => {
const spare = assignTemplateTexts([text('a', 'One'), text('b', 'Two'), text('c', 'Three')], new Set(['title']));
expect(ids(spare)).toEqual({ title: 'a' });
});
+
+ it('TPLWORDS-007: takes the figures a template drew for its design, never a date or a bound text', () => {
+ expect(isTemplateFigureText(text('tc', '00:12:48:03'))).toBe(true);
+ expect(isTemplateFigureText(text('frame', '21'))).toBe(true);
+ expect(isTemplateFigureText(text('day', '12.08.2025'))).toBe(false);
+ expect(isTemplateFigureText(text('year', '2027'))).toBe(false);
+ expect(isTemplateFigureText(text('word', 'REC'))).toBe(false);
+ expect(isTemplateFigureText(text('bound', '14', { binding: { source: 'entry.title', entryId: 1 } }))).toBe(false);
+ });
});
describe('the book words for the roles a page has none for', () => {