further layout preview fixes
This commit is contained in:
55
resources/js/admin/mobile/__tests__/qrLayoutUtils.test.ts
Normal file
55
resources/js/admin/mobile/__tests__/qrLayoutUtils.test.ts
Normal file
@@ -0,0 +1,55 @@
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import type { EventQrInviteLayout } from '../../api';
|
||||
import { buildInitialTextFields } from '../QrLayoutCustomizePage';
|
||||
import { resolveLayoutForFormat } from '../QrPrintPage';
|
||||
|
||||
describe('buildInitialTextFields', () => {
|
||||
it('prefers event name for headline and default copy when customization is missing', () => {
|
||||
const layoutDefaults = {
|
||||
id: 'evergreen-vows',
|
||||
name: 'Evergreen Vows',
|
||||
description: 'Old description',
|
||||
} as EventQrInviteLayout;
|
||||
|
||||
const fields = buildInitialTextFields({
|
||||
customization: null,
|
||||
layoutDefaults,
|
||||
eventName: 'Sommerfest 2025',
|
||||
});
|
||||
|
||||
expect(fields.headline).toBe('Sommerfest 2025');
|
||||
expect(fields.description).toBe('Helft uns, diesen besonderen Tag mit euren schönen Momenten festzuhalten.');
|
||||
expect(fields.instructions).toHaveLength(3);
|
||||
});
|
||||
|
||||
it('uses customization when provided', () => {
|
||||
const fields = buildInitialTextFields({
|
||||
customization: {
|
||||
headline: 'Custom',
|
||||
description: 'Desc',
|
||||
instructions: ['One', 'Two'],
|
||||
},
|
||||
layoutDefaults: null,
|
||||
eventName: 'Ignored',
|
||||
});
|
||||
|
||||
expect(fields.headline).toBe('Custom');
|
||||
expect(fields.description).toBe('Desc');
|
||||
expect(fields.instructions).toEqual(['One', 'Two']);
|
||||
});
|
||||
});
|
||||
|
||||
describe('resolveLayoutForFormat', () => {
|
||||
const layouts: EventQrInviteLayout[] = [
|
||||
{ id: 'portrait-a4', paper: 'a4', orientation: 'portrait', panel_mode: 'single', format_hint: 'poster-a4' } as EventQrInviteLayout,
|
||||
{ id: 'foldable', paper: 'a4', orientation: 'landscape', panel_mode: 'double-mirror', format_hint: 'foldable-a5' } as EventQrInviteLayout,
|
||||
];
|
||||
|
||||
it('returns portrait layout for A4 poster', () => {
|
||||
expect(resolveLayoutForFormat('a4-poster', layouts)).toBe('portrait-a4');
|
||||
});
|
||||
|
||||
it('returns foldable layout for A5 foldable', () => {
|
||||
expect(resolveLayoutForFormat('a5-foldable', layouts)).toBe('foldable');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user