Add missing JS coverage: designer save else branch, calculator default rates

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Serreau Jovann
2026-03-21 12:28:30 +01:00
parent 977044df52
commit ee452c46fe
2 changed files with 36 additions and 0 deletions

View File

@@ -133,6 +133,25 @@ describe('initBilletDesigner', () => {
expect(fetchMock).not.toHaveBeenCalled()
})
it('save includes non-checkbox input values in form data', () => {
const fetchMock = vi.fn().mockResolvedValue({ ok: true })
globalThis.fetch = fetchMock
document.body.innerHTML = `
<div id="billet-designer" data-preview-url="/preview" data-save-url="/save">
<input type="text" name="invitation_title" value="VIP Pass">
<iframe id="billet-preview-frame" src="/preview"></iframe>
<button id="billet-save-design"></button>
</div>
`
initBilletDesigner()
document.getElementById('billet-save-design').click()
const formData = fetchMock.mock.calls[0][1].body
expect(formData.get('invitation_title')).toBe('VIP Pass')
})
it('save includes checkbox values in form data', () => {
const fetchMock = vi.fn().mockResolvedValue({ ok: true })
globalThis.fetch = fetchMock

View File

@@ -15,6 +15,23 @@ describe('initCommissionCalculator', () => {
expect(() => initCommissionCalculator()).not.toThrow()
})
it('uses default stripe rate and fixed when not provided', () => {
document.body.innerHTML = `
<input type="number" id="billet_price" value="10">
<div id="commission-calculator" data-eticket-rate="0">
<span id="calc-price"></span>
<span id="calc-eticket"></span>
<span id="calc-stripe"></span>
<span id="calc-total"></span>
<span id="calc-net"></span>
</div>
`
initCommissionCalculator()
// Default stripe: 10 * 1.5% + 0.25 = 0.40
expect(document.getElementById('calc-stripe').textContent).toBe('- 0,40 \u20AC')
})
function setupCalculator(eticketRate = '5', price = '') {
document.body.innerHTML = `
<input type="number" id="billet_price" value="${price}">