Files
hyprcrd/public/plugins/tests/buckets.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

89 lines
3.3 KiB
JavaScript

import { describe, it, afterEach, expect, $, $$, click, sleep, closeAll, csrf } from './runner.js?v=4';
import { state } from '../../js/modules/state.js';
describe('Bucket Bar', () => {
afterEach(() => closeAll());
it('renders bucket tabs', () => {
const tabs = $$('#bucket-bar [data-bucket]');
expect(tabs.length).toBeGreaterThan(0); // at least "all"
});
it('has "all" bucket', () => {
const all = document.querySelector('#bucket-bar [data-bucket="all"]');
expect(all).toExist();
});
it('clicking bucket filters cards', async () => {
const tabs = $$('#bucket-bar [data-bucket]');
const bucketTab = tabs.find(t => t.dataset.bucket !== 'all' && t.dataset.bucket !== 'current' && t.dataset.bucket !== 'favorites' && t.dataset.bucket !== 'journal' && t.dataset.bucket !== 'none');
if (!bucketTab) return;
click(bucketTab);
await sleep(200);
expect(state.activeBucket).toBe(bucketTab.dataset.bucket);
// Reset
click(document.querySelector('#bucket-bar [data-bucket="all"]'));
await sleep(100);
});
it('"current" bucket works', async () => {
const cur = document.querySelector('#bucket-bar [data-bucket="current"]');
if (!cur) return;
click(cur);
await sleep(200);
expect(state.activeBucket).toBe('current');
click(document.querySelector('#bucket-bar [data-bucket="all"]'));
await sleep(100);
});
it('"journal" bucket works', async () => {
const jour = document.querySelector('#bucket-bar [data-bucket="journal"]');
if (!jour) return;
click(jour);
await sleep(200);
expect(state.activeBucket).toBe('journal');
click(document.querySelector('#bucket-bar [data-bucket="all"]'));
await sleep(100);
});
it('"unsorted" bucket works', async () => {
const none = document.querySelector('#bucket-bar [data-bucket="none"]');
if (!none) return;
click(none);
await sleep(200);
expect(state.activeBucket).toBe('none');
click(document.querySelector('#bucket-bar [data-bucket="all"]'));
await sleep(100);
});
});
describe('Bucket: Create & Delete via API', () => {
it('new bucket appears in bucket bar', async () => {
const b = await fetch('api/buckets', {
method: 'POST', headers: { 'Content-Type': 'application/json', 'X-CSRF-Token': csrf() },
body: JSON.stringify({ name: '__test_bkt_bar__' }),
}).then(r => r.json());
await window._reloadAll?.();
await sleep(200);
const tab = document.querySelector(`#bucket-bar [data-bucket="${b.id}"]`);
expect(tab).toExist();
});
it('deleted bucket disappears from bar', async () => {
const b = await fetch('api/buckets', {
method: 'POST', headers: { 'Content-Type': 'application/json', 'X-CSRF-Token': csrf() },
body: JSON.stringify({ name: '__test_bkt_del__' }),
}).then(r => r.json());
await window._reloadAll?.();
await sleep(100);
await fetch(`api/buckets/${b.id}`, { method: 'DELETE', headers: { 'X-CSRF-Token': csrf() } });
await window._reloadAll?.();
await sleep(200);
expect(document.querySelector(`#bucket-bar [data-bucket="${b.id}"]`)).toBe(null);
});
});