mirror of
https://github.com/wekan/wekan.git
synced 2026-11-24 09:59:47 -05:00
Import many boards: on the import page of every source, several export files, or one .zip holding them, each become their own board through the same path a single import of that file takes, and the page lists what each file became (models/lib/importManyFiles.js). A .zip that is itself one export (Vikunja, Notion, Plane, WeKan with attachments) stays one board. One board per project: for the generalized importer, each swimlane the import would make - a project, folder or list of the tool - becomes its own board (models/lib/importSplit.js), so an export of a whole app imports as many boards, as a Trello .zip does. Kanri's all-data export now reads every board, not only the first, so it splits into one board per Kanri board. Export all boards: All Boards sidebar, or Multi-Selection for the selected boards, downloads every board the user may export in one format, each checked as its own export is. Excel is one workbook with a sheet per board, named after the board; every other format is a .zip with one file per board (server/routes/exportAllBoards.js). The per-format bytes are made in one place, server/lib/renderExternalExport.js, for the board route and this. A WeKan .zip export imports as a new board from All Boards, unpacked on the server with its attachments (it was refused in the browser). api.py gains importboardsfrom and exportallboards, sends every source in the shape the import page sends, and fetches Excel, PDF, CSV and TSV exports from their own routes and writes them as bytes. Fixed while documenting: a Trello Butler rule's list name kept its case, so the rule fires; the HTML export fetches the board JSON by URL instead of a link the export popup no longer has; Tasks.org exports time spent; Nextcloud Deck's done flag marks the due date done. docs/Features/ImportExport has a directory per format with the steps to import and export it, one board and many, and its details, moved from Format-Coverage.md, which is now the index and the shared contract. tests/importExportDocsCoverage.test.cjs fails when a format has no page. Thanks to xet7 !
67 lines
3.6 KiB
JavaScript
67 lines
3.6 KiB
JavaScript
'use strict';
|
|
|
|
// Faults found while documenting every import and export format
|
|
// (docs/Features/ImportExport/<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); });
|