Files
vu/tests/hours/resolve-common.test.ts
T
will 2658a2b94e
Deploy / deploy (push) Successful in 53s
Fix splitNamedAntiphon silently upgrading draft text to verified
Every antiphon that goes through the incipit/full split -- which is
every antiphon across every hour -- lost its real status the moment it
passed through here: splitNamedAntiphon hardcoded `verified` on its
output via verifiedText(), regardless of what the source's actual
status was. Concretely, this meant St. Scholastica's antiphon (I
translated it myself, no English existed in the source), Matthias's and
several other apostles' reworded English, and Gregory the Great's
translated antiphon all silently rendered as if fully verified --
losing the "unverified draft text" UI marker (src/ui/styles.css's
.text-draft, a dashed underline + tooltip) that's supposed to
distinguish "copied straight from the source" from "Claude's own
rendering."

Fixed by having splitNamedAntiphon accept a real ResolvedText and carry
its per-language status through unchanged to both outputs, instead of
silently upgrading everything to verified. Callers whose antiphon never
had a status field to begin with (plain weekday-default antiphons and
Lauds psalmody overrides -- neither type tracks status at all, always
implicitly verified by the source file's own live-checked convention)
now wrap with verifiedText() explicitly at the call site, rather than
that assumption being buried inside splitNamedAntiphon itself.
resolveMinorHourAntiphon (Prime/Terce/Sext/None's override lookup) now
returns a full ResolvedText for the same reason.

Verified end-to-end with St. Scholastica's real draft-English antiphon,
both via a direct unit test and visually in the browser (the dashed
underline now shows correctly under her Benedictus antiphon).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-12 11:34:21 -04:00

58 lines
2.8 KiB
TypeScript

import { describe, expect, it } from 'vitest';
import { resolveDay } from '../../src/calendar';
import { getDayCollect, splitNamedAntiphon } from '../../src/hours/resolve-common';
describe('getDayCollect', () => {
it('resolves a real, verified collect for an ordinary Sunday', () => {
const day = resolveDay('2026-08-09'); // post-pentecost-11
const collect = getDayCollect(day);
expect(collect.status.la).toBe('verified');
expect(collect.status.en).toBe('verified');
expect(collect.text.en).toContain('Let us pray.');
});
it('resolves a real, verified collect for a ferial day via its governing Sunday', () => {
const day = resolveDay('2026-06-14'); // post-pentecost-03's Sunday
const collect = getDayCollect(day);
expect(collect.status.la).toBe('verified');
});
it('resolves as honestly missing for a saint with no authored propers yet', () => {
const day = resolveDay('2026-08-07'); // St. Donatus wins outright, propers: null
expect(day.winner.kind).toBe('sanctoral');
const collect = getDayCollect(day);
expect(collect.status.la).toBe('missing');
expect(collect.status.en).toBe('missing');
});
});
describe('splitNamedAntiphon', () => {
it('carries a verified status through to both the incipit and full forms', () => {
const { incipit, full } = splitNamedAntiphon({
text: { la: 'Foo * bar baz.', en: 'Foo * bar baz.' },
status: { la: 'verified', en: 'verified' },
});
expect(incipit.status).toEqual({ la: 'verified', en: 'verified' });
expect(full.status).toEqual({ la: 'verified', en: 'verified' });
});
it('carries a draft status through to both forms, per language -- the bug this fixes: it used to hardcode verified on everything regardless of the source status, silently dropping the "unverified draft text" UI marker (src/ui/styles.css .text-draft) from every draft antiphon', () => {
const { incipit, full } = splitNamedAntiphon({
text: { la: 'Foo * bar baz.', en: 'Foo * bar baz.' },
status: { la: 'verified', en: 'draft' },
});
expect(incipit.status).toEqual({ la: 'verified', en: 'draft' });
expect(full.status).toEqual({ la: 'verified', en: 'draft' });
});
it("reflects St. Scholastica's own real draft-English antiphon end to end, through Lauds", async () => {
const { resolveOrdo } = await import('../../src/hours/lauds');
const ordo = resolveOrdo('2029-02-10'); // St. Scholastica, a clean year
const idx = ordo.parts.findIndex((p) => p.kind === 'canticle' && p.canticleId === 'benedictus');
const canticle = ordo.parts[idx];
const repeat = ordo.parts[idx + 1];
expect(canticle?.kind === 'canticle' ? canticle.antiphon?.status.en : undefined).toBe('draft');
expect(repeat?.kind === 'antiphon' ? repeat.text.status.en : undefined).toBe('draft');
});
});