mirror of
https://github.com/wekan/wekan.git
synced 2026-11-24 20:45:00 -05:00
The rspack client build treats a `module.exports` file imported into the
client bundle as an ES module and throws
"ES Modules may not assign module.exports" at evaluation time, aborting
the whole client module chain (No such template: swimlane / notifications
/ boardButtons, blank board, missing top bar). This is not an rspack
version regression (the lockfile has pinned ~1.7.x since v8.40); it is
that WeKan added CommonJS helpers to the client bundle.
Convert the 42 client-reachable pure-logic models/lib helpers from
`module.exports = { ... }` to `export { ... }`, and calendarFilter's
internal require('./swimlaneFilter') to an import with a .js extension
(node ESM needs it; rspack/reify tolerate it). Server-only helpers that
use node built-ins (fs/path/child_process) stay CommonJS. The plain-Node
.cjs unit tests for these helpers now use `await import(...js)` (wrapped
in an async IIFE); a source-guard in importVirtualMembers was updated
from module.exports to export. Verified: the full tests/*.test.cjs suite
has the SAME 7 pre-existing failures as before this change and no new
ones.
61 lines
2.7 KiB
JavaScript
61 lines
2.7 KiB
JavaScript
'use strict';
|
|
(async () => {
|
|
|
|
// Plain-Node unit test (no Meteor) for how an imported board member becomes a member of
|
|
// the new board. Run: node tests/importedBoardMemberPlan.test.cjs
|
|
|
|
const assert = require('assert');
|
|
const { planImportedBoardMember } = await import('../models/lib/importedBoardMemberPlan.js');
|
|
|
|
let passed = 0;
|
|
function test(name, fn) {
|
|
fn();
|
|
passed += 1;
|
|
console.log(' ok -', name);
|
|
}
|
|
|
|
const IMPORTER = 'importer-id';
|
|
|
|
// ── positive: original member kept, inactive + non-admin when unmapped ───────
|
|
test('unmapped member is kept by original id, inactive and non-admin', () => {
|
|
const e = planImportedBoardMember({ userId: 'alice', isActive: true, isAdmin: true }, IMPORTER);
|
|
assert.strictEqual(e.userId, 'alice');
|
|
assert.strictEqual(e.wekanId, 'alice');
|
|
assert.strictEqual(e.isActive, false, 'imported member must be inactive until reconciled');
|
|
assert.strictEqual(e.isAdmin, false, 'imported member must not silently gain admin');
|
|
});
|
|
test('supports the id field (client mapper renames userId -> id)', () => {
|
|
const e = planImportedBoardMember({ id: 'bob' }, IMPORTER);
|
|
assert.strictEqual(e.userId, 'bob');
|
|
assert.strictEqual(e.wekanId, 'bob');
|
|
});
|
|
test('a real mapping preserves the mapped role (active + admin)', () => {
|
|
const e = planImportedBoardMember({ userId: 'src', wekanId: 'target', isActive: true, isAdmin: true }, IMPORTER);
|
|
assert.strictEqual(e.userId, 'target');
|
|
assert.strictEqual(e.wekanId, 'target');
|
|
assert.strictEqual(e.isActive, true);
|
|
assert.strictEqual(e.isAdmin, true);
|
|
});
|
|
test('a mapped-but-inactive member stays inactive', () => {
|
|
const e = planImportedBoardMember({ userId: 'src', wekanId: 'target', isActive: false }, IMPORTER);
|
|
assert.strictEqual(e.isActive, false);
|
|
assert.strictEqual(e.isAdmin, false);
|
|
});
|
|
|
|
// ── negative: no member is produced ──────────────────────────────────────────
|
|
test('the importer themselves is not re-added', () => {
|
|
assert.strictEqual(planImportedBoardMember({ userId: IMPORTER, isAdmin: true }, IMPORTER), null);
|
|
assert.strictEqual(planImportedBoardMember({ wekanId: IMPORTER }, IMPORTER), null);
|
|
});
|
|
test('a member with no id is dropped', () => {
|
|
assert.strictEqual(planImportedBoardMember({ isAdmin: true }, IMPORTER), null);
|
|
assert.strictEqual(planImportedBoardMember({}, IMPORTER), null);
|
|
});
|
|
test('null / undefined member is dropped', () => {
|
|
assert.strictEqual(planImportedBoardMember(null, IMPORTER), null);
|
|
assert.strictEqual(planImportedBoardMember(undefined, IMPORTER), null);
|
|
});
|
|
|
|
console.log(`\nimportedBoardMemberPlan: ${passed} tests passed`);
|
|
|
|
})().catch(e => { console.error(e); process.exit(1); }); |