Join nonempty rule description fragments without browser globals

This commit is contained in:
Lauri Ojansivu committed 2026-09-14 19:04:42 +03:00
1 parent f332c63b47
commit 0c51a3261f
3 files changed
+82 -12

No files matched your search

+11 -12
View File
@@ -1121,26 +1121,27 @@ export const Utils = {
getTriggerActionDesc(event, tempInstance) {
const jqueryEl = tempInstance.$(event.currentTarget.parentNode);
const triggerEls = jqueryEl.find('.trigger-content').children();
let finalString = '';
const parts = [];
for (let i = 0; i < triggerEls.length; i++) {
const element = tempInstance.$(triggerEls[i]);
let part = '';
if (element.hasClass('trigger-text')) {
finalString += element.text().toLowerCase();
part = element.text().toLowerCase();
} else if (element.hasClass('user-details')) {
let username = element.find('input').val();
if (username === undefined || username === '') {
username = '*';
}
finalString += `${element
part = `${element
.find('.trigger-text')
.text()
.toLowerCase()} ${username}`;
} else if (element.find('.js-calendar-toggle').length > 0) {
finalString += element.find('.js-calendar-toggle').text().trim();
part = element.find('.js-calendar-toggle').text().trim();
} else if (element.find('.js-calendar-native-time').length > 0) {
finalString += element.find('.js-calendar-native-time').val();
part = element.find('.js-calendar-native-time').val();
} else if (element.find('select').length > 0) {
finalString += element
part = element
.find('select option:selected')
.text()
.toLowerCase();
@@ -1149,14 +1150,12 @@ export const Utils = {
if (inputvalue === undefined || inputvalue === '') {
inputvalue = '*';
}
finalString += inputvalue;
}
// Add space
if (i !== length - 1) {
finalString += ' ';
part = inputvalue;
}
// Buttons and omitted copulas contribute no text or separator.
if (part !== '') parts.push(part);
}
return finalString;
return parts.join(' ');
},
fallbackCopyTextToClipboard(text) {
@@ -228,3 +228,22 @@ control rows, a persisted checklist description and English ordering.
It is syntax checked but not executed: localhost:3000 has no listening app.
The four restored findings remain open pending browser and full native
phrase verification; compilation alone does not prove their final acceptance.
## 2026-09-14 — Saved-description execution verified
The actual getTriggerActionDesc method was extracted and executed in a VM
with DOM/jQuery controls modeled at its boundary. It initially threw because
separator handling referenced the browser-global length. The method now joins
nonempty control fragments, omitting buttons/empty linking-verb text without
leading/trailing separators or depending on browser frame count. Input values,
wildcards, option casing and existing date/time/user-detail branches are kept.
Execution tests verify all four Basque subject phrases in name-first order,
checked/unchecked predicates, literal name markup/emoji text, blank copulas,
buttons, wildcards, user-details and date/time controls. English keeps its
original noun-first order. All Jade templates compile; the browser spec is
successfully registered by Playwright --list with the line reporter. Its
initial default HTML reporter lacked permission to overwrite an existing
report; changing only the reporter resolved registration without filesystem
permission changes. Browser execution and full native fluency remain open.
Four restored and 283 pending findings are not reclassified from VM checks.
+52
View File
@@ -0,0 +1,52 @@
'use strict';
const assert = require('node:assert/strict');
const fs = require('node:fs');
const path = require('node:path');
const vm = require('node:vm');
const root = path.resolve(__dirname, '..');
const source = fs.readFileSync(path.join(root, 'client/lib/utils.js'), 'utf8');
const start = source.indexOf('getTriggerActionDesc(event, tempInstance) {');
assert.ok(start >= 0);
const end = source.indexOf('\n },', start) + 5;
// Execute the production method, without browser globals or a second algorithm.
const describe = vm.runInNewContext(`({${source.slice(start, end)}}).getTriggerActionDesc`);
const eu = JSON.parse(fs.readFileSync(path.join(root, 'imports/i18n/data/eu.i18n.json')));
const empty = { length: 0 };
function element(kind, value) {
return {
hasClass: name => name === (kind === 'text' ? 'trigger-text' : kind === 'user' ? 'user-details' : 'trigger-dropdown'),
text: () => value,
find(selector) {
if (kind === 'date' && selector === '.js-calendar-toggle') return { length: 1, text: () => value };
if (kind === 'time' && selector === '.js-calendar-native-time') return { length: 1, val: () => value };
if (kind === 'user' && selector === 'input') return { length: 1, val: () => value };
if (kind === 'user' && selector === '.trigger-text') return { length: 1, text: () => 'Nork:' };
if (kind === 'select' && (selector === 'select' || selector === 'select option:selected')) return { length: 1, text: () => value };
if (kind === 'input' && selector === 'input') return { length: 1, val: () => value };
return empty;
},
};
}
function run(elements) {
const container = { find: () => ({ children: () => elements }) };
return describe({ currentTarget: { parentNode: container } }, { $: value => value });
}
for (const key of ['r-when-the-label', 'r-when-the-member', 'r-when-the-checklist', 'r-when-the-item']) {
for (const action of ['r-checked', 'r-unchecked']) {
const result = run([element('input', 'Demo :heart:'), element('text', eu[key]), element('text', ''), element('text', eu[action]), element('button', '')]);
assert.equal(result, `Demo :heart: ${eu[key].toLowerCase()} ${eu[action].toLowerCase()}`);
assert.doesNotMatch(result, /hau Demo/);
assert.equal(result, result.trim(), 'description has no trailing separator');
}
}
assert.equal(run([element('text', 'When the label'), element('select', 'URGENT'), element('text', 'is added')]),
'when the label urgent is added', 'other-language order and existing option casing remain');
assert.equal(run([element('input', undefined), element('text', 'Kide hau')]), '* kide hau');
assert.equal(run([element('input', '<b>Demo</b>'), element('text', 'Kide hau')]), '<b>Demo</b> kide hau', 'names remain data; no markup renderer is called');
console.log('Basque saved descriptions: actual production method preserves subject order and input names; no window length dependency');
assert.equal(run([element('text', 'When'), element('date', ' 1405-06-23 '), element('time', '09:30'), element('user', 'Demo')]),
'when 1405-06-23 09:30 nork: Demo');
assert.equal(run([element('user', '')]), 'nork: *');
assert.equal(run([element('input', ' Demo '), element('text', 'Kide hau')]), ' Demo kide hau', 'input whitespace is preserved as data');
assert.equal(run([element('button', ''), element('text', '')]), '');