mirror of
https://github.com/wekan/wekan.git
synced 2026-11-20 09:45:04 -05:00
A feature's guide now sits under the menu it is used from, read from the templates rather than from where somebody once put it: Header-Bar, All-Boards, Pages, Board-Header (search and every Board View), Board-Sidebar (Board Settings, Filter, Members, Labels, Archive), Rules, Swimlanes, Lists, Cards, Member-Settings, Admin-Panel and Login-Page. Topics used from several menus (editor, history, theme, translations, email, troubleshooting) are in General. - Each area has a README mapping its menu entries to their guides and to the template or server module that implements them. Board-Header/README.md lists all 40 Board View entries with the template boardBody.jade renders; five views (Table, Calendar Mode, Time, Timeline, Map) have no guide of their own yet and say so. - Board-View.md listed 25 views while BOARD_VIEWS has 40; it now lists all of them with their English labels. - Pages keep their file names. Where a released changelog links an old path, a "# Moved" page stays there and points to the new one; test-menu.sh skips folders holding only those. - Undo was filed under Login; it is General/Undo now. - Every link in docs, code comments, scripts and tests follows the move; docsLinksResolve checks them all. Tests that read a doc follow it to its new place. boardViewSettings now fails when Board-View.md or Board-Header/README.md differs from BOARD_VIEWS, or names a template boardBody.jade does not render. Thanks to xet7 !
67 lines
3.7 KiB
JavaScript
67 lines
3.7 KiB
JavaScript
'use strict';
|
|
|
|
// Faults found while documenting every import and export format
|
|
// (docs/Features/Board-Sidebar/Board-Settings/Import-Export/<format>/): each is pinned here so it cannot
|
|
// come back. Run: node tests/importExportCodeFixes.test.cjs
|
|
|
|
const assert = require('node:assert/strict');
|
|
const fs = require('node:fs');
|
|
const path = require('node:path');
|
|
const read = file => fs.readFileSync(path.join(__dirname, '..', file), 'utf8');
|
|
|
|
async function main() {
|
|
const { EXTERNAL_PARSERS } = await import('../models/lib/externalParsers.js');
|
|
const { formatTasksOrgBackup, parseTasksOrgBackup } = await import('../models/lib/tasksorgFormat.js');
|
|
let passed = 0;
|
|
const test = (name, fn) => { fn(); passed += 1; console.log(' ok -', name); };
|
|
|
|
test('Trello Butler: the list name keeps its case, so the rule fires on that list', () => {
|
|
const js = read('client/components/rules/rulesImportExport.js');
|
|
assert.match(js, /const added = line\.match\(\/when a card is added to list \["“\]\(\.\+\?\)\["”\]\.\*move the card to the \(top\|bottom\)\/i\);/);
|
|
assert.doesNotMatch(js, /line\.toLowerCase\(\)\.match\(/, 'negative: no lowercased copy is matched for a name');
|
|
});
|
|
|
|
test('HTML export: the board JSON is fetched by URL, not read off a link the popup no longer has', () => {
|
|
const js = read('client/lib/exportHTML.js');
|
|
assert.doesNotMatch(js, /querySelector\('\.download-json-link'\)/);
|
|
assert.match(js, /fetch\(`\/api\/boards\/\$\{encodeURIComponent\(boardId\)\}\/export\?\$\{params\.toString\(\)\}`\)/);
|
|
});
|
|
|
|
test('Nextcloud Deck: done, as a timestamp or as the API\'s true, marks the due date done', () => {
|
|
const board = EXTERNAL_PARSERS.deck({ title: 'D', stacks: [{ title: 'S', cards: [
|
|
{ title: 'api', done: true, duedate: '2026-10-09T00:00:00Z' },
|
|
{ title: 'stamped', done: '2026-10-08T10:00:00Z', duedate: '2026-10-09T00:00:00Z' },
|
|
{ title: 'open', done: false },
|
|
] }] });
|
|
const [api, stamped, open] = board.tasks;
|
|
assert.equal(api.due_complete, true);
|
|
assert.equal(api.date_end, undefined, 'true is not a date');
|
|
assert.equal(stamped.due_complete, true);
|
|
assert.equal(stamped.date_end, '2026-10-08T10:00:00Z');
|
|
assert.equal(open.due_complete, undefined);
|
|
});
|
|
|
|
test('Tasks.org: time spent goes back as elapsedSeconds and imports again', () => {
|
|
const backup = formatTasksOrgBackup({ board: { _id: 'b', title: 'B' }, lists: [{ _id: 'l', title: 'L' }],
|
|
items: [{ cardId: 'c', title: 'Spent', listId: 'l', listTitle: 'L', spentTime: 1.5 }] }, new Date(Date.UTC(2026, 9, 9)));
|
|
const task = backup.data.tasks[0].task;
|
|
assert.equal(task.elapsedSeconds, 5400);
|
|
assert.equal(parseTasksOrgBackup(backup).tasks[0].spent_hours, 1.5);
|
|
const none = formatTasksOrgBackup({ board: { _id: 'b' }, lists: [], items: [{ cardId: 'c', title: 'x' }] }, new Date(0));
|
|
assert.equal(none.data.tasks[0].task.elapsedSeconds, undefined, 'negative: nothing spent writes nothing');
|
|
});
|
|
|
|
test('api.py: exports with routes of their own are fetched there, and written as bytes', () => {
|
|
const api = read('api.py');
|
|
assert.match(api, /elif fmt == 'excel':\s*url = wekanurl \+ apiboards \+ boardid \+ s \+ 'exportExcel'/);
|
|
assert.match(api, /elif fmt == 'pdf':\s*url = wekanurl \+ apiboards \+ boardid \+ s \+ 'exportPDF'/);
|
|
assert.match(api, /params = \{'delimiter': \{'csv': ',', 'scsv': ';', 'tsv': '\\t'\}\[fmt\]\}/);
|
|
assert.match(api, /with open\(outputpath, 'wb'\) as f:\s*f\.write\(response\.content\)/);
|
|
assert.match(api, /def import_document\(source, filepath\):/);
|
|
});
|
|
|
|
console.log(`\nimportExportCodeFixes: ${passed} checks passed`);
|
|
}
|
|
|
|
main().catch(error => { console.error(error); process.exit(1); });
|