mirror of
https://github.com/wekan/wekan.git
synced 2026-11-24 18:10:06 -05:00
Use a stable database ID for new list/source/issue mappings. Stop on creation conflicts without replacing moved cards or claiming successful reconciliation. Cover concurrent database writers, browser clients, moved-card recovery and unrelated database failures. Thanks to xet7.
18 lines
839 B
JavaScript
18 lines
839 B
JavaScript
'use strict';
|
|
const { test } = require('node:test');
|
|
const assert = require('node:assert/strict');
|
|
const { listSyncCardId } = require('../server/lib/listSyncCardId');
|
|
|
|
test('Sync creation identity is stable and isolates lists, sources and issues', () => {
|
|
const id = listSyncCardId('list', 'source', 'issue');
|
|
assert.equal(listSyncCardId('list', 'source', 'issue'), id);
|
|
assert.match(id, /^sync-[a-f0-9]{64}$/);
|
|
for (const tuple of [['other', 'source', 'issue'], ['list', 'other', 'issue'],
|
|
['list', 'source', 'other'], ['list:source', 'issue', ''],
|
|
['list', 'source:issue', '']]) {
|
|
assert.notEqual(listSyncCardId(...tuple), id);
|
|
}
|
|
assert.notEqual(listSyncCardId('a', 'b:c', 'd'), listSyncCardId('a:b', 'c', 'd'));
|
|
assert.equal(listSyncCardId('list', 'source', 123), listSyncCardId('list', 'source', '123'));
|
|
});
|