plugin infrastruktur

This commit is contained in:
th committed 2026-04-10 07:57:53 +02:00
1 parent dd2a995f6c
commit 1545b90f39
43 files changed

No files matched your search

@@ -0,0 +1,53 @@
import { describe, it, afterEach, expect, $, click, pressKey, sleep, closeAll, csrf } from './runner.js';
describe('Image Fullscreen Viewer', () => {
afterEach(async () => {
// Close fullscreen if open
document.querySelector('.detail-image-fs-overlay')?.remove();
await closeAll();
});
it('fullscreen overlay has required elements when opened', async () => {
// Create card with image reference
const res = await fetch('api/cards', {
method: 'POST', headers: { 'Content-Type': 'application/json', 'X-CSRF-Token': csrf() },
body: JSON.stringify({ title: '__test_img_fs__', body: '![test](uploads/nonexist.jpg)', color: '#38bdf8' }),
}).then(r => r.json());
await window._reloadAll?.();
await sleep(200);
// Ensure non-split mode
if (!$('#board-preview')?.classList.contains('hidden')) {
click('#board-split-toggle');
await sleep(100);
}
// Open detail
const cardEl = document.querySelector(`[data-id="${res.id}"]`);
if (!cardEl) return;
click(cardEl);
await sleep(300);
// Check that images in detail would get fullscreen handler
// The overlay is created lazily, verify the create function structure
const { bindDetailImageFullscreen } = await import('../modules/detail.js');
expect(typeof bindDetailImageFullscreen).toBe('function');
});
it('overlay structure is correct when created', () => {
// Manually create to test structure
const overlay = document.createElement('div');
overlay.className = 'detail-image-fs-overlay';
overlay.innerHTML = `
<button class="detail-image-fs-close"></button>
<button class="detail-image-fs-prev"></button>
<button class="detail-image-fs-next"></button>
<div class="detail-image-fs-counter"></div>
<div class="detail-image-fs-stage"><img class="detail-image-fs-img" alt=""></div>
`;
expect(overlay.querySelector('.detail-image-fs-close')).toExist();
expect(overlay.querySelector('.detail-image-fs-prev')).toExist();
expect(overlay.querySelector('.detail-image-fs-next')).toExist();
expect(overlay.querySelector('.detail-image-fs-img')).toExist();
});
});