mirror of
https://github.com/wekan/wekan.git
synced 2026-11-25 04:49:41 -05:00
Board import no longer asks for member mapping up front. Every imported member is
brought in as a virtual (placeholder) user carrying its avatar, username and full
name (the existing createPlaceholderUsers path), added to the board inactive with
no permissions. The client import flow is now a single step that imports
immediately with an empty mapping -- no map-members screen, nothing to get stuck
on.
Mapping a virtual member to an existing user is a deliberate, later action done by
a board admin from the board sidebar member-avatar popup ("Map to existing user"),
and CANNOT be used to gain privileges: the new board-scoped method
mapImportedBoardMember only maps a virtual member onto an existing ACTIVE, REAL
member of the SAME board and never changes that member's role (so no new
membership is created and nothing is escalated); authorization and this guarantee
live in the pure planBoardMemberMapping helper. The mapping reassigns the virtual
member's cards/comments/activities ON THAT BOARD to the target and removes the
placeholder from the board.
Automatic hang mitigation so an import can never spin forever: a client watchdog
surfaces an import-timeout and clears the spinner if importBoard does not answer in
WEKAN_IMPORT_TIMEOUT_MS (default 2 min), and the server bounds creator.create with
the same deadline via a new generic withDeadline() wrapper.
Covered by tests/boardMemberMapPlan.test.cjs (no-escalation + auth matrix),
tests/withDeadline.test.cjs (deadline wrapper) and tests/importVirtualMembers.test.cjs
(wiring).
Thanks to xet7 !
48 lines
1.9 KiB
JavaScript
48 lines
1.9 KiB
JavaScript
'use strict';
|
|
|
|
// Unit tests for the generic hang-mitigation deadline wrapper
|
|
// (models/lib/withDeadline.js): a long/hung operation must never block forever — the
|
|
// wrapper rejects with a timeout error while letting fast operations pass through.
|
|
//
|
|
// Run: node tests/withDeadline.test.cjs
|
|
|
|
const assert = require('assert');
|
|
const { withDeadline } = require('../models/lib/withDeadline.js');
|
|
|
|
(async () => {
|
|
let passed = 0;
|
|
const ok = (name) => { passed += 1; console.log(' ok -', name); };
|
|
|
|
// Resolves with the value when the promise settles before the deadline.
|
|
assert.strictEqual(await withDeadline(Promise.resolve(42), 1000), 42);
|
|
ok('passes through a value that settles in time');
|
|
|
|
// Rejects with the caller's timeout error when the promise never settles.
|
|
let err;
|
|
try { await withDeadline(new Promise(() => {}), 20, () => new Error('op-timeout')); }
|
|
catch (e) { err = e; }
|
|
assert.ok(err && err.message === 'op-timeout', 'uses onTimeout() error');
|
|
ok('rejects with the custom timeout error when it hangs');
|
|
|
|
// A default timeout error is used when no onTimeout is given.
|
|
err = null;
|
|
try { await withDeadline(new Promise(() => {}), 20); }
|
|
catch (e) { err = e; }
|
|
assert.ok(err && /timeout/i.test(err.message), 'has a default timeout error');
|
|
ok('has a default timeout error');
|
|
|
|
// The promise's own rejection propagates (not masked by the deadline).
|
|
err = null;
|
|
try { await withDeadline(Promise.reject(new Error('boom')), 1000); }
|
|
catch (e) { err = e; }
|
|
assert.strictEqual(err.message, 'boom');
|
|
ok('propagates the underlying rejection');
|
|
|
|
// ms <= 0 means "no deadline": just awaits the promise.
|
|
assert.strictEqual(await withDeadline(Promise.resolve('x'), 0), 'x');
|
|
assert.strictEqual(await withDeadline(Promise.resolve('y'), -5), 'y');
|
|
ok('treats a non-positive deadline as no deadline');
|
|
|
|
console.log(`\nwithDeadline: ${passed} tests passed`);
|
|
})().catch(e => { console.error('FAIL', e); process.exit(1); });
|