tests: assert new appointments don't inherit the active bucket

Opens the editor twice against a real bucket as activeBucket: once
with a #termin-seeded body (should stay empty in inp-bucket) and
once with a plain body (should pick up the active bucket id).
Skipped on fresh DBs that have no buckets to inherit from.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
thandClaude Opus 4.6 committed 2026-04-15 22:06:10 +02:00
1 parent 0e3088db9a
commit b08bdbaeb2
1 file changed
+38
+38
View File
@@ -72,3 +72,41 @@ describe('Editor: Card Create', () => {
expect(document.querySelector(`[data-id="${res.id}"]`)).toExist(); 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));
});
});