Files
wekan/tests/datePickerCallbacks.test.cjs
T
Lauri Ojansivu 6c118812f4 Stabilize date editor persistence.
Keep native date and time inputs synchronized with the reactive popup draft, and await every date persistence operation before closing the popup. Add regression coverage for the async callbacks and the Chromium start-date interaction.\n\nThanks to xet7 !
2026-08-19 13:48:00 +03:00

62 lines
1.5 KiB
JavaScript

#!/usr/bin/env node
const assert = require('node:assert/strict');
const fs = require('node:fs');
const path = require('node:path');
const root = path.resolve(__dirname, '..');
const cardDate = fs.readFileSync(
path.join(root, 'client/components/cards/cardDate.js'),
'utf8',
);
const cardDetails = fs.readFileSync(
path.join(root, 'client/components/cards/cardDetails.js'),
'utf8',
);
const datePicker = fs.readFileSync(
path.join(root, 'client/lib/datepicker.js'),
'utf8',
);
for (const method of ['setReceived', 'setStart', 'setDue', 'setEnd']) {
assert.match(
cardDate,
new RegExp(`return currentCard\\.${method}\\(date\\);`),
`${method} callback must return its update promise`,
);
}
for (const method of ['unsetReceived', 'unsetStart', 'unsetDue', 'unsetEnd']) {
assert.match(
cardDate,
new RegExp(`return currentCard\\.${method}\\(\\);`),
`${method} callback must return its update promise`,
);
}
for (const method of [
'cards.setVoteEnd',
'cards.unsetVoteEnd',
'cards.setPokerEnd',
'cards.unsetPokerEnd',
]) {
assert.match(
cardDetails,
new RegExp(`await Meteor\\.callAsync\\('${method.replace('.', '\\.')}'`),
`${method} callback must await the server method`,
);
}
assert.match(
datePicker,
/datePicker\.date\.set\(dateObj\);/,
'a valid edited date must update the reactive popup draft',
);
assert.match(
datePicker,
/datePicker\.date\.set\(draftDate\);/,
'a valid edited time must update the reactive popup draft',
);
console.log('datePickerCallbacks: 14 tests passed');