Fix billet tests: price in euros, add coverage for designer save and billets sortable
- Fix AccountControllerTest: send price_ht in euros (15.00/25.00) not centimes - Add billet-designer tests: save design, save without URL, checkbox values in FormData - Add sortable test: billets-list initialization with data-billet-id Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1128,7 +1128,7 @@ class AccountControllerTest extends WebTestCase
|
||||
$client->loginUser($user);
|
||||
$client->request('POST', '/mon-compte/evenement/'.$event->getId().'/categorie/'.$category->getId().'/billet/ajouter', [
|
||||
'name' => 'Entree VIP',
|
||||
'price_ht' => '1500',
|
||||
'price_ht' => '15.00',
|
||||
'is_generated_billet' => '1',
|
||||
'description' => 'Acces backstage',
|
||||
]);
|
||||
@@ -1201,7 +1201,7 @@ class AccountControllerTest extends WebTestCase
|
||||
$client->loginUser($user);
|
||||
$client->request('POST', '/mon-compte/evenement/'.$event->getId().'/billet/'.$billet->getId().'/modifier', [
|
||||
'name' => 'Entree Premium',
|
||||
'price_ht' => '2500',
|
||||
'price_ht' => '25.00',
|
||||
'is_generated_billet' => '1',
|
||||
'description' => 'Acces VIP',
|
||||
]);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { describe, it, expect, beforeEach } from 'vitest'
|
||||
import { describe, it, expect, beforeEach, vi } from 'vitest'
|
||||
import { initBilletDesigner } from '../../assets/modules/billet-designer.js'
|
||||
|
||||
describe('initBilletDesigner', () => {
|
||||
@@ -93,4 +93,65 @@ describe('initBilletDesigner', () => {
|
||||
const iframe = document.getElementById('billet-preview-frame')
|
||||
expect(iframe.src).toContain('bg_color=%23aabbcc')
|
||||
})
|
||||
|
||||
it('saves design on save button click', () => {
|
||||
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="color" name="accent_color" value="#4f46e5">
|
||||
<input type="text" name="invitation_title" value="VIP">
|
||||
<iframe id="billet-preview-frame" src="/preview"></iframe>
|
||||
<button id="billet-save-design"></button>
|
||||
</div>
|
||||
`
|
||||
|
||||
initBilletDesigner()
|
||||
document.getElementById('billet-save-design').click()
|
||||
|
||||
expect(fetchMock).toHaveBeenCalledWith('/save', expect.objectContaining({
|
||||
method: 'POST',
|
||||
}))
|
||||
})
|
||||
|
||||
it('save does nothing without save url', () => {
|
||||
const fetchMock = vi.fn()
|
||||
globalThis.fetch = fetchMock
|
||||
|
||||
document.body.innerHTML = `
|
||||
<div id="billet-designer" data-preview-url="/preview">
|
||||
<input type="color" name="accent_color" value="#4f46e5">
|
||||
<iframe id="billet-preview-frame" src="/preview"></iframe>
|
||||
<button id="billet-save-design"></button>
|
||||
</div>
|
||||
`
|
||||
|
||||
initBilletDesigner()
|
||||
document.getElementById('billet-save-design').click()
|
||||
|
||||
expect(fetchMock).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('save includes checkbox 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="checkbox" name="show_logo" checked>
|
||||
<input type="color" name="accent_color" value="#000000">
|
||||
<iframe id="billet-preview-frame" src="/preview"></iframe>
|
||||
<button id="billet-save-design"></button>
|
||||
</div>
|
||||
`
|
||||
|
||||
initBilletDesigner()
|
||||
document.getElementById('billet-save-design').click()
|
||||
|
||||
expect(fetchMock).toHaveBeenCalled()
|
||||
const formData = fetchMock.mock.calls[0][1].body
|
||||
expect(formData.get('show_logo')).toBe('1')
|
||||
expect(formData.get('accent_color')).toBe('#000000')
|
||||
})
|
||||
})
|
||||
|
||||
@@ -217,4 +217,24 @@ describe('initSortable', () => {
|
||||
body: JSON.stringify([3, 1, 2]),
|
||||
})
|
||||
})
|
||||
|
||||
it('initializes billets-list sortable', () => {
|
||||
const list = document.createElement('div')
|
||||
list.classList.add('billets-list')
|
||||
list.dataset.reorderUrl = '/billet-reorder'
|
||||
document.body.appendChild(list)
|
||||
|
||||
const el1 = document.createElement('div')
|
||||
el1.dataset.billetId = '10'
|
||||
list.appendChild(el1)
|
||||
|
||||
const el2 = document.createElement('div')
|
||||
el2.dataset.billetId = '20'
|
||||
list.appendChild(el2)
|
||||
|
||||
initSortable()
|
||||
|
||||
expect(el1.getAttribute('draggable')).toBe('true')
|
||||
expect(el2.getAttribute('draggable')).toBe('true')
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user