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 !
110 lines
5.6 KiB
JavaScript
110 lines
5.6 KiB
JavaScript
'use strict';
|
|
|
|
// GitLab issue import and Sync source (models/lib/externalParsers.js), #2698.
|
|
// Run: node tests/gitlabImport.test.cjs
|
|
//
|
|
// parseGitlab used to keep only title, description, state, due date, the
|
|
// first assignee, author and labels, and silently dropped the rest of an
|
|
// Issues API v4 issue. It now meets docs/Features/Board-Sidebar/Board-Settings/Import-Export/Format-
|
|
// Coverage.md like the GitHub adapter: every field either lands on the card,
|
|
// becomes a tag or custom field, or is named in the `unsupported` report.
|
|
|
|
const assert = require('assert');
|
|
|
|
async function main() {
|
|
const { parseGitlab } = await import('../models/lib/externalParsers.js');
|
|
const plan = await import('../models/lib/importedTaskPlan.js');
|
|
let passed = 0;
|
|
const test = (name, fn) => { fn(); passed += 1; console.log(' ok -', name); };
|
|
|
|
const issues = [
|
|
{
|
|
id: 901, iid: 7, title: 'Crash on save', description: 'Steps', state: 'opened',
|
|
labels: [{ name: 'bug', color: '#ff0000' }, 'backend'],
|
|
assignee: { username: 'alice' }, assignees: [{ username: 'alice' }, { username: 'bob' }],
|
|
author: { username: 'carol', name: 'Carol' },
|
|
milestone: { title: 'v2.0', due_date: '2026-10-01' }, iteration: { title: 'Sprint 4' },
|
|
weight: 3, confidential: true, issue_type: 'incident',
|
|
time_stats: { time_estimate: 7200, total_time_spent: 5400 },
|
|
task_completion_status: { count: 4, completed_count: 1 },
|
|
created_at: '2026-01-02T03:04:05Z',
|
|
references: { full: 'group/project#7' }, web_url: 'https://gitlab.example/group/project/-/issues/7',
|
|
notes: [
|
|
{ body: 'I can reproduce', author: { username: 'dave', name: 'Dave' }, created_at: '2026-01-03T00:00:00Z' },
|
|
{ body: 'added ~bug label', system: true, author: { username: 'gitlab' } },
|
|
],
|
|
links: [{ iid: 8, link_type: 'blocks' }, { iid: 99, link_type: 'relates_to' }],
|
|
epic: { id: 1 },
|
|
},
|
|
{ id: 902, iid: 8, title: 'Closed one', state: 'closed', closed_at: '2026-02-01T00:00:00Z', user_notes_count: 2 },
|
|
];
|
|
const result = parseGitlab(issues);
|
|
const [open, closed] = result.tasks;
|
|
|
|
test('title, state, iid key and the source link', () => {
|
|
assert.equal(open.externalId, '7');
|
|
assert.equal(open.ref, '7');
|
|
assert.equal(open.column_name, 'Open');
|
|
assert.equal(closed.column_name, 'Closed');
|
|
assert.match(open.description, /^Steps\n\nSource: group\/project#7 https:\/\/gitlab\.example\/group\/project\/-\/issues\/7$/);
|
|
});
|
|
|
|
test('every assignee, the author and the dates', () => {
|
|
assert.equal(open.owner_username, 'alice');
|
|
assert.deepEqual(open.assignees, ['bob'], 'the second assignee is no longer only a tag');
|
|
assert.equal(open.requested_by, 'carol');
|
|
assert.equal(open.date_due, '2026-10-01');
|
|
assert.equal(open.date_creation, '2026-01-02T03:04:05Z');
|
|
assert.equal(open.date_end, undefined, 'an open issue has no end');
|
|
assert.equal(closed.date_end, '2026-02-01T00:00:00Z');
|
|
});
|
|
|
|
test('labels with details, milestone, iteration, type and confidentiality become tags', () => {
|
|
assert.deepEqual(open.tags, ['bug', 'backend', 'milestone:v2.0', 'iteration:Sprint 4', 'type:incident', 'confidential']);
|
|
assert.ok(result.warnings.some(w => /confidential/.test(w)), 'confidential content is warned about');
|
|
});
|
|
|
|
test('time, weight and task completion', () => {
|
|
assert.equal(open.spent_hours, 1.5);
|
|
assert.deepEqual(open.custom_fields, { Weight: 3, 'Time estimate (hours)': 2, Tasks: '1/4' });
|
|
});
|
|
|
|
test('comments exclude system notes; links become dependencies', () => {
|
|
assert.deepEqual(open.comments, [{ text: 'I can reproduce', author: 'dave', authorName: 'Dave', date: '2026-01-03T00:00:00Z' }]);
|
|
assert.deepEqual(open.dependencies, [{ ref: '8', type: 'blocks' }, { ref: '99', type: 'related-to' }]);
|
|
});
|
|
|
|
test('what has no place is reported, not dropped (negative)', () => {
|
|
assert.ok(result.unsupported.some(u => u.path === '/0/epic'));
|
|
assert.ok(result.unsupported.some(u => u.path === '/1/user_notes_count' && /2 comment/.test(u.reason)),
|
|
'comments that exist upstream but were not exported are reported');
|
|
assert.ok(!result.unsupported.some(u => u.path === '/0/user_notes_count'), 'embedded notes are not reported missing');
|
|
});
|
|
|
|
test('the planner puts them on the card, and a link outside the import is reported', () => {
|
|
const planned = plan.planImportedTask(open, { members: { alice: 'u-alice', bob: 'u-bob' } });
|
|
assert.deepEqual(planned.memberIds, ['u-alice', 'u-bob']);
|
|
assert.equal(planned.card.spentTime, 1.5);
|
|
assert.equal(planned.card.createdAt.toISOString(), '2026-01-02T03:04:05.000Z');
|
|
assert.equal(planned.comments.length, 1);
|
|
const links = plan.planImportedLinks(result.tasks);
|
|
assert.deepEqual(links.dependencies, [{ index: 0, deps: [{ target: 1, type: 'blocks' }] }]);
|
|
assert.ok(links.unsupported.some(u => /not part of this import/.test(u.reason)), '#99 is reported');
|
|
const fields = plan.planImportedCustomFields(result.tasks);
|
|
assert.ok(fields.fields.some(f => f.name === 'Weight'));
|
|
});
|
|
|
|
test('a minimal or legacy issue still imports', () => {
|
|
const minimal = parseGitlab({ issues: [{ id: 5, title: 'Only an id', state: 'opened', labels: ['x'] }] });
|
|
assert.equal(minimal.tasks[0].externalId, '5');
|
|
assert.equal(minimal.tasks[0].description, '');
|
|
assert.deepEqual(minimal.tasks[0].tags, ['x']);
|
|
assert.deepEqual(minimal.unsupported, []);
|
|
assert.equal(parseGitlab([]).tasks.length, 0);
|
|
});
|
|
|
|
console.log(`\ngitlabImport: ${passed} tests passed`);
|
|
}
|
|
|
|
main().catch(error => { console.error(error); process.exitCode = 1; });
|