mirror of
https://github.com/wekan/wekan.git
synced 2026-11-24 18:10:06 -05:00
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 !
62 lines
1.5 KiB
JavaScript
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');
|