another text
+${thisTextShouldAppear}
`, + textExpectedInOutput: thisTextShouldAppear, }, - }) - - // then - expect(result).toMatchFileSnapshot('./__snapshots__/table_of_contents.spec.json.snap') - }) -}) - -describe('rendering a course activity list', () => { - it('renders the activity list', async () => { - // given - const store = wrap(courseActivityListStoreContent) - - // when - const result = renderVueToPdfStructure(CampPrint, { - store, - $tc: tcMock, - locale: 'de', - config: { - language: 'de', - documentName: 'Basiskurs.pdf', - options: { pageNumbers: false }, - camp: store.get('/camps/5d28f99890bc'), - contents: [ - { - type: 'ActivityList', - options: { - periods: ['/periods/88f1f55a69d7'], + ])(`with special text %j`, async ({ name, text, textExpectedInOutput }) => { + // given + const storeWithSingleActivity = cloneDeep(activityWithSingleText) + storeWithSingleActivity['/content_node/single_texts/4300e3355d22'].data.html = text + + const store = wrap(storeWithSingleActivity) + + // when + const result = renderVueToPdfStructure(CampPrint, { + store, + $tc: tcMock, + locale: 'de', + config: { + language: 'de', + documentName: 'Morgenturnen.pdf', + options: { pageNumbers: false, pageSize }, + camp: store.get(campIri), + contents: [ + { + type: 'Activity', + options: { + activity: activityIri, + scheduleEntry: scheduleEntryIri, + }, }, - }, - ], - }, - }) + ], + }, + }) - // then - expect(result).toMatchFileSnapshot('./__snapshots__/activity_list.spec.json.snap') - }) -}) + // then + await expect(result).toMatchFileSnapshot( + `./__snapshots__/single_activity_with_special_text_${name}_${pageSize}.spec.json.snap` + ) -describe('renders a single activity', () => { - const campIri = activityWithSingleText['/camps/3c79b99ab424']._meta.self - const activityIri = activityWithSingleText['/activities/63ad6efc7613']._meta.self - const scheduleEntryIri = - activityWithSingleText['/schedule_entries/51c110ddd923']._meta.self - - const thisTextShouldAppear = 'this text should appear' - it.each([ - { - name: 'with_empty_lists', - text: `another text
-${thisTextShouldAppear}
`, - textExpectedInOutput: thisTextShouldAppear, - }, - ])(`with special text %j`, ({ name, text, textExpectedInOutput }) => { - // given - const storeWithSingleActivity = cloneDeep(activityWithSingleText) - storeWithSingleActivity['/content_node/single_texts/4300e3355d22'].data.html = text - - const store = wrap(storeWithSingleActivity) - - // when - const result = renderVueToPdfStructure(CampPrint, { - store, - $tc: tcMock, - locale: 'de', - config: { - language: 'de', - documentName: 'Morgenturnen.pdf', - options: { pageNumbers: false }, - camp: store.get(campIri), - contents: [ - { - type: 'Activity', - options: { - activity: activityIri, - scheduleEntry: scheduleEntryIri, - }, - }, - ], - }, + expect(JSON.stringify(result, createCircularReplacer())).toMatch( + textExpectedInOutput + ) }) - - // then - expect(result).toMatchFileSnapshot( - `./__snapshots__/single_activity_with_special_text_${name}.spec.json.snap` - ) - - expect(JSON.stringify(result, createCircularReplacer())).toMatch(textExpectedInOutput) }) }) diff --git a/print/assets/print-preview.css b/print/assets/print-preview.css index 098968bd60..100fc1a3db 100644 --- a/print/assets/print-preview.css +++ b/print/assets/print-preview.css @@ -10,17 +10,28 @@ } .tw-break-after-page { - max-width: 794px; /* page width: A4 width of 210mm at 96dpi */ - min-height: 1123px; /* page height: A4 height of 297mm at 96dpi */ background-color: var(--color-paper); padding: 57px; /* page margin: 15mmm at 96dpi */ margin: 35px auto; } - .tw-break-after-page.landscape-page { + .a4.tw-break-after-page { + max-width: 794px; /* page width: A4 width of 210mm at 96dpi */ + min-height: 1123px; /* page height: A4 height of 297mm at 96dpi */ + } + .a5.tw-break-after-page { + max-width: 562px; /* page width: A5 width of 149mm at 96dpi */ + min-height: 794px; /* page height: A5 height of 210mm at 96dpi */ + } + + .a4.tw-break-after-page.landscape-page { max-width: 1123px; /* page width: A4 landscape width of 297mm at 96dpi */ min-height: 794px; /* page height: A4 landscape height of 210mm at 96dpi */ } + .a5.tw-break-after-page.landscape-page { + max-width: 794px; /* page width: A5 landscape width of 210mm at 96dpi */ + min-height: 562px; /* page height: A5 landscape height of 149mm at 96dpi */ + } .tw-break-after-page .tw-break-after-page { margin: 0; /* avoid margin stacking for nested `tw-break-after-page` */ diff --git a/print/components/PicassoChunk.vue b/print/components/PicassoChunk.vue index 83198cfeeb..1cfbab9673 100644 --- a/print/components/PicassoChunk.vue +++ b/print/components/PicassoChunk.vue @@ -1,6 +1,12 @@ -