Files
wekan/tests/syncRuleEmailReportUi.test.cjs
T
Lauri Ojansivu 4790ffb17f Point three source guards at the undo claim and legacy review code.
changeHistoryQuery pins that History rows change in place only in their
undo flags; the claim that undo and redo now take sets them through
named objects, so the guard reads those and still refuses any other
field. historyRestoreAppliesWhatIsShown pins that undo and redo apply
their own direction; they now reach applyRow through applyClaimed with
that direction. The rule email report UI test's sandbox gains a stub
for the legacy review template that follows in the same file. The rules
each guard pins are unchanged.

Thanks to xet7 !
2026-09-30 03:19:02 +03:00

25 lines
1.8 KiB
JavaScript

'use strict';
const { test } = require('node:test');
const assert = require('node:assert/strict');
const fs = require('node:fs'), vm = require('node:vm');
test('report ignores stale callbacks and destroyed views while sending the current filter', () => {
const source = fs.readFileSync(require.resolve('../client/components/settings/adminProblems'), 'utf8');
let created; const calls = [];
// The legacy rule email review follows in the same file; it is exercised
// by tests/syncRuleEmailLegacy.test.cjs and the Playwright spec.
const context = { Template: { syncRuleEmailRecoveryReports: { onCreated(fn) { created = fn; }, helpers() {}, events() {} },
syncRuleEmailLegacyCommands: { onCreated() {}, helpers() {}, events() {} } },
ReactiveVar: class { constructor(value) { this.value = value; } get() { return this.value; } set(value) { this.value = value; } },
TAPi18n: { __: key => key }, Meteor: { call(method, query, callback) { calls.push({ method, query, callback }); } } };
vm.runInNewContext(source.slice(source.indexOf('Template.syncRuleEmailRecoveryReports.onCreated')), context);
const t = { view: { isDestroyed: false } }; created.call(t);
t.status.set('sent'); t.search.set('abc'); t.load(2);
assert.equal(calls[1].query.page, 2); assert.equal(calls[1].query.status, 'sent'); assert.equal(calls[1].query.search, 'abc');
const current = { rows: [{ commandId: 'current' }], total: 21, page: 2, pageSize: 10 };
calls[1].callback(null, current); calls[0].callback(new Error('stale failure'));
assert.equal(t.result.get(), current); assert.equal(t.error.get(), '');
t.load(); calls[2].callback(new Error('failure')); assert.equal(t.error.get(), 'rule-email-recovery-unavailable');
t.load(); t.view.isDestroyed = true; calls[3].callback(null, current);
assert.equal(t.result.get().rows.length, 0);
});