forked from 1b-agent/opencadstudio-upstream
fix: finalize reviewed drawing and interaction paths
Reset stale geometry when automation replaces a drawing and resolve material paths from its directory. Cover precise indexed snapping, large-coordinate line intersections, leader ordering, invalid image buffers and browser clipboard fallback. Preserve Options dialog resizing. Validation: cargo test --workspace --all-features (866 passed); wasm32 application check; Node clipboard regression check; Python binding tests (3 passed).
This commit is contained in:
1 parent
cf12c6a272
commit
9b112e3ac0
6 files changed
+143
-9
No files matched your search
@@ -0,0 +1,42 @@
|
||||
const assert = require('node:assert/strict');
|
||||
const fs = require('node:fs');
|
||||
const path = require('node:path');
|
||||
|
||||
(async () => {
|
||||
const source = fs.readFileSync(path.join(__dirname, '../web/clipboard.js'), 'utf8');
|
||||
const { copyHistory } = await import(`data:text/javascript;base64,${Buffer.from(source).toString('base64')}`);
|
||||
const text = 'LINE\n0,0\n10,10\n<unchanged & literal>\n';
|
||||
let copied;
|
||||
Object.defineProperty(globalThis, 'navigator', { configurable: true, value: {
|
||||
clipboard: { writeText: async value => { copied = value; } },
|
||||
}});
|
||||
assert.equal(await copyHistory(text, 'Copy manually', 'Close'), true);
|
||||
assert.equal(copied, text);
|
||||
const dialogs = [];
|
||||
globalThis.document = {
|
||||
body: { append: dialog => dialogs.push(dialog) },
|
||||
createElement: tag => ({
|
||||
tag, style: {}, events: {},
|
||||
setAttribute(key, value) { this[key] = value; },
|
||||
append(...children) { this.children = children; },
|
||||
addEventListener(event, handler) { this.events[event] = handler; },
|
||||
showModal() { this.open = true; },
|
||||
focus() { this.focused = true; },
|
||||
select() { this.selected = true; },
|
||||
close() { this.events.close(); },
|
||||
remove() { this.removed = true; },
|
||||
}),
|
||||
};
|
||||
for (const clipboard of [{ writeText: async () => { throw Error('Denied'); } }, undefined]) {
|
||||
navigator.clipboard = clipboard;
|
||||
assert.equal(await copyHistory(text, 'Copy manually', 'Close'), false);
|
||||
const dialog = dialogs.at(-1);
|
||||
const [label, field, close] = dialog.children;
|
||||
assert.equal(label.textContent, 'Copy manually');
|
||||
assert.equal(field.value, text);
|
||||
assert.ok(field.readOnly && field.focused && field.selected && dialog.open);
|
||||
close.onclick();
|
||||
assert.ok(dialog.removed);
|
||||
}
|
||||
console.log('Browser clipboard: success, denied and unavailable paths passed.');
|
||||
})().catch(error => { console.error(error); process.exitCode = 1; });
|
||||
Reference in new issue
Block a user