Refractoring Stage 6.4 Migrate remaining mail-related consumers and remove transitional global dependencies.
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
const test = require('node:test');
|
||||
const assert = require('node:assert/strict');
|
||||
const fs = require('node:fs');
|
||||
const path = require('node:path');
|
||||
const { createMailUiApi } = require('../renderer-mail-api.js');
|
||||
|
||||
test('mail feature API exposes explicit state and account/sync UI actions', () => {
|
||||
@@ -10,7 +12,9 @@ test('mail feature API exposes explicit state and account/sync UI actions', () =
|
||||
setPageOffset: value => calls.push(['offset', value]),
|
||||
syncMailbox: (...args) => calls.push(['sync', ...args]),
|
||||
updateAccountCard: value => calls.push(['card', value]),
|
||||
renderList: () => calls.push(['render']),
|
||||
getRenderList: () => () => calls.push(['render']),
|
||||
getOpenMessage: () => () => calls.push(['open']),
|
||||
baseRenderList: () => calls.push(['base-render']),
|
||||
emptyReader: () => '<empty>',
|
||||
openMailAccount: value => calls.push(['open-account', value])
|
||||
};
|
||||
@@ -29,8 +33,20 @@ test('mail feature API exposes explicit state and account/sync UI actions', () =
|
||||
api.syncMailbox(false, { offset: 0 });
|
||||
api.updateAccountCard(api.connectedAccount);
|
||||
api.renderList();
|
||||
api.openMessage(1);
|
||||
api.baseRenderList();
|
||||
assert.equal(api.emptyReader(), '<empty>');
|
||||
api.openMailAccount();
|
||||
assert.deepEqual(calls.map(call => call[0]), ['offset', 'sync', 'card', 'render', 'open-account']);
|
||||
assert.deepEqual(calls.map(call => call[0]), ['offset', 'sync', 'card', 'render', 'open', 'base-render', 'open-account']);
|
||||
assert.equal(Object.isFrozen(api), true);
|
||||
});
|
||||
|
||||
test('account and snooze UI consume the explicit mail API instead of selected legacy globals', () => {
|
||||
const root = path.resolve(__dirname, '..');
|
||||
const accountUi = fs.readFileSync(path.join(root, 'account-ui.js'), 'utf8');
|
||||
const snoozeUi = fs.readFileSync(path.join(root, 'snooze-ui.js'), 'utf8');
|
||||
assert.match(accountUi, /window\.epMailFeatures\.mail/);
|
||||
assert.match(snoozeUi, /window\.epMailFeatures\.mail/);
|
||||
assert.doesNotMatch(accountUi, /\bconnectedMailAccount\b|\bmailPageOffset\b|(?<!\.)\bsyncMailbox\s*\(/);
|
||||
assert.doesNotMatch(snoozeUi, /\bconnectedMailAccount\b|(?<!\.)\bactiveFolder\b|(?<!\.)\bselectedIds\b|(?<!\.)\bsyncMailbox\s*\(/);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user