mirror of
https://github.com/wekan/wekan.git
synced 2026-11-24 20:45:00 -05:00
Remove the progressive HTML4/Legacy Omi middleware, cookieless sessions, page controllers, assets, parity refactors, design documents and associated tests. Restore the standard Meteor interface and operations from before the HTML4 work began. Preserve intervening translations, backup screenshots, session upgrades, cryptographic test identifiers, local image storage, document previews and lazy browser loading. Extract the GIF utilities still required by image features into imageGif. Validate the Node suites and add standard-interface and GIF regressions. Two existing failures remain in docsLinksResolve and ruleDetailsLocalization; browser regressions are registered but require a running server. Thanks to xet7 !
47 lines
1.7 KiB
JavaScript
47 lines
1.7 KiB
JavaScript
'use strict';
|
|
|
|
// Plain-Node regression guard (no Meteor) for issue #5282: deleting an
|
|
// attachment could log a client-side "Removed nonexistent document" exception
|
|
// even though the delete itself succeeded — the same publication-churn class
|
|
// as the fixed #3252 for comments and checklists, whose guards attachments
|
|
// never got.
|
|
// Run: node tests/attachmentDeleteGuard.test.cjs
|
|
|
|
const assert = require('assert');
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
|
|
const repoRoot = path.resolve(__dirname, '..');
|
|
const read = rel => fs.readFileSync(path.join(repoRoot, rel), 'utf8');
|
|
|
|
const attachments = read('client/components/cards/attachments.js');
|
|
const comments = read('client/components/activities/comments.js');
|
|
|
|
let passed = 0;
|
|
function test(name, fn) {
|
|
fn();
|
|
passed += 1;
|
|
console.log(' ok -', name);
|
|
}
|
|
|
|
test('attachment delete only removes when the doc is still in the local cache', () => {
|
|
assert.ok(
|
|
/if \(this\._id && ReactiveCache\.getAttachment\(this\._id\)\) \{\s*\n\s*await Attachments\.removeAsync\(this\._id\);/.test(attachments),
|
|
'removeAsync must be guarded by a Minimongo presence check',
|
|
);
|
|
});
|
|
|
|
test('negative: no unguarded removeAsync remains in the delete handler', () => {
|
|
const handler = attachments.match(/'click \.js-confirm-delete'[\s\S]*?\n \}\),/);
|
|
assert.ok(handler, 'delete handler found');
|
|
const body = handler[0];
|
|
const removes = body.match(/Attachments\.removeAsync/g) || [];
|
|
assert.strictEqual(removes.length, 1, 'exactly one remove call, inside the guard');
|
|
});
|
|
|
|
test('the sibling #3252 guard for comments is still in place (same bug class)', () => {
|
|
assert.ok(/CardComments\.findOne\(commentId\)/.test(comments));
|
|
});
|
|
|
|
console.log(`\n${passed} tests passed`);
|