mirror of
https://github.com/wekan/wekan.git
synced 2026-11-25 17:45:18 -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 !
98 lines
6.9 KiB
JavaScript
98 lines
6.9 KiB
JavaScript
'use strict';
|
|
// The Import page and the Export menu show the other tools grouped by kind,
|
|
// from one table (models/lib/toolGroups.js), so a tool is in the same group
|
|
// whether it is read or written.
|
|
// Run: node --test tests/toolGroups.test.cjs
|
|
const test = require('node:test');
|
|
const assert = require('node:assert');
|
|
const fs = require('node:fs');
|
|
const path = require('node:path');
|
|
const { TOOL_GROUPS, MEMBERS, toolGroupOf, groupTools, withoutCompany } = require('../models/lib/toolGroups');
|
|
|
|
const read = rel => fs.readFileSync(path.join(__dirname, '..', rel), 'utf8');
|
|
const en = JSON.parse(read('imports/i18n/data/en.i18n.json'));
|
|
|
|
test('every import source and every export tool is named in a group, once', () => {
|
|
const importKeys = [...read('models/lib/importSources.js').matchAll(/\{ key: '([a-z]+)', (?:name|product)/g)].map(m => m[1]);
|
|
const exportScope = read('client/components/boards/exportScope.js');
|
|
const json = exportScope.slice(exportScope.indexOf("key: 'json',"), exportScope.indexOf('// Is this popup a whole board'));
|
|
const exportKeys = [...json.matchAll(/key: '([a-z-]+)'/g), ...json.matchAll(/\['([a-z]+)', '[^']+'\]/g)].map(m => m[1])
|
|
.filter(key => key !== 'json' || true);
|
|
const named = Object.values(MEMBERS).flat();
|
|
assert.strictEqual(new Set(named).size, named.length, 'no tool in two groups');
|
|
const missing = [...new Set([...importKeys, ...exportKeys])].filter(key => !named.includes(key));
|
|
assert.deepStrictEqual(missing, [], 'a tool no group names would fall into Kanban without anyone deciding');
|
|
assert.ok(importKeys.length >= 58 && exportKeys.length >= 40);
|
|
});
|
|
|
|
test('the groups are in order, each with a heading in English', () => {
|
|
assert.deepStrictEqual(TOOL_GROUPS.map(g => g.group), ['wekan', '37signals', 'atlassian', 'google', 'microsoft', 'sandstorm',
|
|
'kanban', 'issues', 'tasks', 'spreadsheets', 'text', 'messages', 'website', 'api']);
|
|
for (const g of TOOL_GROUPS.filter(t => t.labelKey)) assert.strictEqual(typeof en[g.labelKey], 'string', g.labelKey);
|
|
assert.deepStrictEqual(['gitlab', 'mail', 'slack', 'csv', 'planka', 'wordpress', 'htmlsite', 'sandstormwordpress'].map(toolGroupOf),
|
|
['issues', 'messages', 'messages', 'spreadsheets', 'api', 'website', 'website', 'sandstorm']);
|
|
});
|
|
|
|
test('grouping keeps the order inside a group and heads only the first of each', () => {
|
|
const out = groupTools([{ key: 'slack' }, { key: 'kanboard' }, { key: 'wekan' }, { key: 'mail' }, { key: 'gitlab' }, { key: 'deck' }]);
|
|
assert.deepStrictEqual(out.map(t => t.key), ['wekan', 'kanboard', 'deck', 'gitlab', 'slack', 'mail']);
|
|
assert.deepStrictEqual(out.map(t => t.groupStart), [true, true, false, true, true, false]);
|
|
assert.deepStrictEqual(out.filter(t => t.groupStart).map(t => t.groupLabelKey), [null, 'tool-group-kanban', 'tool-group-issues', 'tool-group-messages']);
|
|
assert.deepStrictEqual(groupTools([]), []);
|
|
});
|
|
|
|
// 2026-11-20: a company with more than one product is ONE heading with its
|
|
// products under it, without the company's name repeated in each.
|
|
test('a company with several products is headed by its name, which its products drop', () => {
|
|
const out = groupTools([
|
|
{ key: 'slack', name: 'Slack' }, { key: 'mstodo', name: 'Microsoft To Do' }, { key: 'trello', name: 'Trello' },
|
|
{ key: 'planner', label: 'Microsoft Planner' }, { key: 'googlekeep', name: 'Google Keep' }, { key: 'fizzy', name: 'Fizzy' },
|
|
{ key: 'jira', name: 'Jira' }, { key: 'excel', name: 'Excel' }, { key: 'basecamp', name: 'Basecamp' },
|
|
{ key: 'googletakeout', name: 'Google Takeout' }, { key: 'github', name: 'GitHub' },
|
|
]);
|
|
assert.deepStrictEqual(out.map(t => t.name || t.label),
|
|
['Fizzy', 'Basecamp', 'Trello', 'Jira', 'Keep', 'Takeout', 'To Do', 'Planner', 'Excel', 'GitHub', 'Slack']);
|
|
assert.deepStrictEqual(out.filter(t => t.groupStart).map(t => t.groupLabel),
|
|
['37signals', 'Atlassian', 'Google', 'Microsoft', null]);
|
|
assert.deepStrictEqual(out.filter(t => t.groupStart).map(t => t.groupLabelKey), [null, null, null, null, 'tool-group-messages']);
|
|
// 2026-11-21: Lists, Project, Outlook, Teams, OneNote and Azure DevOps Boards
|
|
// joined Microsoft's heading; a name without "Microsoft " stays whole.
|
|
assert.deepStrictEqual(groupTools(['outlook', 'msproject', 'teams', 'onenote', 'mslists', 'azuredevops'].map(key => ({ key,
|
|
name: { outlook: 'Microsoft Outlook (.msg)', msproject: 'Microsoft Project (XML)', teams: 'Microsoft Teams', onenote: 'Microsoft OneNote',
|
|
mslists: 'Microsoft Lists', azuredevops: 'Azure DevOps Boards' }[key] }))).map(t => [t.group, t.name]),
|
|
[['microsoft', 'Outlook (.msg)'], ['microsoft', 'Project (XML)'], ['microsoft', 'Teams'], ['microsoft', 'OneNote'],
|
|
['microsoft', 'Lists'], ['microsoft', 'Azure DevOps Boards']]);
|
|
});
|
|
|
|
test('negative: a company group needs two products, and only its own name is dropped', () => {
|
|
const importNames = new Map([...read('models/lib/importSources.js')
|
|
.matchAll(/\{ key: '([a-z]+)', name: '([^']+)'/g)].map(m => [m[1], m[2]]));
|
|
for (const def of TOOL_GROUPS.filter(g => g.label)) {
|
|
const keys = MEMBERS[def.group];
|
|
assert.ok(keys.every(k => importNames.has(k) || k.startsWith('trello')), `${def.label}: a key that is not a tool`);
|
|
// Trello's three ways out (file, .zip, API) are one product.
|
|
const products = new Set(keys.map(k => k.replace(/^trello.*/, 'trello')));
|
|
assert.ok(products.size >= 2, `${def.label} heads only one product`);
|
|
assert.strictEqual(def.labelKey, undefined, 'a company name is not translated');
|
|
}
|
|
// A product somewhere else keeps its whole name, and a bare company name
|
|
// stays rather than becoming empty.
|
|
assert.deepStrictEqual(groupTools([{ key: 'slack', name: 'Microsoft Slack' }])[0].name, 'Microsoft Slack');
|
|
assert.strictEqual(withoutCompany('Microsoft', 'Microsoft'), 'Microsoft');
|
|
assert.strictEqual(withoutCompany('Microsoftish Tool', 'Microsoft'), 'Microsoftish Tool');
|
|
assert.strictEqual(withoutCompany(undefined, 'Microsoft'), undefined);
|
|
// No product name left in a kind group starts with a company that has a group.
|
|
const companies = TOOL_GROUPS.filter(g => g.label).map(g => g.label);
|
|
const loose = [...importNames].filter(([key, name]) => !TOOL_GROUPS.find(g => g.group === toolGroupOf(key)).label
|
|
&& companies.some(c => name.startsWith(`${c} `)));
|
|
assert.deepStrictEqual(loose, [], 'a company product outside its company group');
|
|
});
|
|
|
|
test('both pages draw the headings', () => {
|
|
assert.match(read('client/components/import/import.jade'), /each importSources\n\s*if groupHeading\n\s*li\.import-source-group \{\{groupHeading\}\}/);
|
|
assert.match(read('client/components/import/import.js'), /groupTools\(IMPORT_SOURCES\.map/);
|
|
assert.match(read('client/components/import/import.js'), /source\.groupLabel \|\| product/);
|
|
assert.match(read('client/components/boards/exportScope.js'), /entry\.groupLabel \|\| group\.heading/);
|
|
assert.match(read('client/components/boards/exportScope.js'), /if \(group\.key !== 'json'\) return \[group\];[\s\S]*groupTools\(group\.entries\)/);
|
|
});
|