diff --git a/public/plugins/tests/editor.test.js b/public/plugins/tests/editor.test.js index 078d060..ecfbf00 100644 --- a/public/plugins/tests/editor.test.js +++ b/public/plugins/tests/editor.test.js @@ -72,3 +72,41 @@ describe('Editor: Card Create', () => { expect(document.querySelector(`[data-id="${res.id}"]`)).toExist(); }); }); + +describe('Editor: new-appointment bucket default', () => { + // New appointments (body pre-seeded with #termin / #geburtstag from + // the calendar day-popup template) must not inherit the currently + // active real bucket — they belong to a calendar. Regular new + // cards keep inheriting so the user doesn't have to re-pick. + + afterEach(async () => { + // Close any open modal and restore the runner's baseline bucket. + document.dispatchEvent(new KeyboardEvent('keydown', { key: 'Escape', bubbles: true })); + await sleep(80); + window.state.activeBucket = 'all'; + }); + + it('#termin body forces empty bucket; plain body inherits active', async () => { + const buckets = await fetch('api/buckets').then(r => r.json()); + if (!Array.isArray(buckets) || !buckets.length) return; // nothing to inherit from + const b = buckets[0]; + window.state.activeBucket = b.id; + + // Appointment-flavoured body → inp-bucket stays empty. + window._openModal({ id: null, title: '9999-01-01 — probe', body: '#termin', color: '#fb923c', bucket_id: null }); + await sleep(80); + const apptBucket = $('#inp-bucket').value; + document.dispatchEvent(new KeyboardEvent('keydown', { key: 'Escape', bubbles: true })); + await sleep(120); + + // Plain body → inp-bucket inherits the active bucket id. + window._openModal({ id: null, title: '__test_inherit__', body: '', color: '#38bdf8', bucket_id: null }); + await sleep(80); + const regBucket = $('#inp-bucket').value; + document.dispatchEvent(new KeyboardEvent('keydown', { key: 'Escape', bubbles: true })); + await sleep(120); + + expect(apptBucket).toBe(''); + expect(regBucket).toBe(String(b.id)); + }); +});