Refractoring Stage 6.6 Migrated productivity.js and shortcuts.js mail-state access and render/preferences hooks to the mail feature API.

This commit is contained in:
2026-10-16 21:03:40 +03:00
parent 84a63441ef
commit 38340442f0
21 changed files with 389 additions and 293 deletions
+8
View File
@@ -2,6 +2,7 @@ const test = require('node:test');
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 read = file => fs.readFileSync(path.join(root, file), 'utf8');
@@ -27,3 +28,10 @@ test('desktop, Android web generation, and offline cache include renderer suppor
assert.ok(worker.includes(`'./${file}'`), `service worker is missing ${file}`);
}
});
test('classic renderer scripts have no duplicate global lexical declarations', () => {
const html = read('index.html');
const scripts = [...html.matchAll(/<script src="([^"]+)"/g)].map(match => match[1]);
const source = scripts.map(script => read(script)).join('\n');
assert.doesNotThrow(() => new vm.Script(source, { filename: 'renderer-classic-scripts.js' }));
});
+6
View File
@@ -62,12 +62,18 @@ test('account and snooze UI consume the explicit mail API instead of selected le
const snoozeUi = fs.readFileSync(path.join(root, 'snooze-ui.js'), 'utf8');
const attachmentUi = fs.readFileSync(path.join(root, 'attachments.js'), 'utf8');
const pgpMailUi = fs.readFileSync(path.join(root, 'pgp-mail-ui.js'), 'utf8');
const shortcutsUi = fs.readFileSync(path.join(root, 'shortcuts.js'), 'utf8');
const productivityUi = fs.readFileSync(path.join(root, 'productivity.js'), 'utf8');
assert.match(accountUi, /window\.epMailFeatures\.mail/);
assert.match(snoozeUi, /window\.epMailFeatures\.mail/);
assert.match(attachmentUi, /window\.epMailFeatures\.mail/);
assert.match(pgpMailUi, /window\.epMailFeatures\.mail/);
assert.match(shortcutsUi, /window\.epMailFeatures\.mail/);
assert.match(shortcutsUi, /window\.epMailFeatures\.productivity/);
assert.doesNotMatch(accountUi, /\bconnectedMailAccount\b|\bmailPageOffset\b|(?<!\.)\bsyncMailbox\s*\(/);
assert.doesNotMatch(snoozeUi, /\bconnectedMailAccount\b|(?<!\.)\bactiveFolder\b|(?<!\.)\bselectedIds\b|(?<!\.)\bsyncMailbox\s*\(/);
assert.doesNotMatch(attachmentUi, /\bconnectedMailAccount\b|(?<!\.)\bactiveFolder\b|(?<!\.)\bmessages\.find/);
assert.doesNotMatch(pgpMailUi, /(?<!\.)\bmessages\.find|(?<!\.)\bactiveMessage\b|window\.pgpPrepareSend/);
assert.match(productivityUi, /window\.epMailFeatures\.productivity/);
assert.doesNotMatch(shortcutsUi, /(?<!\.)\bactiveMessage\b|(?<!\.)\bopenMessage\s*\(/);
});