UI-tests und fixes aus tests
This commit is contained in:
1 parent
73da8fb849
commit
968d980be1
46 files changed
+3853
-61
No files matched your search
@@ -0,0 +1,74 @@
|
||||
import { describe, it, afterEach, expect, $, click, pressKey, sleep, closeAll, csrf } from './runner.js';
|
||||
|
||||
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();
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user