diff --git a/tests/lo-roundtrip.test.ts b/tests/lo-roundtrip.test.ts index 5154cab..d62fc4e 100644 --- a/tests/lo-roundtrip.test.ts +++ b/tests/lo-roundtrip.test.ts @@ -89,8 +89,12 @@ const fixture: N = { { type: 'tableCell', attrs: { colspan: 1, rowspan: 1, colwidth: [240], borderTop: 'none', borderRight: '2.25pt solid #FF0000' }, content: [P(null, T('B2'))] }, ] }, ] }, + // A list and a nested image survive only in a Writer text frame — a drawing-object + // text box flattens both, so this guards the Frame-parent discriminator. TBX({ width: 288, height: 96, fillColor: '#FFFFFF', strokeColor: '#000000', strokeWidthPt: 1 }, - P(null, T('box text')), P(null, T('second para'))), + P(null, T('box text')), + { type: 'bulletList', content: [LI(P(null, T('box bullet')))] }, + P(null, T('second para'), IMGN(40, 20))), TBX({ width: 192, height: 96, wrap: 'right', shapeKind: 'ellipse', fillColor: '#FFEE00', strokeColor: '#FF0000', strokeWidthPt: 2.25, rotation: 30 }, P(null, T('in ellipse'))), P(null, T('The end.')), @@ -199,7 +203,9 @@ describe.skipIf(!SOFFICE)('LibreOffice round-trip (needs soffice on PATH)', () = check('LO: both text boxes survive', boxes.length === 2, (res.content.content ?? []).map((n: N) => n.type)); const [plain, ellipse] = boxes; check('LO: box geometry survives (288×96)', Math.abs((plain?.attrs?.width ?? 0) - 288) <= 3 && Math.abs((plain?.attrs?.height ?? 0) - 96) <= 3, plain?.attrs); - check('LO: box paragraphs survive', plain?.content?.length === 2, plain?.content); + check('LO: box content survives (para, list, para)', plain?.content?.length === 3 + && plain?.content?.[1]?.type === 'bulletList', plain?.content?.map((n: N) => n.type)); + check('LO: box keeps its nested image', JSON.stringify(plain).includes('"image"'), plain?.content); check('LO: ellipse kind + fill survive', ellipse?.attrs?.shapeKind === 'ellipse' && String(ellipse?.attrs?.fillColor).toUpperCase() === '#FFEE00', ellipse?.attrs); const brot = ellipse?.attrs?.rotation ?? 0; check('LO: ellipse rotation survives (~30°)', Math.abs(brot - 30) <= 2 || Math.abs(brot - 330) <= 2, brot); diff --git a/tests/roundtrip.test.ts b/tests/roundtrip.test.ts index 8cec6ee..fd30430 100644 --- a/tests/roundtrip.test.ts +++ b/tests/roundtrip.test.ts @@ -2203,6 +2203,18 @@ describe('Leg 21: page background, page border and watermark', () => { back.watermark); }); + it('ODT: border and padding are carved out of the margins, and grown back', async () => { + // ODF lays the border + fo:padding inside fo:margin-*; the text area must stay + // at the configured margins, so the export shrinks them by 0.2cm + 1pt (0.035cm). + const styles = strFromU8(unzipSync(await odt())['styles.xml']); + check('top margin shrunk', styles.includes('fo:margin-top="2.765cm"'), + styles.match(/]*/)?.[0]); + check('left margin shrunk', styles.includes('fo:margin-left="2.265cm"')); + const back = importOdt(await odt()).margins; + check('margins reconstructed', !!back && Math.abs(back.top - 3) < 0.01 + && Math.abs(back.left - 2.5) < 0.01 && Math.abs(back.right - 1.5) < 0.01, back); + }); + it('an undecorated document writes none of it', async () => { const styles = strFromU8(unzipSync(await buildOdt(doc, margins, 'portrait'))['styles.xml']); check('no page background', !styles.includes('fo:background-color'), styles.match(/fo:background-color="[^"]*"/g)); diff --git a/tests/unit/notes.test.ts b/tests/unit/notes.test.ts index e344788..4b1006f 100644 --- a/tests/unit/notes.test.ts +++ b/tests/unit/notes.test.ts @@ -30,6 +30,15 @@ describe('note numbering', () => { expect([0, 1].map((i) => noteLabel(i, 'footnote', s))).toEqual(['[4]', '[5]']); }); + // The affixes are note-area text: LibreOffice keeps the anchor a bare number (probed). + it('keeps the prefix/suffix off the anchor', () => { + const s = withFootnote({ prefix: '(', suffix: ')' }); + expect(noteLabel(0, 'footnote', s, undefined, false)).toBe('1'); + const refs = [REF('a', 'footnote'), REF('b', 'footnote')]; + expect([...noteLabels(refs, s, undefined, false).values()]).toEqual(['1', '2']); + expect([...noteLabels(refs, s).values()]).toEqual(['(1)', '(2)']); + }); + it('keeps a note the file numbered by hand', () => { expect(noteLabel(0, 'footnote', DEFAULT_NOTE_SETTINGS, '*')).toBe('*'); });