Files
hyprcrd/public/plugins/tests/editor.test.js
thandClaude Opus 4.6 088c225202 runner: bump RUNNER_V ?v=3 → ?v=4 so test-shield removal loads
The test-shield (#test-shield) was added in loader.js (always fresh
via plugin manager ?v=time()) but the removal lives in runner.js
hideProgress(). runner.js was still cached at ?v=3 in the browser,
so the shield stayed after the run. Bumping to ?v=4 in loader.js +
all 42 test files forces a fresh runner.js load.

chore: bump version to 0.9.15

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-12 11:04:23 +02:00

75 lines
2.3 KiB
JavaScript

import { describe, it, afterEach, expect, $, click, pressKey, sleep, closeAll, csrf } from './runner.js?v=4';
describe('Editor: Structure', () => {
it('has all elements', () => {
for (const id of ['modal', 'inp-title', 'editor-body', 'editor-preview', 'color-presets']) {
expect($(`#${id}`)).toExist();
}
});
it('has save buttons', () => {
for (const id of ['modal-save', 'modal-save-close', 'modal-cancel']) {
expect($(`#${id}`)).toExist();
}
});
it('has due date and done toggle', () => {
expect($('#inp-due-date')).toExist();
expect($('#inp-done-toggle')).toExist();
});
});
describe('Editor: Open/Close', () => {
afterEach(() => closeAll());
it('opens on add button', async () => {
click('#add-btn');
await sleep(200);
expect($('#modal')).toBeVisible();
});
it('title field focused on open', async () => {
click('#add-btn');
await sleep(200);
expect(document.activeElement).toBe($('#inp-title'));
});
it('closes on cancel', async () => {
click('#add-btn');
await sleep(100);
click('#modal-cancel');
await sleep(150);
expect($('#modal')).toBeHidden();
});
it('closes on ESC', async () => {
click('#add-btn');
await sleep(100);
pressKey('Escape');
await sleep(150);
expect($('#modal')).toBeHidden();
});
it('opens on board right-click (new card)', async () => {
const board = $('#board');
board.dispatchEvent(new MouseEvent('contextmenu', { bubbles: true, clientX: 100, clientY: 300 }));
await sleep(200);
expect($('#modal')).toBeVisible();
});
});
describe('Editor: Card Create', () => {
afterEach(() => closeAll());
it('creates card via API and shows on board', async () => {
const res = await fetch('api/cards', {
method: 'POST', headers: { 'Content-Type': 'application/json', 'X-CSRF-Token': csrf() },
body: JSON.stringify({ title: '__test_editor__', body: 'body text', color: '#fb7185' }),
}).then(r => r.json());
expect(res.id).toBeGreaterThan(0);
await window._reloadAll?.();
await sleep(200);
expect(document.querySelector(`[data-id="${res.id}"]`)).toExist();
});
});