56 lines
1.8 KiB
JavaScript
56 lines
1.8 KiB
JavaScript
import { describe, it, afterEach, expect, $, $$, rightClick, sleep } from './runner.js';
|
|
|
|
describe('Context Menu', () => {
|
|
afterEach(async () => {
|
|
document.dispatchEvent(new MouseEvent('click'));
|
|
await sleep(50);
|
|
});
|
|
|
|
it('opens on card right-click', async () => {
|
|
const card = $('#board [data-id]');
|
|
if (!card) return;
|
|
rightClick(card);
|
|
await sleep(150);
|
|
expect($('#ctx-menu').classList.contains('hidden')).toBe(false);
|
|
});
|
|
|
|
it('has all standard actions', async () => {
|
|
const card = $('#board [data-id]');
|
|
if (!card) return;
|
|
rightClick(card);
|
|
await sleep(150);
|
|
const actions = $$('#ctx-items [data-action]').map(b => b.dataset.action);
|
|
for (const a of ['open', 'edit', 'duplicate', 'due-date', 'save-md', 'push-relay', 'favorite', 'color', 'bucket', 'tags', 'delete']) {
|
|
expect(actions).toContain(a);
|
|
}
|
|
});
|
|
|
|
it('has color submenu with presets', async () => {
|
|
const card = $('#board [data-id]');
|
|
if (!card) return;
|
|
rightClick(card);
|
|
await sleep(100);
|
|
const colors = $$('#ctx-color-grid [data-ctx-color]');
|
|
expect(colors.length).toBeGreaterThan(5);
|
|
});
|
|
|
|
it('has tag submenu with input', async () => {
|
|
const card = $('#board [data-id]');
|
|
if (!card) return;
|
|
rightClick(card);
|
|
await sleep(100);
|
|
expect($('#ctx-tag-input')).toExist();
|
|
expect($('#ctx-tag-list')).toExist();
|
|
});
|
|
|
|
it('closes on document click', async () => {
|
|
const card = $('#board [data-id]');
|
|
if (!card) return;
|
|
rightClick(card);
|
|
await sleep(100);
|
|
document.dispatchEvent(new MouseEvent('click'));
|
|
await sleep(50);
|
|
expect($('#ctx-menu').classList.contains('hidden')).toBe(true);
|
|
});
|
|
});
|