Files
wekan/tests/playwrightAttachmentCleanup.test.cjs
T
Lauri Ojansivu 721805b800 Fix source development startup warnings and browser fixture cleanup
Cache Meteor package transforms, make development DEBUG logging opt-in, and replace legacy CAS URL parsing while preserving callback encoding and custom HTTPS ports. Clean attachment metadata during browser fixture teardown, including failure paths.

Verify six focused Node suites, nine sequential browser checks across Chromium, Firefox and WebKit, and live HTTP requests with deprecation tracing. Document the package cache and verification limits.

Thanks to xet7.
2026-09-20 12:25:56 +03:00

33 lines
1.4 KiB
JavaScript

'use strict';
const assert = require('node:assert/strict');
const fs = require('node:fs');
const vm = require('node:vm');
const { EJSON } = require('bson');
const records = [
{ _id: 'owned', meta: { boardId: 'test-board' } },
{ _id: 'other', meta: { boardId: 'other-board' } },
{ _id: 'unscoped', meta: {} },
];
const sandbox = { module: { exports: {} }, process, __dirname: require('node:path').resolve('tests/playwright/helpers'),
require(name) {
if (name !== 'child_process') return require(name);
return { execFileSync(_node, _args, options) {
for (const op of EJSON.parse(options.input).ops) {
if (op.collection !== 'attachments') continue;
assert.equal(op.method, 'deleteMany');
assert.deepEqual(Object.keys(op.filter), ['meta.boardId']);
for (let i = records.length - 1; i >= 0; i--) {
if (records[i].meta.boardId === op.filter['meta.boardId']) records.splice(i, 1);
}
}
return '{}';
} };
},
};
vm.runInNewContext(fs.readFileSync('tests/playwright/helpers/db.js', 'utf8'), sandbox);
sandbox.module.exports.cleanup({ boardIds: ['test-board'] });
assert.deepEqual(records.map(row => row._id), ['other', 'unscoped']);
sandbox.module.exports.cleanup({ boardIds: [] });
assert.equal(records.length, 2);
console.log('Browser fixture cleanup removes owned attachment metadata and preserves other/unscoped records.');