فینورا پرو - سامانه جامع حسابداری و صدور فاکتور
test(ux): require native click regression against accidental Enter-to-save when Cancel or inputs focused
davoodmehraban89 committed
Oct 30, 2026 at 23:38 UTC
026156ab37a6b73334fe963d5b0a92f4c07d315a
1 file changed
+11
tests/ui-control-structure.test.mjs
+11
@@ -98,3 +98,14 @@ test('Q01: Escape is handled once for nested financial dialogs and shortcut targ
98
assert.match(modal, /shortcuts\.escapeCloses === false/);
99
assert.match(modal, /this\.close\(\)/);
100
});
101
+
102
+test('Q01: pressing plain Enter on focused Cancel, buttons or inputs must not invoke global save', () => {
103
+ const shortcuts = fs.readFileSync(path.join(root, 'src','core','KeyboardShortcuts.js'), 'utf8');
104
+ const nativeAudit = fs.readFileSync(path.join(root,'tests','windows-vm-ui-interaction-audit-browser.js'), 'utf8');
105
+ assert.match(shortcuts, /active !== modal\.querySelector\('\.modal-card'\)/,
106
+ 'plain Enter must only target the dialog surface, never its focused controls');
107
+ assert.match(shortcuts, /e\.key === 'Enter' && !e\.shiftKey && this\.settings\.enterConfirms && modal/);
108
+ assert.match(nativeAudit, /enterOnFocusedCancelDoesNotSave:true/);
109
+ assert.match(nativeAudit, /enterOnInputDoesNotSubmit:true/);
110
+ assert.match(nativeAudit, /'Enter on focused Cancel was hijacked as financial confirmation'/);
111
+});