mirror of
https://github.com/wekan/wekan.git
synced 2026-11-24 18:10:06 -05:00
Import and Export have a new group, Website: - WordPress (.xml): WordPress eXtended RSS from Tools -> Export, as Squarespace, Wix and others also write it; written as WordPress reads it. - WordPress REST API (.json): /wp-json/wp/v2/posts and /pages. - Ghost: its JSON export, written as Ghost's importer reads it. - Blogger (.xml): its Atom backup. - Hugo, Jekyll, Eleventy, Astro (.zip): Markdown files with YAML or TOML front matter, and their images; written as content/pages and content/posts. - HTML website, Medium (.zip): a site's .html pages and images, read for their main text; written as the published site itself, ready for any web server, with the cards' attachments beside their pages. - Substack (.zip): posts.csv and the posts' HTML. Each page and post becomes a card in the list of its status (Published, Draft, Pending review, Scheduled, Private), pages in the swimlane Pages and posts in Posts, its content as Markdown, a subpage as a subtask, categories and tags as labels, approved comments as comments, a .zip's images as attachments. A site's HTML is read as text, so no script of it reaches a card; a card's text is written into an exported site escaped, never as markup. Board View / Website shows the board as that website: the cards of its Published list (every list when it has none), Pages as the menu with the subpages, the other cards as posts, newest first, and the cards' attachments - built straight from the board. As a public board's default view in Board Settings / Board View, it is what visitors see at the board's address instead of the kanban; a draft is never shown, not even by its id. Admin Panel / Features can turn it off. The Sandstorm WordPress and Hacker CMS grain imports stay under Sandstorm, by the rule that a platform's apps are listed under it. 12 new strings are translated in every language. Lower-confidence translations: ace, ak, ay, bi, bm, bo, dz, ee, chr, bua, cv, ba, csb, an, co, br, ary, bho, as, am, ckb, iu, kl, ff, fj, gn, gv, kw, ig, ha, haw, ks, kok, fur, hsb, fo, ku, lld, nah, rup, sah, se, sc, scn, nap, qu, sm, pap, lg, nd, ss, nso, rn, om, mg, ny, sn, so, ps, sd, mai, or_IN, my, la, tig, wal, tlh, vo, zgh and ve-PP. Thanks to xet7 !
92 lines
6.2 KiB
JavaScript
92 lines
6.2 KiB
JavaScript
'use strict';
|
|
|
|
// The one description of every import source (models/lib/importSources.js),
|
|
// which the import page, "Import many boards" and api.py's lists follow, and
|
|
// the one path the page reads every source through.
|
|
// Run: node tests/importSources.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 reg = await import('../models/lib/importSources.js');
|
|
const many = await import('../models/lib/importManyFiles.js');
|
|
const { EXTERNAL_PARSERS } = await import('../models/lib/externalParsers.js');
|
|
let passed = 0;
|
|
const test = (name, fn) => { fn(); passed += 1; console.log(' ok -', name); };
|
|
|
|
test('every source is described once, with what its file is sent as', () => {
|
|
const keys = reg.IMPORT_SOURCES.map(s => s.key);
|
|
assert.equal(new Set(keys).size, keys.length, 'no source twice');
|
|
// 44 with Fizzy, the six fetched from a service's API
|
|
// (models/lib/apiImportServices.js), and the ten mail, calendar, chat and
|
|
// note sources (mail ... evernote, Rocket.Chat among them); 2026-11-21 six
|
|
// more of Microsoft's: Azure DevOps Boards, Lists, Project, Outlook, Teams
|
|
// and OneNote; and twelve Sandstorm apps' grain backups.
|
|
// And seven websites (server/lib/websiteImport.js).
|
|
assert.equal(keys.length, 85, "every source the import page offers");
|
|
for (const source of reg.IMPORT_SOURCES) {
|
|
assert.ok(source.product || source.name, source.key);
|
|
assert.ok(['text', 'json', 'excel', 'rows', 'binary', 'zip'].includes(source.send), `${source.key} send`);
|
|
// Only ever a .zip: no text to paste, and read as one export of the tool.
|
|
if (source.send === 'zip') assert.ok(!source.paste && source.zipSend === 'zip' && source.files.join() === '.zip', `${source.key} zip`);
|
|
// A binary source names the extensions it reads as bytes.
|
|
if (source.send === 'binary') assert.ok((source.binaryFiles || []).length, `${source.key} binaryFiles`);
|
|
assert.ok(source.paste || (source.files && source.files.length), `${source.key} can be given somehow`);
|
|
for (const ext of source.files || []) assert.match(ext, /^\.[a-z]+$/, `${source.key} ${ext}`);
|
|
}
|
|
assert.equal(reg.acceptFor('vikunja'), '.zip,.json');
|
|
assert.equal(reg.zipIsOneExport('notion'), true);
|
|
assert.equal(reg.zipIsOneExport('todoist'), false);
|
|
assert.equal(reg.importSource('nope'), null, 'negative: an unknown source is nothing');
|
|
});
|
|
|
|
test('the server knows every source the registry names, and the generalized ones are parsed', () => {
|
|
const shape = read('models/lib/importSourceShape.js');
|
|
const importJs = read('models/import.js');
|
|
for (const source of reg.IMPORT_SOURCES) {
|
|
assert.match(shape, new RegExp(`case '${source.key}':`), `${source.key} has a shape check`);
|
|
// Leo and OPML, and mail, Slack, Google Takeout and Evernote, are decoded on
|
|
// the server only (htmlparser2, mailparser, unzipper - server/lib/messageImports.js).
|
|
// The websites are read there too (server/lib/websiteImport.js, WEBSITE_SOURCES).
|
|
if (source.creator === 'generalized' && !['leo', 'opml', 'kanboard', 'mail', 'googletakeout', 'slack', 'evernote', 'outlook',
|
|
...require('../server/lib/websiteImport.js').WEBSITE_SOURCES].includes(source.key)) {
|
|
assert.equal(typeof EXTERNAL_PARSERS[source.key], 'function', `${source.key} has a parser`);
|
|
}
|
|
if (source.zipSend === 'zip') assert.match(importJs, new RegExp(`case '${source.key}':[\\s\\S]{0,800}?zip`, 'i'), `${source.key} reads its .zip on the server`);
|
|
}
|
|
assert.match(importJs, /new KanboardCreator\(data, 'leo'\)/);
|
|
});
|
|
|
|
test('the many-files lists are read from it', () => {
|
|
assert.deepEqual(many.EXCEL_SOURCES, reg.IMPORT_SOURCES.filter(s => s.send === 'excel').map(s => s.key));
|
|
// Telegram and Discord: the export folder zipped, with the message files beside the JSON.
|
|
assert.deepEqual(many.ZIP_EXPORT_SOURCES.sort(), ['discord', 'fizzy', 'googletakeout', 'htmlsite', 'markdownsite', 'notion', 'onenote', 'outlook', 'plane', 'rocketchat', 'sandstormdavros', 'sandstormethercalc', 'sandstormgogs', 'sandstormhackercms', 'sandstormmutodo', 'sandstormprioritize', 'sandstormradicalecalendar', 'sandstormradicalecontacts', 'sandstormsandchat', 'sandstormwekan', 'sandstormwordpress', 'sandstormyatl', 'slack', 'substack', 'teams', 'telegram', 'vikunja', 'wekan']);
|
|
assert.match(read('api.py'), /ZIP_IMPORT_SOURCES = \{'vikunja', 'notion', 'plane', 'slack', 'googletakeout', 'telegram', 'discord', 'rocketchat', 'fizzy',\s+'outlook', 'teams', 'onenote',\s+'sandstormwekan', [^}]*'sandstormwordpress'\}/);
|
|
assert.deepEqual(many.OWN_CREATOR_SOURCES.sort(), ['csv', 'excel', 'jira', 'trello', 'wekan']);
|
|
// api.py cannot import JavaScript; its lists must agree by hand.
|
|
const api = read('api.py');
|
|
assert.match(api, new RegExp(`EXCEL_IMPORT_SOURCES = \\{${many.EXCEL_SOURCES.map(k => `'${k}'`).join(', ')}\\}`));
|
|
});
|
|
|
|
test('the page reads every source through one path, with one file chooser', () => {
|
|
const page = read('client/components/import/import.js');
|
|
assert.match(page, /import \{ IMPORT_SOURCES, importSource as importSourceSpec, acceptFor, isApiImport \} from '\/models\/lib\/importSources';/);
|
|
assert.match(page, /doc = documentForFile\(dataSource, file\.name \|\| '', new Uint8Array\(await file\.arrayBuffer\(\)\)\);/);
|
|
// Negative: no source has a file-reading branch of its own any more.
|
|
for (const key of ['vikunja', 'notion', 'plane', 'planner', 'monday', 'wrike', 'markdown']) {
|
|
assert.doesNotMatch(page, new RegExp(`if \\(dataSource === '${key}'`), key);
|
|
}
|
|
assert.doesNotMatch(page, /^const IMPORT_SOURCES = \[/m, 'no second list');
|
|
const jade = read('client/components/import/import.jade');
|
|
assert.equal((jade.match(/type="file"/g) || []).length, 3, 'one file chooser, Trello\'s package and Import many boards');
|
|
assert.match(jade, /input\.js-import-file\(id='import-file' type="file" accept="\{\{importAccept\}\}"\)/);
|
|
});
|
|
|
|
console.log(`\nimportSources: ${passed} checks passed`);
|
|
}
|
|
|
|
main().catch(error => { console.error(error); process.exit(1); });
|